Forráskód Böngészése

Merge remote-tracking branch 'origin/dev_v1.0.1' into dev_v1.0.1

wangliang 1 éve
szülő
commit
6a56447594

+ 3 - 2
sop-api/src/main/java/com/qmth/sop/server/api/TBDeviceInOutController.java

@@ -73,8 +73,9 @@ public class TBDeviceInOutController {
     @ApiOperation(value = "查询可出库的设备信息")
     @RequestMapping(value = "/can_out_info", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = DeviceInOutResult.class)})
-    public Result findDeviceCanOutInfo(@ApiParam(value = "供应商id") @RequestParam(required = false) String supplierId) {
-        return ResultUtil.ok(tbDeviceInOutService.findDeviceCanOutInfo(SystemConstant.convertIdToLong(supplierId)));
+    public Result findDeviceCanOutInfo(@ApiParam(value = "供应商id") @RequestParam(required = false) String supplierId,
+                                       @ApiParam(value = "sop编号") @RequestParam(required = false) String sopNo) {
+        return ResultUtil.ok(tbDeviceInOutService.findDeviceCanOutInfo(SystemConstant.convertIdToLong(supplierId), sopNo));
     }
 
     @ApiOperation(value = "查询可入库的设备信息")

+ 13 - 1
sop-business/src/main/java/com/qmth/sop/business/bean/params/DeviceInOutSubmitParam.java

@@ -37,6 +37,9 @@ public class DeviceInOutSubmitParam implements Serializable {
     @NotNull(message = "缺少出入库类型")
     private InOutTypeEnum inOutType;
 
+    @ApiModelProperty("推送供应商签收")
+    private Boolean pushSupplier;
+
     @ApiModelProperty("出入库登记单")
     @NotEmpty(message = "缺少出入库登记单")
     private List<DeviceInOutForm> deviceInOutFormList;
@@ -45,12 +48,13 @@ public class DeviceInOutSubmitParam implements Serializable {
 
     }
 
-    public DeviceInOutSubmitParam(Long serviceUnitId, String crmNo, String sopNo, Long inOutTime, InOutTypeEnum inOutType, List<DeviceInOutForm> deviceInOutFormList) {
+    public DeviceInOutSubmitParam(Long serviceUnitId, String crmNo, String sopNo, Long inOutTime, InOutTypeEnum inOutType,Boolean pushSupplier, List<DeviceInOutForm> deviceInOutFormList) {
         this.serviceUnitId = serviceUnitId;
         this.crmNo = crmNo;
         this.sopNo = sopNo;
         this.inOutTime = inOutTime;
         this.inOutType = inOutType;
+        this.pushSupplier = pushSupplier;
         this.deviceInOutFormList = deviceInOutFormList;
     }
 
@@ -94,6 +98,14 @@ public class DeviceInOutSubmitParam implements Serializable {
         this.inOutType = inOutType;
     }
 
+    public Boolean getPushSupplier() {
+        return pushSupplier;
+    }
+
+    public void setPushSupplier(Boolean pushSupplier) {
+        this.pushSupplier = pushSupplier;
+    }
+
     public List<DeviceInOutForm> getDeviceInOutFormList() {
         return deviceInOutFormList;
     }

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/DeviceInOutResult.java

@@ -92,6 +92,9 @@ public class DeviceInOutResult {
     @ApiModelProperty("快递单照片")
     private String basePhotoPath;
 
+    @ApiModelProperty("默认数据")
+    private Boolean defaultData;
+
     public String getSerialNo() {
         return serialNo;
     }
@@ -299,4 +302,12 @@ public class DeviceInOutResult {
     public void setBasePhotoPath(String basePhotoPath) {
         this.basePhotoPath = basePhotoPath;
     }
+
+    public Boolean getDefaultData() {
+        return defaultData;
+    }
+
+    public void setDefaultData(Boolean defaultData) {
+        this.defaultData = defaultData;
+    }
 }

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

@@ -3,6 +3,7 @@ package com.qmth.sop.business.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.sop.business.bean.params.DeviceDeliveryParam;
+import com.qmth.sop.business.bean.params.DeviceInOutForm;
 import com.qmth.sop.business.bean.result.TBDeviceDeliveryResult;
 import com.qmth.sop.business.entity.TBDeviceDelivery;
 import com.qmth.sop.common.enums.DeviceDeliveryStatusEnum;
@@ -91,4 +92,18 @@ public interface TBDeviceDeliveryService extends IService<TBDeviceDelivery> {
      * @param receiveEndTime    验收结束时间分页结果
      */
     void dataExport(Long serviceId, DeviceUsageTypeEnum usageType, String crmNo, DeviceDeliveryStatusEnum status, Long deliverUserId, Long deliveryStartTime, Long deliveryEndTime, String serialNo, Long supplierId, Long receiveStartTime, Long receiveEndTime) throws Exception;
+
+    /**
+     * 新增设备发货入库记录
+     *
+     * @param deviceInOutFormList 设备信息
+     */
+    void addInRecord(List<DeviceInOutForm> deviceInOutFormList);
+
+    /**
+     * 更新设备发货出库记录
+     *
+     * @param deviceInOutFormList 设备信息
+     */
+    void updateOutRecord(List<DeviceInOutForm> deviceInOutFormList);
 }

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

@@ -48,9 +48,10 @@ public interface TBDeviceInOutService extends IService<TBDeviceInOut> {
      * 查询可出库的设备信息
      *
      * @param supplierId 供应商id
+     * @param sopNo      sopNo
      * @return 可出库设备信息
      */
-    List<DeviceInOutResult> findDeviceCanOutInfo(Long supplierId);
+    List<DeviceInOutResult> findDeviceCanOutInfo(Long supplierId, String sopNo);
 
     /**
      * 查询可入库设备信息

+ 75 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDeviceDeliveryServiceImpl.java

@@ -8,11 +8,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.sop.business.bean.dto.DataPermissionDto;
 import com.qmth.sop.business.bean.dto.DeviceDeliveryImportDto;
 import com.qmth.sop.business.bean.dto.DeviceInfoDto;
-import com.qmth.sop.business.bean.dto.UserArchivesImportDto;
 import com.qmth.sop.business.bean.params.DeviceDeliveryParam;
-import com.qmth.sop.business.bean.query.UserArchivesQuery;
+import com.qmth.sop.business.bean.params.DeviceInOutForm;
 import com.qmth.sop.business.bean.result.TBDeviceDeliveryResult;
-import com.qmth.sop.business.entity.*;
+import com.qmth.sop.business.entity.SysDevice;
+import com.qmth.sop.business.entity.SysSupplier;
+import com.qmth.sop.business.entity.SysUser;
+import com.qmth.sop.business.entity.TBDeviceDelivery;
 import com.qmth.sop.business.mapper.TBDeviceDeliveryMapper;
 import com.qmth.sop.business.service.*;
 import com.qmth.sop.business.util.excel.BasicExcelListener;
@@ -236,7 +238,6 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
     @Override
     public void dataExport(Long serviceId, DeviceUsageTypeEnum usageType, String crmNo, DeviceDeliveryStatusEnum status, Long deliverUserId, Long deliveryStartTime, Long deliveryEndTime, String serialNo, Long supplierId, Long receiveStartTime, Long receiveEndTime) throws Exception {
         List<TBDeviceDeliveryResult> datasource = this.list(serviceId, usageType, crmNo, status, deliverUserId, deliveryStartTime, deliveryEndTime, serialNo, supplierId, receiveStartTime, receiveEndTime);
-
         File fileTemp = null;
         try {
             fileTemp = SystemConstant.getFileTempVar(SystemConstant.XLSX_PREFIX);
@@ -250,6 +251,76 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
         }
     }
 
+    @Transactional
+    @Override
+    public void addInRecord(List<DeviceInOutForm> deviceInOutFormList) {
+        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
+        for (DeviceInOutForm deviceInOutForm : deviceInOutFormList) {
+            String serialNo = deviceInOutForm.getSerialNo();
+            List<TBDeviceDelivery> outList = this.list(new QueryWrapper<TBDeviceDelivery>()
+                    .lambda()
+                    .eq(TBDeviceDelivery::getStatus, DeviceDeliveryStatusEnum.RECEIVE)
+                    .eq(TBDeviceDelivery::getEffect, true)
+                    .eq(TBDeviceDelivery::getSerialNo, serialNo)
+                    .eq(TBDeviceDelivery::getDeliveryType, InOutTypeEnum.OUT));
+
+            if (CollectionUtils.isNotEmpty(outList)) {
+                if (outList.size() > 1) {
+                    throw ExceptionResultEnum.ERROR.exception(String.format("存在多条有效的设备发货记录序列号[%s]", serialNo));
+                }
+                TBDeviceDelivery out = outList.get(0);
+                out.setEffect(false);
+                this.updateById(out);
+
+                TBDeviceDelivery in = new TBDeviceDelivery();
+                in.setCrmNo(out.getCrmNo());
+                in.setSerialNo(serialNo);
+                in.setUsageType(out.getUsageType());
+                in.setSupplierId(out.getSupplierId());
+                in.setMailingAddress(deviceInOutForm.getAddress());
+                // 发货时发货人信息
+                Long outDeliverUserId = out.getDeliverUserId();
+                if (Objects.isNull(outDeliverUserId)) {
+                    throw ExceptionResultEnum.ERROR.exception("发货人信息为空");
+                }
+                SysUser outDeliveryUser = sysUserService.getById(outDeliverUserId);
+                in.setConsignee(outDeliveryUser.getRealName());
+                in.setConsigneePhone(outDeliveryUser.getMobileNumber());
+                in.setExpressPhotoPath(deviceInOutForm.getBasePhotoPath());
+                in.setDeliveryType(InOutTypeEnum.IN);
+                in.setStatus(DeviceDeliveryStatusEnum.DELIVER);
+                in.setDeliverTime(System.currentTimeMillis());
+                in.setDeliverUserId(requestUser.getId());
+                in.setEffect(true);
+                in.setEnable(true);
+                this.save(in);
+            }
+        }
+    }
+
+    @Transactional
+    @Override
+    public void updateOutRecord(List<DeviceInOutForm> deviceInOutFormList) {
+        for (DeviceInOutForm deviceInOutForm : deviceInOutFormList) {
+            String serialNo = deviceInOutForm.getSerialNo();
+            List<TBDeviceDelivery> outList = this.list(new QueryWrapper<TBDeviceDelivery>()
+                    .lambda()
+                    .eq(TBDeviceDelivery::getStatus, DeviceDeliveryStatusEnum.RECEIVE)
+                    .eq(TBDeviceDelivery::getEffect, true)
+                    .eq(TBDeviceDelivery::getSerialNo, serialNo)
+                    .eq(TBDeviceDelivery::getDeliveryType, InOutTypeEnum.OUT));
+
+            if (CollectionUtils.isNotEmpty(outList)) {
+                if (outList.size() > 1) {
+                    throw ExceptionResultEnum.ERROR.exception(String.format("存在多条有效的设备发货记录序列号[%s]", serialNo));
+                }
+                TBDeviceDelivery out = outList.get(0);
+                out.setExpressPhotoPath(deviceInOutForm.getBasePhotoPath());
+                this.updateById(out);
+            }
+        }
+    }
+
 
     /**
      * 补充结果信息

+ 58 - 7
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDeviceInOutServiceImpl.java

@@ -1,11 +1,13 @@
 package com.qmth.sop.business.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.sop.business.bean.dto.DataPermissionDto;
+import com.qmth.sop.business.bean.dto.SopCrmInfo;
 import com.qmth.sop.business.bean.params.DeviceInOutForm;
 import com.qmth.sop.business.bean.params.DeviceInOutSubmitParam;
 import com.qmth.sop.business.bean.result.DeviceInOutResult;
@@ -15,10 +17,12 @@ import com.qmth.sop.business.service.*;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.*;
 import com.qmth.sop.common.util.ServletUtil;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 import java.util.stream.Collectors;
@@ -44,6 +48,8 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
     private TBCrmService tbCrmService;
     @Resource
     private SysCustomService sysCustomService;
+    @Resource
+    private TBDeviceDeliveryService tbDeviceDeliveryService;
 
     @Override
     public IPage<DeviceInOutResult> findDeviceInOutPageBySop(Long serviceUnitId, DeviceUsageTypeEnum usageType, Long userId, DeviceStatusEnum deviceStatus, Long inOutTimeStart, Long inOutTimeEnd, String deviceNo, String customName, String location, String address, String serialNo, Integer pageNumber, Integer pageSize) {
@@ -72,13 +78,48 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
     }
 
     @Override
-    public List<DeviceInOutResult> findDeviceCanOutInfo(Long supplierId) {
-        return this.baseMapper.findDeviceCanOutInfo(supplierId, DeviceStatusEnum.NORMAL, InOutTypeEnum.IN).stream().peek(e -> {
+    public List<DeviceInOutResult> findDeviceCanOutInfo(Long supplierId, String sopNo) {
+        SopCrmInfo sopCrmInfo = tbCrmService.findSopCrmInfoBySop(sopNo);
+        String crmNo = sopCrmInfo.getCrmNo();
+        List<TBDeviceDelivery> tbDeviceDeliveryList = tbDeviceDeliveryService.list(new QueryWrapper<TBDeviceDelivery>()
+                .lambda()
+                .eq(TBDeviceDelivery::getEffect, true)
+                .eq(TBDeviceDelivery::getDeliveryType, InOutTypeEnum.OUT)
+                .eq(TBDeviceDelivery::getStatus, DeviceDeliveryStatusEnum.RECEIVE));
+
+        List<DeviceInOutResult> result = new ArrayList<>();
+        List<DeviceInOutResult> deviceInOutResultList = this.baseMapper.findDeviceCanOutInfo(supplierId, DeviceStatusEnum.NORMAL, InOutTypeEnum.IN);
+        for (DeviceInOutResult e : deviceInOutResultList) {
             String locationArrTemp = e.getLocationArrTemp();
             if (locationArrTemp != null && locationArrTemp.length() > 0) {
                 e.setLocationArr(JSON.parseArray(locationArrTemp, String.class));
             }
-        }).collect(Collectors.toList());
+            String serialNo = e.getSerialNo();
+            List<TBDeviceDelivery> cellDeliveryList = tbDeviceDeliveryList.stream().filter(dd -> dd.getSerialNo().equals(serialNo)).collect(Collectors.toList());
+
+            if (CollectionUtils.isEmpty(cellDeliveryList)) {
+                result.add(e);
+            } else {
+                if (cellDeliveryList.size() > 1) {
+                    throw ExceptionResultEnum.ERROR.exception(String.format("设备发货信息,设备[%s]存在多条有效的记录", serialNo));
+                }
+                TBDeviceDelivery tbDeviceDelivery = cellDeliveryList.get(0);
+                String deliveryCrmNo = tbDeviceDelivery.getCrmNo();
+                if (crmNo != null && crmNo.length() > 0) {
+                    // 用于sop
+                    if (crmNo.equals(deliveryCrmNo)) {
+                        e.setDefaultData(true);
+                        result.add(e);
+                    }
+                } else {
+                    // 用于培训
+                    if (deliveryCrmNo == null || deliveryCrmNo.length() == 0) {
+                        result.add(e);
+                    }
+                }
+            }
+        }
+        return result;
     }
 
     @Override
@@ -88,6 +129,7 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
             if (locationArrTemp != null && locationArrTemp.length() > 0) {
                 e.setLocationArr(JSON.parseArray(locationArrTemp, String.class));
             }
+            e.setDefaultData(true);
         }).collect(Collectors.toList());
     }
 
@@ -103,12 +145,12 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
         Long serviceUnitId = deviceInOutSubmitParam.getServiceUnitId();
         String crmNo = deviceInOutSubmitParam.getCrmNo();
         String customName = null;
-        if (crmNo != null && crmNo.length() > 0){
+        if (crmNo != null && crmNo.length() > 0) {
             TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
-            if (Objects.nonNull(tbCrm)){
+            if (Objects.nonNull(tbCrm)) {
                 Long customId = tbCrm.getCustomId();
                 SysCustom sysCustom = sysCustomService.getById(customId);
-                if (Objects.nonNull(sysCustom)){
+                if (Objects.nonNull(sysCustom)) {
                     customName = sysCustom.getName();
                 }
             }
@@ -158,7 +200,7 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
             tbDeviceInOut.setUsageType(usageType);
             tbDeviceInOut.setBasePhotoPath(e.getBasePhotoPath());
             tbDeviceInOut.setInOutTime(inOutTime);
-            if (finalCustomName != null && finalCustomName.length() > 0){
+            if (finalCustomName != null && finalCustomName.length() > 0) {
                 tbDeviceInOut.setCustomName(finalCustomName);
             }
 
@@ -175,6 +217,15 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
             return Stream.of(tbDeviceInOut);
         }).collect(Collectors.toList());
         this.saveBatch(tbDeviceInOutList);
+        // 更新发货出库记录(快递单)
+        if (InOutTypeEnum.OUT.equals(inOutType) && deviceInOutSubmitParam.getPushSupplier()) {
+            tbDeviceDeliveryService.updateOutRecord(deviceInOutFormList);
+        }
+
+        // 新增发货入库记录
+        if (InOutTypeEnum.IN.equals(inOutType) && deviceInOutSubmitParam.getPushSupplier()) {
+            tbDeviceDeliveryService.addInRecord(deviceInOutFormList);
+        }
     }
 
     @Override

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

@@ -995,7 +995,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 }
             }
             tbDeviceInOutService.deviceInOutSubmit(new DeviceInOutSubmitParam(crmProjectResult.getServiceUnitId(),
-                    tfCustomFlowEntity.getCrmNo(), tfCustomFlowEntity.getCode(), deviceInOutTime, type, deviceInOutFormList));
+                    tfCustomFlowEntity.getCrmNo(), tfCustomFlowEntity.getCode(), deviceInOutTime, type, true, deviceInOutFormList));
         }
     }