|
@@ -1,11 +1,13 @@
|
|
package com.qmth.sop.business.service.impl;
|
|
package com.qmth.sop.business.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
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.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.qmth.sop.business.bean.dto.DataPermissionDto;
|
|
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.DeviceInOutForm;
|
|
import com.qmth.sop.business.bean.params.DeviceInOutSubmitParam;
|
|
import com.qmth.sop.business.bean.params.DeviceInOutSubmitParam;
|
|
import com.qmth.sop.business.bean.result.DeviceInOutResult;
|
|
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.contant.SystemConstant;
|
|
import com.qmth.sop.common.enums.*;
|
|
import com.qmth.sop.common.enums.*;
|
|
import com.qmth.sop.common.util.ServletUtil;
|
|
import com.qmth.sop.common.util.ServletUtil;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -44,6 +48,8 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
|
|
private TBCrmService tbCrmService;
|
|
private TBCrmService tbCrmService;
|
|
@Resource
|
|
@Resource
|
|
private SysCustomService sysCustomService;
|
|
private SysCustomService sysCustomService;
|
|
|
|
+ @Resource
|
|
|
|
+ private TBDeviceDeliveryService tbDeviceDeliveryService;
|
|
|
|
|
|
@Override
|
|
@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) {
|
|
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
|
|
@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();
|
|
String locationArrTemp = e.getLocationArrTemp();
|
|
if (locationArrTemp != null && locationArrTemp.length() > 0) {
|
|
if (locationArrTemp != null && locationArrTemp.length() > 0) {
|
|
e.setLocationArr(JSON.parseArray(locationArrTemp, String.class));
|
|
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
|
|
@Override
|
|
@@ -88,6 +129,7 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
|
|
if (locationArrTemp != null && locationArrTemp.length() > 0) {
|
|
if (locationArrTemp != null && locationArrTemp.length() > 0) {
|
|
e.setLocationArr(JSON.parseArray(locationArrTemp, String.class));
|
|
e.setLocationArr(JSON.parseArray(locationArrTemp, String.class));
|
|
}
|
|
}
|
|
|
|
+ e.setDefaultData(true);
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -103,12 +145,12 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
|
|
Long serviceUnitId = deviceInOutSubmitParam.getServiceUnitId();
|
|
Long serviceUnitId = deviceInOutSubmitParam.getServiceUnitId();
|
|
String crmNo = deviceInOutSubmitParam.getCrmNo();
|
|
String crmNo = deviceInOutSubmitParam.getCrmNo();
|
|
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)) {
|
|
Long customId = tbCrm.getCustomId();
|
|
Long customId = tbCrm.getCustomId();
|
|
SysCustom sysCustom = sysCustomService.getById(customId);
|
|
SysCustom sysCustom = sysCustomService.getById(customId);
|
|
- if (Objects.nonNull(sysCustom)){
|
|
|
|
|
|
+ if (Objects.nonNull(sysCustom)) {
|
|
customName = sysCustom.getName();
|
|
customName = sysCustom.getName();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -158,7 +200,7 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
|
|
tbDeviceInOut.setUsageType(usageType);
|
|
tbDeviceInOut.setUsageType(usageType);
|
|
tbDeviceInOut.setBasePhotoPath(e.getBasePhotoPath());
|
|
tbDeviceInOut.setBasePhotoPath(e.getBasePhotoPath());
|
|
tbDeviceInOut.setInOutTime(inOutTime);
|
|
tbDeviceInOut.setInOutTime(inOutTime);
|
|
- if (finalCustomName != null && finalCustomName.length() > 0){
|
|
|
|
|
|
+ if (finalCustomName != null && finalCustomName.length() > 0) {
|
|
tbDeviceInOut.setCustomName(finalCustomName);
|
|
tbDeviceInOut.setCustomName(finalCustomName);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -175,6 +217,15 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
|
|
return Stream.of(tbDeviceInOut);
|
|
return Stream.of(tbDeviceInOut);
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
this.saveBatch(tbDeviceInOutList);
|
|
this.saveBatch(tbDeviceInOutList);
|
|
|
|
+ // 更新发货出库记录(快递单)
|
|
|
|
+ if (InOutTypeEnum.OUT.equals(inOutType) && deviceInOutSubmitParam.getPushSupplier()) {
|
|
|
|
+ tbDeviceDeliveryService.updateOutRecord(deviceInOutFormList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 新增发货入库记录
|
|
|
|
+ if (InOutTypeEnum.IN.equals(inOutType) && deviceInOutSubmitParam.getPushSupplier()) {
|
|
|
|
+ tbDeviceDeliveryService.addInRecord(deviceInOutFormList);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|