Explorar el Código

fix:设备发货(签收返还)补充需求

caozixuan hace 1 año
padre
commit
b551cafbb9

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

@@ -29,16 +29,16 @@ import javax.annotation.Resource;
 @RestController
 @RestController
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_SSO)
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_SSO)
 public class SsoController {
 public class SsoController {
+
     @Resource
     @Resource
     private SsoService ssoService;
     private SsoService ssoService;
 
 
     @ApiOperation(value = "软通智能客服单点登录")
     @ApiOperation(value = "软通智能客服单点登录")
-    @ApiResponses({@ApiResponse(code = 200, message = "软通智能客服单点登录", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "软通智能客服单点登录", response = Result.class) })
     @RequestMapping(value = "/rtzf/login", method = RequestMethod.POST)
     @RequestMapping(value = "/rtzf/login", method = RequestMethod.POST)
     @OperationLog(logType = LogTypeEnum.UN_KNOW)
     @OperationLog(logType = LogTypeEnum.UN_KNOW)
     public Result analysisLogin() {
     public Result analysisLogin() {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        return ResultUtil.ok("https://www.baidu.com/",ExceptionResultEnum.SUCCESS.getMessage());
-//        return ResultUtil.ok(ssoService.rtzfSsoLogin(requestUser));
+        return ResultUtil.ok(ssoService.rtzfSsoLogin(requestUser), ExceptionResultEnum.SUCCESS.getMessage());
     }
     }
 }
 }

+ 50 - 39
sop-api/src/main/java/com/qmth/sop/server/api/TBDeviceDeliveryController.java

@@ -4,6 +4,7 @@ package com.qmth.sop.server.api;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.params.DeviceDeliveryParam;
 import com.qmth.sop.business.bean.params.DeviceDeliveryParam;
+import com.qmth.sop.business.bean.params.DeviceInOutForm;
 import com.qmth.sop.business.bean.result.ProjectExchangeResult;
 import com.qmth.sop.business.bean.result.ProjectExchangeResult;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBDeviceDelivery;
 import com.qmth.sop.business.entity.TBDeviceDelivery;
@@ -28,6 +29,7 @@ import javax.annotation.Resource;
 import javax.validation.Valid;
 import javax.validation.Valid;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import javax.validation.constraints.Min;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 import java.util.Optional;
 import java.util.Optional;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
@@ -50,21 +52,16 @@ public class TBDeviceDeliveryController {
 
 
     @ApiOperation(value = "设备发货列表分页查询")
     @ApiOperation(value = "设备发货列表分页查询")
     @RequestMapping(value = "/page", method = RequestMethod.POST)
     @RequestMapping(value = "/page", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = ProjectExchangeResult.class)})
-    public Result list(@ApiParam(value = "服务单元id") @RequestParam(required = false) String serviceId,
-                       @ApiParam(value = "用途类型") @RequestParam(required = false) DeviceUsageTypeEnum usageType,
-                       @ApiParam(value = "项目单号") @RequestParam(required = false) String crmNo,
-                       @ApiParam(value = "发货状态") @RequestParam(required = false) DeviceDeliveryStatusEnum status,
-                       @ApiParam(value = "发货人id") @RequestParam(required = false) String deliverUserId,
-                       @ApiParam(value = "发货开始时间") @RequestParam(required = false) Long deliverStartTime,
-                       @ApiParam(value = "发货结束时间") @RequestParam(required = false) Long deliverEndTime,
-                       @ApiParam(value = "设备序列号") @RequestParam(required = false) String serialNo,
-                       @ApiParam(value = "设备编号") @RequestParam(required = false) String deviceNo,
-                       @ApiParam(value = "供应商id") @RequestParam(required = false) String supplierId,
-                       @ApiParam(value = "签收开始时间") @RequestParam(required = false) Long receiveStartTime,
-                       @ApiParam(value = "签收结束时间") @RequestParam(required = false) Long receiveEndTime,
-                       @ApiParam(value = "页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
-                       @ApiParam(value = "页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) throws Exception {
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = ProjectExchangeResult.class) })
+    public Result list(@ApiParam(value = "服务单元id") @RequestParam(required = false) String serviceId, @ApiParam(value = "用途类型") @RequestParam(required = false) DeviceUsageTypeEnum usageType,
+            @ApiParam(value = "项目单号") @RequestParam(required = false) String crmNo, @ApiParam(value = "发货状态") @RequestParam(required = false) DeviceDeliveryStatusEnum status,
+            @ApiParam(value = "发货人id") @RequestParam(required = false) String deliverUserId, @ApiParam(value = "发货开始时间") @RequestParam(required = false) Long deliverStartTime,
+            @ApiParam(value = "发货结束时间") @RequestParam(required = false) Long deliverEndTime, @ApiParam(value = "设备序列号") @RequestParam(required = false) String serialNo,
+            @ApiParam(value = "设备编号") @RequestParam(required = false) String deviceNo, @ApiParam(value = "供应商id") @RequestParam(required = false) String supplierId,
+            @ApiParam(value = "签收开始时间") @RequestParam(required = false) Long receiveStartTime, @ApiParam(value = "签收结束时间") @RequestParam(required = false) Long receiveEndTime,
+            @ApiParam(value = "页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+            @ApiParam(value = "页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize)
+            throws Exception {
         return ResultUtil.ok(tbDeviceDeliveryService.page(new Page<>(pageNumber, pageSize), SystemConstant.convertIdToLong(serviceId),
         return ResultUtil.ok(tbDeviceDeliveryService.page(new Page<>(pageNumber, pageSize), SystemConstant.convertIdToLong(serviceId),
                 usageType, crmNo, status, SystemConstant.convertIdToLong(deliverUserId), deliverStartTime, deliverEndTime,
                 usageType, crmNo, status, SystemConstant.convertIdToLong(deliverUserId), deliverStartTime, deliverEndTime,
                 serialNo, deviceNo, SystemConstant.convertIdToLong(supplierId), receiveStartTime, receiveEndTime));
                 serialNo, deviceNo, SystemConstant.convertIdToLong(supplierId), receiveStartTime, receiveEndTime));
@@ -72,10 +69,11 @@ public class TBDeviceDeliveryController {
 
 
     @ApiOperation(value = "设备发货保存接口")
     @ApiOperation(value = "设备发货保存接口")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @RequestMapping(value = "/save", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = Object.class) })
     @OperationLog(logType = LogTypeEnum.UPDATE)
     @OperationLog(logType = LogTypeEnum.UPDATE)
     @Transactional
     @Transactional
-    public Result save(@Valid @ApiParam(value = "设备发货修改信息", required = true) @RequestBody DeviceDeliveryParam deviceDeliveryParam, BindingResult bindingResult) throws Exception {
+    public Result save(@Valid @ApiParam(value = "设备发货修改信息", required = true) @RequestBody DeviceDeliveryParam deviceDeliveryParam,
+            BindingResult bindingResult) throws Exception {
         if (bindingResult.hasErrors()) {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
         }
@@ -85,7 +83,7 @@ public class TBDeviceDeliveryController {
 
 
     @ApiOperation(value = "设备发货查询单个记录接口")
     @ApiOperation(value = "设备发货查询单个记录接口")
     @RequestMapping(value = "/find/by/id", method = RequestMethod.POST)
     @RequestMapping(value = "/find/by/id", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = TBDeviceDelivery.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = TBDeviceDelivery.class) })
     public Result edit(@ApiParam(value = "设备发货id", required = true) @RequestParam String id) throws Exception {
     public Result edit(@ApiParam(value = "设备发货id", required = true) @RequestParam String id) throws Exception {
         TBDeviceDelivery tbDeviceDelivery = tbDeviceDeliveryService.getById(SystemConstant.convertIdToLong(id));
         TBDeviceDelivery tbDeviceDelivery = tbDeviceDeliveryService.getById(SystemConstant.convertIdToLong(id));
         Optional.ofNullable(tbDeviceDelivery).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到设备发货信息"));
         Optional.ofNullable(tbDeviceDelivery).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到设备发货信息"));
@@ -94,50 +92,63 @@ public class TBDeviceDeliveryController {
 
 
     @ApiOperation(value = "设备发货状态修改接口")
     @ApiOperation(value = "设备发货状态修改接口")
     @RequestMapping(value = "/status/update", method = RequestMethod.POST)
     @RequestMapping(value = "/status/update", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = Object.class) })
     @OperationLog(logType = LogTypeEnum.UPDATE)
     @OperationLog(logType = LogTypeEnum.UPDATE)
     @Transactional
     @Transactional
-    public Result statusUpdate(@ApiParam(value = "设备发货id", required = true) @RequestParam List<String> idList,
-                               @ApiParam(value = "设备发货状态", required = true) @RequestParam DeviceDeliveryStatusEnum status) {
+    public Result statusUpdate(@ApiParam(value = "设备发货id", required = true) @RequestParam List<String> idList, @ApiParam(value = "设备发货状态", required = true) @RequestParam DeviceDeliveryStatusEnum status) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         if (CollectionUtils.isNotEmpty(idList)) {
         if (CollectionUtils.isNotEmpty(idList)) {
-            tbDeviceDeliveryService.updateStatus(idList.stream().map(SystemConstant::convertIdToLong).collect(Collectors.toList()), status, requestUser.getId());
+            tbDeviceDeliveryService.updateStatus(
+                    idList.stream().map(SystemConstant::convertIdToLong).collect(Collectors.toList()), status,
+                    requestUser.getId());
         }
         }
         return ResultUtil.ok();
         return ResultUtil.ok();
     }
     }
 
 
     @ApiOperation(value = "设备发货导入")
     @ApiOperation(value = "设备发货导入")
     @RequestMapping(value = "/import", method = RequestMethod.POST)
     @RequestMapping(value = "/import", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = Object.class) })
     @OperationLog(logType = LogTypeEnum.IMPORT)
     @OperationLog(logType = LogTypeEnum.IMPORT)
-    public Result importDeviceDelivery(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file) throws Exception {
+    public Result importDeviceDelivery(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file)
+            throws Exception {
         tbDeviceDeliveryService.deviceDeliveryImport(file);
         tbDeviceDeliveryService.deviceDeliveryImport(file);
         return ResultUtil.ok();
         return ResultUtil.ok();
     }
     }
 
 
     @ApiOperation(value = "设备发货导出")
     @ApiOperation(value = "设备发货导出")
     @RequestMapping(value = "/export", method = RequestMethod.POST)
     @RequestMapping(value = "/export", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = ProjectExchangeResult.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = ProjectExchangeResult.class) })
     @OperationLog(logType = LogTypeEnum.EXPORT)
     @OperationLog(logType = LogTypeEnum.EXPORT)
-    public void export(@ApiParam(value = "服务单元id") @RequestParam(required = false) Long serviceId,
-                       @ApiParam(value = "用途类型") @RequestParam(required = false) DeviceUsageTypeEnum usageType,
-                       @ApiParam(value = "项目单号") @RequestParam(required = false) String crmNo,
-                       @ApiParam(value = "发货状态") @RequestParam(required = false) DeviceDeliveryStatusEnum status,
-                       @ApiParam(value = "发货人id") @RequestParam(required = false) Long deliverUserId,
-                       @ApiParam(value = "发货开始时间") @RequestParam(required = false) Long deliverStartTime,
-                       @ApiParam(value = "发货结束时间") @RequestParam(required = false) Long deliverEndTime,
-                       @ApiParam(value = "设备序列号") @RequestParam(required = false) String serialNo,
-                       @ApiParam(value = "设备编号") @RequestParam(required = false) String deviceNo,
-                       @ApiParam(value = "供应商id") @RequestParam(required = false) Long supplierId,
-                       @ApiParam(value = "签收开始时间") @RequestParam(required = false) Long receiveStartTime,
-                       @ApiParam(value = "签收结束时间") @RequestParam(required = false) Long receiveEndTime) throws Exception {
-        tbDeviceDeliveryService.dataExport(serviceId, usageType, crmNo, status, deliverUserId, deliverStartTime, deliverEndTime, serialNo, deviceNo, supplierId, receiveStartTime, receiveEndTime);
+    public void export(@ApiParam(value = "服务单元id") @RequestParam(required = false) Long serviceId, @ApiParam(value = "用途类型") @RequestParam(required = false) DeviceUsageTypeEnum usageType,
+            @ApiParam(value = "项目单号") @RequestParam(required = false) String crmNo, @ApiParam(value = "发货状态") @RequestParam(required = false) DeviceDeliveryStatusEnum status,
+            @ApiParam(value = "发货人id") @RequestParam(required = false) Long deliverUserId, @ApiParam(value = "发货开始时间") @RequestParam(required = false) Long deliverStartTime,
+            @ApiParam(value = "发货结束时间") @RequestParam(required = false) Long deliverEndTime, @ApiParam(value = "设备序列号") @RequestParam(required = false) String serialNo,
+            @ApiParam(value = "设备编号") @RequestParam(required = false) String deviceNo, @ApiParam(value = "供应商id") @RequestParam(required = false) Long supplierId,
+            @ApiParam(value = "签收开始时间") @RequestParam(required = false) Long receiveStartTime, @ApiParam(value = "签收结束时间") @RequestParam(required = false) Long receiveEndTime) throws Exception {
+        tbDeviceDeliveryService.dataExport(serviceId, usageType, crmNo, status, deliverUserId, deliverStartTime,
+                deliverEndTime, serialNo, deviceNo, supplierId, receiveStartTime, receiveEndTime);
     }
     }
 
 
     @ApiOperation(value = "设备发货人列表查询")
     @ApiOperation(value = "设备发货人列表查询")
     @RequestMapping(value = "/delivery_user_list", method = RequestMethod.POST)
     @RequestMapping(value = "/delivery_user_list", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = SysUser.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = SysUser.class) })
     public Result findDeliveryUserList() {
     public Result findDeliveryUserList() {
         return ResultUtil.ok(tbDeviceDeliveryService.findDeliveryUserList());
         return ResultUtil.ok(tbDeviceDeliveryService.findDeliveryUserList());
     }
     }
+
+    @ApiOperation(value = "设备发货可返还设备列表查询")
+    @RequestMapping(value = "/can_return_info", method = RequestMethod.POST)
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = SysUser.class) })
+    public Result findDeviceReturnList(@ApiParam(value = "设备发货id集合") @RequestParam(required = false) List<String> idList) {
+        List<Long> deviceDeliveryIdList = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(idList)) {
+            deviceDeliveryIdList = idList.stream().map(SystemConstant::convertIdToLong).distinct().collect(Collectors.toList());
+
+        }
+        List<DeviceInOutForm> deviceInOutFormList = tbDeviceDeliveryService.findDeviceReturnList(deviceDeliveryIdList);
+        if (CollectionUtils.isEmpty(deviceInOutFormList)) {
+            throw ExceptionResultEnum.ERROR.exception("缺少可返还的设备发货记录");
+        }
+        return ResultUtil.ok(deviceInOutFormList);
+    }
 }
 }

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

@@ -139,21 +139,35 @@ public interface TBDeviceDeliveryService extends IService<TBDeviceDelivery> {
     /**
     /**
      * 根据sop表单信息更新状态
      * 根据sop表单信息更新状态
      *
      *
-     * @param flowTaskResult
-     * @param status
-     * @param userId
+     * @param flowTaskResult flowTaskResult
+     * @param status         status
+     * @param userId         userId
      */
      */
     void updateStatusBySop(FlowTaskResult flowTaskResult, DeviceDeliveryStatusEnum status, Long userId);
     void updateStatusBySop(FlowTaskResult flowTaskResult, DeviceDeliveryStatusEnum status, Long userId);
 
 
     /**
     /**
      * 更新设备相关
      * 更新设备相关
      *
      *
-     * @param flowTaskResult
-     * @param sopNo
-     * @param status
-     * @param userId
-     * @param deviceDeliveryUpdate
+     * @param flowTaskResult       flowTaskResult
+     * @param sopNo                sopNo
+     * @param status               status
+     * @param userId               userId
+     * @param deviceDeliveryUpdate deviceDeliveryUpdate
      */
      */
     void updateDeviceRelated(FlowTaskResult flowTaskResult, String sopNo, DeviceDeliveryStatusEnum status, Long userId,
     void updateDeviceRelated(FlowTaskResult flowTaskResult, String sopNo, DeviceDeliveryStatusEnum status, Long userId,
             Boolean deviceDeliveryUpdate);
             Boolean deviceDeliveryUpdate);
-}
+
+    /**
+     * 自动新增培训用出库明细记录(签收时)
+     *
+     * @param deviceDeliveryIdList 设备发货id集合
+     */
+    void autoOutDeviceForTrain(List<Long> deviceDeliveryIdList);
+
+    /**
+     * 查询设备返还集合(返还时)
+     * @param deviceDeliveryIdList 设备发货id集合
+     * @return 设备返还表单
+     */
+    List<DeviceInOutForm> findDeviceReturnList(List<Long> deviceDeliveryIdList);
+}

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

@@ -24,7 +24,7 @@ public class SsoServiceImpl implements SsoService {
 
 
     @Override
     @Override
     public String rtzfSsoLogin(SysUser requestUser) {
     public String rtzfSsoLogin(SysUser requestUser) {
-        String tenantId = "ceshitanantId";
+        String tenantId = "30002";
         String ssoUrl = sysConfigService.findByConfigKey(SystemConstant.RTZF_OSS_LOGIN_URL).getConfigValue();
         String ssoUrl = sysConfigService.findByConfigKey(SystemConstant.RTZF_OSS_LOGIN_URL).getConfigValue();
         String token = rtzfApiUtils.getRtzfToken(requestUser, LoginTypeEnum.SSO_LOGIN);
         String token = rtzfApiUtils.getRtzfToken(requestUser, LoginTypeEnum.SSO_LOGIN);
 
 

+ 152 - 29
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDeviceDeliveryServiceImpl.java

@@ -12,6 +12,7 @@ import com.qmth.sop.business.bean.dto.DeviceDeliveryImportDto;
 import com.qmth.sop.business.bean.dto.DeviceInfoDto;
 import com.qmth.sop.business.bean.dto.DeviceInfoDto;
 import com.qmth.sop.business.bean.params.DeviceDeliveryParam;
 import com.qmth.sop.business.bean.params.DeviceDeliveryParam;
 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.result.FlowFormWidgetResult;
 import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
 import com.qmth.sop.business.bean.result.TBDeviceDeliveryResult;
 import com.qmth.sop.business.bean.result.TBDeviceDeliveryResult;
@@ -67,7 +68,7 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
     private TBCrmService tbCrmService;
     private TBCrmService tbCrmService;
 
 
     @Resource
     @Resource
-    TBDeviceInOutService tbDeviceInOutService;
+    private TBDeviceInOutService tbDeviceInOutService;
 
 
     @Transactional
     @Transactional
     @Override
     @Override
@@ -165,6 +166,7 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                     willAddSysDevice.setLocation(supplierName);
                     willAddSysDevice.setLocation(supplierName);
                     willAddSysDevice.setBound(InOutTypeEnum.IN);
                     willAddSysDevice.setBound(InOutTypeEnum.IN);
                     willAddSysDevice.setEnable(true);
                     willAddSysDevice.setEnable(true);
+                    willAddSysDevice.setScanCount(0L);
                     sysDeviceService.save(willAddSysDevice);
                     sysDeviceService.save(willAddSysDevice);
                 } else {
                 } else {
                     if (InOutTypeEnum.OUT.equals(sysDevice.getBound())) {
                     if (InOutTypeEnum.OUT.equals(sysDevice.getBound())) {
@@ -229,15 +231,9 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
             String crmNo, DeviceDeliveryStatusEnum status, Long deliverUserId, Long deliveryStartTime,
             String crmNo, DeviceDeliveryStatusEnum status, Long deliverUserId, Long deliveryStartTime,
             Long deliveryEndTime, String serialNo, String deviceNo, Long supplierId, Long receiveStartTime,
             Long deliveryEndTime, String serialNo, String deviceNo, Long supplierId, Long receiveStartTime,
             Long receiveEndTime) throws Exception {
             Long receiveEndTime) throws Exception {
-        if (crmNo != null && crmNo.length() > 0) {
-            crmNo = SystemConstant.translateSpecificSign(crmNo);
-        }
-        if (serialNo != null && serialNo.length() > 0) {
-            serialNo = SystemConstant.translateSpecificSign(serialNo);
-        }
-        if (deviceNo != null && deviceNo.length() > 0) {
-            deviceNo = SystemConstant.translateSpecificSign(deviceNo);
-        }
+        crmNo = SystemConstant.translateSpecificSign(crmNo);
+        serialNo = SystemConstant.translateSpecificSign(serialNo);
+        deviceNo = SystemConstant.translateSpecificSign(deviceNo);
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
         if (dpr.getHasDeviceDelivery() && !dpr.getHasAdmin() && !dpr.getHasPmo() && !dpr.getHasBusiness()
         if (dpr.getHasDeviceDelivery() && !dpr.getHasAdmin() && !dpr.getHasPmo() && !dpr.getHasBusiness()
@@ -326,6 +322,7 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                     throw ExceptionResultEnum.ERROR.exception(String.format("存在多条有效的设备发货记录序列号[%s]", serialNo));
                     throw ExceptionResultEnum.ERROR.exception(String.format("存在多条有效的设备发货记录序列号[%s]", serialNo));
                 }
                 }
                 TBDeviceDelivery out = outList.get(0);
                 TBDeviceDelivery out = outList.get(0);
+                out.setStatus(DeviceDeliveryStatusEnum.RETURN);
                 out.setEffect(false);
                 out.setEffect(false);
                 this.updateById(out);
                 this.updateById(out);
 
 
@@ -381,8 +378,7 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
     public void updateStatus(List<Long> deviceDeliveryIdList, DeviceDeliveryStatusEnum status, Long requestUserId) {
     public void updateStatus(List<Long> deviceDeliveryIdList, DeviceDeliveryStatusEnum status, Long requestUserId) {
         if (CollectionUtils.isNotEmpty(deviceDeliveryIdList)) {
         if (CollectionUtils.isNotEmpty(deviceDeliveryIdList)) {
             // 只有在生命周期的才能被操作
             // 只有在生命周期的才能被操作
-            List<TBDeviceDelivery> tbDeviceDeliveryList = this.list(
-                    new QueryWrapper<TBDeviceDelivery>().lambda().in(TBDeviceDelivery::getId, deviceDeliveryIdList));
+            List<TBDeviceDelivery> tbDeviceDeliveryList = this.listByIds(deviceDeliveryIdList);
 
 
             switch (status) {
             switch (status) {
             case DELIVER:
             case DELIVER:
@@ -421,6 +417,12 @@ 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 {
+                        // 出库签收自动生成出入库登记出库记录
+                        if (DeviceUsageTypeEnum.PROJECT.equals(e.getUsageType())) {
+                            throw ExceptionResultEnum.ERROR.exception("项目用途的设备不能手动签收(sop现场环境测试签收)");
+                        }
+                        this.autoOutDeviceForTrain(deviceDeliveryIdList);
                     }
                     }
                 }).collect(Collectors.toList());
                 }).collect(Collectors.toList());
                 this.updateBatchById(tbDeviceDeliveryList);
                 this.updateBatchById(tbDeviceDeliveryList);
@@ -474,13 +476,6 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
         return result;
         return result;
     }
     }
 
 
-    /**
-     * 根据sop表单信息更新状态
-     *
-     * @param flowTaskResult
-     * @param status
-     * @param userId
-     */
     @Override
     @Override
     @Transactional
     @Transactional
     public void updateStatusBySop(FlowTaskResult flowTaskResult, DeviceDeliveryStatusEnum status, Long userId) {
     public void updateStatusBySop(FlowTaskResult flowTaskResult, DeviceDeliveryStatusEnum status, Long userId) {
@@ -511,15 +506,6 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
         }
         }
     }
     }
 
 
-    /**
-     * 更新设备相关
-     *
-     * @param flowTaskResult
-     * @param sopNo
-     * @param status
-     * @param userId
-     * @param deviceDeliveryUpdate
-     */
     @Override
     @Override
     @Transactional
     @Transactional
     public void updateDeviceRelated(FlowTaskResult flowTaskResult, String sopNo, DeviceDeliveryStatusEnum status,
     public void updateDeviceRelated(FlowTaskResult flowTaskResult, String sopNo, DeviceDeliveryStatusEnum status,
@@ -549,7 +535,7 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                             sysDeviceService.updateById(sysDevice);
                             sysDeviceService.updateById(sysDevice);
                         }
                         }
                         tbDeviceInOutService.removeByIds(
                         tbDeviceInOutService.removeByIds(
-                                tbDeviceInOutList.stream().map(s -> s.getId()).collect(Collectors.toList()));
+                                tbDeviceInOutList.stream().map(TBDeviceInOut::getId).collect(Collectors.toList()));
                     }
                     }
                 }
                 }
             }
             }
@@ -570,6 +556,143 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
         }
         }
     }
     }
 
 
+    @Transactional
+    @Override
+    public void autoOutDeviceForTrain(List<Long> deviceDeliveryIdList) {
+        List<TBDeviceDelivery> tbDeviceDeliveryList = this.listByIds(deviceDeliveryIdList);
+        if (CollectionUtils.isNotEmpty(tbDeviceDeliveryList)) {
+
+            List<DeviceInOutForm> deviceInOutFormList = new ArrayList<>();
+            for (TBDeviceDelivery tbDeviceDelivery : tbDeviceDeliveryList) {
+                String serialNo = tbDeviceDelivery.getSerialNo();
+                if (!tbDeviceDelivery.getEffect()) {
+                    throw ExceptionResultEnum.ERROR.exception(String.format("所选设备序列号为[%s]的记录是已完成的数据,不能操作", serialNo));
+                }
+                TBDeviceInOut tbDeviceInOut = tbDeviceInOutService.getOne(
+                        new QueryWrapper<TBDeviceInOut>().lambda().eq(TBDeviceInOut::getDeviceSerialNo, serialNo).orderByDesc(TBDeviceInOut::getSerialNo).last(SystemConstant.LIMIT1));
+
+                SysDevice sysDevice = sysDeviceService.getOne(
+                        new QueryWrapper<SysDevice>().lambda().eq(SysDevice::getSerialNo, serialNo).last(SystemConstant.LIMIT1));
+                if (Objects.isNull(sysDevice)) {
+                    throw ExceptionResultEnum.ERROR.exception(String.format("所选设备序列号为[%s]的设备在设备配置表中不存在", serialNo));
+                }
+                InOutTypeEnum sysType = sysDevice.getBound();
+                if (Objects.nonNull(tbDeviceInOut)) {
+                    InOutTypeEnum inOutType = tbDeviceInOut.getType();
+                    if (!sysType.equals(inOutType)) {
+                        throw ExceptionResultEnum.ERROR.exception(
+                                String.format("所选设备序列号为[%s]的设备状态异常(设备配置和设备出入库明细不一致)", serialNo));
+                    }
+
+                    if (InOutTypeEnum.OUT.equals(sysType)) {
+                        throw ExceptionResultEnum.ERROR.exception(String.format("所选设备序列号为[%s]的设备为出库状态,状态异常", serialNo));
+                    }
+                }
+
+                DeviceInOutForm deviceInOutForm = new DeviceInOutForm();
+                deviceInOutForm.setSerialNo(serialNo);
+                deviceInOutForm.setDeviceBrand(sysDevice.getBrand());
+                Long supplierId = tbDeviceDelivery.getSupplierId();
+                SysSupplier sysSupplier = sysSupplierService.getById(supplierId);
+                if (Objects.isNull(sysSupplier)) {
+                    throw ExceptionResultEnum.ERROR.exception("供应商不存在");
+                }
+                deviceInOutForm.setSupplierName(sysSupplier.getName());
+                deviceInOutForm.setDeviceStatus(sysDevice.getStatus());
+                int scanCount = 0;
+                Long scanCountL = sysDevice.getScanCount();
+                if (scanCountL != null && scanCountL > 0) {
+                    scanCount = scanCountL.intValue();
+                }
+                deviceInOutForm.setScanCount(scanCount);
+                deviceInOutForm.setLocation(sysDevice.getLocation());
+                deviceInOutForm.setAddress(tbDeviceDelivery.getMailingAddress());
+                deviceInOutForm.setExpressNo(tbDeviceDelivery.getExpressNo());
+                deviceInOutFormList.add(deviceInOutForm);
+            }
+            DeviceInOutSubmitParam deviceInOutSubmitParam = new DeviceInOutSubmitParam();
+            deviceInOutSubmitParam.setInOutTime(System.currentTimeMillis());
+            deviceInOutSubmitParam.setInOutType(InOutTypeEnum.OUT);
+            deviceInOutSubmitParam.setPushSupplier(true);
+            deviceInOutSubmitParam.setDeviceInOutFormList(deviceInOutFormList);
+            tbDeviceInOutService.deviceInOutSubmit(deviceInOutSubmitParam);
+        }
+    }
+
+    @Override
+    public List<DeviceInOutForm> findDeviceReturnList(List<Long> deviceDeliveryIdList) {
+        List<DeviceInOutForm> deviceInOutFormList = new ArrayList<>();
+        List<TBDeviceDelivery> tbDeviceDeliveryList;
+        if (CollectionUtils.isNotEmpty(deviceDeliveryIdList)) {
+            tbDeviceDeliveryList = this.listByIds(deviceDeliveryIdList);
+        } else {
+            // 查询所有可返还设备(设备发货管理状态为(出库,effect,已签收,用途为培训))
+            tbDeviceDeliveryList = this.list(
+                    new QueryWrapper<TBDeviceDelivery>().lambda().eq(TBDeviceDelivery::getEffect, true)
+                            .eq(TBDeviceDelivery::getDeliveryType, InOutTypeEnum.OUT)
+                            .eq(TBDeviceDelivery::getStatus, DeviceDeliveryStatusEnum.RECEIVE)
+                            .eq(TBDeviceDelivery::getUsageType, DeviceUsageTypeEnum.OTHER));
+        }
+
+        if (CollectionUtils.isNotEmpty(tbDeviceDeliveryList)) {
+            for (TBDeviceDelivery tbDeviceDelivery : tbDeviceDeliveryList) {
+                String serialNo = tbDeviceDelivery.getSerialNo();
+                if (!tbDeviceDelivery.getEffect()) {
+                    throw ExceptionResultEnum.ERROR.exception(String.format("所选设备序列号为[%s]的记录是已完成的数据,不能操作", serialNo));
+                }
+                InOutTypeEnum type = tbDeviceDelivery.getDeliveryType();
+                DeviceDeliveryStatusEnum status = tbDeviceDelivery.getStatus();
+                if (!InOutTypeEnum.OUT.equals(type) || !DeviceDeliveryStatusEnum.RECEIVE.equals(status) || DeviceUsageTypeEnum.PROJECT.equals(tbDeviceDelivery.getUsageType())) {
+                    throw ExceptionResultEnum.ERROR.exception(
+                            String.format("所选设备序列号为[%s]的记录的发货状态必须是[%s][%s],且不能是[%s]用途", serialNo, InOutTypeEnum.OUT.getTitle(),
+                                    DeviceDeliveryStatusEnum.RECEIVE.getTitle(), DeviceUsageTypeEnum.PROJECT.getTitle()));
+                }
+
+                TBDeviceInOut tbDeviceInOut = tbDeviceInOutService.getOne(
+                        new QueryWrapper<TBDeviceInOut>().lambda().eq(TBDeviceInOut::getDeviceSerialNo, serialNo).orderByDesc(TBDeviceInOut::getSerialNo).last(SystemConstant.LIMIT1));
+
+                SysDevice sysDevice = sysDeviceService.getOne(
+                        new QueryWrapper<SysDevice>().lambda().eq(SysDevice::getSerialNo, serialNo).last(SystemConstant.LIMIT1));
+                if (Objects.isNull(sysDevice)) {
+                    throw ExceptionResultEnum.ERROR.exception(String.format("所选设备序列号为[%s]的设备在设备配置表中不存在", serialNo));
+                }
+                InOutTypeEnum sysType = sysDevice.getBound();
+                if (Objects.nonNull(tbDeviceInOut)) {
+                    InOutTypeEnum inOutType = tbDeviceInOut.getType();
+                    if (!sysType.equals(inOutType)) {
+                        throw ExceptionResultEnum.ERROR.exception(
+                                String.format("所选设备序列号为[%s]的设备状态异常(设备配置和设备出入库明细不一致)", serialNo));
+                    }
+
+                    if (InOutTypeEnum.IN.equals(sysType)) {
+                        throw ExceptionResultEnum.ERROR.exception(String.format("所选设备序列号为[%s]的设备为入库状态,状态异常", serialNo));
+                    }
+                }
+
+                DeviceInOutForm deviceInOutForm = new DeviceInOutForm();
+                deviceInOutForm.setSerialNo(serialNo);
+                deviceInOutForm.setDeviceBrand(sysDevice.getBrand());
+                Long supplierId = tbDeviceDelivery.getSupplierId();
+                SysSupplier sysSupplier = sysSupplierService.getById(supplierId);
+                if (Objects.isNull(sysSupplier)) {
+                    throw ExceptionResultEnum.ERROR.exception("供应商不存在");
+                }
+                deviceInOutForm.setSupplierName(sysSupplier.getName());
+                deviceInOutForm.setDeviceStatus(sysDevice.getStatus());
+                int scanCount = 0;
+                Long scanCountL = sysDevice.getScanCount();
+                if (scanCountL != null && scanCountL > 0) {
+                    scanCount = scanCountL.intValue();
+                }
+                deviceInOutForm.setScanCount(scanCount);
+                deviceInOutForm.setLocation(sysDevice.getLocation());
+                deviceInOutForm.setAddress(sysSupplier.getName());
+                deviceInOutFormList.add(deviceInOutForm);
+            }
+        }
+        return deviceInOutFormList;
+    }
+
     /**
     /**
      * 补充结果信息
      * 补充结果信息
      *
      *

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

@@ -121,16 +121,11 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
                     continue;
                     continue;
                 }
                 }
                 if (crmNo != null && crmNo.length() > 0) {
                 if (crmNo != null && crmNo.length() > 0) {
-                    // 用于sop
+                    // 用于sop(若设备发货管理里有数据,只能选用派单号相同的)
                     if (crmNo.equals(deliveryCrmNo)) {
                     if (crmNo.equals(deliveryCrmNo)) {
                         e.setDefaultData(true);
                         e.setDefaultData(true);
                         e.setExpressNo(tbDeviceDelivery.getExpressNo());
                         e.setExpressNo(tbDeviceDelivery.getExpressNo());
                         result.add(e);
                         result.add(e);
-                    } else if (deliveryCrmNo == null || deliveryCrmNo.length() == 0) {
-                        // 也可以选用设备发货管理里没有绑sop的
-                        e.setDefaultData(true);
-                        e.setExpressNo(tbDeviceDelivery.getExpressNo());
-                        result.add(e);
                     }
                     }
                 } else {
                 } else {
                     // 用于培训
                     // 用于培训

+ 12 - 6
sop-business/src/main/java/com/qmth/sop/business/sync/RtzfApiUtils.java

@@ -36,7 +36,7 @@ public class RtzfApiUtils {
     private static final Logger log = LoggerFactory.getLogger(RtzfApiUtils.class);
     private static final Logger log = LoggerFactory.getLogger(RtzfApiUtils.class);
 
 
     @ApiModelProperty("用户登录 url")
     @ApiModelProperty("用户登录 url")
-    final String loginUrl = "/tenant/login/password/or/code/login";
+    final String loginUrl = "https://qmth.echo-isoftstone.com/tenant/login/password/or/code/login";
 
 
     @ApiModelProperty("接口访问默认账号")
     @ApiModelProperty("接口访问默认账号")
     final String defaultAccount = "?";
     final String defaultAccount = "?";
@@ -64,8 +64,10 @@ public class RtzfApiUtils {
                     password = defaultPassword;
                     password = defaultPassword;
                     break;
                     break;
                 case SSO_LOGIN:
                 case SSO_LOGIN:
-                    account = String.valueOf(requestUser.getId());
-                    password = requestUser.getPassword();
+//                    account = String.valueOf(requestUser.getId());
+//                    password = requestUser.getPassword();
+                    account = "18903719928";
+                    password = "zgFX6eUFrx89xEW1J8OpxAeVZ7uY2u4VVQsFQc9//sY=";
                     break;
                     break;
             }
             }
 
 
@@ -80,11 +82,15 @@ public class RtzfApiUtils {
             if (Objects.isNull(rtzfResult) || !"0".equals(rtzfResult.getCode())) {
             if (Objects.isNull(rtzfResult) || !"0".equals(rtzfResult.getCode())) {
                 throw ExceptionResultEnum.ERROR.exception("用户登录获取token失败 : " + rtzfResult.getMsg());
                 throw ExceptionResultEnum.ERROR.exception("用户登录获取token失败 : " + rtzfResult.getMsg());
             }
             }
-            RtzfToken rtzfToken = (RtzfToken) rtzfResult.getData();
-            if (Objects.isNull(rtzfToken) || rtzfToken.getToken() == null || rtzfToken.getToken().length() == 0) {
+            JSONObject data = rtzfResult.getData();
+            if (Objects.isNull(data)){
+                throw ExceptionResultEnum.ERROR.exception("用户登录获取token失败 : 未能解析data数据");
+            }
+            String token = data.getString("token");
+            if (token == null || token.length() == 0) {
                 throw ExceptionResultEnum.ERROR.exception("用户登录获取token为空");
                 throw ExceptionResultEnum.ERROR.exception("用户登录获取token为空");
             }
             }
-            return rtzfToken.getToken();
+            return token;
         } catch (Exception e) {
         } catch (Exception e) {
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         }
         }

+ 4 - 3
sop-business/src/main/java/com/qmth/sop/business/sync/been/rtzf/RtzfResult.java

@@ -1,5 +1,6 @@
 package com.qmth.sop.business.sync.been.rtzf;
 package com.qmth.sop.business.sync.been.rtzf;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
@@ -14,7 +15,7 @@ public class RtzfResult {
     private String code;
     private String code;
 
 
     @ApiModelProperty("数据")
     @ApiModelProperty("数据")
-    private Object data;
+    private JSONObject data;
 
 
     @ApiModelProperty("返回信息")
     @ApiModelProperty("返回信息")
     private String msg;
     private String msg;
@@ -32,11 +33,11 @@ public class RtzfResult {
         this.code = code;
         this.code = code;
     }
     }
 
 
-    public Object getData() {
+    public JSONObject getData() {
         return data;
         return data;
     }
     }
 
 
-    public void setData(Object data) {
+    public void setData(JSONObject data) {
         this.data = data;
         this.data = data;
     }
     }
 
 

+ 17 - 1
sop-business/src/main/resources/db/log/caozixuan_update_log.sql

@@ -552,4 +552,20 @@ UPDATE sys_privilege SET related = '1062,1063,1064,1065,1066,1067,1068,1069,1070
 UPDATE sys_privilege SET related = '1057,1058,1059,1060,1061' WHERE (id = '1103');
 UPDATE sys_privilege SET related = '1057,1058,1059,1060,1061' WHERE (id = '1103');
 UPDATE sys_privilege SET related = '1094,1095,1097' WHERE (id = '1104');
 UPDATE sys_privilege SET related = '1094,1095,1097' WHERE (id = '1104');
 UPDATE sys_privilege SET related = '1090,1091,1092,1093' WHERE (id = '1105');
 UPDATE sys_privilege SET related = '1090,1091,1092,1093' WHERE (id = '1105');
-UPDATE sys_privilege SET related = '1083,1084,1085,1086,1087,1088,1089' WHERE (id = '1106');
+UPDATE sys_privilege SET related = '1083,1084,1085,1086,1087,1088,1089' WHERE (id = '1106');
+
+-- 2023-12-13
+INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('38', 'rtzf.oss.login.url', '软通智服单点登录接口', 'https://qmth.echo-isoftstone.com/login', '1', '1', '1');
+
+-- 2023-12-14
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, related, enable, default_auth, front_display) VALUES ('3076', '批量返还', 'BatchReturn', 'BUTTON', '3053', '5', 'AUTH', '3078,2035', '1', '0', '1');
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, related, enable, default_auth, front_display) VALUES ('3077', '返还', 'Return', 'LINK', '3053', '6', 'AUTH', '3078,2035', '1', '0', '1');
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('3078', '设备发货可返还设备列表查询', '/api/admin/device/delivery/can_return_info', 'URL', '3053', '8', 'AUTH', '1', '1', '0');
+
+UPDATE sys_device
+SET
+    scan_count = 0
+WHERE
+    scan_count IS NULL;
+ALTER TABLE sys_device
+    CHANGE COLUMN scan_count scan_count BIGINT NOT NULL DEFAULT 0 COMMENT '总扫描量' ;

+ 3 - 1
sop-common/src/main/java/com/qmth/sop/common/enums/DeviceDeliveryStatusEnum.java

@@ -15,7 +15,9 @@ public enum DeviceDeliveryStatusEnum {
 
 
     RECEIVE("已签收"),
     RECEIVE("已签收"),
 
 
-    CANCEL("作废");
+    CANCEL("作废"),
+
+    RETURN("已返还");
 
 
     DeviceDeliveryStatusEnum(String title) {
     DeviceDeliveryStatusEnum(String title) {
         this.title = title;
         this.title = title;