浏览代码

设备出入库登记查询

haogh 1 年之前
父节点
当前提交
719325dfe4

+ 12 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/DeviceInOutForm.java

@@ -1,6 +1,7 @@
 package com.qmth.sop.business.bean.params;
 package com.qmth.sop.business.bean.params;
 
 
 import com.qmth.sop.common.enums.DeviceStatusEnum;
 import com.qmth.sop.common.enums.DeviceStatusEnum;
+import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
@@ -46,6 +47,9 @@ public class DeviceInOutForm implements Serializable {
     @ApiModelProperty("快递单号")
     @ApiModelProperty("快递单号")
     private String expressNo;
     private String expressNo;
 
 
+    @ApiModelProperty("派单号")
+    private String crmNo;
+
     public String getExpressNo() {
     public String getExpressNo() {
         return expressNo;
         return expressNo;
     }
     }
@@ -133,4 +137,12 @@ public class DeviceInOutForm implements Serializable {
     public void setBasePhotoPath(String basePhotoPath) {
     public void setBasePhotoPath(String basePhotoPath) {
         this.basePhotoPath = basePhotoPath;
         this.basePhotoPath = basePhotoPath;
     }
     }
+
+    public String getCrmNo() {
+        return crmNo;
+    }
+
+    public void setCrmNo(String crmNo) {
+        this.crmNo = crmNo;
+    }
 }
 }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/TBDeviceDeliveryService.java

@@ -182,7 +182,7 @@ public interface TBDeviceDeliveryService extends IService<TBDeviceDelivery> {
      *
      *
      * @param deviceDeliveryIdList 设备发货id集合
      * @param deviceDeliveryIdList 设备发货id集合
      */
      */
-    void autoOutDeviceForTrain(List<Long> deviceDeliveryIdList);
+    void autoOutDeviceForTrain(List<Long> deviceDeliveryIdList, InOutTypeEnum inOutType);
 
 
     /**
     /**
      * 查询设备返还集合(返还时)
      * 查询设备返还集合(返还时)

+ 43 - 16
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDeviceDeliveryServiceImpl.java

@@ -420,6 +420,16 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                     e.setStatus(DeviceDeliveryStatusEnum.DELIVER);
                     e.setStatus(DeviceDeliveryStatusEnum.DELIVER);
                 }).collect(Collectors.toList());
                 }).collect(Collectors.toList());
                 this.updateBatchById(tbDeviceDeliveryList);
                 this.updateBatchById(tbDeviceDeliveryList);
+
+                //更新设备的状态为出库
+                tbDeviceDeliveryList.forEach(e -> {
+                    SysDevice device = sysDeviceService.getOne(
+                            new QueryWrapper<SysDevice>().lambda().eq(SysDevice::getSerialNo, e.getSerialNo()));
+                   if(Objects.nonNull(device)) {
+                       device.setBound(InOutTypeEnum.OUT);
+                       sysDeviceService.updateById(device);
+                   }
+                });
                 break;
                 break;
             case RECEIVE:
             case RECEIVE:
                 // 变更为已签收状态(设备发货列表点击签收触发||sop现场测试签收 -> DELIVER -> RECEIVE)
                 // 变更为已签收状态(设备发货列表点击签收触发||sop现场测试签收 -> DELIVER -> RECEIVE)
@@ -431,6 +441,7 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                             String.format("只有[出入库过程中]且[%s]的发货记录才能[%s]", DeviceDeliveryStatusEnum.DELIVER.getTitle(),
                             String.format("只有[出入库过程中]且[%s]的发货记录才能[%s]", DeviceDeliveryStatusEnum.DELIVER.getTitle(),
                                     "签收"));
                                     "签收"));
                 }
                 }
+
                 tbDeviceDeliveryList = tbDeviceDeliveryList.stream().peek(e -> {
                 tbDeviceDeliveryList = tbDeviceDeliveryList.stream().peek(e -> {
                     Long currenTime = System.currentTimeMillis();
                     Long currenTime = System.currentTimeMillis();
                     e.setReceiveUserId(requestUserId);
                     e.setReceiveUserId(requestUserId);
@@ -440,18 +451,30 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                     e.setStatus(DeviceDeliveryStatusEnum.RECEIVE);
                     e.setStatus(DeviceDeliveryStatusEnum.RECEIVE);
                     if (InOutTypeEnum.IN.equals(e.getDeliveryType())) {
                     if (InOutTypeEnum.IN.equals(e.getDeliveryType())) {
                         e.setEffect(false);
                         e.setEffect(false);
-                    } else {
+                        needAutoReceiveIdList.add(e.getId());
+                    }
+                     /*else {
                         // 出库签收自动生成出入库登记出库记录
                         // 出库签收自动生成出入库登记出库记录
-                        if (DeviceUsageTypeEnum.PROJECT.equals(e.getUsageType())) {
+                       if (DeviceUsageTypeEnum.PROJECT.equals(e.getUsageType())) {
                             throw ExceptionResultEnum.ERROR.exception("项目用途的设备不能手动签收(sop现场环境测试签收)");
                             throw ExceptionResultEnum.ERROR.exception("项目用途的设备不能手动签收(sop现场环境测试签收)");
                         }
                         }
                         needAutoReceiveIdList.add(e.getId());
                         needAutoReceiveIdList.add(e.getId());
-                    }
+                    }*/
                 }).collect(Collectors.toList());
                 }).collect(Collectors.toList());
+                this.updateBatchById(tbDeviceDeliveryList);
+                //更新设备的状态为入库
+                tbDeviceDeliveryList.forEach(e -> {
+                    SysDevice device = sysDeviceService.getOne(
+                            new QueryWrapper<SysDevice>().lambda().eq(SysDevice::getSerialNo, e.getSerialNo()));
+                    if(Objects.nonNull(device)) {
+                        device.setBound(InOutTypeEnum.IN);
+                        sysDeviceService.updateById(device);
+                    }
+                });
+
                 if (CollectionUtils.isNotEmpty(needAutoReceiveIdList)) {
                 if (CollectionUtils.isNotEmpty(needAutoReceiveIdList)) {
-                    this.autoOutDeviceForTrain(needAutoReceiveIdList);
+                    this.autoOutDeviceForTrain(needAutoReceiveIdList, InOutTypeEnum.IN);
                 }
                 }
-                this.updateBatchById(tbDeviceDeliveryList);
                 break;
                 break;
             case CANCEL:
             case CANCEL:
                 // 变更为已作废状态(只有带发货状态能被作废)
                 // 变更为已作废状态(只有带发货状态能被作废)
@@ -591,19 +614,19 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
 
 
     @Transactional
     @Transactional
     @Override
     @Override
-    public void autoOutDeviceForTrain(List<Long> deviceDeliveryIdList) {
+    public void autoOutDeviceForTrain(List<Long> deviceDeliveryIdList, InOutTypeEnum inOutType) {
         List<TBDeviceDelivery> tbDeviceDeliveryList = this.listByIds(deviceDeliveryIdList);
         List<TBDeviceDelivery> tbDeviceDeliveryList = this.listByIds(deviceDeliveryIdList);
         if (CollectionUtils.isNotEmpty(tbDeviceDeliveryList)) {
         if (CollectionUtils.isNotEmpty(tbDeviceDeliveryList)) {
 
 
             List<DeviceInOutForm> deviceInOutFormList = new ArrayList<>();
             List<DeviceInOutForm> deviceInOutFormList = new ArrayList<>();
             for (TBDeviceDelivery tbDeviceDelivery : tbDeviceDeliveryList) {
             for (TBDeviceDelivery tbDeviceDelivery : tbDeviceDeliveryList) {
                 String serialNo = tbDeviceDelivery.getSerialNo();
                 String serialNo = tbDeviceDelivery.getSerialNo();
-                if (!tbDeviceDelivery.getEffect()) {
+                /*if (!tbDeviceDelivery.getEffect()) {
                     throw ExceptionResultEnum.ERROR.exception(String.format("所选设备序列号为[%s]的记录是已完成的数据,不能操作", serialNo));
                     throw ExceptionResultEnum.ERROR.exception(String.format("所选设备序列号为[%s]的记录是已完成的数据,不能操作", serialNo));
-                }
-                TBDeviceInOut tbDeviceInOut = tbDeviceInOutService.getOne(
+                }*/
+               /* TBDeviceInOut tbDeviceInOut = tbDeviceInOutService.getOne(
                         new QueryWrapper<TBDeviceInOut>().lambda().eq(TBDeviceInOut::getDeviceSerialNo, serialNo)
                         new QueryWrapper<TBDeviceInOut>().lambda().eq(TBDeviceInOut::getDeviceSerialNo, serialNo)
-                                .orderByDesc(TBDeviceInOut::getSerialNo).last(SystemConstant.LIMIT1));
+                                .orderByDesc(TBDeviceInOut::getSerialNo).last(SystemConstant.LIMIT1));*/
 
 
                 SysDevice sysDevice = sysDeviceService.getOne(
                 SysDevice sysDevice = sysDeviceService.getOne(
                         new QueryWrapper<SysDevice>().lambda().eq(SysDevice::getSerialNo, serialNo)
                         new QueryWrapper<SysDevice>().lambda().eq(SysDevice::getSerialNo, serialNo)
@@ -611,7 +634,7 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                 if (Objects.isNull(sysDevice)) {
                 if (Objects.isNull(sysDevice)) {
                     throw ExceptionResultEnum.ERROR.exception(String.format("所选设备序列号为[%s]的设备在设备配置表中不存在", serialNo));
                     throw ExceptionResultEnum.ERROR.exception(String.format("所选设备序列号为[%s]的设备在设备配置表中不存在", serialNo));
                 }
                 }
-                InOutTypeEnum sysType = sysDevice.getBound();
+                /*InOutTypeEnum sysType = sysDevice.getBound();
                 if (Objects.nonNull(tbDeviceInOut)) {
                 if (Objects.nonNull(tbDeviceInOut)) {
                     InOutTypeEnum inOutType = tbDeviceInOut.getType();
                     InOutTypeEnum inOutType = tbDeviceInOut.getType();
                     if (!sysType.equals(inOutType)) {
                     if (!sysType.equals(inOutType)) {
@@ -622,7 +645,7 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                     if (InOutTypeEnum.OUT.equals(sysType)) {
                     if (InOutTypeEnum.OUT.equals(sysType)) {
                         throw ExceptionResultEnum.ERROR.exception(String.format("所选设备序列号为[%s]的设备为出库状态,状态异常", serialNo));
                         throw ExceptionResultEnum.ERROR.exception(String.format("所选设备序列号为[%s]的设备为出库状态,状态异常", serialNo));
                     }
                     }
-                }
+                }*/
 
 
                 DeviceInOutForm deviceInOutForm = new DeviceInOutForm();
                 DeviceInOutForm deviceInOutForm = new DeviceInOutForm();
                 deviceInOutForm.setSerialNo(serialNo);
                 deviceInOutForm.setSerialNo(serialNo);
@@ -643,11 +666,12 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                 deviceInOutForm.setLocation(sysDevice.getLocation());
                 deviceInOutForm.setLocation(sysDevice.getLocation());
                 deviceInOutForm.setAddress(tbDeviceDelivery.getMailingAddress());
                 deviceInOutForm.setAddress(tbDeviceDelivery.getMailingAddress());
                 deviceInOutForm.setExpressNo(tbDeviceDelivery.getExpressNo());
                 deviceInOutForm.setExpressNo(tbDeviceDelivery.getExpressNo());
+                deviceInOutForm.setCrmNo(tbDeviceDelivery.getCrmNo());
                 deviceInOutFormList.add(deviceInOutForm);
                 deviceInOutFormList.add(deviceInOutForm);
             }
             }
             DeviceInOutSubmitParam deviceInOutSubmitParam = new DeviceInOutSubmitParam();
             DeviceInOutSubmitParam deviceInOutSubmitParam = new DeviceInOutSubmitParam();
             deviceInOutSubmitParam.setInOutTime(System.currentTimeMillis());
             deviceInOutSubmitParam.setInOutTime(System.currentTimeMillis());
-            deviceInOutSubmitParam.setInOutType(InOutTypeEnum.OUT);
+            deviceInOutSubmitParam.setInOutType(inOutType);
             deviceInOutSubmitParam.setPushSupplier(true);
             deviceInOutSubmitParam.setPushSupplier(true);
             deviceInOutSubmitParam.setDeviceInOutFormList(deviceInOutFormList);
             deviceInOutSubmitParam.setDeviceInOutFormList(deviceInOutFormList);
             tbDeviceInOutService.deviceInOutSubmit(deviceInOutSubmitParam);
             tbDeviceInOutService.deviceInOutSubmit(deviceInOutSubmitParam);
@@ -764,6 +788,8 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                 .set(TBDeviceDelivery::getStatus, DeviceDeliveryStatusEnum.USING).set(TBDeviceDelivery::getReceiveUserId, userId)
                 .set(TBDeviceDelivery::getStatus, DeviceDeliveryStatusEnum.USING).set(TBDeviceDelivery::getReceiveUserId, userId)
                 .set(TBDeviceDelivery::getReceiveTime, now).set(TBDeviceDelivery::getUpdateId, userId)
                 .set(TBDeviceDelivery::getReceiveTime, now).set(TBDeviceDelivery::getUpdateId, userId)
                 .set(TBDeviceDelivery::getUpdateTime, now));
                 .set(TBDeviceDelivery::getUpdateTime, now));
+        //写入设备出入库登记(出库)
+        autoOutDeviceForTrain(Collections.singletonList(id), InOutTypeEnum.OUT);
     }
     }
 
 
     @Override
     @Override
@@ -792,6 +818,10 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                 .set(TBDeviceDelivery::getStatus, DeviceDeliveryStatusEnum.DELIVER).set(TBDeviceDelivery::getReceiveUserId, null)
                 .set(TBDeviceDelivery::getStatus, DeviceDeliveryStatusEnum.DELIVER).set(TBDeviceDelivery::getReceiveUserId, null)
                 .set(TBDeviceDelivery::getReceiveTime, null).set(TBDeviceDelivery::getUpdateId, userId)
                 .set(TBDeviceDelivery::getReceiveTime, null).set(TBDeviceDelivery::getUpdateId, userId)
                 .set(TBDeviceDelivery::getUpdateTime, now));
                 .set(TBDeviceDelivery::getUpdateTime, now));
+
+        //删除设备出入库登记
+        tbDeviceInOutService.remove(new QueryWrapper<TBDeviceInOut>().lambda().eq(TBDeviceInOut::getCrmNo, deviceDelivery.getCrmNo())
+                .eq(TBDeviceInOut::getDeviceSerialNo, deviceDelivery.getSerialNo()).eq(TBDeviceInOut::getType, InOutTypeEnum.OUT));
     }
     }
 
 
     @Override
     @Override
@@ -801,9 +831,6 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
         if (Objects.isNull(deviceDelivery)) {
         if (Objects.isNull(deviceDelivery)) {
             throw ExceptionResultEnum.ERROR.exception(String.format("设备发货记录不存在,ID:[%s]", id));
             throw ExceptionResultEnum.ERROR.exception(String.format("设备发货记录不存在,ID:[%s]", id));
         }
         }
-//        if (deviceDelivery.getDeviceStatus().equals(deviceStatus)) {
-//            throw ExceptionResultEnum.ERROR.exception("未做改动");
-//        }
         //更新设备发货记录的设备状态
         //更新设备发货记录的设备状态
         this.update(new UpdateWrapper<TBDeviceDelivery>().lambda().eq(TBDeviceDelivery::getId, id)
         this.update(new UpdateWrapper<TBDeviceDelivery>().lambda().eq(TBDeviceDelivery::getId, id)
                 .set(TBDeviceDelivery::getDeviceStatus, deviceStatus).set(TBDeviceDelivery::getUpdateId, userId)
                 .set(TBDeviceDelivery::getDeviceStatus, deviceStatus).set(TBDeviceDelivery::getUpdateId, userId)

+ 22 - 8
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDeviceInOutServiceImpl.java

@@ -169,7 +169,7 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
         }
         }
         List<String> alreadyOutSerialNoList = alreadyOutList.stream().map(TBDeviceInOut::getDeviceSerialNo).distinct().collect(Collectors.toList());
         List<String> alreadyOutSerialNoList = alreadyOutList.stream().map(TBDeviceInOut::getDeviceSerialNo).distinct().collect(Collectors.toList());
 
 
-        String customName = null;
+       /* String customName = null;
         if (crmNo != null && crmNo.length() > 0) {
         if (crmNo != null && crmNo.length() > 0) {
             TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
             TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
             if (Objects.nonNull(tbCrm)) {
             if (Objects.nonNull(tbCrm)) {
@@ -179,23 +179,23 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
                     customName = sysCustom.getName();
                     customName = sysCustom.getName();
                 }
                 }
             }
             }
-        }
+        }*/
 
 
-        DeviceUsageTypeEnum usageType;
+        /*DeviceUsageTypeEnum usageType;
         if (sopNo != null && sopNo.length() > 0) {
         if (sopNo != null && sopNo.length() > 0) {
             usageType = DeviceUsageTypeEnum.PROJECT;
             usageType = DeviceUsageTypeEnum.PROJECT;
         } else {
         } else {
             usageType = DeviceUsageTypeEnum.OTHER;
             usageType = DeviceUsageTypeEnum.OTHER;
-        }
+        }*/
         if (deviceInOutSubmitParam.getDeviceInOutFormList().size() > deviceInOutSubmitParam.getDeviceInOutFormList().stream().map(DeviceInOutForm::getSerialNo).distinct().count()) {
         if (deviceInOutSubmitParam.getDeviceInOutFormList().size() > deviceInOutSubmitParam.getDeviceInOutFormList().stream().map(DeviceInOutForm::getSerialNo).distinct().count()) {
             throw ExceptionResultEnum.ERROR.exception("出入库登记表中设备编号有重复");
             throw ExceptionResultEnum.ERROR.exception("出入库登记表中设备编号有重复");
         }
         }
 
 
         List<DeviceInOutForm> deviceInOutFormList = deviceInOutSubmitParam.getDeviceInOutFormList();
         List<DeviceInOutForm> deviceInOutFormList = deviceInOutSubmitParam.getDeviceInOutFormList();
-        String finalCustomName = customName;
+        //String finalCustomName = customName;
         List<TBDeviceInOut> tbDeviceInOutList = deviceInOutFormList.stream().filter(e -> !alreadyOutSerialNoList.contains(e.getSerialNo())).flatMap(e -> {
         List<TBDeviceInOut> tbDeviceInOutList = deviceInOutFormList.stream().filter(e -> !alreadyOutSerialNoList.contains(e.getSerialNo())).flatMap(e -> {
             TBDeviceInOut tbDeviceInOut = new TBDeviceInOut();
             TBDeviceInOut tbDeviceInOut = new TBDeviceInOut();
-            if (serviceUnitId != null && serviceUnitId > 0) {
+            /*if (serviceUnitId != null && serviceUnitId > 0) {
                 tbDeviceInOut.setServiceId(serviceUnitId);
                 tbDeviceInOut.setServiceId(serviceUnitId);
             }
             }
             if (crmNo != null && crmNo.length() > 0) {
             if (crmNo != null && crmNo.length() > 0) {
@@ -203,7 +203,19 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
             }
             }
             if (sopNo != null && sopNo.length() > 0) {
             if (sopNo != null && sopNo.length() > 0) {
                 tbDeviceInOut.setSopNo(sopNo);
                 tbDeviceInOut.setSopNo(sopNo);
+            }*/
+            String finalCustomName = null;
+            TBCrm tbCrm = tbCrmService.findByCrmNo(e.getCrmNo());
+            if (Objects.nonNull(tbCrm)) {
+                Long customId = tbCrm.getCustomId();
+                SysCustom sysCustom = sysCustomService.getById(customId);
+                if (Objects.nonNull(sysCustom)) {
+                    finalCustomName = sysCustom.getName();
+                }
+                tbDeviceInOut.setServiceId(tbCrm.getServiceId());
             }
             }
+            tbDeviceInOut.setCrmNo(e.getCrmNo());
+
             try {
             try {
                 tbDeviceInOut.setSerialNo(sequenceService.createSerialNo(SequenceEnum.DEVICE_IN_OUT_CODE));
                 tbDeviceInOut.setSerialNo(sequenceService.createSerialNo(SequenceEnum.DEVICE_IN_OUT_CODE));
             } catch (InterruptedException ex) {
             } catch (InterruptedException ex) {
@@ -217,10 +229,12 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
             tbDeviceInOut.setAddress(e.getAddress());
             tbDeviceInOut.setAddress(e.getAddress());
             tbDeviceInOut.setAddressArr(JSON.toJSONString(e.getAddressArr()));
             tbDeviceInOut.setAddressArr(JSON.toJSONString(e.getAddressArr()));
             tbDeviceInOut.setStatus(e.getDeviceStatus());
             tbDeviceInOut.setStatus(e.getDeviceStatus());
-            tbDeviceInOut.setUsageType(usageType);
+            tbDeviceInOut.setUsageType(DeviceUsageTypeEnum.PROJECT);
             tbDeviceInOut.setBasePhotoPath(e.getBasePhotoPath());
             tbDeviceInOut.setBasePhotoPath(e.getBasePhotoPath());
             tbDeviceInOut.setInOutTime(inOutTime);
             tbDeviceInOut.setInOutTime(inOutTime);
-            if (finalCustomName != null && finalCustomName.length() > 0) {
+            tbDeviceInOut.setCreateId(requestUser.getId());
+            tbDeviceInOut.setCreateTime(System.currentTimeMillis());
+            if (finalCustomName != null && !finalCustomName.isEmpty()) {
                 tbDeviceInOut.setCustomName(finalCustomName);
                 tbDeviceInOut.setCustomName(finalCustomName);
             }
             }