feat:准备物料入库接口
This commit is contained in:
@@ -76,7 +76,10 @@ public interface QmsCommonConstant {
|
||||
|
||||
/** 已驳回 **/
|
||||
String REJECTED = "rejected";
|
||||
|
||||
|
||||
/** 已拒绝 **/
|
||||
String REFUSED = "refused";
|
||||
|
||||
/** 作废 **/
|
||||
String VOID = "void";
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore;
|
||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundRespVO;
|
||||
@@ -31,8 +32,9 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 入库")
|
||||
@RestController
|
||||
@RequestMapping("/t/material-inventory-inbound")
|
||||
@RequestMapping("/qms/resource/material-inventory-inbound")
|
||||
@Validated
|
||||
@DeptDataPermissionIgnore(enable = "true")
|
||||
public class MaterialInventoryInboundController implements BusinessControllerMarker {
|
||||
|
||||
|
||||
@@ -40,15 +42,15 @@ public class MaterialInventoryInboundController implements BusinessControllerMar
|
||||
private MaterialInventoryInboundService materialInventoryInboundService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建入库")
|
||||
@PreAuthorize("@ss.hasPermission('t:material-inventory-inbound:create')")
|
||||
@Operation(summary = "物料入库")
|
||||
// @PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound:create')")
|
||||
public CommonResult<MaterialInventoryInboundRespVO> createMaterialInventoryInbound(@Valid @RequestBody MaterialInventoryInboundSaveReqVO createReqVO) {
|
||||
return success(materialInventoryInboundService.createMaterialInventoryInbound(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新入库")
|
||||
@PreAuthorize("@ss.hasPermission('t:material-inventory-inbound:update')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound:update')")
|
||||
public CommonResult<Boolean> updateMaterialInventoryInbound(@Valid @RequestBody MaterialInventoryInboundSaveReqVO updateReqVO) {
|
||||
materialInventoryInboundService.updateMaterialInventoryInbound(updateReqVO);
|
||||
return success(true);
|
||||
@@ -57,7 +59,7 @@ public class MaterialInventoryInboundController implements BusinessControllerMar
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除入库")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('t:material-inventory-inbound:delete')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound:delete')")
|
||||
public CommonResult<Boolean> deleteMaterialInventoryInbound(@RequestParam("id") Long id) {
|
||||
materialInventoryInboundService.deleteMaterialInventoryInbound(id);
|
||||
return success(true);
|
||||
@@ -66,7 +68,7 @@ public class MaterialInventoryInboundController implements BusinessControllerMar
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除入库")
|
||||
@PreAuthorize("@ss.hasPermission('t:material-inventory-inbound:delete')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound:delete')")
|
||||
public CommonResult<Boolean> deleteMaterialInventoryInboundList(@RequestBody BatchDeleteReqVO req) {
|
||||
materialInventoryInboundService.deleteMaterialInventoryInboundListByIds(req.getIds());
|
||||
return success(true);
|
||||
@@ -75,7 +77,7 @@ public class MaterialInventoryInboundController implements BusinessControllerMar
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得入库")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('t:material-inventory-inbound:query')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound:query')")
|
||||
public CommonResult<MaterialInventoryInboundRespVO> getMaterialInventoryInbound(@RequestParam("id") Long id) {
|
||||
MaterialInventoryInboundDO materialInventoryInbound = materialInventoryInboundService.getMaterialInventoryInbound(id);
|
||||
return success(BeanUtils.toBean(materialInventoryInbound, MaterialInventoryInboundRespVO.class));
|
||||
@@ -83,7 +85,7 @@ public class MaterialInventoryInboundController implements BusinessControllerMar
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得入库分页")
|
||||
@PreAuthorize("@ss.hasPermission('t:material-inventory-inbound:query')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound:query')")
|
||||
public CommonResult<PageResult<MaterialInventoryInboundRespVO>> getMaterialInventoryInboundPage(@Valid MaterialInventoryInboundPageReqVO pageReqVO) {
|
||||
PageResult<MaterialInventoryInboundDO> pageResult = materialInventoryInboundService.getMaterialInventoryInboundPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, MaterialInventoryInboundRespVO.class));
|
||||
@@ -91,7 +93,7 @@ public class MaterialInventoryInboundController implements BusinessControllerMar
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出入库 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('t:material-inventory-inbound:export')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportMaterialInventoryInboundExcel(@Valid MaterialInventoryInboundPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 入库 Response VO")
|
||||
@@ -48,6 +49,26 @@ public class MaterialInventoryInboundRespVO {
|
||||
@ExcelProperty("申请时间")
|
||||
private LocalDateTime applyTime;
|
||||
|
||||
@Schema(description = "监督人,危化品才有")
|
||||
@ExcelProperty("监督人,危化品才有")
|
||||
private String superviseUser;
|
||||
|
||||
@Schema(description = "监督人id,危化品才有")
|
||||
@ExcelProperty("监督人id,危化品才有")
|
||||
private Long superviseUserId;
|
||||
|
||||
@Schema(description = "批次工段id")
|
||||
@ExcelProperty("批次工段id")
|
||||
private Long gongduanId;
|
||||
|
||||
@Schema(description = "入库数量")
|
||||
@ExcelProperty("入库数量")
|
||||
private BigDecimal quantity;
|
||||
|
||||
@Schema(description = "库位id")
|
||||
@ExcelProperty("库位id")
|
||||
private Long locationId;
|
||||
|
||||
@Schema(description = "流程实例id", example = "16660")
|
||||
@ExcelProperty("流程实例id")
|
||||
private String flowInstanceId;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.zt.plat.module.qms.resource.material.controller.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 入库新增/修改 Request VO")
|
||||
@@ -36,6 +38,21 @@ public class MaterialInventoryInboundSaveReqVO {
|
||||
@Schema(description = "申请时间")
|
||||
private LocalDateTime applyTime;
|
||||
|
||||
@Schema(description = "监督人,危化品才有")
|
||||
private String superviseUser;
|
||||
|
||||
@Schema(description = "监督人id,危化品才有")
|
||||
private Long superviseUserId;
|
||||
|
||||
@Schema(description = "批次工段id")
|
||||
private Long gongduanId;
|
||||
|
||||
@Schema(description = "入库数量")
|
||||
private BigDecimal quantity;
|
||||
|
||||
@Schema(description = "库位id")
|
||||
private Long locationId;
|
||||
|
||||
@Schema(description = "流程实例id", example = "16660")
|
||||
private String flowInstanceId;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.zt.plat.module.qms.resource.material.controller.vo;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.zt.plat.module.qms.core.aspect.annotation.Dict;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -97,6 +98,7 @@ public class MaterialProductRespVO {
|
||||
|
||||
@Schema(description = "开封后保质期是否变化,1-是,0-否")
|
||||
@ExcelProperty("开封后保质期是否变化,1-是,0-否")
|
||||
@Dict(dicCode = "yes_or_no")
|
||||
private Integer openDueFlag;
|
||||
|
||||
@Schema(description = "开封后保质期(天)")
|
||||
@@ -133,6 +135,7 @@ public class MaterialProductRespVO {
|
||||
|
||||
@Schema(description = "是否进行库存预警,1-是,0-否")
|
||||
@ExcelProperty("是否进行库存预警,1-是,0-否")
|
||||
@Dict(dicCode = "yes_or_no")
|
||||
private Integer InventoryAlarmFlag;
|
||||
|
||||
@Schema(description = "库存预警区间,json格式配置")
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
/**
|
||||
* 入库 DO
|
||||
@@ -70,6 +71,31 @@ public class MaterialInventoryInboundDO extends BusinessBaseDO {
|
||||
*/
|
||||
@TableField("APL_TM")
|
||||
private LocalDateTime applyTime;
|
||||
/**
|
||||
* 监督人,危化品才有
|
||||
*/
|
||||
@TableField("SUPR_USER")
|
||||
private String superviseUser;
|
||||
/**
|
||||
* 监督人id,危化品才有
|
||||
*/
|
||||
@TableField("SUPR_USER_ID")
|
||||
private Long superviseUserId;
|
||||
/**
|
||||
* 批次工段id
|
||||
*/
|
||||
@TableField("GONG_ID")
|
||||
private Long gongduanId;
|
||||
/**
|
||||
* 入库数量
|
||||
*/
|
||||
@TableField("QTY")
|
||||
private BigDecimal quantity;
|
||||
/**
|
||||
* 库位id
|
||||
*/
|
||||
@TableField("LOC_ID")
|
||||
private Long locationId;
|
||||
/**
|
||||
* 流程实例id
|
||||
*/
|
||||
|
||||
@@ -85,11 +85,14 @@ public interface MaterialBatchMapper extends BaseMapperX<MaterialBatchDO> {
|
||||
.selectAs(MaterialProductDO::getName, MaterialBatchRespVO::getProductName)
|
||||
.selectAs(MaterialProductDO::getCode, MaterialBatchRespVO::getProductCode)
|
||||
.selectAs(MaterialProductDO::getModelNo, MaterialBatchRespVO::getProductModelNo)
|
||||
.selectAs("batch.MFR_DT", MaterialBatchDO::getManufacturerDate)
|
||||
.selectAs("batch.DUE_DT", MaterialBatchDO::getDueDate)
|
||||
.leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialBatchDO::getProductId)
|
||||
.leftJoin(MaterialBatchDO.class, "batch", MaterialBatchDO::getId, MaterialBatchDO::getParentId)
|
||||
// 只查询工段
|
||||
.ne(MaterialBatchDO::getParentId, 0)
|
||||
.eq(MaterialBatchDO::getSubmitStatus, 1)
|
||||
.notExists("SELECT 1 FROM t_mtrl_lfc_dtl ld WHERE ld.BAT_GONG_ID = t.id AND ld.DELETED = 0")
|
||||
.notExists("SELECT 1 FROM t_mtrl_lfc_dtl ld WHERE ld.BAT_GONG_ID = t.ID AND ld.DELETED = 0")
|
||||
// .eq(onlyGong != null && visitDeptId != null && onlyGong, MaterialBatchDO::getAssignDepartmentId, visitDeptId)
|
||||
.in(CollUtil.isNotEmpty(pdtIds), MaterialBatchDO::getProductId, pdtIds)
|
||||
.eq(CollUtil.isEmpty(pdtIds) && reqVO.getProductId() != null, MaterialBatchDO::getProductId, reqVO.getProductId())
|
||||
@@ -106,7 +109,7 @@ public interface MaterialBatchMapper extends BaseMapperX<MaterialBatchDO> {
|
||||
.eqIfExists(MaterialBatchDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
|
||||
.eqIfExists(MaterialBatchDO::getRemark, reqVO.getRemark())
|
||||
// .betweenIfPresent(MaterialBatchDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(MaterialBatchDO::getId);
|
||||
.orderByDesc(MaterialBatchDO::getParentId);
|
||||
return selectJoinPage(reqVO, MaterialBatchRespVO.class, wrapper);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@ import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryI
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundRespVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundSaveReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryInboundDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialLifecycleDetailDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryInboundMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -30,8 +32,18 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb
|
||||
@Resource
|
||||
private MaterialInventoryInboundMapper materialInventoryInboundMapper;
|
||||
|
||||
@Autowired
|
||||
private MaterialLifecycleDetailService materialLifecycleDetailService;
|
||||
|
||||
@Override
|
||||
public MaterialInventoryInboundRespVO createMaterialInventoryInbound(MaterialInventoryInboundSaveReqVO createReqVO) {
|
||||
// 1.校验工段是否已经验收
|
||||
Long gongduanId = createReqVO.getGongduanId();
|
||||
MaterialLifecycleDetailDO lifecycleDetail = materialLifecycleDetailService.getMaterialLifecycleDetailByGongId(gongduanId);
|
||||
// 2.入库数量不大于批次工段数量
|
||||
// 3.保存入库记录
|
||||
// 4.生成物料实例
|
||||
// 5.保存入库明细
|
||||
// 插入
|
||||
MaterialInventoryInboundDO materialInventoryInbound = BeanUtils.toBean(createReqVO, MaterialInventoryInboundDO.class);
|
||||
materialInventoryInboundMapper.insert(materialInventoryInbound);
|
||||
|
||||
@@ -89,4 +89,19 @@ public interface MaterialLifecycleDetailService {
|
||||
* @return 明细列表
|
||||
*/
|
||||
List<MaterialLifecycleDetailRespVO> getMaterialLifecycleDetailListByLfcId(Long id);
|
||||
|
||||
/**
|
||||
* 根据工段id 获取流程明细数据
|
||||
* @param gongduanId 工段id
|
||||
* @return 明细数据
|
||||
*/
|
||||
MaterialLifecycleDetailDO getMaterialLifecycleDetailByGongId(Long gongduanId);
|
||||
|
||||
/**
|
||||
* 更新流程明细状态
|
||||
*
|
||||
* @param lfcId 流程id
|
||||
* @param status 状态
|
||||
*/
|
||||
void updateDetailStatus(Long lfcId, String status);
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.qms.enums.QmsBpmConstant;
|
||||
import com.zt.plat.module.qms.enums.QmsCommonConstant;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecycleDetailPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecycleDetailRespVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecycleDetailSaveReqVO;
|
||||
@@ -112,4 +114,21 @@ public class MaterialLifecycleDetailServiceImpl implements MaterialLifecycleDeta
|
||||
return materialLifecycleDetailMapper.selectListWithPdtBatInfo(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MaterialLifecycleDetailDO getMaterialLifecycleDetailByGongId(Long gongduanId) {
|
||||
|
||||
return materialLifecycleDetailMapper.selectOne(Wrappers.lambdaQuery(MaterialLifecycleDetailDO.class)
|
||||
.eq(MaterialLifecycleDetailDO::getBatchGongduanId, gongduanId)
|
||||
.eq(MaterialLifecycleDetailDO::getTreatmentStatus, QmsCommonConstant.COMPLETED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDetailStatus(Long lfcId, String status) {
|
||||
boolean isCompleted = QmsCommonConstant.COMPLETED.equals(status);
|
||||
MaterialLifecycleDetailDO detailUpdate = new MaterialLifecycleDetailDO().setTreatmentStatus(isCompleted ? 1 : 0);
|
||||
materialLifecycleDetailMapper.update(detailUpdate, Wrappers.lambdaQuery(MaterialLifecycleDetailDO.class)
|
||||
.eq(MaterialLifecycleDetailDO::getLifecycleId, lfcId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.zt.plat.module.qms.resource.material.service;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zt.plat.framework.common.exception.ServiceException;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
@@ -17,6 +18,8 @@ import com.zt.plat.module.bpm.api.task.dto.BpmTaskApproveReqDTO;
|
||||
import com.zt.plat.module.bpm.api.task.dto.BpmTaskRespDTO;
|
||||
import com.zt.plat.module.qms.api.task.BMPCallbackInterface;
|
||||
import com.zt.plat.module.qms.api.task.dto.QmsBpmDTO;
|
||||
import com.zt.plat.module.qms.common.data.service.DataKeyCheckService;
|
||||
import com.zt.plat.module.qms.enums.QmsBpmConstant;
|
||||
import com.zt.plat.module.qms.enums.QmsCommonConstant;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.*;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO;
|
||||
@@ -70,6 +73,9 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService ,
|
||||
@Autowired
|
||||
private BpmProcessInstanceApi bpmProcessInstanceApi;
|
||||
|
||||
@Autowired
|
||||
private DataKeyCheckService dataKeyCheckService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public MaterialLifecycleRespVO createMaterialLifecycle(MaterialLifecycleSaveReqVO createReqVO) {
|
||||
@@ -114,7 +120,7 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService ,
|
||||
MaterialLifecycleDetailDO detailDO = new MaterialLifecycleDetailDO();
|
||||
detailDO.setLifecycleId(mtrlLfc.getId())
|
||||
.setProductId(gong.getProductId()).setBatchId(gong.getParentId())
|
||||
.setBatchGongduanId(gong.getId())
|
||||
.setBatchGongduanId(gong.getId()).setBusinessType(mtrlLfc.getBusinessType())
|
||||
.setAssayFlag(gong.getAssayFlag())
|
||||
.setTreatmentStatus(0);
|
||||
return detailDO;
|
||||
@@ -276,19 +282,18 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService ,
|
||||
BpmProcessInstanceCreateReqDTO reqDTO = new BpmProcessInstanceCreateReqDTO();
|
||||
reqDTO.setBusinessKey(String.valueOf(lifecycleDO.getId()))
|
||||
.setVariables(variables);
|
||||
|
||||
// switch (lifecycleDO.getBusinessType()) {
|
||||
// case "验收":
|
||||
// reqDTO.setProcessDefinitionKey("MATERIAL_ACCEPTANCE_FLOW_KEY");
|
||||
// break;
|
||||
// case "退换货":
|
||||
// reqDTO.setProcessDefinitionKey("MATERIAL_RETURN_EXCHANGE_FLOW_KEY");
|
||||
// break;
|
||||
// case "配置申请":
|
||||
// reqDTO.setProcessDefinitionKey("MATERIAL_CONFIG_APPLY_FLOW_KEY");
|
||||
// break;
|
||||
// }
|
||||
reqDTO.setProcessDefinitionKey("QMS_RESOURCE_MATERIAL_COMMON");
|
||||
// TODO 流程key根据业务类型动态获取
|
||||
switch (lifecycleDO.getBusinessType()) {
|
||||
case "验收":
|
||||
reqDTO.setProcessDefinitionKey("QMS_RESOURCE_MATERIAL_ACCEPTANCE");
|
||||
break;
|
||||
case "退换货":
|
||||
reqDTO.setProcessDefinitionKey("QMS_RESOURCE_MATERIAL_RETURN_EXCHANGE");
|
||||
break;
|
||||
case "配置申请":
|
||||
reqDTO.setProcessDefinitionKey("QMS_RESOURCE_MATERIAL_CONFIG_APPLY");
|
||||
break;
|
||||
}
|
||||
CommonResult<String> result = bpmProcessInstanceApi.createProcessInstance(loginUserId, reqDTO);
|
||||
if(!result.isSuccess()){
|
||||
throw exception0(ERROR_CODE_MODULE_COMMON, result.getMsg());
|
||||
@@ -307,36 +312,72 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService ,
|
||||
*/
|
||||
@Override
|
||||
public CommonResult<JSONObject> callback(QmsBpmDTO reqDTO) {
|
||||
log.info("物料流程回调信息:{}", reqDTO.toString());
|
||||
/*
|
||||
QmsBpmDTO(
|
||||
processInstanceId=042585c1-00e3-11f1-9df0-005056c00001,
|
||||
businessKey=2018618104343769090,
|
||||
variables={
|
||||
"_FLOWABLE_SKIP_EXPRESSION_ENABLED":true,
|
||||
"processInstanceId":"042585c1-00e3-11f1-9df0-005056c00001",
|
||||
"nrOfActiveInstances":1,
|
||||
"bpmFieldExtensions":[],
|
||||
"PROCESS_STATUS":1,
|
||||
"currentActivityInsId":"043c904a-00e3-11f1-9df0-005056c00001",
|
||||
"bpmCallbackBean":"materialLifecycleService",
|
||||
"applyDepartment":"检验检测管理中心",
|
||||
"Activity_0tp833v_assignees":["2008359763063820290"],
|
||||
"loopCounter":0,
|
||||
"applyUserId":"2008359763063820290",
|
||||
"nrOfInstances":1,
|
||||
"PROCESS_START_USER_ID":"2008359763063820290",
|
||||
"applyUser":"云铜检验管理员",
|
||||
"Activity_0tp833v_assignee":"2008359763063820290",
|
||||
"applyDepartmentId":170,
|
||||
"applyTime":"2026-02-03 17:30:44",
|
||||
"mainId":"2018618104343769090",
|
||||
"bpmCallbackActivityId":"Activity_0tp833v",
|
||||
"nrOfCompletedInstances":1
|
||||
},
|
||||
state=)
|
||||
*/
|
||||
// 变更流程状态
|
||||
return null;
|
||||
log.debug("物料流程回调信息:{}", reqDTO.toString());
|
||||
|
||||
JSONObject variables = reqDTO.getVariables();
|
||||
String processInsId = reqDTO.getProcessInstanceId();
|
||||
String currentActivityInsId = variables.getString(QmsBpmConstant.BPM_CUR_ACTIVITY_INS_ID);
|
||||
String returnFlag = variables.getString(QmsBpmConstant.BPM_REJECT_TO_FIRST_FLAG);
|
||||
// 同一个节点需要避免重复处理
|
||||
String checkKey = currentActivityInsId;
|
||||
if(StrUtil.isEmpty(currentActivityInsId))
|
||||
checkKey = processInsId + "-create";
|
||||
if("1".equals(returnFlag))
|
||||
checkKey += "-reject";
|
||||
try{
|
||||
dataKeyCheckService.create(checkKey, this.getClass().getName());
|
||||
} catch (Exception e){
|
||||
log.error("checkKey 重复:key={}", checkKey);
|
||||
return CommonResult.success(new JSONObject());
|
||||
}
|
||||
// 流程状态处理 1-提交(含退回) 3-拒绝 4-取消流程
|
||||
String PROCESS_STATUS = variables.getString(QmsBpmConstant.PROCESS_INSTANCE_VARIABLE_STATUS);
|
||||
String businessKey = reqDTO.getBusinessKey();
|
||||
JSONArray fieldExtensions = new JSONArray();
|
||||
if(variables.containsKey(QmsBpmConstant.BPM_FIELD_EXTENSIONS)){
|
||||
fieldExtensions = variables.getJSONArray(QmsBpmConstant.BPM_FIELD_EXTENSIONS);
|
||||
}
|
||||
MaterialLifecycleDO entity = materialLifecycleMapper.selectById(Long.valueOf(businessKey));
|
||||
// String currentActivityId = variables.getString(QmsBpmConstant.BPM_CALLBACK_ACTIVITY_ID);
|
||||
// 检查是否最后一个节点
|
||||
boolean lastActivityFlag = false;
|
||||
boolean firstActivityFlag = false;
|
||||
if(!fieldExtensions.isEmpty()){
|
||||
for(int i = 0; i < fieldExtensions.size(); i++){
|
||||
JSONObject fieldExtension = fieldExtensions.getJSONObject(i);
|
||||
if(fieldExtension.getString("fieldName").equalsIgnoreCase(QmsBpmConstant.BPM_LAST_ACTIVITY_FLAG)){
|
||||
lastActivityFlag = true;
|
||||
}
|
||||
if(fieldExtension.getString("fieldName").equalsIgnoreCase(QmsBpmConstant.BPM_FIRST_ACTIVITY_FLAG)){
|
||||
firstActivityFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 根据流程状态处理业务数据
|
||||
if(("1").equals(returnFlag)){
|
||||
// 驳回。流程需要配置退回到发起节点
|
||||
entity.setFlowStatus(QmsCommonConstant.REJECTED);
|
||||
} else if("3".equals(PROCESS_STATUS)){
|
||||
// 拒绝
|
||||
entity.setFlowStatus(QmsCommonConstant.REFUSED);
|
||||
} else if("4".equals(PROCESS_STATUS)){
|
||||
// 作废
|
||||
entity.setFlowStatus(QmsCommonConstant.VOID);
|
||||
} else if("1".equals(PROCESS_STATUS) || "2".equals(PROCESS_STATUS)){
|
||||
// 通过
|
||||
if(firstActivityFlag)
|
||||
// 驳回后重新提交
|
||||
entity.setFlowStatus(QmsCommonConstant.IN_PROGRESS);
|
||||
if(lastActivityFlag) {
|
||||
// 结束审批
|
||||
entity.setFlowStatus(QmsCommonConstant.COMPLETED);
|
||||
// 更新明细处理状态
|
||||
materialLifecycleDetailService.updateDetailStatus(entity.getId(), QmsCommonConstant.COMPLETED);
|
||||
// TODO 物料入库
|
||||
}
|
||||
|
||||
}
|
||||
materialLifecycleMapper.updateById(entity);
|
||||
return CommonResult.success(new JSONObject());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user