소스 검색

sop新增设备出入库

wangliang 1 년 전
부모
커밋
277528ebcd

+ 3 - 1
sop-business/src/main/java/com/qmth/sop/business/bean/params/DeviceInOutForm.java

@@ -3,6 +3,7 @@ package com.qmth.sop.business.bean.params;
 import com.qmth.sop.common.enums.DeviceStatusEnum;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.io.Serializable;
 import java.util.List;
 
 /**
@@ -10,7 +11,8 @@ import java.util.List;
  * @Author: CaoZixuan
  * @Date: 2023-08-24
  */
-public class DeviceInOutForm {
+public class DeviceInOutForm implements Serializable {
+
     @ApiModelProperty("设备编号")
     private String deviceNo;
 

+ 17 - 2
sop-business/src/main/java/com/qmth/sop/business/bean/params/DeviceInOutSubmitParam.java

@@ -8,6 +8,7 @@ import org.hibernate.validator.constraints.Range;
 
 import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
+import java.io.Serializable;
 import java.util.List;
 
 /**
@@ -15,7 +16,8 @@ import java.util.List;
  * @Author: CaoZixuan
  * @Date: 2023-08-24
  */
-public class DeviceInOutSubmitParam {
+public class DeviceInOutSubmitParam implements Serializable {
+
     @ApiModelProperty("服务单元id")
     @JsonSerialize(using = ToStringSerializer.class)
     private Long serviceUnitId;
@@ -28,7 +30,7 @@ public class DeviceInOutSubmitParam {
 
     @ApiModelProperty("出入库时间")
     @NotNull(message = "缺少出入库时间")
-    @Range(min = 1L,message = "缺少出入库时间")
+    @Range(min = 1L, message = "缺少出入库时间")
     private Long inOutTime;
 
     @ApiModelProperty("出入库类型")
@@ -39,6 +41,19 @@ public class DeviceInOutSubmitParam {
     @NotEmpty(message = "缺少出入库登记单")
     private List<DeviceInOutForm> deviceInOutFormList;
 
+    public DeviceInOutSubmitParam() {
+
+    }
+
+    public DeviceInOutSubmitParam(Long serviceUnitId, String crmNo, String sopNo, Long inOutTime, InOutTypeEnum inOutType, List<DeviceInOutForm> deviceInOutFormList) {
+        this.serviceUnitId = serviceUnitId;
+        this.crmNo = crmNo;
+        this.sopNo = sopNo;
+        this.inOutTime = inOutTime;
+        this.inOutType = inOutType;
+        this.deviceInOutFormList = deviceInOutFormList;
+    }
+
     public Long getServiceUnitId() {
         return serviceUnitId;
     }

+ 12 - 3
sop-business/src/main/java/com/qmth/sop/business/service/TBSopInfoService.java

@@ -129,7 +129,16 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      *
      * @param map
      */
-    public void saveJobRemind(Map<String, Object> map);
+    public void saveJobRemind(Map<String, Object> map) throws InterruptedException;
+
+    /**
+     * sop保存设备信息
+     *
+     * @param map
+     * @param setup
+     * @throws InterruptedException
+     */
+    public void sopDeviceInOutSave(Map<String, Object> map, Integer setup) throws InterruptedException;
 
     /**
      * sop编辑
@@ -137,7 +146,7 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      * @param id
      * @return
      */
-    public FlowResult sopEdit(Long id);
+    public FlowResult sopEdit(Long id) throws InterruptedException;
 
     /**
      * sop保存
@@ -145,7 +154,7 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      * @param sopSaveParam
      * @return
      */
-    public Boolean sopSave(SopSaveParam sopSaveParam);
+    public Boolean sopSave(SopSaveParam sopSaveParam) throws InterruptedException;
 
     List<SysUser> userList(Long id);
 }

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

@@ -80,6 +80,12 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     @Value("${db.name}")
     String databaseName;
 
+    @Resource
+    TBDeviceInOutService tbDeviceInOutService;
+
+    @Resource
+    TFFlowLogService tfFlowLogService;
+
     /**
      * 查询动态sop表名是否存在
      *
@@ -309,8 +315,12 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             flowApproveParam.setFormProperties(JacksonUtil.parseJson(flowTaskResult));
         }
 
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(tfCustomFlowEntity.getCode(), tfCustomFlowEntity.getCrmNo());
+        Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
+
         Map<String, Object> map = activitiService.taskApprove(flowApproveParam);
         if (flowApproveParam.getApprove() != FlowApprovePassEnum.DRAFT) {
+            map.put(SystemConstant.CRM_INFO, crmProjectResult);
             tbSopInfoService.saveJobRemind(map);
         }
         TFFlowApprove tfFlowApprove = (TFFlowApprove) map.get(SystemConstant.FLOW_APPROVE);
@@ -634,6 +644,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
 
         Map<String, Object> map = activitiService.taskApprove(new FlowApproveParam(flowDeploymentId, approve, approveUserIds, crmNo, formProperties));
         if (approve != FlowApprovePassEnum.DRAFT) {
+            map.put(SystemConstant.CRM_INFO, crmProjectResult);
             tbSopInfoService.saveJobRemind(map);
         }
 
@@ -660,7 +671,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
      */
     @Override
     @Transactional
-    public void saveJobRemind(Map<String, Object> map) {
+    public void saveJobRemind(Map<String, Object> map) throws InterruptedException {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         TFCustomFlow tfCustomFlow = (TFCustomFlow) map.get(SystemConstant.FLOW_CUSTOM);
         Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
@@ -686,6 +697,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 } else if (tfFlowApprove.getSetup().intValue() == 3) {//内审
                     processLimitedTime = tfFlowApprove.getUpdateTime();
                 } else if (tfFlowApprove.getSetup().intValue() == 5) {//扫描准备
+                    tbSopInfoService.sopDeviceInOutSave(map, 4);
                     FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
                     processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.SCAN_START_TIME);
                     execField = SystemConstant.SCAN_START_TIME;
@@ -718,6 +730,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                     processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.ENV_DEPLOYMENT_TIME);
                     execField = SystemConstant.ENV_DEPLOYMENT_TIME;
                 } else if (tfFlowApprove.getSetup().intValue() == 6) {//扫描准备
+                    tbSopInfoService.sopDeviceInOutSave(map, 5);
                     FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
                     processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.SCAN_START_TIME);
                     execField = SystemConstant.SCAN_START_TIME;
@@ -757,6 +770,54 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                     tsJobRemindService.saveJobRemind(tsJobRemindList);
                 }
             }
+        } else if (tfFlowApprove.getStatus() == FlowStatusEnum.FINISH) {
+            if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop
+                tbSopInfoService.sopDeviceInOutSave(map, 10);
+            } else if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop
+                tbSopInfoService.sopDeviceInOutSave(map, 11);
+            }
+        }
+    }
+
+    /**
+     * sop保存设备信息
+     *
+     * @param map
+     * @param setup
+     * @throws InterruptedException
+     */
+    @Override
+    @Transactional
+    public void sopDeviceInOutSave(Map<String, Object> map, Integer setup) throws InterruptedException {
+        TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
+        Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+
+        FlowTaskResult flowTaskResultDeviceTable = this.getFormProperties(tfCustomFlowEntity, setup);
+        if (Objects.nonNull(flowTaskResultDeviceTable)) {
+            CrmProjectResult crmProjectResult = (CrmProjectResult) map.get(SystemConstant.CRM_INFO);
+            List<FlowFormWidgetResult> flowFormWidgetResultList = flowTaskResultDeviceTable.getFormProperty();
+            List<DeviceInOutForm> deviceInOutFormList = new ArrayList<>();
+            InOutTypeEnum type = null;
+            Long deviceInOutTime = null;
+            for (FlowFormWidgetResult f : flowFormWidgetResultList) {
+                if (f.getFormId().contains(SystemConstant.DEVICE_OUT_TIME) || f.getFormId().contains(SystemConstant.DEVICE_IN_TIME)) {
+                    JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+                    String value = jsonObject.getString(SystemConstant.VALUE);
+                    deviceInOutTime = Long.parseLong(value);
+                    type = f.getFormId().contains(SystemConstant.DEVICE_OUT_TIME) ? InOutTypeEnum.OUT : InOutTypeEnum.IN;
+                } else if (f.getFormId().contains(SystemConstant.DEVICE_OUT_TABLE) || f.getFormId().contains(SystemConstant.DEVICE_IN_TABLE)) {
+                    if (Objects.isNull(type)) {
+                        type = f.getFormId().contains(SystemConstant.DEVICE_OUT_TABLE) ? InOutTypeEnum.OUT : InOutTypeEnum.IN;
+                    }
+                    JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+                    JSONArray jsonArray = jsonObject.getJSONArray(SystemConstant.VALUE);
+                    for (int i = 0; i < jsonArray.size(); i++) {
+                        deviceInOutFormList.add(GsonUtil.fromJson(GsonUtil.toJson(jsonArray.getJSONObject(i)), DeviceInOutForm.class));
+                    }
+                }
+            }
+            tbDeviceInOutService.deviceInOutSubmit(new DeviceInOutSubmitParam(crmProjectResult.getServiceUnitId(),
+                    tfCustomFlowEntity.getCrmNo(), tfCustomFlowEntity.getCode(), deviceInOutTime, type, deviceInOutFormList));
         }
     }
 
@@ -767,7 +828,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
      * @return
      */
     @Override
-    public FlowResult sopEdit(Long id) {
+    public FlowResult sopEdit(Long id) throws InterruptedException {
         Optional.ofNullable(id).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("sopId不能为空"));
         TBSopInfo tbSopInfo = this.getById(id);
         Optional.ofNullable(tbSopInfo).orElseThrow(() -> ExceptionResultEnum.SOP_INFO_NO_DATA.exception());
@@ -778,10 +839,6 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, tfCustomFlowEntity.getFlowId()));
         Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
 
-//        if (tfFlowApprove.getStatus() == FlowStatusEnum.FINISH || tfFlowApprove.getStatus() == FlowStatusEnum.END) {
-//            throw ExceptionResultEnum.ERROR.exception("已结束的流程不允许修改");
-//        }
-
         FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
         FlowResult flowResultNew = new FlowResult();
         BeanUtils.copyProperties(flowResult, flowResultNew);
@@ -819,7 +876,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
      */
     @Override
     @Transactional
-    public Boolean sopSave(SopSaveParam sopSaveParam) {
+    public Boolean sopSave(SopSaveParam sopSaveParam) throws InterruptedException {
         TBSopInfo tbSopInfo = this.getById(sopSaveParam.getId());
         Optional.ofNullable(tbSopInfo).orElseThrow(() -> ExceptionResultEnum.SOP_INFO_NO_DATA.exception());
 
@@ -829,14 +886,30 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, tfCustomFlowEntity.getFlowId()));
         Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
 
-        if (tfFlowApprove.getStatus() == FlowStatusEnum.FINISH || tfFlowApprove.getStatus() == FlowStatusEnum.END) {
-            throw ExceptionResultEnum.ERROR.exception("已结束的流程不允许修改");
-        }
+//        if (tfFlowApprove.getStatus() == FlowStatusEnum.FINISH || tfFlowApprove.getStatus() == FlowStatusEnum.END) {
+//            throw ExceptionResultEnum.ERROR.exception("已结束的流程不允许修改");
+//        }
 
         TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(tfCustomFlowEntity.gettFCustomFlowId());
         Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
 
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        if (tfFlowApprove.getStatus() != FlowStatusEnum.FINISH && tfFlowApprove.getStatus() != FlowStatusEnum.END) {
+            Map<String, Object> map = new HashMap<>();
+            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(tfCustomFlowEntity.getCode(), tfCustomFlowEntity.getCrmNo());
+            Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
+
+            TFFlowLog tfFlowLog = tfFlowLogService.getOne(new QueryWrapper<TFFlowLog>().lambda().eq(TFFlowLog::getFlowId, tfCustomFlowEntity.getFlowId()).last(" order by create_time limit 1 "));
+            Optional.ofNullable(tfFlowLog).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_LOG_NO_DATA.exception());
+
+            map.put(SystemConstant.FLOW_CUSTOM, tfCustomFlow);
+            map.put(SystemConstant.FLOW_ENTITY, tfCustomFlowEntity);
+            map.put(SystemConstant.FLOW_APPROVE, tfFlowApprove);
+            map.put(SystemConstant.FLOW_APPROVE_LOG, tfFlowLog);
+            map.put(SystemConstant.CRM_INFO, crmProjectResult);
+            tbSopInfoService.saveJobRemind(map);
+        }
+
         FlowResult flowResultParam = JSONObject.parseObject(sopSaveParam.getFormProperties(), FlowResult.class);
         LinkedHashMap<String, FlowTaskResult> setupParamMap = flowResultParam.getSetupMap();
         for (Map.Entry<String, FlowTaskResult> entry : setupParamMap.entrySet()) {

+ 5 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -145,6 +145,11 @@ public class SystemConstant {
     public static final String MARK_END_TIME = "mark_end_time";//评卷结束时间
     public static final String SERVICE_FINISH_PLAN_DATE = "service_finish_plan_date";//现场服务完成撤场计划时间
 
+    public static final String DEVICE_OUT_TIME = "device_out_time";//设备出库时间
+    public static final String DEVICE_OUT_TABLE = "device_out_table";//设备出库
+    public static final String DEVICE_IN_TIME = "device_in_time";//设备入库时间
+    public static final String DEVICE_IN_TABLE = "device_in_table";//设备入库
+
     /**
      * 研究生SOP处理时限字段
      */