系统问题解决

This commit is contained in:
liang.chao 2024-12-03 16:01:06 +08:00
parent 3d62104bc7
commit c5cc430b1e
6 changed files with 51 additions and 6 deletions

View File

@ -26,7 +26,7 @@ public interface DevInfoMapper {
*/ */
DevInfoVo selectDevInfoByMaId(Long maId); DevInfoVo selectDevInfoByMaId(Long maId);
Integer getMaStatusByMaId(Long maId); DevInfo getMaStatusByMaId(Long maId);
int getHotSearchCountByMaId(Long maId); int getHotSearchCountByMaId(Long maId);

View File

@ -536,11 +536,13 @@ public class DevInfoServiceImpl implements DevInfoService {
if (CollectionUtil.isNotEmpty(maIds)) { if (CollectionUtil.isNotEmpty(maIds)) {
for (Long maId : maIds) { for (Long maId : maIds) {
Integer oldStatus = devInfoMapper.getMaStatusByMaId(maId); DevInfo dto = devInfoMapper.getMaStatusByMaId(maId);
Integer newStatus = devInfo.getMaStatus(); Integer newStatus = devInfo.getMaStatus();
if (dto.getDeviceCount() == 0 && newStatus.equals(LISTING.getCode())){
return AjaxResult.warn("设备ID:" + maId + "库存为0无法上架");
}
// 根据旧状态和新状态进行状态转换检查 // 根据旧状态和新状态进行状态转换检查
switch (oldStatus) { switch (dto.getMaStatus()) {
case 0: case 0:
if (newStatus.equals(TO_BE_LISTED.getCode()) || newStatus.equals(ON_HIRE.getCode())) {continue;} if (newStatus.equals(TO_BE_LISTED.getCode()) || newStatus.equals(ON_HIRE.getCode())) {continue;}
return AjaxResult.warn("设备ID:" + maId + "是草稿状态,只能进行保存操作:" + newStatus); return AjaxResult.warn("设备ID:" + maId + "是草稿状态,只能进行保存操作:" + newStatus);

View File

@ -11,6 +11,7 @@ import com.bonus.material.order.mapper.OrderMapper;
import com.bonus.material.order.service.OrderService; import com.bonus.material.order.service.OrderService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -77,6 +78,24 @@ public class OrderController extends BaseController {
@PostMapping("/updateOrderStatus") @PostMapping("/updateOrderStatus")
public AjaxResult updateOrderStatus(@RequestBody OrderDetailDto orderInfoDto) { public AjaxResult updateOrderStatus(@RequestBody OrderDetailDto orderInfoDto) {
String userName = SecurityUtils.getLoginUser().getUsername(); String userName = SecurityUtils.getLoginUser().getUsername();
if (orderInfoDto.getOrderId() == null || StringUtils.isBlank(orderInfoDto.getOrderStatus())) {
return error("参数错误");
}
if (orderInfoDto.getOrderStatus().equals("5")) {
List<OrderDetailDto> dtos = orderMapper.getOrderDetailsByOrderId(orderInfoDto.getOrderId());
if (dtos.size() > 0) {
for (OrderDetailDto dto : dtos) {
if ("0".equals(dto.getManageType())) {
// 编码设备已退租的重新上架
dto.setMaStatus("2");
orderMapper.updateDeviceStatus(dto);
} else {
// 数量设备已退租的增加库存
orderMapper.updateAddDevCount(dto);
}
}
}
}
Integer i = orderMapper.updateOrderStatus(orderInfoDto.getOrderId(), orderInfoDto.getOrderStatus(), userName); Integer i = orderMapper.updateOrderStatus(orderInfoDto.getOrderId(), orderInfoDto.getOrderStatus(), userName);
if (i > 0) { if (i > 0) {
return success(); return success();

View File

@ -30,6 +30,9 @@ public interface OrderMapper {
Integer updateOrderStatus(@Param("orderId") Integer orderId, @Param("orderStatus") String orderStatus,@Param("userName") String userName); Integer updateOrderStatus(@Param("orderId") Integer orderId, @Param("orderStatus") String orderStatus,@Param("userName") String userName);
Integer updateDevCount(OrderDetailDto orderDetailDto); Integer updateDevCount(OrderDetailDto orderDetailDto);
Integer updateAddDevCount(OrderDetailDto orderDetailDto);
List<OrderDetailDto> selectOrderDetailsByOderId(String orderId); List<OrderDetailDto> selectOrderDetailsByOderId(String orderId);
List<OrderDetailDto> getOrderDetailsByOrderId(Integer orderId);
} }

View File

@ -619,8 +619,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
</insert> </insert>
<select id="getMaStatusByMaId" resultType="java.lang.Integer"> <select id="getMaStatusByMaId" resultType="com.bonus.material.device.domain.DevInfo">
select ma_status from ma_dev_info where ma_id = #{maId} select ma_status,device_count from ma_dev_info where ma_id = #{maId}
</select> </select>
<select id="selectCompany" resultType="java.lang.Integer"> <select id="selectCompany" resultType="java.lang.Integer">

View File

@ -53,11 +53,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
,rent_over_user = #{userName} ,rent_over_user = #{userName}
,rent_over_time = now() ,rent_over_time = now()
</if> </if>
<if test="orderStatus == 7">
,rent_over_user = #{userName}
,rent_over_time = now()
</if>
where order_id = #{orderId} where order_id = #{orderId}
</update> </update>
<update id="updateDevCount"> <update id="updateDevCount">
update ma_dev_info set device_count = device_count - #{num} where ma_id = #{maId} and is_active = 1 update ma_dev_info set device_count = device_count - #{num} where ma_id = #{maId} and is_active = 1
</update> </update>
<update id="updateAddDevCount">
update ma_dev_info set device_count = device_count + #{num} where ma_id = #{maId} and is_active = 1
</update>
<select id="getdeviceCount" resultType="com.bonus.material.device.domain.DevInfo"> <select id="getdeviceCount" resultType="com.bonus.material.device.domain.DevInfo">
select device_count,device_name from ma_dev_info where ma_id = #{maId} and is_active = 1 select device_count,device_name from ma_dev_info where ma_id = #{maId} and is_active = 1
</select> </select>
@ -233,4 +240,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
moi.order_id = #{orderId} and bfi.task_type = 17 moi.order_id = #{orderId} and bfi.task_type = 17
GROUP BY hh.ma_id GROUP BY hh.ma_id
</select> </select>
<select id="getOrderDetailsByOrderId" resultType="com.bonus.material.order.domain.OrderDetailDto">
SELECT
hh.id,
hh.ma_id,
hh.num,
mt.manage_type
FROM
ma_order_details hh
LEFT JOIN ma_dev_info mdi ON hh.ma_id = mdi.ma_id
LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id
WHERE
mt.del_flag = 0 and hh.order_id = #{orderId}
</select>
</mapper> </mapper>