diff --git a/zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/ErrorCodeConstants.java b/zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/ErrorCodeConstants.java index c1ceefac..ad13a6e6 100644 --- a/zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/ErrorCodeConstants.java +++ b/zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/ErrorCodeConstants.java @@ -180,7 +180,7 @@ public interface ErrorCodeConstants { ErrorCode MATERIAL_INFOMATION_NOT_EXISTS = new ErrorCode(1_032_160_000, "试剂耗材不存在"); ErrorCode MATERIAL_PRODUCT_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料分类/大类不存在"); ErrorCode MATERIAL_PRODUCT_PARENT_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料分类/大类的父类不存在"); - ErrorCode MATERIAL_PRODUCT_CODE_EXISTED = new ErrorCode(1_032_160_000, "物料大类编码重复"); + ErrorCode MATERIAL_PRODUCT_CODE_MODELNO_EXISTED = new ErrorCode(1_032_160_000, "物料大类【编码+型号】重复"); ErrorCode MATERIAL_CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_032_160_000, "分类下含有子分类或物料大类,不可删除"); ErrorCode MATERIAL_PRODUCT_EXISTS_BATCH = new ErrorCode(1_032_160_000, "物料大类下存在物料批次,不可删除"); ErrorCode MATERIAL_PRODUCTS_EXISTS_CATEGORY = new ErrorCode(1_032_160_000, "物料大类列表中存在分类数据"); @@ -192,6 +192,7 @@ public interface ErrorCodeConstants { ErrorCode MATERIAL_BATCH_ASSIGN_END = new ErrorCode(1_032_160_000, "物料批次已拆分,不可操作"); ErrorCode GONGDUAN_BELONG_MATERIAL_BATCH_NOT_EQUAL = new ErrorCode(1_032_160_000, "工段所属的物料批次不一致"); ErrorCode GONGDUAN_QUANTITY_MATERIAL_BATCH_NOT_EQUAL = new ErrorCode(1_032_160_000, "工段累加数量和批次数量不一致"); + ErrorCode GONGDUAN_QUANTITY_MATERIAL_BATCH_AVAILABLE_QUANTITY_NOT_EQUAL = new ErrorCode(1_032_160_000, "工段累加数量和批次可用数量不一致"); ErrorCode MATERIAL_INVENTORY_INBOUND_NOT_EXISTS = new ErrorCode(1_032_160_000, "入库,出库不存在"); ErrorCode MATERIAL_INVENTORY_INBOUND_DETAIL_NOT_EXISTS = new ErrorCode(1_032_160_000, "入库明细,出库明细等不存在"); diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/controller/admin/ReportDocumentMainController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/controller/admin/ReportDocumentMainController.java index 69949dd1..e41e961e 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/controller/admin/ReportDocumentMainController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/controller/admin/ReportDocumentMainController.java @@ -15,11 +15,10 @@ import com.zt.plat.framework.excel.core.util.ExcelUtils; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigUserSignatureDO; import com.zt.plat.module.qms.business.config.service.ConfigUserSignatureService; import com.zt.plat.module.qms.business.reportdoc.controller.vo.*; +import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentFileDO; import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainDO; import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentTypeDO; -import com.zt.plat.module.qms.business.reportdoc.service.ReportDocumentDataService; -import com.zt.plat.module.qms.business.reportdoc.service.ReportDocumentMainService; -import com.zt.plat.module.qms.business.reportdoc.service.ReportDocumentTypeService; +import com.zt.plat.module.qms.business.reportdoc.service.*; import com.zt.plat.module.qms.common.data.dal.dataobject.DataTemplateDO; import com.zt.plat.module.qms.common.data.service.DataTemplateService; import com.zt.plat.module.qms.enums.QmsCommonConstant; @@ -29,6 +28,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; @@ -63,6 +63,9 @@ public class ReportDocumentMainController extends AbstractFileUploadController i @Resource private ReportDocumentMainService reportDocumentMainService; @Resource private ReportDocumentDataService reportDocumentDataService; @Resource private ReportDocumentTypeService reportDocumentTypeService; + @Resource private ReportDocumentFileService reportDocumentFileService; + @Resource private ReportDocumentAssistService reportDocumentAssistService; + @Resource private DataTemplateService dataTemplateService; @@ -228,4 +231,16 @@ public class ReportDocumentMainController extends AbstractFileUploadController i return null; } + + @GetMapping("/createIWorkflow") + @Operation(summary = "创建iwork流程-调试用") + //@PreAuthorize("@ss.hasPermission('qms:report-document-main:query')") + public CommonResult createIWorkflow(HttpServletRequest request) { + String mainId = request.getParameter("mainId"); + String fileId = request.getParameter("fileId"); + ReportDocumentMainDO mainDO = reportDocumentMainService.getReportDocumentMain(Long.valueOf(mainId)); + ReportDocumentFileDO fileDO = reportDocumentFileService.getReportDocumentFile(Long.valueOf(fileId)); + return reportDocumentAssistService.createIWorkflow(mainDO, fileDO); + } + } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/dal/mapper/ReportDocumentDataMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/dal/mapper/ReportDocumentDataMapper.java index 8971467c..159c81c2 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/dal/mapper/ReportDocumentDataMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/dal/mapper/ReportDocumentDataMapper.java @@ -6,6 +6,10 @@ import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.module.qms.business.reportdoc.controller.vo.*; import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentDataDO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; /** * 检测报告明细 Mapper @@ -26,4 +30,6 @@ public interface ReportDocumentDataMapper extends BaseMapperX> queryBaseSampleBySourceId(@Param("sourceId") Long sourceId); + } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/listener/IWorkBizCallbackListener.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/listener/IWorkBizCallbackListener.java new file mode 100644 index 00000000..24279fce --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/listener/IWorkBizCallbackListener.java @@ -0,0 +1,64 @@ +package com.zt.plat.module.qms.business.reportdoc.listener; + +import com.alibaba.fastjson.JSONObject; +import com.zt.plat.module.system.mq.iwork.IWorkBizCallbackMessage; +import com.zt.plat.module.system.mq.iwork.IWorkBizCallbackResultMessage; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; +import org.apache.rocketmq.spring.core.RocketMQListener; +import org.apache.rocketmq.spring.core.RocketMQTemplate; +import org.springframework.stereotype.Component; + +@Slf4j +@Component +@RequiredArgsConstructor +@RocketMQMessageListener( + topic = IWorkBizCallbackMessage.TOPIC, + consumerGroup = IWorkBizCallbackMessage.TOPIC + "_CONSUMER_local", + selectorExpression = ReportDocListenerConstant.IWORK_BIZ_CALL_BACK_KEY // 与 bizCallbackKey 一致 +) +public class IWorkBizCallbackListener implements RocketMQListener { + private final RocketMQTemplate rocketMQTemplate; + @Override + public void onMessage(IWorkBizCallbackMessage message) { + log.info("收到 iWork 回调: requestId={}", message.getRequestId()); + log.info("收到 iWork 回调: message={}", JSONObject.toJSONString(message)); + + IWorkBizCallbackResultMessage result; + try { + // 处理业务逻辑 + processCallback(message); + + result = IWorkBizCallbackResultMessage.builder() + .requestId(message.getRequestId()) + .bizCallbackKey(message.getBizCallbackKey()) + .success(true) + .attempt(message.getAttempt()) + .maxAttempts(message.getMaxAttempts()) + .payload(message.getPayload()) + .build(); + } catch (Exception e) { + log.error("处理回调失败", e); + result = IWorkBizCallbackResultMessage.builder() + .requestId(message.getRequestId()) + .bizCallbackKey(message.getBizCallbackKey()) + .success(false) + .errorMessage(e.getMessage()) + .attempt(message.getAttempt()) + .maxAttempts(message.getMaxAttempts()) + .payload(message.getPayload()) + .build(); + } + + // 发送处理结果 + rocketMQTemplate.syncSend(IWorkBizCallbackResultMessage.TOPIC, result); + } + + private void processCallback(IWorkBizCallbackMessage message) { + // 业务处理逻辑 + // 1. 解析 payload 获取回调数据 + // 2. 更新业务状态 + // 3. 保存签章文件等 + } +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/listener/ReportDocListenerConstant.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/listener/ReportDocListenerConstant.java new file mode 100644 index 00000000..52464ddf --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/listener/ReportDocListenerConstant.java @@ -0,0 +1,9 @@ +package com.zt.plat.module.qms.business.reportdoc.listener; + +public class ReportDocListenerConstant { + + /** + * iwork回调key,用于消息队列接收消息 + * */ + public static final String IWORK_BIZ_CALL_BACK_KEY = "qms_report_document_seal_callback"; +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/service/ReportDocumentAssistService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/service/ReportDocumentAssistService.java index 4e3db6d5..d9de9d9b 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/service/ReportDocumentAssistService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/service/ReportDocumentAssistService.java @@ -16,6 +16,7 @@ import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFil import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentFileDO; import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainDO; import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentTypeDO; +import com.zt.plat.module.qms.business.reportdoc.listener.ReportDocListenerConstant; import com.zt.plat.module.qms.common.data.dal.dataobject.DataTemplateDO; import com.zt.plat.module.qms.common.data.service.DataTemplateService; import com.zt.plat.module.qms.core.code.SequenceUtil; @@ -105,6 +106,7 @@ public class ReportDocumentAssistService { dto.setYysx("检测报告用印"); dto.setXyywjUrl(docFile.getUrl()); dto.setYwxtdjbh(sequenceUtil.genCode(sequenceKey)); + dto.setBizCallbackKey(ReportDocListenerConstant.IWORK_BIZ_CALL_BACK_KEY); //业务回调标识,回调分发使用 return iWorkIntegrationApi.createWorkflow(dto); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/service/ReportDocumentDataServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/service/ReportDocumentDataServiceImpl.java index baa54322..c5952968 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/service/ReportDocumentDataServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/reportdoc/service/ReportDocumentDataServiceImpl.java @@ -25,6 +25,7 @@ import org.springframework.validation.annotation.Validated; import java.util.ArrayList; import java.util.List; +import java.util.Map; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.zt.plat.module.qms.enums.ErrorCodeConstants.REPORT_DOCUMENT_DATA_NOT_EXISTS; @@ -46,6 +47,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService @Resource private ReportDocumentDataMapper reportDocumentDataMapper; @Resource private ConfigReportFieldService configReportFieldService; @Resource private ConfigUserSignatureService configUserSignatureService; + @Resource private ReportDocumentTypeService reportDocumentTypeService; private final String colPrefix = "col"; private final String sampleCodeKey = "SMP_CD"; private final String sampleNameKey = "SMP_NAME"; @@ -82,7 +84,9 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService if(fieldListAll.isEmpty()) return CommonResult.error(REPORT_DOCUMENT_TYPE_NOT_EXISTS.getCode(), "未配置报表字段,请联系管理员处理!"); List dataList = listByMainDataId(mainData.getId()).getData(); - + ReportDocumentDataDO firstDataDO = null; + if(!dataList.isEmpty()) + firstDataDO = dataList.get(0); //拆分dataList,按样品分类key拆分 List> dataListGroup = new ArrayList<>(); String[] sampleTypeKeys = new String[]{"inspectionAnalysisSample", "comprehensiveInspectionSample"}; //商检分析样、商检综合样 @@ -140,7 +144,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService rowList = assembleEmpty(configJson, rowList); //处理数据分页 if("1".equals(pageFlag)){ - JSONArray pageRowList = assemblePageRowList(rowList, configJson, mainData); + JSONArray pageRowList = assemblePageRowList(rowList, configJson, mainData, firstDataDO); return CommonResult.success(pageRowList); } } @@ -166,22 +170,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService ] * */ JSONArray result = new JSONArray(); - JSONObject resultData = new JSONObject(); - JSONObject headerData = new JSONObject(); - JSONObject firstRow = rowList.getJSONObject(0); - if(rowTypeTitle.equals(firstRow.getString(rowTypeKey))){ - headerData = firstRow.clone(); - rowList.remove(0); - } - putEmptyTitleToNotFirstRow(rowList); - resultData.put("headerData", headerData); - resultData.put("tableList", rowList); - String formData = mainData.getFormData(); - String signatureData = mainData.getDocumentSignature(); - if(!ObjectUtils.isEmpty(formData)) - resultData.put("formData", JSONObject.parseObject(formData)); - if(!ObjectUtils.isEmpty(signatureData)) - resultData.put("signatureData", JSONObject.parseObject(signatureData)); + JSONObject resultData = assembleResultData(mainData, rowList, firstDataDO); result.add(resultData); return CommonResult.success(result); } @@ -196,7 +185,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService * 处理分页 * * */ - private JSONArray assemblePageRowList(JSONArray rowList, JSONObject configJson, ReportDocumentMainDO mainData){ + private JSONArray assemblePageRowList(JSONArray rowList, JSONObject configJson, ReportDocumentMainDO mainData, ReportDocumentDataDO firstDataDO){ JSONArray pageRowList = new JSONArray(); Integer maxRowCount = 20; String maxRowCountStr = configJson.getString("maxRowCount"); //最大行数 @@ -211,7 +200,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService rowList.add(t.clone()); } pageRowList.add(rowList); - return assemblePageResult(mainData, pageRowList, maxRowCount); + return assemblePageResult(mainData, pageRowList, maxRowCount, firstDataDO); } JSONArray remainingRows = new JSONArray(); remainingRows.addAll(rowList); @@ -271,7 +260,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService pageRow.add(t.clone()); } - return assemblePageResult(mainData, pageRowList, maxRowCount); + return assemblePageResult(mainData, pageRowList, maxRowCount, firstDataDO); } /* * 修改数据结构 @@ -280,17 +269,9 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService "tableList": [{},] },] * */ - private JSONArray assemblePageResult(ReportDocumentMainDO mainData, JSONArray pageRowList, Integer maxRowCount){ + private JSONArray assemblePageResult(ReportDocumentMainDO mainData, JSONArray pageRowList, Integer maxRowCount, ReportDocumentDataDO firstDataDO){ JSONArray result = new JSONArray(); - String formData = mainData.getFormData(); - String signatureData = mainData.getDocumentSignature(); - String signatureJsonStr = assembleSignature(signatureData); - JSONObject formDataJson = new JSONObject(); - boolean hasSignatureData = false; - if(!ObjectUtils.isEmpty(formData)) - formDataJson = JSONObject.parseObject(formData); - if(!ObjectUtils.isEmpty(signatureJsonStr)) - hasSignatureData = true; + //在最后一页填充空行 JSONArray pageRow = pageRowList.getJSONArray(pageRowList.size() - 1); while(pageRow.size() < maxRowCount){ @@ -300,25 +281,88 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService } for(int i=0;i> baseSampleList = reportDocumentDataMapper.queryBaseSampleBySourceId(firstDataDO.getSourceId()); + if(!baseSampleList.isEmpty()){ + materialName = String.valueOf(baseSampleList.get(0).get("MTRL_NAME")); + } + + if(!materialName.equals(tongJingKuang)){ + hideMethod = true; + hideSignature = true; + }else if(sampleTypeKey.equals(comprehensiveInspectionSample)){ + hideMethod = true; + } + } + if(hideMethod){ + formDataJson.replace(standardKey, "/"); + } + if(hideSignature){ + if(!ObjectUtils.isEmpty(signatureKey)){ + JSONObject opinion = signatureJson.getJSONObject(signatureKey); + if(opinion != null){ + opinion.replace("signTime", ""); + opinion.replace("signatureId", ""); + opinion.replace("userName", "/"); + opinion.replace("signatureIdBase64", ""); + opinion.replace("userId", ""); + } + } + } + //======根据样品类型,动态处理“方法”、“签发”的值========end + resultData.put("headerData", headerData); + resultData.put("tableList", rows); + resultData.put("formData", formDataJson); + if(!ObjectUtils.isEmpty(signatureJsonStr)) + resultData.put("signatureData", signatureJson); + return resultData; + } private void putEmptyTitleToNotFirstRow(JSONArray rows){ for(int i = 1; i < rows.size(); i++){ diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/admin/DeviceConfigBusinessItemController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/admin/DeviceConfigBusinessItemController.java index 51cc23f9..eb9f1584 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/admin/DeviceConfigBusinessItemController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/admin/DeviceConfigBusinessItemController.java @@ -108,7 +108,7 @@ public class DeviceConfigBusinessItemController extends AbstractFileUploadContro Long productId = pageReqVO.getProductId(); if (productId != null) { - DeviceConfigBusinessRuleDO ruleDO = deviceConfigBusinessRuleService.getByProductId(productId, DeviceConstant.MAINTAIN_TYPE); + DeviceConfigBusinessRuleDO ruleDO = deviceConfigBusinessRuleService.getByProductId(productId, pageReqVO.getBusinessDomain()); if(ruleDO != null){ pageReqVO.setRuleId(ruleDO.getId()); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/admin/DeviceMaintainController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/admin/DeviceMaintainController.java index 80b97792..0ad32f0c 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/admin/DeviceMaintainController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/admin/DeviceMaintainController.java @@ -20,6 +20,7 @@ import jakarta.validation.*; import jakarta.servlet.http.*; import java.text.SimpleDateFormat; +import java.time.LocalDate; import java.util.*; import java.io.IOException; @@ -103,8 +104,23 @@ public class DeviceMaintainController extends AbstractFileUploadController imple @PostMapping("/create") @Operation(summary = "创建设备-点检、保养记录") // @PreAuthorize("@ss.hasPermission('qms:device-maintain:create')") - public CommonResult createDeviceMaintain(@Valid @RequestBody DeviceMaintainSaveReqVO createReqVO) { - return success(deviceMaintainService.createDeviceMaintain(createReqVO)); + public CommonResult createDeviceMaintain(@RequestBody JSONObject jsonObject) { + Long deviceId = jsonObject.getLong("deviceId"); + String dataType = jsonObject.getString("dataType"); + String dateStr = jsonObject.getString("date"); + if (deviceId == null || dataType == null) { + return CommonResult.error(DEVICE_MAINTAIN_NOT_EXISTS.getCode(), "参数错误"); + } + //检查设备状态 + CommonResult checkResult = deviceInfomationService.checkDeviceUsable(deviceId); + if(!checkResult.isSuccess()){ + return checkResult.error(checkResult.getCode(), checkResult.getMsg()); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if(ObjectUtils.isEmpty(dateStr)) + dateStr = sdf.format(new Date()); + LocalDate localDate = LocalDate.parse(dateStr); + return deviceMaintainService.create(deviceId, localDate, dataType); } @PutMapping("/update") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/vo/DeviceConfigBusinessItemPageReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/vo/DeviceConfigBusinessItemPageReqVO.java index 408444dc..399e8a95 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/vo/DeviceConfigBusinessItemPageReqVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/vo/DeviceConfigBusinessItemPageReqVO.java @@ -57,4 +57,7 @@ public class DeviceConfigBusinessItemPageReqVO extends PageParam { @Schema(description = "设备大类id") private Long productId; + @Schema(description = "业务类型") + private String businessDomain; + } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/dal/dataobject/DeviceMaintainItemDO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/dal/dataobject/DeviceMaintainItemDO.java index 4314fabf..d4e00bc1 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/dal/dataobject/DeviceMaintainItemDO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/dal/dataobject/DeviceMaintainItemDO.java @@ -99,7 +99,7 @@ public class DeviceMaintainItemDO extends BusinessBaseDO { /** * 所属周期截止日期 */ - @TableField("FREQ_TM_STRT") + @TableField("FREQ_TM_END") private LocalDateTime frequencyTimeEnd; /** * 检查标准 diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java index 12ded776..62da82c4 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java @@ -1,5 +1,6 @@ package com.zt.plat.module.qms.resource.material.controller.admin; +import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationSaveReqVO; @@ -39,6 +40,7 @@ import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*; @RestController @RequestMapping("/qms/resource/material-infomation") @Validated +@DeptDataPermissionIgnore(enable = "true") public class MaterialInfomationController implements BusinessControllerMarker { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialLifecycleDetailController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialLifecycleDetailController.java index 5b214a8f..35c75a72 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialLifecycleDetailController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialLifecycleDetailController.java @@ -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.MaterialLifecycleDetailPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecycleDetailRespVO; @@ -33,6 +34,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RestController @RequestMapping("/qms/resource/material-lifecycle-detail") @Validated +@DeptDataPermissionIgnore(enable = "true") public class MaterialLifecycleDetailController implements BusinessControllerMarker { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialStandardSolutionController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialStandardSolutionController.java index 9d77f3e5..79021097 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialStandardSolutionController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialStandardSolutionController.java @@ -9,6 +9,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.device.controller.vo.DeviceProductPageReqVO; import com.zt.plat.module.qms.resource.device.controller.vo.DeviceProductRespVO; @@ -42,6 +43,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RequestMapping("/qms/resource/material-standard-solution") @Validated @FileUploadController(source = "qms.materialstandardsolution") +@DeptDataPermissionIgnore(enable = "true") public class MaterialStandardSolutionController extends AbstractFileUploadController implements BusinessControllerMarker{ static { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseController.java index 9ba44368..4684309a 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseController.java @@ -9,6 +9,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.MaterialUseEndReusePageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseEndReuseRespVO; @@ -36,6 +37,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RequestMapping("/qms/resource/material-use-end-reuse") @Validated @FileUploadController(source = "qms.materialuseendreuse") +@DeptDataPermissionIgnore(enable = "true") public class MaterialUseEndReuseController extends AbstractFileUploadController implements BusinessControllerMarker{ static { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseDetailController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseDetailController.java index 80d4f1fa..2f72ec15 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseDetailController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseDetailController.java @@ -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.MaterialUseEndReuseDetailPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseEndReuseDetailRespVO; @@ -33,6 +34,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RestController @RequestMapping("/qms/resource/material-use-end-reuse-detail") @Validated +@DeptDataPermissionIgnore(enable = "true") public class MaterialUseEndReuseDetailController implements BusinessControllerMarker { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordController.java index 4c9cea24..4b5341c8 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordController.java @@ -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.*; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialUseRecordDO; @@ -33,6 +34,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RestController @RequestMapping("/qms/resource/material-use-record") @Validated +@DeptDataPermissionIgnore(enable = "true") public class MaterialUseRecordController implements BusinessControllerMarker { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordDetailController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordDetailController.java index 147a0aba..71e448b3 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordDetailController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordDetailController.java @@ -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.MaterialUseRecordDetailPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseRecordDetailRespVO; @@ -35,6 +36,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RestController @RequestMapping("/qms/resource/material-use-record-detail") @Validated +@DeptDataPermissionIgnore(enable = "true") public class MaterialUseRecordDetailController implements BusinessControllerMarker { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialBatchPageReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialBatchPageReqVO.java index bd9d19a8..fd7b3ac0 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialBatchPageReqVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialBatchPageReqVO.java @@ -16,6 +16,9 @@ import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH @Data public class MaterialBatchPageReqVO extends PageParam { + @Schema(description = "分类其他配置") + private String categoryCustomConfig; + @Schema(description = "物料大类id", example = "9381") private Long productId; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialBatchRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialBatchRespVO.java index be7005fd..eaa294d8 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialBatchRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialBatchRespVO.java @@ -1,5 +1,6 @@ package com.zt.plat.module.qms.resource.material.controller.vo; +import cn.hutool.json.JSONObject; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; @@ -29,6 +30,10 @@ public class MaterialBatchRespVO { @ExcelProperty("物料大类id") private Long productId; + @Schema(description = "分类自定义配置") + @ExcelProperty("分类自定义配置") + private JSONObject categoryCustomConfig; + @Schema(description = "物料大类名称") @ExcelProperty("物料大类名称") private String productName; @@ -73,6 +78,10 @@ public class MaterialBatchRespVO { @ExcelProperty("已入库数量") private BigDecimal inboundEndQuantity; + @Schema(description = "检定/校准数量") + @ExcelProperty("检定/校准数量") + private BigDecimal verificationQuantity; + @Schema(description = "锁定数量") @ExcelProperty("锁定数量") private BigDecimal lockQuantity; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialLifecycleDetailRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialLifecycleDetailRespVO.java index c3b49c49..94b01f16 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialLifecycleDetailRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialLifecycleDetailRespVO.java @@ -114,6 +114,10 @@ public class MaterialLifecycleDetailRespVO { @ExcelProperty("批次或工段数量") private BigDecimal inboundQuantity; + @Schema(description = "批次或工段可用数量") + @ExcelProperty("批次或工段可用数量") + private BigDecimal remaineQuantity; + @Schema(description = "影响数量", example = "15772") @ExcelProperty("影响数量") private String influenceCount; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialProductSaveReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialProductSaveReqVO.java index 66cd8e87..e5e81b79 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialProductSaveReqVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialProductSaveReqVO.java @@ -1,6 +1,5 @@ package com.zt.plat.module.qms.resource.material.controller.vo; -import com.baomidou.mybatisplus.annotation.TableField; import com.zt.plat.module.qms.resource.material.valid.AddGroup; import com.zt.plat.module.qms.resource.material.valid.UpdateGroup; import io.swagger.v3.oas.annotations.media.Schema; @@ -100,10 +99,10 @@ public class MaterialProductSaveReqVO { private Integer assayFlag; @Schema(description = "是否进行库存预警,1-是,0-否") - private Integer InventoryAlarmFlag; + private Integer inventoryAlarmFlag; @Schema(description = "库存预警区间,json格式配置") - private String InventoryAlarmRange; + private String inventoryAlarmRange; @Schema(description = "备注") private String remark; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/query/MaterialProductQueryVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/query/MaterialProductQueryVO.java index cf626edd..422460ef 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/query/MaterialProductQueryVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/query/MaterialProductQueryVO.java @@ -1,5 +1,7 @@ package com.zt.plat.module.qms.resource.material.controller.vo.query; +import cn.hutool.json.JSONObject; +import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -40,7 +42,10 @@ public class MaterialProductQueryVO { private Integer assayFlag; @Schema(description = "是否进行库存预警,1-是,0-否") - private Integer InventoryAlarmFlag; + private Integer inventoryAlarmFlag; + + @Schema(description = "分类其他配置") + private String categoryCustomConfig; @Schema(description = "备注") private String remark; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialLifecycleDetailMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialLifecycleDetailMapper.java index 16863a0f..1aec4f55 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialLifecycleDetailMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialLifecycleDetailMapper.java @@ -1,17 +1,13 @@ package com.zt.plat.module.qms.resource.material.dal.mapper; import cn.hutool.core.collection.CollUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.zt.plat.framework.common.pojo.PageResult; 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.MPJLambdaWrapperX; 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.dal.dataobject.*; -import groovy.util.logging.Slf4j; import org.apache.ibatis.annotations.Mapper; import java.util.HashMap; @@ -44,7 +40,7 @@ public interface MaterialLifecycleDetailMapper extends BaseMapperX selectListWithPdtBatInfo(Long id){ + default List selectListWithGongPdtBatInfo(Long id){ MPJLambdaWrapper wrapper = new MPJLambdaWrapper() .selectAll(MaterialLifecycleDetailDO.class) .selectAs("product.NAME", MaterialLifecycleDetailRespVO::getProductName) @@ -130,4 +126,22 @@ public interface MaterialLifecycleDetailMapper extends BaseMapperX selectListWithBatchPdtBatInfo(Long id) { + MPJLambdaWrapper wrapper = new MPJLambdaWrapper() + .selectAll(MaterialLifecycleDetailDO.class) + .selectAs("product.NAME", MaterialLifecycleDetailRespVO::getProductName) + .selectAs("product.CD", MaterialLifecycleDetailRespVO::getProductCode) + .selectAs("product.MDL_NO", MaterialLifecycleDetailRespVO::getProductModelNo) + .selectAs("product.UNT", MaterialLifecycleDetailRespVO::getUnit) + .selectAs(MaterialBatchDO::getBatchNo, MaterialLifecycleDetailRespVO::getBatchNo) + .selectAs(MaterialBatchDO::getInboundQuantity, MaterialLifecycleDetailRespVO::getInboundQuantity) + .selectAs(MaterialBatchDO::getRemaineQuantity, MaterialLifecycleDetailRespVO::getRemaineQuantity) + .leftJoin(MaterialBatchDO.class, "batch", MaterialBatchDO::getId, MaterialLifecycleDetailDO::getBatchId) + .leftJoin(MaterialProductDO.class, "product", MaterialProductDO::getId, MaterialBatchDO::getProductId) + + .eq(MaterialLifecycleDetailDO::getLifecycleId, id); + + return selectJoinList(MaterialLifecycleDetailRespVO.class, wrapper); + } } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialBatchBusinessType.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialBatchBusinessType.java new file mode 100644 index 00000000..03414b8b --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialBatchBusinessType.java @@ -0,0 +1,16 @@ +package com.zt.plat.module.qms.resource.material.enums; + +/** + * 物料批次业务类型 + * + */ +public enum MaterialBatchBusinessType { + /** + * 拆分到工段 + */ + batch_assign_gong, + /** + * 检定 + */ + verify, +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialBatchOperationType.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialBatchOperationType.java index 51f26210..a2eeb46f 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialBatchOperationType.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialBatchOperationType.java @@ -1,7 +1,7 @@ package com.zt.plat.module.qms.resource.material.enums; /** - * 物料批次工段枚举 + * 物料批次操作类型 * */ public enum MaterialBatchOperationType { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialFlowType.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialFlowType.java index f159fd52..9bfd9778 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialFlowType.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialFlowType.java @@ -13,7 +13,7 @@ public enum MaterialFlowType { make_apply("配置申请"), - verify_calibrate("检定校准") + verify_calibrate("量具检定") ; private final String name; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java index 5cf7b4d1..376afb53 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java @@ -1,7 +1,10 @@ package com.zt.plat.module.qms.resource.material.service; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zt.plat.framework.common.exception.ServiceException; import com.zt.plat.framework.common.pojo.CommonResult; @@ -11,12 +14,15 @@ import com.zt.plat.module.bpm.api.task.BpmProcessInstanceApi; import com.zt.plat.module.bpm.api.task.dto.BpmProcessInstanceRespDTO; import com.zt.plat.module.bpm.api.task.dto.UserSimpleDTO; import com.zt.plat.module.qms.core.code.SequenceUtil; +import com.zt.plat.module.qms.core.constant.DataTypeConstant; import com.zt.plat.module.qms.enums.AdjustType; import com.zt.plat.module.qms.enums.LockType; import com.zt.plat.module.qms.resource.material.constant.MaterialConstants; 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.MaterialBatchSaveReqVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductRespVO; +import com.zt.plat.module.qms.resource.material.controller.vo.query.MaterialProductQueryVO; 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.MaterialLifecycleDetailDO; @@ -26,6 +32,7 @@ import com.zt.plat.module.qms.resource.material.enums.MaterialAcceptStatus; import com.zt.plat.module.qms.resource.material.enums.MaterialBatchGongType; import com.zt.plat.module.qms.resource.material.enums.MaterialFlowType; import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -34,6 +41,7 @@ import org.springframework.validation.annotation.Validated; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.List; import java.util.Map; @@ -49,6 +57,7 @@ import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*; * * @author 后台管理 */ +@Slf4j @Service @Validated public class MaterialBatchServiceImpl implements MaterialBatchService { @@ -178,8 +187,8 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { for (MaterialBatchSaveReqVO batAsn : createReqVOs) { total = total.add(batAsn.getInboundQuantity()); } - if (total.compareTo(mtrlBat.getInboundQuantity()) != 0) - throw exception(GONGDUAN_QUANTITY_MATERIAL_BATCH_NOT_EQUAL); + if (total.compareTo(mtrlBat.getRemaineQuantity()) != 0) + throw exception(GONGDUAN_QUANTITY_MATERIAL_BATCH_AVAILABLE_QUANTITY_NOT_EQUAL); // 修改工段 boolean exists = materialBatchMapper.exists(Wrappers.lambdaQuery(MaterialBatchDO.class) .eq(MaterialBatchDO::getParentId, batId)); @@ -218,18 +227,25 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { MaterialBatchDO batchDO = materialBatchMapper.selectById(id); if (batchDO == null) throw exception(MATERIAL_BATCH_NOT_EXISTS); if (batchDO.getSubmitStatus() == 1) throw new ServiceException(1_032_160_000, "批次已经提交过"); - List gongduans = this.getGongduanListByBatIds(Collections.singletonList(id)); - if (CollUtil.isEmpty(gongduans)) throw new ServiceException(1_032_160_000, "批次还未拆分,不可提交"); - // 批次存在锁定数量时不可提交 - if (batchDO.getLockQuantity().compareTo(BigDecimal.ZERO) > 0) - throw new ServiceException(1_032_160_000, String.format("批次存在锁定数量【%s】,不可提交", batchDO.getLockQuantity())); - // 批次可用数量可能存在变更,需要再次校验数量一致性 - BigDecimal gongTotalInbQuantity = BigDecimal.ZERO; - for (MaterialBatchDO gongduan : gongduans) { - gongTotalInbQuantity = gongTotalInbQuantity.add(gongduan.getInboundQuantity()); + // 检查是否属于检定批次 + Boolean isVerify = materialProductService.checkIsVerifyCategoryByPdtId(batchDO.getProductId()); + if (!isVerify) { + + List gongduans = this.getGongduanListByBatIds(Collections.singletonList(id)); + if (CollUtil.isEmpty(gongduans)) throw new ServiceException(1_032_160_000, "批次还未拆分,不可提交"); + // 批次存在锁定数量时不可提交 + if (batchDO.getLockQuantity().compareTo(BigDecimal.ZERO) > 0) + throw new ServiceException(1_032_160_000, String.format("批次存在锁定数量【%s】,不可提交", batchDO.getLockQuantity())); + // 批次可用数量可能存在变更,需要再次校验数量一致性 + BigDecimal gongTotalInbQuantity = BigDecimal.ZERO; + for (MaterialBatchDO gongduan : gongduans) { + gongTotalInbQuantity = gongTotalInbQuantity.add(gongduan.getInboundQuantity()); + } + if (batchDO.getRemaineQuantity().compareTo(gongTotalInbQuantity) != 0) + throw exception(GONGDUAN_QUANTITY_MATERIAL_BATCH_AVAILABLE_QUANTITY_NOT_EQUAL); + } - if (batchDO.getInboundQuantity().compareTo(gongTotalInbQuantity) != 0) - throw exception(GONGDUAN_QUANTITY_MATERIAL_BATCH_NOT_EQUAL); + batchDO.setSubmitStatus(1).setSubmitDate(LocalDateTime.now()); materialBatchMapper.updateById(batchDO); // 提交工段 @@ -353,10 +369,10 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { public PageResult getBatchGongPageWithPdtInfo(MaterialBatchPageReqVO pageReqVO) { // 分为 批次分页、验收、入库、退换货 Long pdtId = pageReqVO.getProductId(); - PageResult pageResult; - if (pdtId == null) { - pageResult = materialBatchMapper.selectPageWithPdtInfo(pageReqVO, List.of()); - } else { + PageResult pageResult = new PageResult<>(); + + String categoryCustomConfig = pageReqVO.getCategoryCustomConfig(); + if (pdtId != null){ List mtrlDos = materialProductService.getMaterialProductsByLikeIdPath(pdtId); if (CollUtil.isEmpty(mtrlDos)) { pageResult = materialBatchMapper.selectPageWithPdtInfo(pageReqVO, List.of()); @@ -364,7 +380,18 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { List pdtIds = mtrlDos.stream().map(MaterialProductDO::getId).toList(); pageResult = materialBatchMapper.selectPageWithPdtInfo(pageReqVO, pdtIds); } + } else if (StrUtil.isNotEmpty(categoryCustomConfig)) { + List categoryAndData = materialProductService.getCategoryAndData(new MaterialProductQueryVO().setCategoryCustomConfig(categoryCustomConfig)); + if (CollUtil.isNotEmpty(categoryAndData)) { + List pdtIds = categoryAndData.stream() + .filter(p -> DataTypeConstant.DATA_TYPE_DATA.equals(p.getNodeType())) + .map(MaterialProductRespVO::getId).toList(); + pageResult = materialBatchMapper.selectPageWithPdtInfo(pageReqVO, pdtIds); + } + } else { + pageResult = materialBatchMapper.selectPageWithPdtInfo(pageReqVO, List.of()); } + // 查全部 if (StrUtil.isEmpty(pageReqVO.getDataType())) { List respVOS = pageResult.getList(); @@ -380,18 +407,32 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { } } + if (StrUtil.isEmpty(pageReqVO.getDataType()) || MaterialBatchGongType.batch.name().equals(pageReqVO.getDataType())) { + List batches = pageResult.getList(); + if (CollUtil.isNotEmpty(batches)) { + List pdtIds = batches.stream().map(MaterialBatchRespVO::getProductId).toList(); + List pdts = materialProductService.getMaterialProductListByPdtIds(pdtIds); + Map productDOMapById = pdts.stream().collect(Collectors.toMap(MaterialProductDO::getId, Function.identity())); + List topCategories = materialProductService.getTopCategoriesByPdtIds(pdtIds); + batches.forEach(batch -> { + Long productId = batch.getProductId(); + MaterialProductDO productDO = productDOMapById.get(productId); + for (MaterialProductDO topCategory : topCategories) { + if (productDO.getIdPath().contains("/" + topCategory.getId() + "/")) { + batch.setCategoryCustomConfig(JSONUtil.parseObj(topCategory.getCustomConfig())); + } + } + + }); + pageResult.setList(batches); + } + } + // 需要组装children if (!MaterialBatchGongType.gong.name().equals(pageReqVO.getDataType()) && pageReqVO.getChildren()) { List voList = pageResult.getList(); if (CollUtil.isNotEmpty(voList)) { List treeVos = this.listTransTree(voList, 0L); - for (MaterialBatchRespVO batch : treeVos) { - List children = batch.getChildren(); - if (CollUtil.isEmpty(children)) continue; - children.forEach(child -> - batch.setInboundEndQuantity(batch.getInboundEndQuantity().add(child.getInboundEndQuantity())) - ); - } pageResult.setList(treeVos); } } @@ -428,14 +469,16 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { for (MaterialBatchDO batchDO : batchDOS) { MaterialLifecycleDetailDO detailDO = lifecycleDetailDOMapByBatchId.get(batchDO.getId()); BigDecimal influenceCount = detailDO.getInfluenceCount(); + BigDecimal oriVerificationQuantity = batchDO.getVerificationQuantity(); + BigDecimal oriRemaineQuantity = batchDO.getRemaineQuantity(); switch (adjustType) { case add -> { - batchDO.setVerificationQuantity(batchDO.getVerificationQuantity().add(influenceCount)); - batchDO.setRemaineQuantity(batchDO.getRemaineQuantity().subtract(influenceCount)); + batchDO.setVerificationQuantity(oriVerificationQuantity.add(influenceCount)); + batchDO.setRemaineQuantity(oriRemaineQuantity.subtract(influenceCount)); } case subtract -> { - batchDO.setVerificationQuantity(batchDO.getVerificationQuantity().subtract(influenceCount)); - batchDO.setRemaineQuantity(batchDO.getRemaineQuantity().add(influenceCount)); + batchDO.setVerificationQuantity(oriVerificationQuantity.subtract(influenceCount)); + batchDO.setRemaineQuantity(oriRemaineQuantity.add(influenceCount)); } } } @@ -458,9 +501,8 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { Map batchDOMap = batchDOS.stream().collect(Collectors.toMap(MaterialBatchDO::getId, Function.identity())); List gongs = lifecycleDetailDOs.stream().map(detailDO -> { MaterialBatchDO batchDO = batchDOMap.get(detailDO.getBatchId()); - // TODO 此批次此部门下可能已经创建过 Long deptId = startUser.getDeptId(); - MaterialBatchDO gong = new MaterialBatchDO() + return new MaterialBatchDO() .setParentId(detailDO.getBatchId()) .setProductId(batchDO.getProductId()) .setAssignDepartmentId(deptId) @@ -468,8 +510,10 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { .setInboundQuantity(detailDO.getQualifiedCount()) .setBatchNo(batchDO.getBatchNo()) .setRemaineQuantity(detailDO.getQualifiedCount()) - .setAcceptanceStatus(MaterialAcceptStatus.accepted.name()); - return gong; + .setAcceptanceStatus(MaterialAcceptStatus.accepted.name()) + .setSubmitStatus(1).setSubmitDate(batchDO.getSubmitDate()) + .setRemark(String.format("【%s】于%s发起检定,检定数量:%s,合格数量:%s", startUser.getNickname(), instanceData.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), + detailDO.getInfluenceCount(), detailDO.getQualifiedCount())); }).toList(); materialBatchMapper.insertBatch(gongs); } @@ -485,7 +529,11 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { throw new ServiceException(1_032_160_000, "退换货数量大于可用数量"); batOrGong.setLockQuantity(lockQuantity); } - case unlock -> batOrGong.setLockQuantity(batOrGong.getLockQuantity().subtract(influenceCount)); + case unlock -> { + batOrGong.setLockQuantity(batOrGong.getLockQuantity().subtract(influenceCount)); + if (batOrGong.getLockQuantity().compareTo(BigDecimal.ZERO) < 0) + throw new ServiceException(1_032_160_000, "锁定数量小于0,数据异常"); + } } } } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundServiceImpl.java index f1942a08..563ee746 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundServiceImpl.java @@ -92,13 +92,18 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb List infomationDOS = materialInfomationService.saveMaterialInfomationsByBatInb(locationId, reqQuantity, gongduanId, product, batch); // 5.保存入库明细 materialInventoryInboundDetailService.saveInboundDetails(infomationDOS, inbound, batchId, gongduanId); + // 是否为检定入库 + Boolean isVerify = materialProductService.checkIsVerifyCategoryByPdtId(batch.getProductId()); // 更新工段已入库数量和可用数量 gongDO.setInboundEndQuantity(gongDO.getInboundEndQuantity().add(reqQuantity)); gongDO.setRemaineQuantity(gongDO.getRemaineQuantity().subtract(reqQuantity)); materialBatchService.updateById(gongDO); // 更新批次已入库数量和可用数量 batch.setInboundEndQuantity(batch.getInboundEndQuantity().add(reqQuantity)); - batch.setRemaineQuantity(batch.getRemaineQuantity().subtract(reqQuantity)); + if (!isVerify) { + // 检定业务 检定流程提交时已经扣减过可用数量 + batch.setRemaineQuantity(batch.getRemaineQuantity().subtract(reqQuantity)); + } materialBatchService.updateById(batch); // 更新物料大类预警级别 materialProductService.updateMaterialProductAlarmLevel(Collections.singletonList(productId)); diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleDetailServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleDetailServiceImpl.java index 68038002..f32609a1 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleDetailServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleDetailServiceImpl.java @@ -1,21 +1,16 @@ package com.zt.plat.module.qms.resource.material.service; import cn.hutool.core.collection.CollUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zt.plat.framework.common.exception.ServiceException; 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.MaterialInventoryInboundSaveReqVO; 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; import com.zt.plat.module.qms.resource.material.dal.dataobject.*; import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialLifecycleDetailMapper; import com.zt.plat.module.qms.resource.material.enums.MaterialFlowType; -import com.zt.plat.module.qms.resource.material.enums.MaterialInfomationOrigin; import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; @@ -140,46 +135,52 @@ public class MaterialLifecycleDetailServiceImpl implements MaterialLifecycleDeta @Override public List getDetailListWithPdtInfoByLfcId(MaterialLifecycleDO lifecycleDO) { // 退换货时单独处理 - String businessType = lifecycleDO.getBusinessType(); - MaterialFlowType flowType = MaterialFlowType.fromName(businessType); - if (MaterialFlowType.return_material.equals(flowType) || MaterialFlowType.exchange_material.equals(flowType)) { - List detailRespVOS = materialLifecycleDetailMapper.selectListWithReturnExchangeInfo(lifecycleDO.getId()); - if (CollUtil.isEmpty(detailRespVOS)) return detailRespVOS; - List batOrGongIds = detailRespVOS.stream() - .flatMap(detail -> Stream.of(detail.getBatchId(), detail.getBatchGongduanId()).filter(Objects::nonNull)) - .toList(); - List batOrGongDOS = materialBatchService.getListByIds(batOrGongIds); - if (CollUtil.isEmpty(batOrGongDOS)) return detailRespVOS; - Set pdtIds = batOrGongDOS.stream().map(MaterialBatchDO::getProductId).collect(Collectors.toSet()); - List products = materialProductService.getMaterialProductListByPdtIds(new ArrayList<>(pdtIds)); - if (CollUtil.isEmpty(products)) return detailRespVOS; - Map batOrGongMapById = batOrGongDOS.stream().collect(Collectors.toMap(MaterialBatchDO::getId, Function.identity())); - Map productMapById = products.stream().collect(Collectors.toMap(MaterialProductDO::getId, Function.identity())); - for (MaterialLifecycleDetailRespVO detailRespVO : detailRespVOS) { - MaterialProductDO productDO = new MaterialProductDO(); - if (detailRespVO.getBatchId() != null) { - MaterialBatchDO batchDO = batOrGongMapById.get(detailRespVO.getBatchId()); - detailRespVO.setGongParentId(0L); - detailRespVO.setInboundQuantity(batchDO.getInboundQuantity()); - productDO = productMapById.get(batchDO.getProductId()); - } else if (detailRespVO.getBatchGongduanId() != null) { - MaterialBatchDO gongDO = batOrGongMapById.get(detailRespVO.getBatchGongduanId()); - detailRespVO.setGongParentId(gongDO.getParentId()); - detailRespVO.setBatchNo(gongDO.getBatchNo()); - detailRespVO.setInboundQuantity(gongDO.getInboundQuantity()); - productDO = productMapById.get(gongDO.getProductId()); - } - detailRespVO - .setProductId(productDO.getId()) - .setProductName(productDO.getName()) - .setProductCode(productDO.getCode()) - .setProductModelNo(productDO.getModelNo()); + MaterialFlowType flowType = MaterialFlowType.fromName(lifecycleDO.getBusinessType()); + switch (flowType) { + case acceptance -> { + return materialLifecycleDetailMapper.selectListWithGongPdtBatInfo(lifecycleDO.getId()); + } + case verify_calibrate -> { + return materialLifecycleDetailMapper.selectListWithBatchPdtBatInfo(lifecycleDO.getId()); + } + case return_material, exchange_material -> { + List detailRespVOS = materialLifecycleDetailMapper.selectListWithReturnExchangeInfo(lifecycleDO.getId()); + if (CollUtil.isEmpty(detailRespVOS)) return detailRespVOS; + List batOrGongIds = detailRespVOS.stream() + .flatMap(detail -> Stream.of(detail.getBatchId(), detail.getBatchGongduanId()).filter(Objects::nonNull)) + .toList(); + List batOrGongDOS = materialBatchService.getListByIds(batOrGongIds); + if (CollUtil.isEmpty(batOrGongDOS)) return detailRespVOS; + Set pdtIds = batOrGongDOS.stream().map(MaterialBatchDO::getProductId).collect(Collectors.toSet()); + List products = materialProductService.getMaterialProductListByPdtIds(new ArrayList<>(pdtIds)); + if (CollUtil.isEmpty(products)) return detailRespVOS; + Map batOrGongMapById = batOrGongDOS.stream().collect(Collectors.toMap(MaterialBatchDO::getId, Function.identity())); + Map productMapById = products.stream().collect(Collectors.toMap(MaterialProductDO::getId, Function.identity())); + for (MaterialLifecycleDetailRespVO detailRespVO : detailRespVOS) { + MaterialProductDO productDO = new MaterialProductDO(); + if (detailRespVO.getBatchId() != null) { + MaterialBatchDO batchDO = batOrGongMapById.get(detailRespVO.getBatchId()); + detailRespVO.setGongParentId(0L); + detailRespVO.setInboundQuantity(batchDO.getInboundQuantity()); + productDO = productMapById.get(batchDO.getProductId()); + } else if (detailRespVO.getBatchGongduanId() != null) { + MaterialBatchDO gongDO = batOrGongMapById.get(detailRespVO.getBatchGongduanId()); + detailRespVO.setGongParentId(gongDO.getParentId()); + detailRespVO.setBatchNo(gongDO.getBatchNo()); + detailRespVO.setInboundQuantity(gongDO.getInboundQuantity()); + productDO = productMapById.get(gongDO.getProductId()); + } + detailRespVO + .setProductId(productDO.getId()) + .setProductName(productDO.getName()) + .setProductCode(productDO.getCode()) + .setProductModelNo(productDO.getModelNo()); + } + return detailRespVOS; } - return detailRespVOS; - } else { - return materialLifecycleDetailMapper.selectListWithPdtBatInfo(lifecycleDO.getId()); } + return List.of(); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleServiceImpl.java index b1dd9960..4852fe12 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleServiceImpl.java @@ -227,9 +227,10 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , || MaterialFlowType.exchange_material.getName().equals(mtrlLfc.getBusinessType()); if (isReturnExchangeMaterial) lockReturnExchangeResources(oriDetailList, LockType.unlock); - // 释放原理啊物料检定资源 + // 释放原理物料检定资源 boolean isVerifyCalibrate = MaterialFlowType.verify_calibrate.getName().equals(mtrlLfc.getBusinessType()); if (isVerifyCalibrate) lockVerifyCalibrateResources(oriDetailList, LockType.unlock); + List detailDOS = getLifecycleDetailDOSByBusinessType(detailList, mtrlLfc); // 保存新的明细 materialLifecycleDetailService.saveBatch(detailDOS); @@ -309,14 +310,22 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , List batches = materialBatchService.getBatchListByBatchIds(batIds); if (CollUtil.isEmpty(batches) || batches.size() != batIds.size()) throw new ServiceException(1_032_160_000, "批次不存在或与传入的批次数量不匹配"); - // 检定数量检验 + for (MaterialBatchDO batch : batches) { + if (batch.getSubmitStatus() != 1) + throw new ServiceException(1_032_160_000, String.format("批次【%s】未提交,不可检定", batch.getBatchNo())); + } + // 检定数量校验 Map batchDOMapById = batches.stream().collect(Collectors.toMap(MaterialBatchDO::getId, Function.identity())); for (MaterialLifecycleDetailSaveReqVO reqDetail : reqDetails) { MaterialBatchDO batchDO = batchDOMapById.get(reqDetail.getBatchId()); - // 可用数量 BigDecimal remaineQuantity = batchDO.getRemaineQuantity(); + if (reqDetail.getInfluenceCount().compareTo(BigDecimal.ZERO) <= 0) + throw new ServiceException(1_032_160_000, "检定数量不能小于等于0"); if (reqDetail.getInfluenceCount().compareTo(remaineQuantity) > 0) + // 可用数量 throw new ServiceException(1_032_160_000, String.format("检定数量超过了批次【%s】可用数量【%s】", batchDO.getBatchNo(), remaineQuantity)); + if (reqDetail.getQualifiedCount().compareTo(reqDetail.getInfluenceCount()) > 0) + throw new ServiceException(1_032_160_000, "合格数量超过了检定数量"); } return reqDetails.stream().map(detail -> { @@ -324,6 +333,8 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , detailDO.setLifecycleId(mtrlLfc.getId()) .setBatchId(detail.getBatchId()) .setInfluenceCount(detail.getInfluenceCount()) + .setQualifiedCount(detail.getQualifiedCount()) + .setUnqualifiedCount(detail.getInfluenceCount().subtract(detail.getQualifiedCount())) .setBusinessType(mtrlLfc.getBusinessType()) .setTreatmentStatus(0) .setRemark(detail.getRemark()); diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductService.java index 9d4ae049..45d9222a 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductService.java @@ -132,4 +132,20 @@ public interface MaterialProductService { * @return 物料数据 */ MaterialProductRespVO getMaterialProductInfoWithFiles(Long id); + + /** + * 获取顶级分类 + * + * @param pdtIds 大类ids + * @return 顶级分类 + */ + List getTopCategoriesByPdtIds(List pdtIds); + + /** + * 检查是否是检定的分类 + * + * @param productId 大类id + * @return 是否是审核的分类 + */ + Boolean checkIsVerifyCategoryByPdtId(Long productId); } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java index 4a9e6ba7..f79571bc 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java @@ -4,15 +4,18 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zt.plat.framework.common.exception.ServiceException; import com.zt.plat.framework.common.pojo.CommonResult; import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX; import com.zt.plat.module.infra.api.businessfile.dto.BusinessFileWithUrlRespDTO; import com.zt.plat.module.qms.common.service.BusinessFileService; import com.zt.plat.module.qms.core.constant.DataTypeConstant; +import com.zt.plat.module.qms.enums.QmsCommonConstant; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductSaveReqVO; @@ -21,6 +24,7 @@ import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialProductMapper; import com.zt.plat.module.qms.resource.material.enums.MaterialInventoryAlarmLevel; import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -38,6 +42,7 @@ import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*; * * @author 后台管理 */ +@Slf4j @Service @Validated public class MaterialProductServiceImpl implements MaterialProductService { @@ -195,7 +200,7 @@ public class MaterialProductServiceImpl implements MaterialProductService { // 新增 if (reqId == null) { boolean exists = materialProductMapper.exists(queryWrapperX); - if (exists) throw exception(MATERIAL_PRODUCT_CODE_EXISTED); + if (exists) throw exception(MATERIAL_PRODUCT_CODE_MODELNO_EXISTED); // 从直接父分类获取是否危险品、是否标准物质、是否标准溶液 MaterialProductDO prnCtg = materialProductMapper.selectById(mtrl.getParentId()); if (prnCtg != null) { @@ -214,15 +219,12 @@ public class MaterialProductServiceImpl implements MaterialProductService { if (origDO == null) throw exception(MATERIAL_PRODUCT_NOT_EXISTS); queryWrapperX.neIfPresent(MaterialProductDO::getId, reqId); boolean exists = materialProductMapper.exists(queryWrapperX); - if (exists) throw exception(MATERIAL_PRODUCT_CODE_EXISTED); + if (exists) throw exception(MATERIAL_PRODUCT_CODE_MODELNO_EXISTED); businessFileService.deleteBusinessFileList(createReqVO.getDeleteFileIdList()); Long newParentId = createReqVO.getParentId(); - if (origDO.getParentId().equals(newParentId)) { - materialProductMapper.updateById(mtrl); - return BeanUtils.toBean(mtrl, MaterialProductRespVO.class); - } else { + if (!origDO.getParentId().equals(newParentId)) { // 父节点有变更,更新大类属性 MaterialProductDO productDO = materialProductMapper.selectById(newParentId); MaterialProductDO topParent; @@ -243,9 +245,23 @@ public class MaterialProductServiceImpl implements MaterialProductService { String newIdPath = getIdPath(mtrl); mtrl.setIdPath(newIdPath); materialProductMapper.updateById(mtrl); + // 处理库存预警级别 + handleInventoryAlarmLevel(mtrl, reqId); return BeanUtils.toBean(mtrl, MaterialProductRespVO.class); } + private void handleInventoryAlarmLevel(MaterialProductDO mtrl, Long reqId) { + if (mtrl.getInventoryAlarmFlag() != null && mtrl.getInventoryAlarmFlag() == 1) { + // 根据实际库存数量计算准确的预警级别 + this.updateMaterialProductAlarmLevel(Collections.singletonList(reqId)); + } else if (mtrl.getInventoryAlarmFlag() != null && mtrl.getInventoryAlarmFlag() == 0) { + // 明确禁用预警,清空预警级别 + materialProductMapper.update(Wrappers.lambdaUpdate(MaterialProductDO.class) + .eq(MaterialProductDO::getId, reqId) + .set(MaterialProductDO::getInventoryAlarmLevel, null)); + } + } + @Override public void updateMaterialProduct(MaterialProductSaveReqVO updateReqVO) { // 校验存在 @@ -337,17 +353,27 @@ public class MaterialProductServiceImpl implements MaterialProductService { @Override public List getCategoryAndData(MaterialProductQueryVO queryVO) { - LambdaQueryWrapperX wrapperX = new LambdaQueryWrapperX() + LambdaQueryWrapper wrapperX = new LambdaQueryWrapperX() .eqIfPresent(MaterialProductDO::getNodeType, queryVO.getNodeType()) .eqIfPresent(MaterialProductDO::getHazardous, queryVO.getHazardous()) .eqIfPresent(MaterialProductDO::getStandardSolutionFlag, queryVO.getStandardSolutionFlag()) .eqIfPresent(MaterialProductDO::getStandardMaterialFlag, queryVO.getStandardMaterialFlag()) - .likeIfPresent(MaterialProductDO::getName, queryVO.getName()); + .likeIfPresent(MaterialProductDO::getName, queryVO.getName()) + .and(StrUtil.isNotEmpty(queryVO.getCategoryCustomConfig()),wrapper -> + wrapper.eq(MaterialProductDO::getNodeType, DataTypeConstant.DATA_TYPE_CATEGORY) + .like(MaterialProductDO::getCustomConfig, queryVO.getCategoryCustomConfig())); List mtrlDos = materialProductMapper.selectList(wrapperX); if (CollUtil.isEmpty(mtrlDos)) return List.of(); - return mtrlDos.stream().map(m -> BeanUtils.toBean(m, MaterialProductRespVO.class)).toList(); + if (StrUtil.isNotEmpty(queryVO.getCategoryCustomConfig()) && StrUtil.isEmpty(queryVO.getNodeType())) { + List ctgIds = mtrlDos.stream().map(MaterialProductDO::getId).toList(); + List pdts = materialProductMapper.selectList(Wrappers.lambdaQuery(MaterialProductDO.class) + .in(MaterialProductDO::getParentId, ctgIds)); + mtrlDos.addAll(pdts); + } + + return BeanUtils.toBean(mtrlDos, MaterialProductRespVO.class); } @Override @@ -359,11 +385,9 @@ public class MaterialProductServiceImpl implements MaterialProductService { List voList = mtrlDos.stream().map(m -> BeanUtils.toBean(m, MaterialProductRespVO.class)).toList(); // 一次性获取大类下的库存数量 Map stockQuantityMap = materialProductMapper.getStockQuantityByPdtIds(mtrlIds); - if (CollUtil.isNotEmpty(stockQuantityMap)) { - for (MaterialProductRespVO vo : voList) { - Long val = stockQuantityMap.get(vo.getId()); - vo.setInventoryQuantity(BigDecimal.valueOf(val == null ? 0L : val)); - } + for (MaterialProductRespVO vo : voList) { + Long val = stockQuantityMap.get(vo.getId()); + vo.setInventoryQuantity(BigDecimal.valueOf(val == null ? 0L : val)); } return new PageResult<>(voList, pageResult.getTotal()); @@ -401,7 +425,8 @@ public class MaterialProductServiceImpl implements MaterialProductService { // BigDecimal[] safeRange = (BigDecimal[]) alarmRange.get(MaterialInventoryAlarmLevel.safe.name()); List dangerRange = alarmRange.getJSONArray(MaterialInventoryAlarmLevel.danger.name()).toList(BigDecimal.class); List warnRange = alarmRange.getJSONArray(MaterialInventoryAlarmLevel.warn.name()).toList(BigDecimal.class); - BigDecimal inventoryQuantity = BigDecimal.valueOf(stockQuantityMap.get(m.getId())); + Long qty = stockQuantityMap.get(m.getId()); + BigDecimal inventoryQuantity = BigDecimal.valueOf(qty == null ? 0L : qty); if (inventoryQuantity.compareTo(dangerRange.get(1)) <= 0) { alarmLevel = MaterialInventoryAlarmLevel.danger.name(); } else if (inventoryQuantity.compareTo(warnRange.get(1)) <= 0) { @@ -426,4 +451,31 @@ public class MaterialProductServiceImpl implements MaterialProductService { return respVO; } + @Override + public List getTopCategoriesByPdtIds(List pdtIds) { + List productDOS = materialProductMapper.selectByIds(pdtIds); + // 获取顶级分类ids ipPath格式:/0/2015987059211448321/2018922665117827074/2018932101769150466/ + Set topCategoryIds = productDOS.stream() + .map(MaterialProductDO::getIdPath) + .filter(StrUtil::isNotEmpty) + .map(path -> path.split("/")) + .filter(segments -> segments.length > 2) + .map(segments -> segments[2]) + .map(Long::parseLong) + .collect(Collectors.toSet()); + return materialProductMapper.selectByIds(topCategoryIds); + } + + @Override + public Boolean checkIsVerifyCategoryByPdtId(Long productId) { + + List topCategories = this.getTopCategoriesByPdtIds(Collections.singletonList(productId)); + if (CollUtil.isEmpty(topCategories)) return false; + MaterialProductDO topCtg = topCategories.get(0); + JSONObject customConfig = JSONUtil.parseObj(topCtg.getCustomConfig()); + Object verifyCalibrateFlag = customConfig.get("verifyCalibrateFlag"); + if (verifyCalibrateFlag == null) return false; + return "1".equals(verifyCalibrateFlag); + } + } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordServiceImpl.java index 211a1c73..51adce40 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordServiceImpl.java @@ -55,6 +55,7 @@ public class MaterialUseRecordServiceImpl implements MaterialUseRecordService { BigDecimal operationQuantity = createReqVO.getOperationQuantity(); MaterialInfomationDO infomationDO = materialInfomationService.getMaterialInfomation(infomationId); if (infomationDO == null) throw new ServiceException(1_032_160_000, "物料实例不存在"); + if (infomationDO.getUseEndFlag() == 1) throw new ServiceException(1_032_160_000, "物料已用完"); // 使用量不能大于剩余量 BigDecimal remainingVolume = infomationDO.getRemainingVolume(); diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/constant/RecordConstants.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/constant/RecordConstants.java index 39d17066..066759b4 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/constant/RecordConstants.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/constant/RecordConstants.java @@ -99,4 +99,14 @@ public class RecordConstants { * */ public static final String RECORD_UPDATE_DEFINITION_KEY = "QMS_RECORD_UPDATE"; } + + /** + * 权限类型 + */ + public static class PermissionSourceType { + /** 分类 */ + public static final String CATEGORY = "分类"; + /** 记录 */ + public static final String RECORD = "记录"; + } } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordapply/vo/RecordApplyRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordapply/vo/RecordApplyRespVO.java index 76978218..add72860 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordapply/vo/RecordApplyRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordapply/vo/RecordApplyRespVO.java @@ -3,6 +3,7 @@ package com.zt.plat.module.qms.resource.record.controller.admin.recordapply.vo; import com.alibaba.fastjson2.JSONObject; import com.zt.plat.module.qms.core.aspect.annotation.Dict; import com.zt.plat.module.qms.resource.record.controller.admin.recordapplydetail.vo.RecordApplyDetailRespVO; +import com.zt.plat.module.qms.resource.record.controller.admin.recordapplydetail.vo.RecordApplyDetailSaveReqVO; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotEmpty; import lombok.*; @@ -133,7 +134,7 @@ public class RecordApplyRespVO { // @Schema(description = "用户IDs") // private Long[] deptIds; - private List paramsList; + private List paramsList; } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordapply/vo/RecordApplySaveReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordapply/vo/RecordApplySaveReqVO.java index e40930e9..9f7e24c1 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordapply/vo/RecordApplySaveReqVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordapply/vo/RecordApplySaveReqVO.java @@ -2,6 +2,7 @@ package com.zt.plat.module.qms.resource.record.controller.admin.recordapply.vo; import com.alibaba.excel.annotation.ExcelProperty; import com.zt.plat.module.qms.resource.record.controller.admin.recordapplydetail.vo.RecordApplyDetailRespVO; +import com.zt.plat.module.qms.resource.record.controller.admin.recordapplydetail.vo.RecordApplyDetailSaveReqVO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; @@ -91,6 +92,8 @@ public class RecordApplySaveReqVO { @Schema(description = "流程实例ID") private String flowInstanceId; + // ============================================ + @Schema(description = "文件记录ID") private Long recordId; @@ -100,10 +103,10 @@ public class RecordApplySaveReqVO { @Schema(description = "用户IDs") private Long[] deptIds; - private List paramsList; + private List paramsList; // 分发参数 - private List targetList; +// private List targetList; } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordapplydetail/vo/RecordApplyDetailSaveReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordapplydetail/vo/RecordApplyDetailSaveReqVO.java index 70728dab..aab7ad42 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordapplydetail/vo/RecordApplyDetailSaveReqVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordapplydetail/vo/RecordApplyDetailSaveReqVO.java @@ -34,6 +34,8 @@ public class RecordApplyDetailSaveReqVO { @Schema(description = "更改原因") private String modifyCause; + private String formData; + @Schema(description = "是否长期有效") private String permanently; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordcategory/RecordCategoryController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordcategory/RecordCategoryController.java index 9277c6e4..289f85ca 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordcategory/RecordCategoryController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordcategory/RecordCategoryController.java @@ -112,15 +112,6 @@ public class RecordCategoryController extends AbstractFileUploadController imple return success(BeanUtils.toBean(recordCategory, RecordCategoryRespVO.class)); } - @GetMapping("/isAdminByUserId") - @Operation(summary = "通过分类Id判断当前用户是否有管理员权限") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - //@PreAuthorize("@ss.hasPermission('qms:record-category:query')") - public CommonResult isAdminByUserId(@RequestParam("id") Long id) { - boolean b = recordCategoryService.isAdminByUserId(id); - return success(b); - } - // 文件评审,获取满足当前账户权限的记录列表 @GetMapping("/getReviewRecordList") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordpermission/RecordPermissionController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordpermission/RecordPermissionController.java index fadd52f2..7150df60 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordpermission/RecordPermissionController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordpermission/RecordPermissionController.java @@ -96,6 +96,25 @@ public class RecordPermissionController extends AbstractFileUploadController imp return success(BeanUtils.toBean(recordPermission, RecordPermissionRespVO.class)); } + @GetMapping("/isAdminByUserId") + @Operation(summary = "通过分类Id判断当前用户是否有管理员权限") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + //@PreAuthorize("@ss.hasPermission('qms:record-category:query')") + public CommonResult isAdminByUserId(@RequestParam("categoryId") Long categoryId) { + boolean b = recordPermissionService.isAdminByUserId(categoryId); + return success(b); + } + + @GetMapping("/getMatchedPermissionList") + @Operation(summary = "获得记录权限列表") + //@PreAuthorize("@ss.hasPermission('qms:record-permission:query')") + public CommonResult> getMatchedPermissionList(@RequestParam("sourceId") Long sourceId) { +// Long sourceId = pageReqVO.getSourceId(); + if (sourceId == null) return success(null); + List matchedPermissionList = recordPermissionService.getMatchedPermissionList(sourceId); + return success(BeanUtils.toBean(matchedPermissionList, RecordPermissionRespVO.class)); + } + @GetMapping("/page") @Operation(summary = "获得记录权限分页") //@PreAuthorize("@ss.hasPermission('qms:record-permission:query')") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordrecord/RecordRecordController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordrecord/RecordRecordController.java index 78b1d8e0..f48d63bf 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordrecord/RecordRecordController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/controller/admin/recordrecord/RecordRecordController.java @@ -11,6 +11,7 @@ import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.R import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.RecordRecordRespVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.RecordRecordSaveReqVO; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordpermission.RecordPermissionDO; +import com.zt.plat.module.qms.resource.record.service.recordpermission.RecordPermissionService; import org.springframework.web.bind.annotation.*; import jakarta.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -60,6 +61,9 @@ public class RecordRecordController extends AbstractFileUploadController impleme @Resource private RecordRecordService recordRecordService; + + @Resource + private RecordPermissionService recordPermissionService; @Resource private BusinessFileService businessFileService; @@ -109,14 +113,6 @@ public class RecordRecordController extends AbstractFileUploadController impleme return success(vo); } - @GetMapping("/justRecordPermission") - @Operation(summary = "判断当前文件的权限") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - //@PreAuthorize("@ss.hasPermission('qms:record-record:query')") - public CommonResult justRecordPermission(@RequestParam("id") Long id) { - return recordRecordService.justRecordPermission(id); - } - @GetMapping("/page") @Operation(summary = "获得文件、模板、记录分页") //@PreAuthorize("@ss.hasPermission('qms:record-record:query')") @@ -131,13 +127,14 @@ public class RecordRecordController extends AbstractFileUploadController impleme return success(BeanUtils.toBean(pageResult, RecordRecordRespVO.class)); } + // TODO @GetMapping("/getMatchedPermissionList") @Operation(summary = "获得记录权限列表") //@PreAuthorize("@ss.hasPermission('qms:record-permission:query')") - public CommonResult> getMatchedPermissionList(@Valid RecordPermissionPageReqVO pageReqVO) { - Long sourceId = pageReqVO.getSourceId(); + public CommonResult> getMatchedPermissionList(@RequestParam("sourceId") Long sourceId) { +// Long sourceId = pageReqVO.getSourceId(); if (sourceId == null) return success(null); - List matchedPermissionList = recordRecordService.getMatchedPermissionList(sourceId); + List matchedPermissionList = recordPermissionService.getMatchedPermissionList(sourceId); return success(BeanUtils.toBean(matchedPermissionList, RecordPermissionRespVO.class)); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/dataobject/recordapplydetail/RecordApplyDetailDO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/dataobject/recordapplydetail/RecordApplyDetailDO.java index 7dbb3801..6eeedcb5 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/dataobject/recordapplydetail/RecordApplyDetailDO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/dataobject/recordapplydetail/RecordApplyDetailDO.java @@ -58,8 +58,8 @@ public class RecordApplyDetailDO extends BusinessBaseDO { @TableField("TGT_ID") private Long targetId; - @TableField("TGT_NAME") - private String targetName; + @TableField("FORM_DAT") + private String formData; /** * 是否需要更改 */ diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/mapper/RecordCategoryMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/mapper/RecordCategoryMapper.java index 017cf51f..38c28573 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/mapper/RecordCategoryMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/mapper/RecordCategoryMapper.java @@ -1,14 +1,11 @@ package com.zt.plat.module.qms.resource.record.dal.mapper; import com.zt.plat.framework.common.pojo.PageResult; -import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; +import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.module.qms.resource.record.controller.admin.recordcategory.vo.RecordCategoryPageReqVO; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordcategory.RecordCategoryDO; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import java.util.List; -import java.util.Set; /** * 文件记录分类 Mapper @@ -35,16 +32,4 @@ public interface RecordCategoryMapper extends BaseMapperX { .orderByDesc(RecordCategoryDO::getId)); } - /** - * 检查用户是否有指定分类的管理员权限 - * 查询条件:permission='管理员' AND - * 1. 用户是管理员 ( targetId=userId AND targetType='用户') - * 2. 或用户所在部门有权限 (targetType='部门' AND targetId in userDepts) - * 3. 或用户的角色有权限 (targetType='角色' AND targetId in userRoles) - */ - boolean checkUserAdminPermission(@Param("categoryId") Long categoryId, - @Param("userId") Long userId, - @Param("userDepts") List userDepts, - @Param("userRoles") Set userRoles); - } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/mapper/RecordPermissionMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/mapper/RecordPermissionMapper.java index 29b4abcb..b72d0788 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/mapper/RecordPermissionMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/mapper/RecordPermissionMapper.java @@ -1,11 +1,15 @@ package com.zt.plat.module.qms.resource.record.dal.mapper; import com.zt.plat.framework.common.pojo.PageResult; -import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; +import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.module.qms.resource.record.controller.admin.recordpermission.vo.RecordPermissionPageReqVO; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordpermission.RecordPermissionDO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Set; /** * 记录权限 Mapper @@ -35,4 +39,17 @@ public interface RecordPermissionMapper extends BaseMapperX .orderByDesc(RecordPermissionDO::getId)); } + /** + * 检查用户是否有指定分类的管理员权限 + * 查询条件:permission='管理员' AND + * 1. 用户是管理员 ( targetId=userId AND targetType='用户') + * 2. 或用户所在部门有权限 (targetType='部门' AND targetId in userDepts) + * 3. 或用户的角色有权限 (targetType='角色' AND targetId in userRoles) + */ + List selectPermissionList(@Param("categoryId") Long categoryId, + @Param("userId") Long userId, + @Param("userDepts") List userDepts, + @Param("userRoles") Set userRoles, + @Param("permission") String permission); // permission: 管理员/可编辑/可查看 + } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/mapper/RecordRecordMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/mapper/RecordRecordMapper.java index a1ed9ba0..46b9a5fb 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/mapper/RecordRecordMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/dal/mapper/RecordRecordMapper.java @@ -8,6 +8,8 @@ import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.module.qms.resource.record.controller.admin.recordapply.vo.RecordApplyJoinPageVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.RecordRecordPageReqVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.RecordRecordRespVO; +import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.RecordRecordSaveReqVO; +import com.zt.plat.module.qms.resource.record.dal.dataobject.recordpermission.RecordPermissionDO; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordrecord.RecordRecordDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -53,9 +55,9 @@ public interface RecordRecordMapper extends BaseMapperX { /** * 多表关联分页查询:recordRecord、recordApplyDetail、recordApply * 关联关系:recordRecord.id = recordApplyDetail.documentId - * recordApplyDetail.applyId = recordApply.id + * recordApplyDetail.applyId = recordApply.id */ - IPage selectRecordWithApplyPage(Page page,@Param("reqVO") RecordRecordPageReqVO reqVO); + IPage selectRecordWithApplyPage(Page page, @Param("reqVO") RecordRecordPageReqVO reqVO); /** * 文件评审分页查询:关联查询 recordApply、recordApplyDetail、recordRecord @@ -78,4 +80,15 @@ public interface RecordRecordMapper extends BaseMapperX { "WHERE tra.BSN_TP = #{businessType}") Long selectRecordReviewCount(String businessType); + /** + * 通过记录Id 查询权限列表 + * sourceId == recordId + * 1. 用户 ( targetId=userId AND targetType='用户') + * 2. 用户所在部门有权限 (targetType='部门' AND targetId in userDepts) + */ + IPage selectRecordPermissionList(Page page, + @Param("pageReqVO") RecordRecordPageReqVO pageReqVO, + @Param("userId") Long userId, + @Param("userDepts") List userDepts); + } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordapply/RecordApplyServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordapply/RecordApplyServiceImpl.java index 31fbdec8..9260205b 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordapply/RecordApplyServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordapply/RecordApplyServiceImpl.java @@ -27,9 +27,8 @@ import com.zt.plat.module.qms.resource.record.controller.admin.recordapply.vo.Re import com.zt.plat.module.qms.resource.record.controller.admin.recordapply.vo.RecordApplyRespVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordapply.vo.RecordApplySaveReqVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordapplydetail.vo.RecordApplyDetailPageReqVO; -import com.zt.plat.module.qms.resource.record.controller.admin.recordapplydetail.vo.RecordApplyDetailRespVO; +import com.zt.plat.module.qms.resource.record.controller.admin.recordapplydetail.vo.RecordApplyDetailSaveReqVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.RecordRecordPageReqVO; -import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.RecordRecordRespVO; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordapply.RecordApplyDO; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordapplydetail.RecordApplyDetailDO; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordcategory.RecordCategoryDO; @@ -156,41 +155,11 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn return recordApplyMapper.selectPage(pageReqVO); } - //创建临时数据 - @Override - @Transactional(rollbackFor = Exception.class) - public CommonResult createApplyData(RecordApplySaveReqVO param) { - String businessType = param.getBusinessType(); - if (ObjectUtils.isEmpty(businessType)) - throw exception0(RECORD_APPLY_NOT_EXISTS.getCode(), "请选择业务类型"); - // TODO -// Long recordId = param.getRecordId(); -// List documentIds = new ArrayList<>(); -// if (!ObjectUtils.isEmpty(recordId)) documentIds.add(recordId); -// List paramsList = param.getParamsList(); -// if (!ObjectUtils.isEmpty(paramsList)) { -// paramsList.forEach(item -> { -// Long documentId = item.getDocumentId(); -// if (!ObjectUtils.isEmpty(documentId)) { -// documentIds.add(documentId); -// }; -// }); -// } -// List statuses = Arrays.asList(QmsCommonConstant.NOT_START, QmsCommonConstant.RUNNING, QmsCommonConstant.COMPLETED); -// List recordApplyDOS = selectApplyByStatus(businessType, documentIds, statuses); -// if (!ObjectUtils.isEmpty(recordApplyDOS)) return CommonResult.error(RECORD_APPLY_NOT_EXISTS.getCode(),"存在提交的文件在审批中或审批完成"); - - RecordApplyDO recordApply = createApply(param); - - addDetail(param,recordApply); - - return CommonResult.success(BeanUtils.toBean(recordApply, RecordApplyRespVO.class)); - } - // 创建申请数据 - public RecordApplyDO createApply(RecordApplySaveReqVO param){ + public RecordApplyDO createApply(RecordApplySaveReqVO param) { RecordApplyDO recordApply = BeanUtils.toBean(param, RecordApplyDO.class); recordApply.setBusinessStatus(QmsCommonConstant.NOT_START); // 未发起 + recordApply.setApplyStartDate(LocalDateTime.now()); // 申请开始时间 String businessType = param.getBusinessType(); //取当前用户 LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); @@ -201,21 +170,186 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn recordApply.setApplyDepartmentName(loginUser.getVisitDeptName()); //生成标题 - String title = nickName + "的"+ businessType +"_" + new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(new Date()); + String title = nickName + "的" + businessType + "_" + new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(new Date()); recordApply.setTitle(title); try { recordApplyMapper.insert(recordApply); } catch (Exception e) { throw new RuntimeException(e); } - return recordApply; + return recordApply; + } + + //创建临时数据 + @Override + @Transactional(rollbackFor = Exception.class) + public CommonResult createApplyData(RecordApplySaveReqVO param) { + String businessType = param.getBusinessType(); + if (ObjectUtils.isEmpty(businessType)) + throw exception0(RECORD_APPLY_NOT_EXISTS.getCode(), "请选择业务类型"); + List paramsList = param.getParamsList(); + if (ObjectUtils.isEmpty(paramsList)) + throw exception0(RECORD_APPLY_NOT_EXISTS.getCode(), "没有找到文件记录数据"); + // TODO + RecordApplyDO recordApply = createApply(param); + + List detailSaveReqVOList = new ArrayList<>(); + switch (businessType) { + case RecordConstants.BusinessType.REVIEW: // 评审 + detailSaveReqVOList = addReviewDetail(param, recordApply); + break; + case RecordConstants.BusinessType.DISTRIBUTION: // 分发 + detailSaveReqVOList = addDistributionDetail(param, recordApply); + break; + case RecordConstants.BusinessType.RECORD_UPDATE: // 更改申请 + detailSaveReqVOList = addUpdateDetail(param, recordApply); + break; + case RecordConstants.BusinessType.INVALID: // 作废 + detailSaveReqVOList = addInvalidDetail(param, recordApply); + break; + case RecordConstants.BusinessType.VIEW_APPLY: // 查看 + detailSaveReqVOList = addViewApplyDetail(param, recordApply); + break; + case RecordConstants.BusinessType.RECORD_SUBMIT: // 提交 + detailSaveReqVOList = addRecordSubmitDetail(param, recordApply); + break; + } + + if (ObjectUtils.isEmpty(detailSaveReqVOList)) + throw exception0(RECORD_APPLY_NOT_EXISTS.getCode(), "没有找到文件记录数据"); + boolean recordApplyDetailBatch = recordApplyDetailService.createRecordApplyDetailBatch(detailSaveReqVOList); + if (!recordApplyDetailBatch) + throw exception(RECORD_APPLY_NOT_EXISTS, "保存申请明细失败"); + return CommonResult.success(BeanUtils.toBean(recordApply, RecordApplyRespVO.class)); + } + + // 保存评审明细 + public List addReviewDetail(RecordApplySaveReqVO param, RecordApplyDO recordApplyDO) { + List paramsList = param.getParamsList(); + List detailSaveReqVOList = new ArrayList<>(); + for (RecordApplyDetailSaveReqVO item : paramsList) { + RecordApplyDetailDO recordApplyDetailDO = new RecordApplyDetailDO(); + recordApplyDetailDO.setApplyId(recordApplyDO.getId()); + recordApplyDetailDO.setDocumentId(item.getDocumentId()); + recordApplyDetailDO.setIsModify(item.getIsModify()); + recordApplyDetailDO.setModifyCause(item.getModifyCause()); + recordApplyDetailDO.setFormData(item.getFormData()); + detailSaveReqVOList.add(recordApplyDetailDO); + } +// recordApplyDetailService.createRecordApplyDetailBatch(detailSaveReqVOList); + return detailSaveReqVOList; + } + + // 添加分发明细 + public List addDistributionDetail(RecordApplySaveReqVO param, RecordApplyDO recordApplyDO) { + Long recordId = param.getParamsList().get(0).getDocumentId(); + String assignTarget = param.getAssignTarget(); + + List detailSaveReqVOList = new ArrayList<>(); + if (assignTarget.equals(RecordConstants.TargetType.USER)) { // 用户 + String targetUserIds = param.getTargetUserIds(); + String[] userIds = targetUserIds.split(","); + for (String userId : userIds) { + if (ObjectUtils.isEmpty(userId)) break; // 过滤空 + RecordApplyDetailDO recordApplyDetailDO = new RecordApplyDetailDO(); + recordApplyDetailDO.setApplyId(recordApplyDO.getId()); + recordApplyDetailDO.setDocumentId(recordId); + recordApplyDetailDO.setTargetId(Long.valueOf(userId));//用户Id + recordApplyDetailDO.setTargetType(RecordConstants.TargetType.USER); + recordApplyDetailDO.setApplyStartDate(LocalDateTime.now()); // TODO 申请开始时间 + detailSaveReqVOList.add(recordApplyDetailDO); + } + } else if (assignTarget.equals(RecordConstants.TargetType.DEPT)) { + String targetDepartmentIds = param.getTargetDepartmentIds(); +// if (ObjectUtils.isEmpty(targetDepartmentIds)) throw exception0(RECORD_RECORD_NOT_EXISTS.getCode(),"分发部门不存在"); + String[] deptIds = targetDepartmentIds.split(","); + for (String deptId : deptIds) { + if (ObjectUtils.isEmpty(deptId)) break; // 过滤空 + RecordApplyDetailDO recordApplyDetailDO = new RecordApplyDetailDO(); + recordApplyDetailDO.setApplyId(recordApplyDO.getId()); + recordApplyDetailDO.setDocumentId(recordId); + recordApplyDetailDO.setTargetId(Long.valueOf(deptId));//部门Id + recordApplyDetailDO.setTargetType(RecordConstants.TargetType.DEPT); + recordApplyDetailDO.setApplyStartDate(LocalDateTime.now()); // TODO 申请开始时间 + detailSaveReqVOList.add(recordApplyDetailDO); + } + } +// recordApplyDetailService.createRecordApplyDetailBatch(detailSaveReqVOList); + return detailSaveReqVOList; + } + + // 添加更改申请明细 + public List addUpdateDetail(RecordApplySaveReqVO param, RecordApplyDO recordApplyDO) { + List paramsList = param.getParamsList(); + List detailSaveReqVOList = new ArrayList<>(); + for (RecordApplyDetailSaveReqVO item : paramsList) { + RecordApplyDetailDO recordApplyDetailDO = new RecordApplyDetailDO(); + recordApplyDetailDO.setApplyId(recordApplyDO.getId()); + recordApplyDetailDO.setDocumentId(item.getDocumentId()); + recordApplyDetailDO.setIsModify(item.getIsModify()); + recordApplyDetailDO.setModifyCause(item.getModifyCause()); + recordApplyDetailDO.setFormData(item.getFormData()); + detailSaveReqVOList.add(recordApplyDetailDO); + } +// recordApplyDetailService.createRecordApplyDetailBatch(detailSaveReqVOList); + return detailSaveReqVOList; + } + + // 添加作废明细 + public List addInvalidDetail(RecordApplySaveReqVO param, RecordApplyDO recordApplyDO) { + List paramsList = param.getParamsList(); + List detailSaveReqVOList = new ArrayList<>(); + for (RecordApplyDetailSaveReqVO item : paramsList) { + RecordApplyDetailDO recordApplyDetailDO = new RecordApplyDetailDO(); + recordApplyDetailDO.setApplyId(recordApplyDO.getId()); + recordApplyDetailDO.setDocumentId(item.getDocumentId()); + recordApplyDetailDO.setIsModify(item.getIsModify()); + recordApplyDetailDO.setModifyCause(item.getModifyCause()); + recordApplyDetailDO.setFormData(item.getFormData()); + detailSaveReqVOList.add(recordApplyDetailDO); + } +// recordApplyDetailService.createRecordApplyDetailBatch(detailSaveReqVOList); + return detailSaveReqVOList; + } + + // 添加查看申请 + public List addViewApplyDetail(RecordApplySaveReqVO param, RecordApplyDO recordApplyDO) { + List paramsList = param.getParamsList(); + List detailSaveReqVOList = new ArrayList<>(); + for (RecordApplyDetailSaveReqVO item : paramsList) { + RecordApplyDetailDO recordApplyDetailDO = new RecordApplyDetailDO(); + recordApplyDetailDO.setApplyId(recordApplyDO.getId()); + recordApplyDetailDO.setDocumentId(item.getDocumentId()); + Long userId = SecurityFrameworkUtils.getLoginUser().getId(); + recordApplyDetailDO.setTargetId(userId); + recordApplyDetailDO.setTargetType(RecordConstants.TargetType.USER); // 用户 + recordApplyDetailDO.setIsModify(item.getIsModify()); + recordApplyDetailDO.setModifyCause(item.getModifyCause()); + recordApplyDetailDO.setFormData(item.getFormData()); + detailSaveReqVOList.add(recordApplyDetailDO); + } +// recordApplyDetailService.createRecordApplyDetailBatch(detailSaveReqVOList); + return detailSaveReqVOList; + } + + // 添加文件提交明细 + public List addRecordSubmitDetail(RecordApplySaveReqVO param, RecordApplyDO recordApplyDO) { +// List paramsList = param.getParamsList(); + List detailSaveReqVOList = new ArrayList<>(); + RecordApplyDetailDO recordApplyDetailDO = new RecordApplyDetailDO(); + Long recordId = param.getParamsList().get(0).getDocumentId(); + recordApplyDetailDO.setApplyId(recordApplyDO.getId()); + recordApplyDetailDO.setDocumentId(recordId); // 文件Id + detailSaveReqVOList.add(recordApplyDetailDO); +// recordApplyDetailService.createRecordApplyDetailBatch(detailSaveReqVOList); + return detailSaveReqVOList; } //增加明细 @Transactional(rollbackFor = Exception.class) - public CommonResult addDetail(RecordApplySaveReqVO param,RecordApplyDO recordApplyDO) { + public CommonResult addDetail(RecordApplySaveReqVO param, RecordApplyDO recordApplyDO) { String businessType = param.getBusinessType(); - List paramsList = param.getParamsList(); + List paramsList = param.getParamsList(); //申请通用明细记录 List detailSaveReqVOList = new ArrayList<>(); // 判断是否是评审,如果是评审,一批评审文件对应一个申请记录,对应多条申请明细记录 @@ -224,12 +358,12 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn || RecordConstants.BusinessType.VIEW_APPLY.equals(businessType) || RecordConstants.BusinessType.INVALID.equals(businessType)) { // 评审,或修改申请,或查看申请,或文件作废 if (ObjectUtils.isEmpty(paramsList)) throw exception(RECORD_RECORD_NOT_EXISTS, "请选择至少一条文件记录"); - for (RecordApplyDetailRespVO item : paramsList) { + for (RecordApplyDetailSaveReqVO item : paramsList) { RecordApplyDetailDO recordApplyDetailDO = getRecordApplyDetailDO(recordApplyDO, item, businessType); detailSaveReqVOList.add(recordApplyDetailDO); } } else if (RecordConstants.BusinessType.DISTRIBUTION.equals(businessType)) { // 分发 - Long recordId = param.getParamsList().get(0).getId(); + Long recordId = param.getParamsList().get(0).getDocumentId(); String targetDepartmentIds = param.getTargetDepartmentIds(); // if (ObjectUtils.isEmpty(targetDepartmentIds)) throw exception0(RECORD_RECORD_NOT_EXISTS.getCode(),"分发部门不存在"); String[] deptIds = targetDepartmentIds.split(","); @@ -262,8 +396,7 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn detailSaveReqVOList.add(recordApplyDetailDO); } } - } - else { + } else { RecordApplyDetailDO recordApplyDetailDO = new RecordApplyDetailDO(); Long recordId = param.getRecordId(); recordApplyDetailDO.setApplyId(recordApplyDO.getId()); @@ -278,15 +411,15 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn } @NotNull - private RecordApplyDetailDO getRecordApplyDetailDO(RecordApplyDO recordApplyDO, RecordApplyDetailRespVO item, String businessType) { + private RecordApplyDetailDO getRecordApplyDetailDO(RecordApplyDO recordApplyDO, RecordApplyDetailSaveReqVO item, String businessType) { RecordApplyDetailDO recordApplyDetailDO = new RecordApplyDetailDO(); recordApplyDetailDO.setApplyId(recordApplyDO.getId()); recordApplyDetailDO.setDocumentId(item.getDocumentId()); // 文件Id - if (RecordConstants.BusinessType.VIEW_APPLY.equals(businessType)){ + if (RecordConstants.BusinessType.VIEW_APPLY.equals(businessType)) { recordApplyDetailDO.setTargetType(RecordConstants.TargetType.USER); recordApplyDetailDO.setTargetId(loginUser.getId()); // 申请人,当前用户 } - if (RecordConstants.BusinessType.REVIEW.equals(businessType)){ // 评审 是否 修改文件 + if (RecordConstants.BusinessType.REVIEW.equals(businessType)) { // 评审 是否 修改文件 recordApplyDetailDO.setIsModify(item.getIsModify()); recordApplyDetailDO.setModifyCause(item.getModifyCause()); } @@ -356,7 +489,8 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn // 判断文件提交是否需要走流程 public boolean justifyRecordApply(RecordRecordDO recordDO) { Integer recordStatus = recordDO.getRecordStatus(); - if (recordStatus != null && recordStatus == 1) throw exception(RECORD_APPLY_NOT_EXISTS, "文件已提交,无法提交申请"); + if (recordStatus != null && recordStatus == 1) + throw exception(RECORD_APPLY_NOT_EXISTS, "文件已提交,无法提交申请"); RecordCategoryDO recordCategory = recordCategoryService.getRecordCategory(recordDO.getCategoryId()); // 获取分类的根分类Id String idPath = recordCategory.getIdPath(); @@ -402,26 +536,18 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn @Transactional(rollbackFor = Exception.class) public CommonResult submitRecordApply(RecordApplySaveReqVO param) { LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - if (ObjectUtils.isEmpty(loginUser)) throw exception0(1_032_350_401,"请重新登录"); + if (ObjectUtils.isEmpty(loginUser)) throw exception0(RECORD_RECORD_NOT_EXISTS.getCode(), "请重新登录"); String nickName = SecurityFrameworkUtils.getLoginUserNickname(); - Long recordId = param.getRecordId();// 文件Id Long applyId = param.getId(); // 申请Id String paramBusinessType = param.getBusinessType(); RecordApplyDO recordApplyDO; if (!ObjectUtils.isEmpty(paramBusinessType) && paramBusinessType.equals(RecordConstants.BusinessType.RECORD_SUBMIT)) { // 创建申请记录 - recordApplyDO = createApply(param); - applyId = recordApplyDO.getId(); - // 创建申请明细 - RecordApplyDetailRespVO saveReqVO = new RecordApplyDetailRespVO(); - saveReqVO.setDocumentId(recordId); - List recordApplyDetailDOS = new ArrayList<>(); - recordApplyDetailDOS.add(saveReqVO); - param.setParamsList(recordApplyDetailDOS); - addDetail(param,recordApplyDO); + CommonResult applyData = createApplyData(param); + applyId = applyData.getData().getId(); } - if (ObjectUtils.isEmpty(applyId)) throw exception0(1_032_350_401,"申请记录不存在"); + if (ObjectUtils.isEmpty(applyId)) throw exception0(RECORD_RECORD_NOT_EXISTS.getCode(), "申请记录不存在"); recordApplyDO = recordApplyMapper.selectById(applyId); JSONObject formData = new JSONObject(); @@ -433,9 +559,13 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn switch (businessType) { case RecordConstants.BusinessType.RECORD_SUBMIT: // 判断根分类上是否配置自定义配置,允许提交,则需要走流程,否则直接提交 - if (ObjectUtils.isEmpty(recordId)) throw exception0(RECORD_RECORD_NOT_EXISTS.getCode(),"请选择文件记录"); + List paramsList = param.getParamsList(); + Long recordId = paramsList.get(0).getDocumentId(); + if (ObjectUtils.isEmpty(recordId)) + throw exception0(RECORD_RECORD_NOT_EXISTS.getCode(), "请选择文件记录"); RecordRecordDO entity = recordRecordService.getRecordById(recordId); - if (ObjectUtils.isEmpty(entity)) throw exception0(RECORD_RECORD_NOT_EXISTS.getCode(),"文件记录实体不存在"); + if (ObjectUtils.isEmpty(entity)) + throw exception0(RECORD_RECORD_NOT_EXISTS.getCode(), "文件记录实体不存在"); boolean b = justifyRecordApply(entity); if (b) { // 不需要走流程,直接返回成功 @@ -444,7 +574,6 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn reqDTO.setProcessDefinitionKey(RecordConstants.ProcessDefinitionKey.RECORD_SUBMIT_DEFINITION_KEY); break; case RecordConstants.BusinessType.DISTRIBUTION: // 分发 - if (ObjectUtils.isEmpty(recordId)) throw exception(RECORD_RECORD_NOT_EXISTS,"请选择文件记录"); reqDTO.setProcessDefinitionKey(RecordConstants.ProcessDefinitionKey.DISTRIBUTION__DEFINITION_KEY); // 文件分发需要关联权限表, break; @@ -502,7 +631,7 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn public CommonResult callback(QmsBpmDTO reqDTO) { log.error("文件下发流程回调:{}", JSONObject.toJSONString(reqDTO)); loginUser = SecurityFrameworkUtils.getLoginUser(); - if (ObjectUtils.isEmpty(loginUser)) throw exception0(1_032_350_401,"当前用户不存在,请重新登录"); + if (ObjectUtils.isEmpty(loginUser)) throw exception0(1_032_350_401, "当前用户不存在,请重新登录"); JSONObject variables = reqDTO.getVariables(); // TODO 目前审批意见在流程回调时保存,后续可以考虑在每个节点完成时保存审批意见,这样可以避免审批意见丢失的情况,同时也能更及时地记录审批意见 JSONObject taskVariables = variables.getJSONObject("taskVariables"); @@ -518,7 +647,6 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn RecordApplyDO recordApplyDO = recordApplyMapper.selectById(Long.valueOf(mainId)); // 申请记录 if (recordApplyDO == null) throw exception0(RECORD_APPLY_NOT_EXISTS.getCode(), "申请记录不存在"); - JSONObject ret = new JSONObject(); //同一个节点实例只触发一次 @@ -546,17 +674,17 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn log.info("firstActivityFlag:{}",firstActivityFlag); - if ("1".equals(firstActivityFlag)) { // 执行到申请人节点,修改状态 + if ("1".equals(firstActivityFlag)) { // 执行到申请人节点,待处理 if (PROCESS_STATUS.equals("1")) { - recordApplyDO.setBusinessStatus(QmsCommonConstant.RUNNING); - recordApplyMapper.updateById(recordApplyDO); +// recordApplyDO.setBusinessStatus(QmsCommonConstant.RUNNING); +// recordApplyMapper.updateById(recordApplyDO); return CommonResult.success(ret); } } // 拒绝,PROCESS_STATUS 状态是3,拒绝。回退上一步流程,修改状态 - if ("3".equals(PROCESS_STATUS)){ - if (businessType.equals(RecordConstants.BusinessType.RECORD_SUBMIT)){ + if ("3".equals(PROCESS_STATUS)) { + if (businessType.equals(RecordConstants.BusinessType.RECORD_SUBMIT)) { recordApplyDO.setBusinessStatus(QmsCommonConstant.VOID); recordApplyMapper.updateById(recordApplyDO); return CommonResult.success(ret); @@ -579,10 +707,11 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn // //作废 TODO //// entity.setBusinessStatus(QmsCommonConstant.VOID); // } else - if ("1".equals(PROCESS_STATUS)) { + if ("1".equals(PROCESS_STATUS)) { //通过 List recordApplyDetailDOS = recordApplyDetailService.selectList(new RecordApplyDetailPageReqVO().setApplyId(Long.valueOf(mainId))); - if (ObjectUtils.isEmpty(recordApplyDetailDOS)) throw exception0(RECORD_RECORD_NOT_EXISTS.getCode(),"未找到对应的申请明细记录"); + if (ObjectUtils.isEmpty(recordApplyDetailDOS)) + throw exception0(RECORD_RECORD_NOT_EXISTS.getCode(), "未找到对应的申请明细记录"); // TODO 业务代码,通过业务类型判断 List recordRecordDOS = new ArrayList<>(); switch (businessType) { @@ -595,21 +724,7 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn recordApplyFlowStatus(entity); break; case RecordConstants.BusinessType.REVIEW: // 评审 - List detailDOList = new ArrayList<>(); - // 1条申请----> 多条明细记录 ----> 多条文件记录 - for (RecordApplyDetailDO applyDetailDO : recordApplyDetailDOS) { - if (applyDetailDO.getIsModify() == 1){ - RecordApplyDetailRespVO detailDO = new RecordApplyDetailRespVO(); - detailDO.setDocumentId(applyDetailDO.getDocumentId()); - detailDOList.add(detailDO); - } - } - // 文件评审通过了,如果需要修改文件,直接申请流程 - if (ObjectUtils.isEmpty(detailDOList)) break; - RecordApplySaveReqVO recordApplyRespVO = new RecordApplySaveReqVO(); - recordApplyRespVO.setBusinessType(RecordConstants.BusinessType.RECORD_UPDATE); - recordApplyRespVO.setParamsList(detailDOList); - createApplyData(recordApplyRespVO); + reviewCallHandle(recordApplyDetailDOS); break; case RecordConstants.BusinessType.DISTRIBUTION: // 分发 recordPermissionAdd(recordApplyDetailDOS); @@ -649,6 +764,26 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn return CommonResult.success(ret); } + // 评审通过,处理修改修改的文件,走更改申请流程 + public void reviewCallHandle(List recordApplyDetailDOS){ + List detailDOList = new ArrayList<>(); + // 1条申请----> 多条明细记录 ----> 多条文件记录 + for (RecordApplyDetailDO applyDetailDO : recordApplyDetailDOS) { + if (applyDetailDO.getIsModify() == 1) { //是否修改,是:直接创建更改申请 + RecordApplyDetailSaveReqVO detailDO = new RecordApplyDetailSaveReqVO(); + detailDO.setDocumentId(applyDetailDO.getDocumentId()); + detailDOList.add(detailDO); + } + } + // 文件评审通过了,如果需要修改文件,直接申请流程 + if (!ObjectUtils.isEmpty(detailDOList)) { + RecordApplySaveReqVO recordApplyRespVO = new RecordApplySaveReqVO(); + recordApplyRespVO.setBusinessType(RecordConstants.BusinessType.RECORD_UPDATE); + recordApplyRespVO.setParamsList(detailDOList); + createApplyData(recordApplyRespVO); + } + } + // 文件提交-更改状态 public void recordApplyFlowStatus(RecordRecordDO recordDO) { // 修改文件状态为已生效 @@ -663,6 +798,8 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn // 文件分发/申请-添加权限 public void recordPermissionAdd(List recordApplyDetailDOS) { + String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname(); + String visitDeptName = loginUser.getVisitDeptName(); for (RecordApplyDetailDO applyDetailDO : recordApplyDetailDOS) { // 添加记录 String targetType = applyDetailDO.getTargetType(); @@ -671,6 +808,7 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn // 通过-----> 创建人员权限表记录 RecordPermissionDO permissionDO = new RecordPermissionDO(); permissionDO.setPermission(RecordConstants.PermissionType.VIEW); // 可查看 + permissionDO.setSourceType(RecordConstants.PermissionSourceType.RECORD); // 记录权限 permissionDO.setSourceId(applyDetailDO.getDocumentId()); // 文件Id permissionDO.setDeptId(loginUser.getVisitDeptId()); permissionDO.setDeptName(loginUser.getVisitDeptName()); @@ -678,10 +816,13 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn if (targetType.equals(RecordConstants.TargetType.USER)) { permissionDO.setTargetId(String.valueOf(applyDetailDO.getTargetId())); // 用户Id permissionDO.setTargetType(RecordConstants.TargetType.USER); + permissionDO.setTargetName(loginUserNickname); } else { // 部门 permissionDO.setTargetId(String.valueOf(applyDetailDO.getTargetId())); // 部门Id permissionDO.setTargetType(RecordConstants.TargetType.DEPT); + permissionDO.setTargetName(visitDeptName); } + permissionDOList.add(permissionDO); boolean b = recordPermissionService.insertRecordPermissionBatch(permissionDOList); if (!b) throw exception(RECORD_APPLY_NOT_EXISTS, "保存分发权限失败"); @@ -690,11 +831,11 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn /** - * 文件评审分页查询,我需要查询出 recordApply 和 recordApplyDetail 和recordRecord 关联的数据,其中: + * 文件评审分页查询,我需要查询出 recordApply 和 recordApplyDetail 和recordRecord 关联的数据,其中: * recordApply 对 recordApplyDetail 一对多的关系 * recordApplyDetail 对 和recordRecord 一对一的关系 * 查询条件:recordApply 的 businessType = '文件评审' - * */ + */ @Override public PageResult recordReviewPage(RecordRecordPageReqVO pageReqVO) { // 使用多表连接查询获取文件评审数据 @@ -723,7 +864,7 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn @Override public PageResult recordUpdatePage(RecordApplyPageReqVO pageReqVO) { Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); - recordApplyMapper.recordUpdatePage(page,pageReqVO); + recordApplyMapper.recordUpdatePage(page, pageReqVO); return null; } @@ -731,12 +872,12 @@ public class RecordApplyServiceImpl implements RecordApplyService, BMPCallbackIn @Override public PageResult recordInvalidPage(RecordApplyPageReqVO pageReqVO) { Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); - recordApplyMapper.recordUpdatePage(page,pageReqVO); + recordApplyMapper.recordUpdatePage(page, pageReqVO); return null; } //查询提交的流程是否存在没有处理或者通过的的数据 public List selectApplyByStatus(String businessType, java.util.List documentIds, java.util.List businessStatuses) { - return recordApplyMapper.selectApplyByStatus(businessType,documentIds,businessStatuses); + return recordApplyMapper.selectApplyByStatus(businessType, documentIds, businessStatuses); } } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordapplydetail/RecordApplyDetailService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordapplydetail/RecordApplyDetailService.java index 6c2bb583..ee1cafd3 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordapplydetail/RecordApplyDetailService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordapplydetail/RecordApplyDetailService.java @@ -86,7 +86,7 @@ public interface RecordApplyDetailService { List selectAllList(Long applyId) ; /** - * 关联查询明细和记录 + * 关联 * @param applyId * @return */ diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordapplydetail/RecordApplyDetailServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordapplydetail/RecordApplyDetailServiceImpl.java index 20212b29..c31a3e7f 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordapplydetail/RecordApplyDetailServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordapplydetail/RecordApplyDetailServiceImpl.java @@ -113,7 +113,6 @@ public class RecordApplyDetailServiceImpl implements RecordApplyDetailService { } // 通过 recordApplyDetail 表关联查询 recordRecord 表 - @Override public List selectDetailAndRecordList(Long applyId) { return recordApplyDetailMapper.selectDetailAndRecordList(applyId); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordcategory/RecordCategoryService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordcategory/RecordCategoryService.java index ffe1ab16..716fe279 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordcategory/RecordCategoryService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordcategory/RecordCategoryService.java @@ -73,11 +73,4 @@ public interface RecordCategoryService { List getReviewRecordList(); - /** - * 判断当前分类是否有管理员权限 - * @param categoryId - * @return - */ - - boolean isAdminByUserId(Long categoryId); } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordcategory/RecordCategoryServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordcategory/RecordCategoryServiceImpl.java index e9c59dc6..78e0b793 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordcategory/RecordCategoryServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordcategory/RecordCategoryServiceImpl.java @@ -14,12 +14,11 @@ import com.zt.plat.module.qms.resource.record.constant.RecordConstants; import com.zt.plat.module.qms.resource.record.controller.admin.recordcategory.vo.RecordCategoryPageReqVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordcategory.vo.RecordCategoryRespVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordcategory.vo.RecordCategorySaveReqVO; -import com.zt.plat.module.qms.resource.record.dal.mapper.RecordCategoryMapper; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordcategory.RecordCategoryDO; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordpermission.RecordPermissionDO; +import com.zt.plat.module.qms.resource.record.dal.mapper.RecordCategoryMapper; import com.zt.plat.module.qms.resource.record.service.recordpermission.RecordPermissionService; import com.zt.plat.module.system.api.dept.DeptApi; -import com.zt.plat.module.system.api.dept.dto.DeptRespDTO; import com.zt.plat.module.system.api.permission.PermissionApi; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; @@ -35,8 +34,8 @@ import java.util.Set; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0; -import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList; -import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*; +import static com.zt.plat.module.qms.enums.ErrorCodeConstants.RECORD_CATEGORY_NOT_EXISTS; +import static com.zt.plat.module.qms.enums.ErrorCodeConstants.RECORD_FILE_EXISTS; /** * 文件记录分类 Service 实现类 @@ -67,24 +66,6 @@ public class RecordCategoryServiceImpl implements RecordCategoryService { private List dictionaryBusinessDOS = new ArrayList<>(); private List businessDOList = new ArrayList<>(); - // 判断当前用户是否有管理员权限 - @Override - public boolean isAdminByUserId(Long categoryId){ - // 获取当前用户的id,部门,角色 - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - Long userId = loginUser.getId(); - - // 获取用户所在的所有部门(包括父部门) - List parentDepts = getParentDepts(); - List deptIds = convertList(parentDepts, DeptRespDTO::getId); - - // 获取用户的所有角色 - CommonResult> userRoleIdListByUserId = permissionApi.getUserRoleIdListByUserId(userId); - Set userRoles = userRoleIdListByUserId.getData(); - - // 查询用户是否有该分类的管理员权限 - return recordCategoryMapper.checkUserAdminPermission(categoryId, userId, deptIds, userRoles); - } @Transactional(rollbackFor = Exception.class) @Override @@ -120,61 +101,6 @@ public class RecordCategoryServiceImpl implements RecordCategoryService { return BeanUtils.toBean(recordCategory, RecordCategoryRespVO.class); } - //判断当前用户是否有编辑权限 -// public boolean judgeIsEdit(RecordCategoryDO recordCategoryDO){ -// // 判断当前当户是否可编辑 -// //当前登录用户 -// LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); -// Long userId = loginUser.getId(); -// -// AtomicBoolean pass = new AtomicBoolean(false); -// -// // 通过分类ID 查询 关联权限 -// RecordPermissionDO recordPermissionDO = new RecordPermissionDO(); -// recordPermissionDO.setSourceId(recordCategoryDO.getId()); -// List recordPermissionDOS = recordPermissionService.selectAllList(recordPermissionDO); -// log.info("分类ID: {}, 关联权限列表数据:{}", recordCategoryDO.getId(), recordPermissionDOS); -// if (ObjectUtils.isEmpty(recordPermissionDOS)) { -// return pass.get(); -// } -// -// // 存在,先判断是否是管理员 -// businessDOList=selectDictPermissionByKey(RecordConstants.PermissionType.PERMISSION_KEY); -// String permissionAdmin = getDictValueByKey(businessDOList, RecordConstants.PermissionType.ADMIN);// 管理员权限 -// -// dictionaryBusinessDOS = selectDictTargetTypeByKey(RecordConstants.TargetType.TARGET_KEY); -// // 首先判断当前账户是不是管理员,如果是管理员,则直接查询所有数据返回 -// String targetUser = getDictValueByKey(dictionaryBusinessDOS, RecordConstants.TargetType.USER);// 用户权限 -// RecordPermissionDO permission = judgeIsAdmin(targetUser, userId, permissionAdmin); -// if (!ObjectUtils.isEmpty(permission)) { -// pass.set(true); -// return pass.get(); -// } -// -// -// Long currentDeptId = loginUser.getVisitDeptId(); -// -// //通过DeptApi获取完整部门信息(包括父部门) -// CommonResult deptResult = deptApi.getDept(currentDeptId); -// DeptRespDTO currentDept = deptResult.getData(); -// Long parentDeptId = currentDept.getParentId(); // 获取父部门ID -// List parentDepts = getParentDepts(parentDeptId); -// parentDepts.add(currentDept); -// -// // 可操作的所以权限数据列表 -// List allPermissionList = getAllPermissionList(recordPermissionDOS, userId, parentDepts); -// if (ObjectUtils.isEmpty(allPermissionList)) return pass.get(); -// -// // 判断可操作的数据权限类型 -// allPermissionList.forEach(item->{ -// if (item.getPermission().equals(RecordConstants.PermissionType.ADMIN) -// || item.getPermission().equals(RecordConstants.PermissionType.EDIT)) { -// pass.set(true); -// } -// }); -// return pass.get(); -// } - // 文件评审,获取满足当前账户权限的记录列表 @Override @@ -341,8 +267,6 @@ public class RecordCategoryServiceImpl implements RecordCategoryService { RecordCategoryDO recordCategoryDO = new RecordCategoryDO(); recordCategoryDO.setId(id); recordCategoryDO.setDeleted(true); - //TODO -// recordCategoryMapper.updateById(recordCategoryDO); recordCategoryMapper.deleteById(id); } @@ -408,45 +332,6 @@ public class RecordCategoryServiceImpl implements RecordCategoryService { return businessDOList = dictionaryBusinessService.queryDictItemsByKey(targetKey); } - // 根据当前用户部门获取所有父级部门列表 - public List getParentDepts() { - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - Long currentDeptId = loginUser.getVisitDeptId(); - //通过DeptApi获取完整部门信息(包括父部门) - CommonResult deptResult = deptApi.getDept(currentDeptId); - DeptRespDTO currentDept = deptResult.getData(); - Long parentDeptId = currentDept.getParentId(); // 获取父部门ID -// - List parentDepts = new ArrayList<>(); - // 添加当前部门到父部门列表中 - Long tempParentId = parentDeptId; - while (tempParentId != null && tempParentId != 0) { - CommonResult parentResult = deptApi.getDept(tempParentId); - DeptRespDTO parentDept = parentResult.getData(); - parentDepts.add(parentDept); - tempParentId = parentDept.getParentId(); - } - parentDepts.add(currentDept); - return parentDepts; - } - - // 判断当前当前用户是不是第一个管理员 -// public List judgeIsAdmin() { -// LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); -// Long userId = loginUser.getId(); -// RecordPermissionDO recordPermissionDO = new RecordPermissionDO(); -// -// businessDOList=selectDictPermissionByKey(RecordConstants.PermissionType.PERMISSION_KEY); -// String permissionAdmin = getDictValueByKey(businessDOList, RecordConstants.PermissionType.ADMIN);// 管理员权限 -// dictionaryBusinessDOS = selectDictTargetTypeByKey(RecordConstants.TargetType.TARGET_KEY); -// String targetUser = getDictValueByKey(dictionaryBusinessDOS, RecordConstants.TargetType.USER);// 用户权限 -// -// recordPermissionDO.setTargetType(targetUser); -// recordPermissionDO.setTargetId(userId.toString()); -// recordPermissionDO.setPermission(permissionAdmin); -// return recordPermissionService.selectRecordPermission(recordPermissionDO); -// } - // 获取所有分类树 @Override public List getRecordCategoryTree(RecordCategoryPageReqVO pageReqVO) { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordpermission/RecordPermissionService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordpermission/RecordPermissionService.java index 7eaeaaaf..9ac29084 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordpermission/RecordPermissionService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordpermission/RecordPermissionService.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zt.plat.module.qms.resource.record.controller.admin.recordpermission.vo.RecordPermissionPageReqVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordpermission.vo.RecordPermissionRespVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordpermission.vo.RecordPermissionSaveReqVO; +import com.zt.plat.module.qms.resource.record.dal.dataobject.recordcategory.RecordCategoryDO; import jakarta.validation.*; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordpermission.RecordPermissionDO; import com.zt.plat.framework.common.pojo.PageResult; @@ -62,7 +63,7 @@ public interface RecordPermissionService { */ PageResult getRecordPermissionPage(RecordPermissionPageReqVO pageReqVO); - List selectAllList(RecordPermissionDO recordPermissionDO); + List selectAllListBySourceId(RecordPermissionDO recordPermissionDO); List selectRecordPermission(RecordPermissionDO recordPermissionDO); @@ -70,4 +71,33 @@ public interface RecordPermissionService { boolean insertRecordPermissionBatch(List recordPermissionDO); List selectList(LambdaQueryWrapper lambdaQueryWrapper); + + + /** + * 通过分类Id 获取满足当前用户的权限列表 + * @param categoryId + * @return + */ + List selectPermissionList(long categoryId,String permission); + + /** + * 判断当前分类是否有管理员权限 + * @param categoryId + * @return + */ + + boolean isAdminByUserId(Long categoryId); + + /** + * 获取权限列表 + * @param parentCategoryId + * @return + */ + List getMatchedPermissionList(Long parentCategoryId); + + /** + * 获取当前用户所在的部门以及父部门 + * @return + */ + List getParentDepts(); } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordpermission/RecordPermissionServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordpermission/RecordPermissionServiceImpl.java index 5ac83227..8ad7ab86 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordpermission/RecordPermissionServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordpermission/RecordPermissionServiceImpl.java @@ -3,9 +3,17 @@ package com.zt.plat.module.qms.resource.record.service.recordpermission; import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.zt.plat.framework.common.pojo.CommonResult; +import com.zt.plat.framework.security.core.LoginUser; +import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils; +import com.zt.plat.module.qms.resource.record.constant.RecordConstants; import com.zt.plat.module.qms.resource.record.controller.admin.recordpermission.vo.RecordPermissionPageReqVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordpermission.vo.RecordPermissionRespVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordpermission.vo.RecordPermissionSaveReqVO; +import com.zt.plat.module.qms.resource.record.dal.dataobject.recordcategory.RecordCategoryDO; +import com.zt.plat.module.system.api.dept.DeptApi; +import com.zt.plat.module.system.api.dept.dto.DeptRespDTO; +import com.zt.plat.module.system.api.permission.PermissionApi; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import jakarta.annotation.Resource; @@ -37,10 +45,121 @@ public class RecordPermissionServiceImpl implements RecordPermissionService { @Resource private RecordPermissionMapper recordPermissionMapper; + @Resource + private PermissionApi permissionApi; + + @Resource + private DeptApi deptApi; + + private List deptIds = new ArrayList<>(); + + private Set roles = new HashSet<>(); + + /** + * 通过分类Id 获取满足当前用户的权限列表 + * @param categoryId + * @return + */ + @Override + public List selectPermissionList(long categoryId,String permission){ + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + Long userId = loginUser.getId(); + deptIds = getParentDepts(); + roles = getRoles(userId); + if (deptIds.isEmpty())deptIds.add(0L); + if (roles.isEmpty())roles.add(0L); + // 查询用户是否有该分类的管理员权限 + return recordPermissionMapper.selectPermissionList(categoryId, userId, deptIds, roles, permission); + } + + + // 判断当前用户是否有管理员权限(用户,部门,角色)任意满足 + @Override + public boolean isAdminByUserId(Long categoryId){ + + // 获取用户所在的所有部门(包括父部门) +// deptIds = getParentDepts(); + String admin = RecordConstants.PermissionType.ADMIN; + List recordCategoryDOS = this.selectPermissionList(categoryId,admin); + if (!recordCategoryDOS.isEmpty()) return true; + return false; + } + + /** + * 通过分类Id 获取满足当前用户的权限列表 + * @param categoryId 分类ID(对应 recordPermission.sourceId) + * @return + */ + @Override + public List getMatchedPermissionList(Long categoryId) { + // 获取当前登录用户 + + // 判断是最高管理员 + boolean b = judgeIsAdmin(); + boolean adminByUserId = this.isAdminByUserId(categoryId); + if (b || adminByUserId) { + // 用户是最高管理员,直接返回该分类下的所有权限记录 + RecordPermissionDO query = new RecordPermissionDO(); + query.setSourceId(categoryId); + return this.selectAllListBySourceId(query); + } + + // 直接查询满足条件的权限列表 +// return recordPermissionService.selectPermissionList(categoryId); + return new ArrayList<>(); + + } + + // 获取当前用户所在权限列表 + public Set getRoles(Long userId){ + if (!ObjectUtils.isEmpty(roles)) return roles; + CommonResult> userRoleIdListByUserId = permissionApi.getUserRoleIdListByUserId(userId); + Set userRoles = userRoleIdListByUserId.getData(); + roles.addAll(userRoles); + return userRoles; + } + + @Override + public List getParentDepts() { + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + Long currentDeptId = loginUser.getVisitDeptId(); + if (!ObjectUtils.isEmpty(deptIds)) return deptIds; + //通过DeptApi获取完整部门信息(包括父部门) + CommonResult deptResult = deptApi.getDept(currentDeptId); + DeptRespDTO currentDept = deptResult.getData(); + Long parentDeptId = currentDept.getParentId(); // 获取父部门ID +// + List parentDepts = new ArrayList<>(); + // 添加当前部门到父部门列表中 + Long tempParentId = parentDeptId; + while (tempParentId != null && tempParentId != 0) { + CommonResult parentResult = deptApi.getDept(tempParentId); + DeptRespDTO parentDept = parentResult.getData(); +// parentDepts.add(parentDept.getId()); + deptIds.add(parentDept.getId()); + tempParentId = parentDept.getParentId(); + } +// parentDepts.add(currentDept.getId()); + deptIds.add(currentDept.getId()); + return deptIds; + } + + // 判断当前用户是不是最高管理员 + public boolean judgeIsAdmin() { + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + Long userId = loginUser.getId(); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.eq(RecordPermissionDO::getSourceType, RecordConstants.TargetType.ADMIN); + lambdaQueryWrapper.eq(RecordPermissionDO::getTargetId, userId); + List recordPermissionDOS = this.selectList(lambdaQueryWrapper); + if (!ObjectUtils.isEmpty(recordPermissionDOS)) return true; + return false; + } + // 查询所有记录权限列表 @Override - public List selectAllList(RecordPermissionDO recordPermissionDO) { + public List selectAllListBySourceId(RecordPermissionDO recordPermissionDO) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); if (!ObjectUtils.isEmpty(recordPermissionDO.getSourceId())) wrapper.eq(RecordPermissionDO::getSourceId, recordPermissionDO.getSourceId()); diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordrecord/RecordRecordService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordrecord/RecordRecordService.java index 52ec529b..d3e6d5ed 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordrecord/RecordRecordService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordrecord/RecordRecordService.java @@ -67,16 +67,8 @@ public interface RecordRecordService { PageResult getRecordHistoryPage(RecordRecordPageReqVO pageReqVO); - CommonResult justRecordPermission(Long recordId); +// CommonResult justRecordPermission(Long recordId); - List getMatchedPermissionList(Long parentCategoryId); - - /** - * 提交申请-发起流程 - * - * @return 申请信息 - */ -// CommonResult submitRecordApply(RecordApplyRespVO param); RecordRecordDO getRecordById(Long id); @@ -94,4 +86,6 @@ public interface RecordRecordService { */ void updateRecordRecordListByIds(List recordRecordDOS); + + } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordrecord/RecordRecordServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordrecord/RecordRecordServiceImpl.java index 61f58152..e307868b 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordrecord/RecordRecordServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/record/service/recordrecord/RecordRecordServiceImpl.java @@ -18,7 +18,6 @@ import com.zt.plat.module.qms.resource.record.constant.RecordConstants; import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.RecordRecordPageReqVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.RecordRecordRespVO; import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.RecordRecordSaveReqVO; -//import com.zt.plat.module.qms.resource.record.dal.dao.recordrecord.RecordRecordMapper; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordcategory.RecordCategoryDO; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordpermission.RecordPermissionDO; import com.zt.plat.module.qms.resource.record.dal.dataobject.recordrecord.RecordRecordDO; @@ -71,9 +70,6 @@ public class RecordRecordServiceImpl implements RecordRecordService { @Autowired private DictionaryBusinessService dictionaryBusinessService; // 字典服务 - private List dictionaryBusinessDOS = new ArrayList<>(); - - private List businessDOList = new ArrayList<>(); @Autowired private RecordCategoryService recordCategoryService; @@ -218,54 +214,26 @@ public class RecordRecordServiceImpl implements RecordRecordService { } } - // 判断记录的操作权限 - @Override - public CommonResult justRecordPermission(Long id) { - - RecordRecordDO recordRecordDO = recordRecordMapper.selectById(id); - hasPermissionByCategoryId(recordRecordDO.getCategoryId()); - if (!ObjectUtils.isEmpty(recordRecordDO)) { - Long categoryId = recordRecordDO.getCategoryId(); - RecordCategoryDO recordCategoryDO = recordCategoryService.selectById(categoryId); - Long parentId = recordCategoryDO.getParentId(); - - String dept = RecordConstants.TargetType.DEPT; - String role = RecordConstants.TargetType.ROLE; - - // 判断管理员权限 - List permissionDOList = judgeIsAdmin(parentId,dept,role); - - // 判断当前用户的管理员权限 - LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); - lambdaQueryWrapper.eq(RecordPermissionDO::getTargetId, id); - List recordPermissionDOS = recordPermissionService.selectList(lambdaQueryWrapper); - if (!ObjectUtils.isEmpty(recordPermissionDOS)) - return CommonResult.success(RecordConstants.PermissionType.ADMIN); - String s = hasPermissionByCategoryId(parentId); - return CommonResult.success(s); - } - return CommonResult.success(null); - } @Override public RecordRecordDO getRecordRecord(Long id) { RecordRecordDO recordRecordDO = recordRecordMapper.selectById(id); - hasPermissionByCategoryId(recordRecordDO.getCategoryId()); +// hasPermissionByCategoryId(recordRecordDO.getCategoryId()); if (!ObjectUtils.isEmpty(recordRecordDO)) { Long categoryId = recordRecordDO.getCategoryId(); RecordCategoryDO recordCategoryDO = recordCategoryService.selectById(categoryId); recordRecordDO.setCategoryName(recordCategoryDO.getName()); - // 判断当前操作记录可执行的权限 - Long parentId = recordCategoryDO.getParentId(); - String dept = RecordConstants.TargetType.DEPT; - String role = RecordConstants.TargetType.ROLE; - List permissionDOList = judgeIsAdmin(parentId,dept,role); - if (!ObjectUtils.isEmpty(permissionDOList)){ - // 查询 category 的父级Id - if (ObjectUtils.isEmpty(parentId)) throw exception(RECORD_RECORD_NOT_EXISTS); - Object finalParse = customConfigParseJson(parentId); - recordRecordDO.setCustomConfig(finalParse); - } +// // 判断当前操作记录可执行的权限 +// Long parentId = recordCategoryDO.getParentId(); +// String dept = RecordConstants.TargetType.DEPT; +// String role = RecordConstants.TargetType.ROLE; +// List permissionDOList = judgeIsAdmin(parentId,dept,role); +// if (!ObjectUtils.isEmpty(permissionDOList)){ +// // 查询 category 的父级Id +// if (ObjectUtils.isEmpty(parentId)) throw exception(RECORD_RECORD_NOT_EXISTS); +// Object finalParse = customConfigParseJson(parentId); +// recordRecordDO.setCustomConfig(finalParse); +// } } return recordRecordDO; @@ -276,209 +244,6 @@ public class RecordRecordServiceImpl implements RecordRecordService { return recordRecordMapper.selectById(id); } - public String getDictValueByKey(List businessDOList, String targetKey) { - return businessDOList.stream() - .filter(item -> item.getKey().equals(targetKey)) - .findFirst() - .map(DictionaryBusinessDO::getValue) - .orElse(null); - } - - // 查询字典列表,通过key - public List selectDictTargetTypeByKey(String targetKey) { - return dictionaryBusinessDOS = dictionaryBusinessService.queryDictItemsByKey(targetKey); - } - - public List selectDictPermissionByKey(String targetKey) { - return businessDOList = dictionaryBusinessService.queryDictItemsByKey(targetKey); - } -// -// //判断当前用户是不是最高管理员 -// public List isAdmin(){ -// -// } -// - - // 判断当前用户管理员权限(用户,角色,部门),返回权限列表 - public List judgeIsAdmin(Long parentCategoryId, String dept,String role) { - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - Long userId = loginUser.getId(); - RecordPermissionDO recordPermissionDO = new RecordPermissionDO(); - - businessDOList = selectDictPermissionByKey(RecordConstants.PermissionType.PERMISSION_KEY); - String permissionAdmin = getDictValueByKey(businessDOList, RecordConstants.PermissionType.ADMIN);// 管理员权限 - dictionaryBusinessDOS = selectDictTargetTypeByKey(RecordConstants.TargetType.TARGET_KEY); - String targetUser = getDictValueByKey(dictionaryBusinessDOS, RecordConstants.TargetType.USER);// 用户权限 - - recordPermissionDO.setTargetType(targetUser);// 用户 - recordPermissionDO.setTargetId(userId.toString()); // 用户ID - recordPermissionDO.setPermission(permissionAdmin); // 管理员 - - // 判断是否是最高管理员权限 - recordPermissionDO.setSourceType(RecordConstants.TargetType.ADMIN); //admin - List recordPermissionDOS = recordPermissionService.selectRecordPermission(recordPermissionDO); - if (!ObjectUtils.isEmpty(recordPermissionDOS)) return recordPermissionDOS; - - // 判断是普通管理员权限 - recordPermissionDO.setSourceType(null); - recordPermissionDO.setSourceId(parentCategoryId); - if (!ObjectUtils.isEmpty(dept)){ - recordPermissionDO.setTargetType(dept); - // 当前用户部门ID - Long visitDeptId = loginUser.getVisitDeptId(); - recordPermissionDO.setTargetId(visitDeptId.toString()); - List permissionDOList = recordPermissionService.selectRecordPermission(recordPermissionDO); - if (!ObjectUtils.isEmpty(permissionDOList)) return permissionDOList; - } - if (!ObjectUtils.isEmpty(role)) { - recordPermissionDO.setTargetType(role); - // 当前角色Id - Set userRoleIdList = permissionApi.getUserRoleIdListByUserId(userId).getData(); - if (userRoleIdList.size() == 1) { - recordPermissionDO.setTargetId(userRoleIdList.stream().findFirst().get().toString()); - }else { - // Set 转 permissionDOList - List permissionDOList = new ArrayList<>(); - for (Long roleId : userRoleIdList) { - RecordPermissionDO rolePermissionDO = new RecordPermissionDO(); - rolePermissionDO.setSourceType(null); - rolePermissionDO.setSourceId(parentCategoryId); - rolePermissionDO.setTargetType(role); - rolePermissionDO.setTargetId(roleId.toString()); - rolePermissionDO.setPermission(permissionAdmin); - permissionDOList.add(rolePermissionDO); - } - } - } - return recordPermissionService.selectRecordPermission(recordPermissionDO); - } - - // 根据当前用户部门获取所有子部门列表 - public List getParentDepts() { - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - Long currentDeptId = loginUser.getVisitDeptId(); - List parentDepts = new ArrayList<>(); -// List childDepts = new ArrayList<>(); - - // 添加当前部门 - //通过DeptApi获取完整部门信息(包括父部门) - CommonResult deptResult = deptApi.getDept(currentDeptId); - DeptRespDTO currentDept = deptResult.getData(); - Long parentDeptId = currentDept.getParentId(); // 获取父部门ID -// - // 添加当前部门到父部门列表中 - Long tempParentId = parentDeptId; - while (tempParentId != null && tempParentId != 0) { - CommonResult parentResult = deptApi.getDept(tempParentId); - DeptRespDTO parentDept = parentResult.getData(); - parentDepts.add(parentDept); - tempParentId = parentDept.getParentId(); - } - parentDepts.add(currentDept); - - // 获取所有子部门 -// CommonResult> childDeptListResult = deptApi.getChildDeptList(currentDeptId); -// if (childDeptListResult.isSuccess()) { -// List childDeptList = childDeptListResult.getData(); -// if (CollUtil.isNotEmpty(childDeptList)) { -// childDepts.addAll(childDeptList); -// } -// } - - return parentDepts; - } - - /** - * 权限优先级顺序(由高到低):管理员 > 可编辑 > 可查看 - */ - private static final List PERMISSION_PRIORITY = List.of( - RecordConstants.PermissionType.ADMIN, - RecordConstants.PermissionType.EDIT, - RecordConstants.PermissionType.VIEW - ); - - /** - * 通过 recordCategory 的 categoryId 连接 recordPermission 的 sourceId, - * 查询当前用户在该分类上命中的最高权限类型。 - * 匹配条件:当前部门、所有父级部门、角色,满足任一条件即算命中。 - * - * @param parentCategoryId 分类ID - * @return 命中的最高权限值(管理员/可编辑/可查看),无权限时返回 null - */ - public String hasPermissionByCategoryId(Long parentCategoryId) { - // 获取当前登录用户 - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - Long userId = loginUser.getId(); - - // 1. 查询该分类下所有权限配置(以 sourceId = categoryId 为条件) - RecordPermissionDO query = new RecordPermissionDO(); - query.setSourceId(parentCategoryId); - List permissionList = recordPermissionService.selectAllList(query); -// log.info("分类ID: {},对应权限配置数量: {}", parentCategoryId, permissionList == null ? 0 : permissionList.size()); - if (ObjectUtils.isEmpty(permissionList)) { - return null; - } - - // 2. 加载字典:授权目标类型(用户/部门/角色) - List targetTypeDicts = dictionaryBusinessService.queryDictItemsByKey(RecordConstants.TargetType.TARGET_KEY); - String targetDeptValue = getDictValueByKey(targetTypeDicts, RecordConstants.TargetType.DEPT); // 部门 - String targetRoleValue = getDictValueByKey(targetTypeDicts, RecordConstants.TargetType.ROLE); // 角色 - - // 3. 获取当前用户所在部门及所有父级部门列表 - List allDepts = getParentDepts(); // 包含当前部门和所有父级部门 -// log.info("当前用户部门链(含父级): {}", allDepts); - - // 4. 获取当前用户的角色ID集合 - Set userRoleIds = null; - try { - userRoleIds = permissionApi.getUserRoleIdListByUserId(userId).getData(); -// log.info("当前用户角色ID集合: {}", userRoleIds); - } catch (Exception e) { - log.warn("获取用户角色ID失败,将跳过角色权限校验: {}", e.getMessage()); - } - final Set finalUserRoleIds = userRoleIds; - - // 5. 收集当前用户命中的所有权限值 - List matchedPermissions = new ArrayList<>(); - for (RecordPermissionDO perm : permissionList) { - String targetType = perm.getTargetType(); - String targetId = perm.getTargetId(); - String permission = perm.getPermission(); - - // 5.1 部门条件:当前部门或任意父级部门匹配 - if (targetDeptValue != null && targetDeptValue.equals(targetType)) { - boolean deptMatch = allDepts.stream() - .anyMatch(dept -> dept.getId() != null && dept.getId().toString().equals(targetId)); - if (deptMatch) { -// log.info("部门权限命中,部门ID: {},权限类型: {}", targetId, permission); - matchedPermissions.add(permission); - } - } - - // 5.2 角色条件:当前用户的任意角色匹配 - if (targetRoleValue != null && targetRoleValue.equals(targetType) - && finalUserRoleIds != null) { - boolean roleMatch = finalUserRoleIds.stream() - .anyMatch(roleId -> roleId.toString().equals(targetId)); - if (roleMatch) { -// log.info("角色权限命中,角色ID: {},权限类型: {}", targetId, permission); - matchedPermissions.add(permission); - } - } - } - - // 6. 按照优先级(管理员 > 可编辑 > 可查看)返回最高权限 - for (String level : PERMISSION_PRIORITY) { - if (matchedPermissions.contains(level)) { -// log.info("分类ID: {} 最终命中最高权限: {}", parentCategoryId, level); - return level; - } - } - -// log.info("分类ID: {} 权限校验未通过,当前用户不满足任何授权条件", parentCategoryId); - return null; - } - @Override public PageResult getRecordRecordPage(RecordRecordPageReqVO pageReqVO) { Long categoryId = pageReqVO.getCategoryId(); @@ -488,27 +253,31 @@ public class RecordRecordServiceImpl implements RecordRecordService { if (ObjectUtils.isEmpty(recordCategoryDO)) return new PageResult().setTotal(0L); Long parentId = recordCategoryDO.getParentId(); - // 权限判断 - String dept = RecordConstants.TargetType.DEPT; - String role = RecordConstants.TargetType.ROLE; - List permissionDOList = judgeIsAdmin(parentId, dept, role); + // 判断是否有当前分类的父分类权限 (可编辑,可查看,管理员--> 任意条件) + List recordPermissionDOS = recordPermissionService.selectPermissionList(parentId, null); - if (ObjectUtils.isEmpty(permissionDOList)) { - String permission = hasPermissionByCategoryId(parentId); - if (permission == null) throw exception(RECORD_PERMISSION_NOT_ALLOW); + Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); + + if (ObjectUtils.isEmpty(recordPermissionDOS)) { + // 没有分类的权限,判断是否有文件记录的权限,并获取记录列表 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + Long userId = loginUser.getId(); + List parentDepts = recordPermissionService.getParentDepts(); + IPage iPage = recordRecordMapper.selectRecordPermissionList(page, pageReqVO, userId, parentDepts); + return new PageResult<>(iPage.getRecords(), iPage.getTotal()); } // 设置默认查询最新版 pageReqVO.setCurrentFlag(1); // 多表关联分页查询(关联 RecordApply 获取文件提交信息) - Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); IPage iPage = recordRecordMapper.selectRecordWithApplyPage(page, pageReqVO); - PageResult result = new PageResult<>(iPage.getRecords(), iPage.getTotal()); + String admin = RecordConstants.PermissionType.ADMIN; + List recordPermissionDOAdmins = recordPermissionService.selectPermissionList(parentId, admin); // 填充 customConfig(仅管理员权限时填充) - if (!ObjectUtils.isEmpty(permissionDOList)) { + if (!ObjectUtils.isEmpty(recordPermissionDOAdmins)) { Object finalParse = customConfigParseJson(parentId); result.getList().forEach(record -> { try { @@ -543,84 +312,5 @@ public class RecordRecordServiceImpl implements RecordRecordService { return recordRecordMapper.selectPage(pageReqVO); } - /** - * 根据 categoryId 查询 recordPermission 中关联 sourceId 的所有权限记录, - * 并通过当前用户的部门(含所有父级部门)、角色进行过滤,返回满足条件的权限列表。 - * - * @param categoryId 分类ID(对应 recordPermission.sourceId) - * @return 当前用户命中的权限记录列表(包含管理员/可编辑/可查看等所有类型) - */ - @Override - public List getMatchedPermissionList(Long categoryId) { - // 获取当前登录用户 - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - Long userId = loginUser.getId(); - - // 如果是最高管理员(条件:sourceType:admin;targetId:当前用户;targetType:用户),直接返回该分类下的所有权限记录, - // 无需过滤,按照sourceId 跟 permission 字段进行分类 - List adminCheckResult = judgeIsAdmin(categoryId, null, null); - if (!ObjectUtils.isEmpty(adminCheckResult)) { - // 用户是最高管理员,直接返回该分类下的所有权限记录 - RecordPermissionDO query = new RecordPermissionDO(); - query.setSourceId(categoryId); - List allPermissions = recordPermissionService.selectAllList(query); - return ObjectUtils.isEmpty(allPermissions) ? new ArrayList<>() : allPermissions; - } - - // 1. 查询该分类下所有权限配置(sourceId = categoryId) - RecordPermissionDO query = new RecordPermissionDO(); - query.setSourceId(categoryId); - List permissionList = recordPermissionService.selectAllList(query); - if (ObjectUtils.isEmpty(permissionList)) { - return new ArrayList<>(); - } - - // 2. 加载字典:授权目标类型(部门/角色) - List targetTypeDicts = dictionaryBusinessService.queryDictItemsByKey(RecordConstants.TargetType.TARGET_KEY); - String targetDeptValue = getDictValueByKey(targetTypeDicts, RecordConstants.TargetType.DEPT); // 部门 - String targetRoleValue = getDictValueByKey(targetTypeDicts, RecordConstants.TargetType.ROLE); // 角色 - - // 3. 获取当前用户所在部门及所有父级部门列表 - List allDepts = getParentDepts(); // 包含当前部门和所有父级部门 - - // 4. 获取当前用户的角色ID集合 - Set userRoleIds = null; - try { - userRoleIds = permissionApi.getUserRoleIdListByUserId(userId).getData(); - } catch (Exception e) { - log.warn("获取用户角色ID失败,将跳过角色权限过滤: {}", e.getMessage()); - } - final Set finalUserRoleIds = userRoleIds; - - // 5. 过滤出当前用户命中的所有权限记录 - List recordPermissionDOS = judgeIsAdmin(categoryId,null,null); - List matchedList = new ArrayList<>(recordPermissionDOS); - for (RecordPermissionDO perm : permissionList) { - String targetType = perm.getTargetType(); - String targetId = perm.getTargetId(); - - // 5.1 部门条件:当前部门或任意父级部门匹配 - if (targetDeptValue != null && targetDeptValue.equals(targetType)) { - boolean deptMatch = allDepts.stream() - .anyMatch(dept -> dept.getId() != null && dept.getId().toString().equals(targetId)); - if (deptMatch) { - matchedList.add(perm); - continue; // 已命中,无需再判断角色 - } - } - - // 5.2 角色条件:当前用户的任意角色匹配 - if (targetRoleValue != null && targetRoleValue.equals(targetType) && finalUserRoleIds != null) { - boolean roleMatch = finalUserRoleIds.stream() - .anyMatch(roleId -> roleId.toString().equals(targetId)); - if (roleMatch) { - matchedList.add(perm); - } - } - } - - log.info("分类ID: {} 共命中权限记录数: {}", categoryId, matchedList.size()); - return matchedList; - } } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/business/reportdoc/dal/mapper/ReportDocumentDataMapper.xml b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/business/reportdoc/dal/mapper/ReportDocumentDataMapper.xml index ed2a7332..c90e3bb7 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/business/reportdoc/dal/mapper/ReportDocumentDataMapper.xml +++ b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/business/reportdoc/dal/mapper/ReportDocumentDataMapper.xml @@ -9,4 +9,13 @@ 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ --> + + \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/record/dal/mapper/RecordCategoryMapper.xml b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/record/dal/mapper/RecordCategoryMapper.xml index d2b6acee..d8ebdfe0 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/record/dal/mapper/RecordCategoryMapper.xml +++ b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/record/dal/mapper/RecordCategoryMapper.xml @@ -2,34 +2,9 @@ - + - \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/record/dal/mapper/RecordPermissionMapper.xml b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/record/dal/mapper/RecordPermissionMapper.xml index 99f3b26d..124a1bef 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/record/dal/mapper/RecordPermissionMapper.xml +++ b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/record/dal/mapper/RecordPermissionMapper.xml @@ -9,4 +9,31 @@ 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ --> + + + \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/record/dal/mapper/RecordRecordMapper.xml b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/record/dal/mapper/RecordRecordMapper.xml index ad11da27..771df012 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/record/dal/mapper/RecordRecordMapper.xml +++ b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/record/dal/mapper/RecordRecordMapper.xml @@ -64,9 +64,6 @@ AND trr.NAME LIKE CONCAT('%', #{reqVO.name}, '%') - - AND trr.FORM_KY = #{reqVO.formKey} - AND trr.VER = #{reqVO.version} @@ -76,45 +73,12 @@ AND trr.MKE_DT BETWEEN #{reqVO.makeDate[0]} AND #{reqVO.makeDate[1]} - - AND trr.CNF_FLG = #{reqVO.confidentialFlag} - - - AND trr.CNF_LVL = #{reqVO.confidentialLevel} - - - AND trr.CNF_WY = #{reqVO.confidentialWay} - - - AND trr.CNF_KY = #{reqVO.confidentialKey} - - - AND trr.PMNT = #{reqVO.permanently} - AND trr.EXPR_DT BETWEEN #{reqVO.expirationDate[0]} AND #{reqVO.expirationDate[1]} AND trr.EXPR_STS = #{reqVO.expirationStatus} - - AND trr.CNL_FLG = #{reqVO.cancelFlag} - - - AND trr.FORM_DAT = #{reqVO.formData} - - - AND trr.DAT_COLT_ID = #{reqVO.dataCollectionId} - - - AND trr.SRC_URL = #{reqVO.sourceUrl} - - - AND trr.SYS_DEPT_CD = #{reqVO.systemDepartmentCode} - - - AND trr.RMK = #{reqVO.remark} - AND trr.MAIN_ID = #{reqVO.mainId} @@ -124,4 +88,61 @@ ORDER BY trr.CREATE_TIME ASC + + + \ No newline at end of file