fix:物料验收流程
This commit is contained in:
@@ -93,7 +93,12 @@ public class MaterialBatchController implements BusinessControllerMarker {
|
|||||||
@Operation(summary = "获得物料批次分页")
|
@Operation(summary = "获得物料批次分页")
|
||||||
// @PreAuthorize("@ss.hasPermission('qms:material-batch:query')")
|
// @PreAuthorize("@ss.hasPermission('qms:material-batch:query')")
|
||||||
public CommonResult<PageResult<MaterialBatchRespVO>> getMaterialBatchPage(@Valid MaterialBatchPageReqVO pageReqVO) {
|
public CommonResult<PageResult<MaterialBatchRespVO>> getMaterialBatchPage(@Valid MaterialBatchPageReqVO pageReqVO) {
|
||||||
PageResult<MaterialBatchRespVO> pageResult = materialBatchService.getMaterialBatchPageWithPdtInfo(pageReqVO);
|
PageResult<MaterialBatchRespVO> pageResult;
|
||||||
|
if (!pageReqVO.getOnlyGong()) {
|
||||||
|
pageResult = materialBatchService.getMaterialBatchPageWithPdtInfo(pageReqVO);
|
||||||
|
} else {
|
||||||
|
pageResult = materialBatchService.getMaterialBatchGongPageWithPdtInfo(pageReqVO);
|
||||||
|
}
|
||||||
return success(pageResult);
|
return success(pageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 物料通用流程明细 Response VO")
|
@Schema(description = "管理后台 - 物料通用流程明细 Response VO")
|
||||||
@@ -53,6 +54,10 @@ public class MaterialLifecycleDetailRespVO {
|
|||||||
@ExcelProperty("批次工段-部门名称")
|
@ExcelProperty("批次工段-部门名称")
|
||||||
private String assignDepartmentName;
|
private String assignDepartmentName;
|
||||||
|
|
||||||
|
@Schema(description = "是否检化验,1-是,0-否")
|
||||||
|
@ExcelProperty("是否检化验,1-是,0-否")
|
||||||
|
private Integer assayFlag;
|
||||||
|
|
||||||
@Schema(description = "物料实例id", example = "968")
|
@Schema(description = "物料实例id", example = "968")
|
||||||
@ExcelProperty("物料实例id")
|
@ExcelProperty("物料实例id")
|
||||||
private Long infomationId;
|
private Long infomationId;
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ public class MaterialLifecycleDetailSaveReqVO {
|
|||||||
@Schema(description = "批次工段id", example = "21334")
|
@Schema(description = "批次工段id", example = "21334")
|
||||||
private Long batchGongduanId;
|
private Long batchGongduanId;
|
||||||
|
|
||||||
|
@Schema(description = "是否检化验,1-是,0-否")
|
||||||
|
private Integer assayFlag;
|
||||||
|
|
||||||
@Schema(description = "物料实例id", example = "968")
|
@Schema(description = "物料实例id", example = "968")
|
||||||
private Long infomationId;
|
private Long infomationId;
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ public class MaterialLifecycleSaveReqVO {
|
|||||||
private Long applyDepartmentId;
|
private Long applyDepartmentId;
|
||||||
|
|
||||||
@Schema(description = "申请时间")
|
@Schema(description = "申请时间")
|
||||||
@NotNull(groups = AddGroup.class, message = "申请时间不能为空")
|
|
||||||
private LocalDateTime applyTime;
|
private LocalDateTime applyTime;
|
||||||
|
|
||||||
@Schema(description = "表单数据,表单数据")
|
@Schema(description = "表单数据,表单数据")
|
||||||
@@ -64,6 +63,6 @@ public class MaterialLifecycleSaveReqVO {
|
|||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@Schema(description = "工段列表")
|
@Schema(description = "工段列表")
|
||||||
private List<Long> gongIds;
|
private List<MaterialLifecycleDetailSaveReqVO> detailList;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -48,6 +48,11 @@ public class MaterialLifecycleDetailDO extends BusinessBaseDO {
|
|||||||
*/
|
*/
|
||||||
@TableField("BAT_GONG_ID")
|
@TableField("BAT_GONG_ID")
|
||||||
private Long batchGongduanId;
|
private Long batchGongduanId;
|
||||||
|
/**
|
||||||
|
* 是否检化验,1-是,0-否
|
||||||
|
*/
|
||||||
|
@TableField("ASY_FLG")
|
||||||
|
private Integer assayFlag;
|
||||||
/**
|
/**
|
||||||
* 物料实例id
|
* 物料实例id
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.zt.plat.module.qms.resource.material.dal.mapper;
|
package com.zt.plat.module.qms.resource.material.dal.mapper;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
@@ -44,8 +43,38 @@ public interface MaterialBatchMapper extends BaseMapperX<MaterialBatchDO> {
|
|||||||
.orderByDesc(MaterialBatchDO::getId));
|
.orderByDesc(MaterialBatchDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
// onlyGong 是否只查询工段
|
default PageResult<MaterialBatchRespVO> selectPageWithPdtInfo(MaterialBatchPageReqVO reqVO, List<Long> pdtIds) {
|
||||||
default PageResult<MaterialBatchRespVO> selectPage(MaterialBatchPageReqVO reqVO, List<Long> pdtIds, Boolean onlyGong) {
|
|
||||||
|
MPJLambdaWrapper<MaterialBatchDO> wrapper = new MPJLambdaWrapperX<MaterialBatchDO>()
|
||||||
|
.selectAll(MaterialBatchDO.class)
|
||||||
|
.selectAs(MaterialProductDO::getName, MaterialBatchRespVO::getProductName)
|
||||||
|
.selectAs(MaterialProductDO::getCode, MaterialBatchRespVO::getProductCode)
|
||||||
|
.selectAs(MaterialProductDO::getModelNo, MaterialBatchRespVO::getProductModelNo)
|
||||||
|
.leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialBatchDO::getProductId)
|
||||||
|
// 只查询批次
|
||||||
|
.eq(MaterialBatchDO::getParentId, 0)
|
||||||
|
.in(CollUtil.isNotEmpty(pdtIds), MaterialBatchDO::getProductId, pdtIds)
|
||||||
|
.eq(CollUtil.isEmpty(pdtIds) && reqVO.getProductId() != null, MaterialBatchDO::getProductId, reqVO.getProductId())
|
||||||
|
.likeIfExists(MaterialBatchDO::getBatchNo, reqVO.getBatchNo())
|
||||||
|
.likeIfExists(MaterialBatchDO::getLocation, reqVO.getLocation())
|
||||||
|
.likeIfExists(MaterialBatchDO::getSupplierId, reqVO.getSupplierId())
|
||||||
|
// .betweenIfPresent(MaterialBatchDO::getManufacturerDate, reqVO.getManufacturerDate())
|
||||||
|
// .betweenIfPresent(MaterialBatchDO::getDueDate, reqVO.getDueDate())
|
||||||
|
.eqIfExists(MaterialBatchDO::getAssignDepartmentId, reqVO.getAssignDepartmentId())
|
||||||
|
.likeIfExists(MaterialBatchDO::getAssignDepartmentName, reqVO.getAssignDepartmentName())
|
||||||
|
.eqIfExists(MaterialBatchDO::getAcceptanceStatus, reqVO.getAcceptanceStatus())
|
||||||
|
.eqIfExists(MaterialBatchDO::getAssayFlag, reqVO.getAssayFlag())
|
||||||
|
.eqIfExists(MaterialBatchDO::getAssayStatus, reqVO.getAssayStatus())
|
||||||
|
.eqIfExists(MaterialBatchDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
|
||||||
|
.eqIfExists(MaterialBatchDO::getRemark, reqVO.getRemark())
|
||||||
|
// .betweenIfPresent(MaterialBatchDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(MaterialBatchDO::getId);
|
||||||
|
return selectJoinPage(reqVO, MaterialBatchRespVO.class, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
default PageResult<MaterialBatchRespVO> selectGongPage(MaterialBatchPageReqVO reqVO, List<Long> pdtIds) {
|
||||||
|
|
||||||
|
|
||||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
Long visitDeptId = null;
|
Long visitDeptId = null;
|
||||||
if (loginUser != null) {
|
if (loginUser != null) {
|
||||||
@@ -57,11 +86,10 @@ public interface MaterialBatchMapper extends BaseMapperX<MaterialBatchDO> {
|
|||||||
.selectAs(MaterialProductDO::getCode, MaterialBatchRespVO::getProductCode)
|
.selectAs(MaterialProductDO::getCode, MaterialBatchRespVO::getProductCode)
|
||||||
.selectAs(MaterialProductDO::getModelNo, MaterialBatchRespVO::getProductModelNo)
|
.selectAs(MaterialProductDO::getModelNo, MaterialBatchRespVO::getProductModelNo)
|
||||||
.leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialBatchDO::getProductId)
|
.leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialBatchDO::getProductId)
|
||||||
// 只查询批次,不查询工段
|
|
||||||
.eq(onlyGong != null && !onlyGong, MaterialBatchDO::getParentId, 0)
|
|
||||||
// 只查询工段
|
// 只查询工段
|
||||||
.ne(onlyGong != null && onlyGong, MaterialBatchDO::getParentId, 0)
|
.ne(MaterialBatchDO::getParentId, 0)
|
||||||
.eq(onlyGong != null && onlyGong, MaterialBatchDO::getSubmitStatus, 1)
|
.eq(MaterialBatchDO::getSubmitStatus, 1)
|
||||||
|
.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)
|
// .eq(onlyGong != null && visitDeptId != null && onlyGong, MaterialBatchDO::getAssignDepartmentId, visitDeptId)
|
||||||
.in(CollUtil.isNotEmpty(pdtIds), MaterialBatchDO::getProductId, pdtIds)
|
.in(CollUtil.isNotEmpty(pdtIds), MaterialBatchDO::getProductId, pdtIds)
|
||||||
.eq(CollUtil.isEmpty(pdtIds) && reqVO.getProductId() != null, MaterialBatchDO::getProductId, reqVO.getProductId())
|
.eq(CollUtil.isEmpty(pdtIds) && reqVO.getProductId() != null, MaterialBatchDO::getProductId, reqVO.getProductId())
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.zt.plat.module.qms.resource.material.dal.mapper;
|
package com.zt.plat.module.qms.resource.material.dal.mapper;
|
||||||
|
|
||||||
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
@@ -39,16 +40,18 @@ public interface MaterialLifecycleDetailMapper extends BaseMapperX<MaterialLifec
|
|||||||
}
|
}
|
||||||
|
|
||||||
default List<MaterialLifecycleDetailRespVO> selectListWithPdtBatInfo(Long id){
|
default List<MaterialLifecycleDetailRespVO> selectListWithPdtBatInfo(Long id){
|
||||||
MPJLambdaWrapperX<MaterialLifecycleDetailDO> wrapperX = new MPJLambdaWrapperX<MaterialLifecycleDetailDO>()
|
MPJLambdaWrapper<MaterialLifecycleDetailDO> wrapper = new MPJLambdaWrapper<MaterialLifecycleDetailDO>()
|
||||||
.selectAll(MaterialLifecycleDetailDO.class)
|
.selectAll(MaterialLifecycleDetailDO.class)
|
||||||
.selectAs(MaterialProductDO::getName, MaterialLifecycleDetailRespVO::getProductName)
|
.selectAs(MaterialProductDO::getName, MaterialLifecycleDetailRespVO::getProductName)
|
||||||
.selectAs(MaterialProductDO::getCode, MaterialLifecycleDetailRespVO::getProductCode)
|
.selectAs(MaterialProductDO::getCode, MaterialLifecycleDetailRespVO::getProductCode)
|
||||||
.selectAs(MaterialProductDO::getModelNo, MaterialLifecycleDetailRespVO::getProductModelNo)
|
.selectAs(MaterialProductDO::getModelNo, MaterialLifecycleDetailRespVO::getProductModelNo)
|
||||||
.selectAs(MaterialBatchDO::getBatchNo, MaterialLifecycleDetailRespVO::getBatchNo)
|
.selectAs("batch.BAT_NO", MaterialLifecycleDetailRespVO::getBatchNo)
|
||||||
|
.selectAs("gongduan.INB_QTY", MaterialLifecycleDetailRespVO::getInfluenceCount)
|
||||||
.leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialLifecycleDetailDO::getProductId)
|
.leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialLifecycleDetailDO::getProductId)
|
||||||
.leftJoin(MaterialBatchDO.class, MaterialBatchDO::getId, MaterialLifecycleDetailDO::getBatchId)
|
.leftJoin(MaterialBatchDO.class, "batch", MaterialBatchDO::getId, MaterialLifecycleDetailDO::getBatchId)
|
||||||
|
.leftJoin(MaterialBatchDO.class, "gongduan", MaterialBatchDO::getId, MaterialLifecycleDetailDO::getBatchGongduanId)
|
||||||
.eq(MaterialLifecycleDetailDO::getLifecycleId, id);
|
.eq(MaterialLifecycleDetailDO::getLifecycleId, id);
|
||||||
|
|
||||||
return selectJoinList(MaterialLifecycleDetailRespVO.class, wrapperX);
|
return selectJoinList(MaterialLifecycleDetailRespVO.class, wrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,15 @@
|
|||||||
package com.zt.plat.module.qms.resource.material.service;
|
package com.zt.plat.module.qms.resource.material.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.zt.plat.framework.common.exception.ErrorCode;
|
|
||||||
import com.zt.plat.framework.common.exception.ServiceException;
|
import com.zt.plat.framework.common.exception.ServiceException;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
import com.zt.plat.module.qms.core.code.SequenceUtil;
|
import com.zt.plat.module.qms.core.code.SequenceUtil;
|
||||||
import com.zt.plat.module.qms.enums.ErrorCodeConstants;
|
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO;
|
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchRespVO;
|
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchRespVO;
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchSaveReqVO;
|
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchSaveReqVO;
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductRespVO;
|
|
||||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO;
|
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO;
|
||||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO;
|
|
||||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO;
|
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO;
|
||||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialBatchMapper;
|
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialBatchMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@@ -24,8 +19,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -71,12 +64,10 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
|
|||||||
public void updateMaterialBatch(MaterialBatchSaveReqVO updateReqVO) {
|
public void updateMaterialBatch(MaterialBatchSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
Long reqId = updateReqVO.getId();
|
Long reqId = updateReqVO.getId();
|
||||||
validateMaterialBatchExists(reqId);
|
MaterialBatchDO batchDO = materialBatchMapper.selectById(reqId);
|
||||||
|
if (batchDO == null) throw exception(MATERIAL_BATCH_NOT_EXISTS);
|
||||||
// 已经拆分工段的不可编辑
|
// 已经提交的不可修改
|
||||||
List<MaterialBatchDO> asnDOs = materialBatchMapper.selectList(Wrappers.lambdaQuery(MaterialBatchDO.class)
|
if (batchDO.getSubmitStatus() == 1) throw new ServiceException(1_032_160_000, "批次已经提交,不可修改");
|
||||||
.eq(MaterialBatchDO::getParentId, reqId));
|
|
||||||
if (CollUtil.isNotEmpty(asnDOs)) throw exception(MATERIAL_BATCH_ASSIGN_END);
|
|
||||||
|
|
||||||
// 更新
|
// 更新
|
||||||
MaterialBatchDO updateObj = BeanUtils.toBean(updateReqVO, MaterialBatchDO.class);
|
MaterialBatchDO updateObj = BeanUtils.toBean(updateReqVO, MaterialBatchDO.class);
|
||||||
@@ -137,11 +128,19 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<MaterialBatchRespVO> getMaterialBatchPageWithPdtInfo(MaterialBatchPageReqVO pageReqVO) {
|
public PageResult<MaterialBatchRespVO> getMaterialBatchPageWithPdtInfo(MaterialBatchPageReqVO pageReqVO) {
|
||||||
// 先分页查询批次或工段
|
Long pdtId = pageReqVO.getProductId();
|
||||||
Boolean onlyGong = pageReqVO.getOnlyGong();
|
PageResult<MaterialBatchRespVO> pageResult;
|
||||||
PageResult<MaterialBatchRespVO> pageResult = getMaterialBatchRespVOPageWithPdtInfo(pageReqVO, onlyGong);
|
if (pdtId == null) {
|
||||||
// 只获取工段
|
pageResult = materialBatchMapper.selectPageWithPdtInfo(pageReqVO, List.of());
|
||||||
if (onlyGong) return pageResult;
|
} else {
|
||||||
|
List<MaterialProductDO> mtrlDos = materialProductService.getMaterialProductsByLikeIdPath(pdtId);
|
||||||
|
if (CollUtil.isEmpty(mtrlDos)) {
|
||||||
|
pageResult = materialBatchMapper.selectPageWithPdtInfo(pageReqVO, List.of());
|
||||||
|
} else {
|
||||||
|
List<Long> pdtIds = mtrlDos.stream().map(MaterialProductDO::getId).toList();
|
||||||
|
pageResult = materialBatchMapper.selectPageWithPdtInfo(pageReqVO, pdtIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
// 如果获取是批次分页,再根据批次ids获取工段
|
// 如果获取是批次分页,再根据批次ids获取工段
|
||||||
List<MaterialBatchRespVO> batches = pageResult.getList();
|
List<MaterialBatchRespVO> batches = pageResult.getList();
|
||||||
if (CollUtil.isNotEmpty(batches)) {
|
if (CollUtil.isNotEmpty(batches)) {
|
||||||
@@ -181,7 +180,7 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
|
|||||||
// 2. 拆分后的数量要相等
|
// 2. 拆分后的数量要相等
|
||||||
MaterialBatchDO mtrlBat = materialBatchMapper.selectById(batId);
|
MaterialBatchDO mtrlBat = materialBatchMapper.selectById(batId);
|
||||||
if (mtrlBat == null) throw exception(MATERIAL_BATCH_NOT_EXISTS);
|
if (mtrlBat == null) throw exception(MATERIAL_BATCH_NOT_EXISTS);
|
||||||
|
if (mtrlBat.getSubmitStatus() == 1) throw new ServiceException(1_032_160_000, "批次已经提交,不可修改");
|
||||||
BigDecimal total = BigDecimal.valueOf(0);
|
BigDecimal total = BigDecimal.valueOf(0);
|
||||||
for (MaterialBatchSaveReqVO batAsn : createReqVOs) {
|
for (MaterialBatchSaveReqVO batAsn : createReqVOs) {
|
||||||
total = total.add(batAsn.getInboundQuantity());
|
total = total.add(batAsn.getInboundQuantity());
|
||||||
@@ -192,7 +191,6 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
|
|||||||
boolean exists = materialBatchMapper.exists(Wrappers.lambdaQuery(MaterialBatchDO.class)
|
boolean exists = materialBatchMapper.exists(Wrappers.lambdaQuery(MaterialBatchDO.class)
|
||||||
.eq(MaterialBatchDO::getParentId, batId));
|
.eq(MaterialBatchDO::getParentId, batId));
|
||||||
if (exists) {
|
if (exists) {
|
||||||
if (mtrlBat.getSubmitStatus() == 1) throw new ServiceException(1_032_160_000, "批次已经提交,禁止修改");
|
|
||||||
// 删除之前的拆分数据
|
// 删除之前的拆分数据
|
||||||
materialBatchMapper.delete(Wrappers.lambdaQuery(MaterialBatchDO.class)
|
materialBatchMapper.delete(Wrappers.lambdaQuery(MaterialBatchDO.class)
|
||||||
.eq(MaterialBatchDO::getParentId, batId));
|
.eq(MaterialBatchDO::getParentId, batId));
|
||||||
@@ -267,22 +265,18 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<MaterialBatchRespVO> getMaterialBatchGongPageWithPdtInfo(MaterialBatchPageReqVO pageReqVO) {
|
public PageResult<MaterialBatchRespVO> getMaterialBatchGongPageWithPdtInfo(MaterialBatchPageReqVO pageReqVO) {
|
||||||
|
// 需要排除已经被选择的工段
|
||||||
return getMaterialBatchRespVOPageWithPdtInfo(pageReqVO, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private PageResult<MaterialBatchRespVO> getMaterialBatchRespVOPageWithPdtInfo(MaterialBatchPageReqVO pageReqVO, boolean onlyGong) {
|
|
||||||
Long pdtId = pageReqVO.getProductId();
|
Long pdtId = pageReqVO.getProductId();
|
||||||
PageResult<MaterialBatchRespVO> pageResult;
|
PageResult<MaterialBatchRespVO> pageResult;
|
||||||
if (pdtId == null) {
|
if (pdtId == null) {
|
||||||
pageResult = materialBatchMapper.selectPage(pageReqVO, List.of(), onlyGong);
|
pageResult = materialBatchMapper.selectGongPage(pageReqVO, List.of());
|
||||||
} else {
|
} else {
|
||||||
List<MaterialProductDO> mtrlDos = materialProductService.getMaterialProductsByLikeIdPath(pdtId);
|
List<MaterialProductDO> mtrlDos = materialProductService.getMaterialProductsByLikeIdPath(pdtId);
|
||||||
if (CollUtil.isEmpty(mtrlDos)) {
|
if (CollUtil.isEmpty(mtrlDos)) {
|
||||||
pageResult = materialBatchMapper.selectPage(pageReqVO, List.of(), onlyGong);
|
pageResult = materialBatchMapper.selectGongPage(pageReqVO, List.of());
|
||||||
} else {
|
} else {
|
||||||
List<Long> pdtIds = mtrlDos.stream().map(MaterialProductDO::getId).toList();
|
List<Long> pdtIds = mtrlDos.stream().map(MaterialProductDO::getId).toList();
|
||||||
pageResult = materialBatchMapper.selectPage(pageReqVO, pdtIds, onlyGong);
|
pageResult = materialBatchMapper.selectGongPage(pageReqVO, pdtIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pageResult;
|
return pageResult;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.zt.plat.module.qms.resource.material.service;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.zt.plat.framework.common.exception.ServiceException;
|
import com.zt.plat.framework.common.exception.ServiceException;
|
||||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
@@ -10,23 +12,28 @@ import com.zt.plat.framework.security.core.LoginUser;
|
|||||||
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import com.zt.plat.module.bpm.api.task.BpmProcessInstanceApi;
|
import com.zt.plat.module.bpm.api.task.BpmProcessInstanceApi;
|
||||||
import com.zt.plat.module.bpm.api.task.BpmTaskApi;
|
import com.zt.plat.module.bpm.api.task.BpmTaskApi;
|
||||||
|
import com.zt.plat.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||||
import com.zt.plat.module.bpm.api.task.dto.BpmTaskApproveReqDTO;
|
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.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.enums.QmsCommonConstant;
|
import com.zt.plat.module.qms.enums.QmsCommonConstant;
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecycleDetailRespVO;
|
import com.zt.plat.module.qms.resource.material.controller.vo.*;
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecyclePageReqVO;
|
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecycleRespVO;
|
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecycleSaveReqVO;
|
|
||||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO;
|
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO;
|
||||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialLifecycleDO;
|
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialLifecycleDO;
|
||||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialLifecycleDetailDO;
|
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialLifecycleDetailDO;
|
||||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialLifecycleMapper;
|
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialLifecycleMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -36,15 +43,17 @@ import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.e
|
|||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.ERROR_CODE_MODULE_COMMON;
|
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.ERROR_CODE_MODULE_COMMON;
|
||||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.MATERIAL_LIFECYCLE_NOT_EXISTS;
|
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.MATERIAL_LIFECYCLE_NOT_EXISTS;
|
||||||
|
import static com.zt.plat.module.qms.enums.QmsBpmConstant.BPM_CALLBACK_BEAN_NAME;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料通用流程,物料验收、退换货 Service 实现类
|
* 物料通用流程,物料验收、退换货 Service 实现类
|
||||||
*
|
*
|
||||||
* @author 后台管理
|
* @author 后台管理
|
||||||
*/
|
*/
|
||||||
@Service
|
@Slf4j
|
||||||
|
@Service("materialLifecycleService")
|
||||||
@Validated
|
@Validated
|
||||||
public class MaterialLifecycleServiceImpl implements MaterialLifecycleService {
|
public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , BMPCallbackInterface {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MaterialLifecycleMapper materialLifecycleMapper;
|
private MaterialLifecycleMapper materialLifecycleMapper;
|
||||||
@@ -67,14 +76,28 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService {
|
|||||||
// 插入
|
// 插入
|
||||||
MaterialLifecycleDO mtrlLfc = BeanUtils.toBean(createReqVO, MaterialLifecycleDO.class);
|
MaterialLifecycleDO mtrlLfc = BeanUtils.toBean(createReqVO, MaterialLifecycleDO.class);
|
||||||
mtrlLfc.setSubmitStatus(0);
|
mtrlLfc.setSubmitStatus(0);
|
||||||
|
String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname();
|
||||||
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
|
if (loginUser == null) throw new ServiceException(1_032_160_000, "登录用户不存在");
|
||||||
|
mtrlLfc.setApplyUser(loginUserNickname)
|
||||||
|
.setApplyUserId(loginUser.getId())
|
||||||
|
.setApplyDepartment(loginUser.getVisitDeptName())
|
||||||
|
.setApplyDepartmentId(loginUser.getVisitDeptId());
|
||||||
|
mtrlLfc.setFlowStatus(QmsCommonConstant.NOT_START);
|
||||||
materialLifecycleMapper.insert(mtrlLfc);
|
materialLifecycleMapper.insert(mtrlLfc);
|
||||||
List<Long> gongIds = createReqVO.getGongIds();
|
List<MaterialLifecycleDetailSaveReqVO> detailList = createReqVO.getDetailList();
|
||||||
if (CollUtil.isEmpty(gongIds))
|
if (CollUtil.isEmpty(detailList))
|
||||||
return BeanUtils.toBean(mtrlLfc, MaterialLifecycleRespVO.class);
|
return BeanUtils.toBean(mtrlLfc, MaterialLifecycleRespVO.class);
|
||||||
// 保存工段明细
|
// 保存工段明细
|
||||||
|
List<Long> gongIds = detailList.stream().map(MaterialLifecycleDetailSaveReqVO::getBatchGongduanId).toList();
|
||||||
|
Map<Long, Integer> gongAssayMap = detailList.stream().collect(Collectors.toMap(
|
||||||
|
MaterialLifecycleDetailSaveReqVO::getBatchGongduanId, MaterialLifecycleDetailSaveReqVO::getAssayFlag));
|
||||||
List<MaterialBatchDO> gongs = materialBatchService.getGongduanListByGongIds(gongIds);
|
List<MaterialBatchDO> gongs = materialBatchService.getGongduanListByGongIds(gongIds);
|
||||||
if (CollUtil.isEmpty(gongs) || gongs.size() != gongIds.size())
|
if (CollUtil.isEmpty(gongs) || gongs.size() != gongIds.size())
|
||||||
throw new ServiceException(1_032_160_000, "工段不存在或与传入的工段数量不匹配");
|
throw new ServiceException(1_032_160_000, "工段不存在或与传入的工段数量不匹配");
|
||||||
|
for (MaterialBatchDO gong : gongs) {
|
||||||
|
gong.setAssayFlag(gongAssayMap.get(gong.getId()));
|
||||||
|
}
|
||||||
List<MaterialLifecycleDetailDO> detailDOS = getLifecycleDetailDOsByGongs(gongs, gongIds, mtrlLfc);
|
List<MaterialLifecycleDetailDO> detailDOS = getLifecycleDetailDOsByGongs(gongs, gongIds, mtrlLfc);
|
||||||
materialLifecycleDetailService.saveBatch(detailDOS);
|
materialLifecycleDetailService.saveBatch(detailDOS);
|
||||||
return BeanUtils.toBean(mtrlLfc, MaterialLifecycleRespVO.class);
|
return BeanUtils.toBean(mtrlLfc, MaterialLifecycleRespVO.class);
|
||||||
@@ -92,6 +115,7 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService {
|
|||||||
detailDO.setLifecycleId(mtrlLfc.getId())
|
detailDO.setLifecycleId(mtrlLfc.getId())
|
||||||
.setProductId(gong.getProductId()).setBatchId(gong.getParentId())
|
.setProductId(gong.getProductId()).setBatchId(gong.getParentId())
|
||||||
.setBatchGongduanId(gong.getId())
|
.setBatchGongduanId(gong.getId())
|
||||||
|
.setAssayFlag(gong.getAssayFlag())
|
||||||
.setTreatmentStatus(0);
|
.setTreatmentStatus(0);
|
||||||
return detailDO;
|
return detailDO;
|
||||||
}).toList();
|
}).toList();
|
||||||
@@ -104,21 +128,28 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService {
|
|||||||
MaterialLifecycleDO lifecycleDO = materialLifecycleMapper.selectById(reqId);
|
MaterialLifecycleDO lifecycleDO = materialLifecycleMapper.selectById(reqId);
|
||||||
if (lifecycleDO == null) throw exception(MATERIAL_LIFECYCLE_NOT_EXISTS);
|
if (lifecycleDO == null) throw exception(MATERIAL_LIFECYCLE_NOT_EXISTS);
|
||||||
if (lifecycleDO.getSubmitStatus() == 1) throw new ServiceException(1_032_160_000, "流程已提交,不可修改");
|
if (lifecycleDO.getSubmitStatus() == 1) throw new ServiceException(1_032_160_000, "流程已提交,不可修改");
|
||||||
List<Long> gongIds = updateReqVO.getGongIds();
|
List<MaterialLifecycleDetailSaveReqVO> detailList = updateReqVO.getDetailList();
|
||||||
// 更新
|
// 更新
|
||||||
MaterialLifecycleDO mtrlLfc = BeanUtils.toBean(updateReqVO, MaterialLifecycleDO.class);
|
MaterialLifecycleDO mtrlLfc = BeanUtils.toBean(updateReqVO, MaterialLifecycleDO.class);
|
||||||
if (CollUtil.isEmpty(gongIds)) {
|
if (CollUtil.isEmpty(detailList)) {
|
||||||
materialLifecycleMapper.updateById(mtrlLfc);
|
materialLifecycleMapper.updateById(mtrlLfc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 删除原来的明细
|
// 删除原来的明细
|
||||||
materialLifecycleDetailService.deleteLifecycleDetailListByLfcId(reqId);
|
materialLifecycleDetailService.deleteLifecycleDetailListByLfcId(reqId);
|
||||||
|
List<Long> gongIds = detailList.stream().map(MaterialLifecycleDetailSaveReqVO::getBatchGongduanId).toList();
|
||||||
|
Map<Long, Integer> gongAssayMap = detailList.stream().collect(Collectors.toMap(
|
||||||
|
MaterialLifecycleDetailSaveReqVO::getBatchGongduanId, MaterialLifecycleDetailSaveReqVO::getAssayFlag));
|
||||||
List<MaterialBatchDO> gongs = materialBatchService.getGongduanListByGongIds(gongIds);
|
List<MaterialBatchDO> gongs = materialBatchService.getGongduanListByGongIds(gongIds);
|
||||||
if (CollUtil.isEmpty(gongs) || gongs.size() != gongIds.size())
|
if (CollUtil.isEmpty(gongs) || gongs.size() != gongIds.size())
|
||||||
throw new ServiceException(1_032_160_000, "工段不存在或与传入的工段数量不匹配");
|
throw new ServiceException(1_032_160_000, "工段不存在或与传入的工段数量不匹配");
|
||||||
|
for (MaterialBatchDO gong : gongs) {
|
||||||
|
gong.setAssayFlag(gongAssayMap.get(gong.getId()));
|
||||||
|
}
|
||||||
// 保存新的明细
|
// 保存新的明细
|
||||||
List<MaterialLifecycleDetailDO> detailDOS = getLifecycleDetailDOsByGongs(gongs, gongIds, mtrlLfc);
|
List<MaterialLifecycleDetailDO> detailDOS = getLifecycleDetailDOsByGongs(gongs, gongIds, mtrlLfc);
|
||||||
materialLifecycleDetailService.saveBatch(detailDOS);
|
materialLifecycleDetailService.saveBatch(detailDOS);
|
||||||
|
materialLifecycleMapper.updateById(mtrlLfc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -178,7 +209,18 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<MaterialLifecycleDO> getMaterialLifecyclePage(MaterialLifecyclePageReqVO pageReqVO) {
|
public PageResult<MaterialLifecycleDO> getMaterialLifecyclePage(MaterialLifecyclePageReqVO pageReqVO) {
|
||||||
return materialLifecycleMapper.selectPage(pageReqVO);
|
PageResult<MaterialLifecycleDO> pageResult = materialLifecycleMapper.selectPage(pageReqVO);
|
||||||
|
List<MaterialLifecycleDO> list = pageResult.getList();
|
||||||
|
if (CollUtil.isEmpty(list)) return pageResult;
|
||||||
|
list.forEach(mtrlLfc -> {
|
||||||
|
String formData = mtrlLfc.getFormData();
|
||||||
|
if (formData != null) {
|
||||||
|
String title = (String) JSONUtil.parseObj(formData).get("title");
|
||||||
|
mtrlLfc.setTitle(title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pageResult.setList(list);
|
||||||
|
return pageResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -187,7 +229,7 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService {
|
|||||||
if (lifecycleDO == null) throw exception(MATERIAL_LIFECYCLE_NOT_EXISTS);
|
if (lifecycleDO == null) throw exception(MATERIAL_LIFECYCLE_NOT_EXISTS);
|
||||||
Integer submitStatus = lifecycleDO.getSubmitStatus();
|
Integer submitStatus = lifecycleDO.getSubmitStatus();
|
||||||
if (submitStatus == 1) throw new ServiceException(1_032_160_000, "申请已经提交过");
|
if (submitStatus == 1) throw new ServiceException(1_032_160_000, "申请已经提交过");
|
||||||
|
lifecycleDO.setApplyTime(LocalDateTime.now());
|
||||||
// 发起流程
|
// 发起流程
|
||||||
this.createProcessInstance(lifecycleDO);
|
this.createProcessInstance(lifecycleDO);
|
||||||
|
|
||||||
@@ -197,73 +239,10 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createProcessInstance(MaterialLifecycleDO lifecycleDO) {
|
private void createProcessInstance(MaterialLifecycleDO lifecycleDO) {
|
||||||
/*
|
|
||||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
|
||||||
//当前登录用户昵称
|
|
||||||
String nickName = SecurityFrameworkUtils.getLoginUserNickname();
|
|
||||||
Long id = param.getId();
|
|
||||||
SupplierEvaluationDO entity = getSupplierEvaluation(id);
|
|
||||||
String flowInsId = entity.getFlowInstanceId();
|
|
||||||
|
|
||||||
if(!ObjectUtils.isEmpty(flowInsId)){
|
|
||||||
CommonResult<List<BpmTaskRespDTO>> taskRet = bpmTaskApi.getTaskListByProcessInstanceId(flowInsId);
|
|
||||||
List<BpmTaskRespDTO> taskList = taskRet.getData();
|
|
||||||
if(taskList.isEmpty())
|
|
||||||
throw exception0(ERROR_CODE_MODULE_COMMON, "流程任务查询失败,请联系管理员处理");
|
|
||||||
String taskId = taskList.get(taskList.size() - 1).getId();
|
|
||||||
//驳回后重新提交
|
|
||||||
BpmTaskApproveReqDTO reqVO = new BpmTaskApproveReqDTO();
|
|
||||||
reqVO.setId(taskId);
|
|
||||||
CommonResult<Boolean> result = bpmProcessInstanceApi.approveTask(reqVO);
|
|
||||||
if(!result.isSuccess()){
|
|
||||||
throw exception0(ERROR_CODE_MODULE_COMMON, result.getMsg());
|
|
||||||
}
|
|
||||||
entity.setFlowStatus(QmsCommonConstant.IN_PROGRESS);
|
|
||||||
//todo 生成报告编号 documentCode
|
|
||||||
supplierEvaluationMapper.updateById(entity);
|
|
||||||
SupplierEvaluationRespVO respVO = BeanUtils.toBean(entity, SupplierEvaluationRespVO.class);
|
|
||||||
return CommonResult.success(respVO);
|
|
||||||
}
|
|
||||||
JSONObject formData = new JSONObject();
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
|
|
||||||
formData.put("mainId", id);
|
|
||||||
formData.put("applyUser", nickName);
|
|
||||||
formData.put("applyUserId", loginUser.getId());
|
|
||||||
formData.put("applyDepartment", loginUser.getVisitDeptName());
|
|
||||||
formData.put("applyDepartmentId", loginUser.getVisitDeptId());
|
|
||||||
formData.put("applyTime", sdf.format(new Date()));
|
|
||||||
Map<String, Object> variables = formData.toJavaObject(Map.class);
|
|
||||||
variables.put(BPM_CALLBACK_BEAN_NAME, "supplierEvaluationService"); //流程回调时使用的service
|
|
||||||
BpmProcessInstanceCreateReqDTO reqDTO = new BpmProcessInstanceCreateReqDTO();
|
|
||||||
reqDTO.setBusinessKey(String.valueOf(id));
|
|
||||||
reqDTO.setProcessDefinitionKey(QmsSupplierConstant.EVALUATION_FLOW_KEY);
|
|
||||||
reqDTO.setVariables(variables);
|
|
||||||
CommonResult<String> result = bpmProcessInstanceApi.createProcessInstance(loginUser.getId(), reqDTO);
|
|
||||||
if(!result.isSuccess()){
|
|
||||||
throw exception0(ERROR_CODE_MODULE_COMMON, result.getMsg());
|
|
||||||
}
|
|
||||||
String wfInsId = result.getData();
|
|
||||||
entity.setFlowInstanceId(wfInsId);
|
|
||||||
entity.setFlowStatus(QmsCommonConstant.IN_PROGRESS);
|
|
||||||
entity.setEvaluationDate(LocalDateTime.now());
|
|
||||||
entity.setEvaluator(nickName);
|
|
||||||
supplierEvaluationMapper.updateById(entity);
|
|
||||||
SupplierEvaluationRespVO respVO = BeanUtils.toBean(entity, SupplierEvaluationRespVO.class);
|
|
||||||
return CommonResult.success(respVO);
|
|
||||||
*/
|
|
||||||
// 发起人及其部门
|
|
||||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
|
||||||
String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname();
|
|
||||||
if (loginUser != null) {
|
|
||||||
lifecycleDO.setApplyUser(loginUserNickname)
|
|
||||||
.setApplyUserId(loginUser.getId())
|
|
||||||
.setApplyDepartment(loginUser.getVisitDeptName())
|
|
||||||
.setApplyDepartmentId(loginUser.getVisitDeptId());
|
|
||||||
}
|
|
||||||
String flowInstanceId = lifecycleDO.getFlowInstanceId();
|
String flowInstanceId = lifecycleDO.getFlowInstanceId();
|
||||||
// 创建流程
|
// 流程已经发起过
|
||||||
if (StrUtil.isEmpty(flowInstanceId)) {
|
if (StrUtil.isNotEmpty(flowInstanceId)) {
|
||||||
CommonResult<List<BpmTaskRespDTO>> taskRet = bpmTaskApi.getTaskListByProcessInstanceId(flowInstanceId);
|
CommonResult<List<BpmTaskRespDTO>> taskRet = bpmTaskApi.getTaskListByProcessInstanceId(flowInstanceId);
|
||||||
List<BpmTaskRespDTO> taskList = taskRet.getData();
|
List<BpmTaskRespDTO> taskList = taskRet.getData();
|
||||||
if(CollUtil.isEmpty(taskList))
|
if(CollUtil.isEmpty(taskList))
|
||||||
@@ -279,18 +258,85 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService {
|
|||||||
lifecycleDO.setFlowStatus(QmsCommonConstant.IN_PROGRESS);
|
lifecycleDO.setFlowStatus(QmsCommonConstant.IN_PROGRESS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 发起流程
|
||||||
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
|
if (loginUser == null) return;
|
||||||
|
String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname();
|
||||||
|
Long loginUserId = loginUser.getId();
|
||||||
|
Map<String, Object> variables = new HashMap<>();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
switch (lifecycleDO.getBusinessType()) {
|
variables.put("mainId", lifecycleDO.getId());
|
||||||
case "acceptance":
|
variables.put("applyUser", loginUserNickname);
|
||||||
// 发起验收流程
|
variables.put("applyUserId", loginUserId);
|
||||||
break;
|
variables.put("applyDepartment", loginUser.getVisitDeptName());
|
||||||
case "return_exchange":
|
variables.put("applyDepartmentId", loginUser.getVisitDeptId());
|
||||||
// 发起退换货流程
|
variables.put("applyTime", sdf.format(new Date()));
|
||||||
break;
|
variables.put(BPM_CALLBACK_BEAN_NAME, "materialLifecycleService");
|
||||||
case "config_apply":
|
BpmProcessInstanceCreateReqDTO reqDTO = new BpmProcessInstanceCreateReqDTO();
|
||||||
// 配置申请
|
reqDTO.setBusinessKey(String.valueOf(lifecycleDO.getId()))
|
||||||
break;
|
.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");
|
||||||
|
CommonResult<String> result = bpmProcessInstanceApi.createProcessInstance(loginUserId, reqDTO);
|
||||||
|
if(!result.isSuccess()){
|
||||||
|
throw exception0(ERROR_CODE_MODULE_COMMON, result.getMsg());
|
||||||
}
|
}
|
||||||
|
lifecycleDO.setFlowInstanceId(result.getData());
|
||||||
|
lifecycleDO.setFlowStatus(QmsCommonConstant.IN_PROGRESS);
|
||||||
|
lifecycleDO.setApplyUser(loginUserNickname)
|
||||||
|
.setApplyUserId(loginUserId)
|
||||||
|
.setApplyDepartment(loginUser.getVisitDeptName())
|
||||||
|
.setApplyDepartmentId(loginUser.getVisitDeptId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程回调处理
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user