Compare commits
17 Commits
8e3994b6a8
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
| dd6df68061 | |||
|
|
468e939ab1 | ||
|
|
90b0aa5202 | ||
|
|
33543e5330 | ||
|
|
6a3d585802 | ||
|
|
9eec0bb05e | ||
|
|
8fd750a82f | ||
|
|
2790ed7ea1 | ||
|
|
9f4369bcb2 | ||
|
|
920292cfac | ||
|
|
1187038ba8 | ||
|
|
e2678fe7b4 | ||
|
|
c1b975cca0 | ||
|
|
b7f30012c8 | ||
|
|
000cfca842 | ||
| 6b006513af | |||
|
|
f2571944c1 |
@@ -140,6 +140,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode REPORT_DOCUMENT_DATA_NOT_EXISTS = new ErrorCode(1_032_100_000, "检测报告明细不存在");
|
||||
ErrorCode REPORT_DOCUMENT_TYPE_NOT_EXISTS = new ErrorCode(1_032_100_000, "报告类型配置不存在");
|
||||
ErrorCode REPORT_DOCUMENT_MAIN_CORRELATION_NOT_EXISTS = new ErrorCode(1_032_100_000, "报告主数据关系不存在");
|
||||
ErrorCode REPORT_DOCUMENT_FILE_NOT_EXISTS = new ErrorCode(1_032_100_000, "检测报告附件不存在");
|
||||
|
||||
ErrorCode BUSINESS_SAMPLE_DISPATCH_NOT_EXISTS = new ErrorCode(1_032_100_000, "样品调拨不存在");
|
||||
ErrorCode BUSINESS_SAMPLE_DISPATCH_DETAIL_NOT_EXISTS = new ErrorCode(1_032_100_000, "样品调拨明细不存在");
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
</description>
|
||||
<properties>
|
||||
<zzjc.tio.version>3.9.1.v20251204-RELEASE</zzjc.tio.version>
|
||||
<liteflow.version>2.15.2</liteflow.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- Spring Cloud 基础 -->
|
||||
@@ -141,27 +142,27 @@
|
||||
<dependency>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<artifactId>liteflow-spring-boot-starter</artifactId>
|
||||
<version>2.15.1</version>
|
||||
<version>${liteflow.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<artifactId>liteflow-script-javax-pro</artifactId>
|
||||
<version>2.15.1</version>
|
||||
<version>${liteflow.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<artifactId>liteflow-script-groovy</artifactId>
|
||||
<version>2.15.1</version>
|
||||
<version>${liteflow.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<artifactId>liteflow-script-qlexpress</artifactId>
|
||||
<version>2.15.1</version>
|
||||
<version>${liteflow.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<artifactId>liteflow-script-graaljs</artifactId>
|
||||
<version>2.15.1</version>
|
||||
<version>${liteflow.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- pdfbox -->
|
||||
|
||||
@@ -31,6 +31,9 @@ public class BusinessSubSampleAnalysisGroupPageReqVO extends PageParam {
|
||||
@Schema(description = "样品状态", example = "1")
|
||||
private String sampleStatus;
|
||||
|
||||
@Schema(description = "是否送样")
|
||||
private Integer isSend;
|
||||
|
||||
@Schema(description = "收样人")
|
||||
private String sampleReceiver;
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ public class BusinessSubSampleAnalysisGroupRespVO {
|
||||
@ExcelProperty("样品状态")
|
||||
private String sampleStatus;
|
||||
|
||||
@Schema(description = "是否送样")
|
||||
private Integer isSend;
|
||||
|
||||
@Schema(description = "收样人")
|
||||
@ExcelProperty("收样人")
|
||||
private String sampleReceiver;
|
||||
|
||||
@@ -37,6 +37,9 @@ public class BusinessSubSampleAnalysisGroupSaveReqVO {
|
||||
@NotEmpty(message = "样品状态不能为空")
|
||||
private String sampleStatus;
|
||||
|
||||
@Schema(description = "是否送样")
|
||||
private Integer isSend;
|
||||
|
||||
@Schema(description = "收样人")
|
||||
private String sampleReceiver;
|
||||
|
||||
|
||||
@@ -63,6 +63,9 @@ public class BusinessSubSampleExtendRespVO extends BusinessSubSampleRespVO {
|
||||
|
||||
@Schema(description = "分析部门名称")
|
||||
private String assayDepartmentName;
|
||||
|
||||
@Schema(description = "是否已送样")
|
||||
private Integer isSendSample;
|
||||
|
||||
@Schema(description = "是否打印")
|
||||
private Integer isPrint;
|
||||
|
||||
@@ -145,6 +145,9 @@ public class BusinessSubSamplePageReqVO extends PageParam {
|
||||
@Schema(description = "分析部门状态")
|
||||
private String assayDepartmentStatus;
|
||||
|
||||
@Schema(description = "是否已送样")
|
||||
private Integer isSendSample;
|
||||
|
||||
@Schema(description = "样品流程节点KEY列表")
|
||||
private List<String> sampleFlowNodeKeyList;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zt.plat.module.qms.business.bus.dal.dataobject;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -109,4 +110,20 @@ public class BusinessAssayReportDataDO extends BusinessBaseDO {
|
||||
//样品创建时间
|
||||
@TableField(exist = false)
|
||||
private LocalDateTime baseSampleCreateTime;
|
||||
|
||||
//样品类型key
|
||||
@TableField(exist = false)
|
||||
private String sampleTypeKey;
|
||||
|
||||
//委托样品名称
|
||||
@TableField(exist = false)
|
||||
private String entrustSampleName;
|
||||
|
||||
//委托样品编号
|
||||
@TableField(exist = false)
|
||||
private String entrustSampleCode;
|
||||
|
||||
//委托明细排序
|
||||
@TableField(exist = false)
|
||||
private Integer entrustDetailSort;
|
||||
}
|
||||
@@ -63,6 +63,11 @@ public class BusinessSubSampleAnalysisGroupDO extends BusinessBaseDO {
|
||||
@TableField("SMP_STS")
|
||||
private String sampleStatus;
|
||||
/**
|
||||
* 是否送样
|
||||
*/
|
||||
@TableField("IS_SND")
|
||||
private Integer isSend;
|
||||
/**
|
||||
* 收样人
|
||||
*/
|
||||
@TableField("SMP_RCVR")
|
||||
|
||||
@@ -263,6 +263,31 @@ public interface BusinessAssayTaskDataMapper extends BaseMapperX<BusinessAssayTa
|
||||
.eq(BusinessAssayTaskDataDO::getIsReported, QmsCommonConstant.NO));
|
||||
}
|
||||
|
||||
default List<BusinessAssayTaskDataExtendRespVO> selectBySampleAssayCodesAndConfigAssayMethodId(List<String> sampleAssayCodes, Long configAssayMethodId) {
|
||||
return selectJoinList(BusinessAssayTaskDataExtendRespVO.class, new MPJLambdaWrapperX<BusinessAssayTaskDataDO>()
|
||||
.leftJoin(BusinessSubSampleDO.class, BusinessSubSampleDO::getId, BusinessAssayTaskDataDO::getBusinessSubSampleId)
|
||||
.selectAll(BusinessAssayTaskDataDO.class)
|
||||
.selectAs(BusinessSubSampleDO::getSampleName, BusinessAssayTaskDataExtendRespVO::getSampleName)
|
||||
.selectAs(BusinessSubSampleDO::getSampleCode, BusinessAssayTaskDataExtendRespVO::getSampleCode)
|
||||
.selectAs(BusinessSubSampleDO::getSampleAssayCode, BusinessAssayTaskDataExtendRespVO::getSampleAssayCode)
|
||||
.in(BusinessSubSampleDO::getSampleAssayCode, sampleAssayCodes)
|
||||
.eq(BusinessAssayTaskDataDO::getConfigAssayMethodId, configAssayMethodId)
|
||||
.eq(BusinessAssayTaskDataDO::getIsReported, QmsCommonConstant.NO));
|
||||
}
|
||||
|
||||
default List<BusinessAssayTaskDataExtendRespVO> selectBySampleAssayCodesAndConfigAssayMethodDictionaryBusinessKey(List<String> sampleAssayCodes, String configAssayMethodDictionaryBusinessKey) {
|
||||
return selectJoinList(BusinessAssayTaskDataExtendRespVO.class, new MPJLambdaWrapperX<BusinessAssayTaskDataDO>()
|
||||
.leftJoin(BusinessSubSampleDO.class, BusinessSubSampleDO::getId, BusinessAssayTaskDataDO::getBusinessSubSampleId)
|
||||
.leftJoin(ConfigAssayMethodDO.class, ConfigAssayMethodDO::getId, BusinessAssayTaskDataDO::getConfigAssayMethodId)
|
||||
.selectAll(BusinessAssayTaskDataDO.class)
|
||||
.selectAs(BusinessSubSampleDO::getSampleName, BusinessAssayTaskDataExtendRespVO::getSampleName)
|
||||
.selectAs(BusinessSubSampleDO::getSampleCode, BusinessAssayTaskDataExtendRespVO::getSampleCode)
|
||||
.selectAs(BusinessSubSampleDO::getSampleAssayCode, BusinessAssayTaskDataExtendRespVO::getSampleAssayCode)
|
||||
.in(BusinessSubSampleDO::getSampleAssayCode, sampleAssayCodes)
|
||||
.eq(ConfigAssayMethodDO::getDictionaryBusinessKey, configAssayMethodDictionaryBusinessKey)
|
||||
.eq(BusinessAssayTaskDataDO::getIsReported, QmsCommonConstant.NO));
|
||||
}
|
||||
|
||||
default List<BusinessAssayTaskDataExtendRespVO> selectResultAssessmentList(BusinessAssayTaskDataReqVO reqVO) {
|
||||
MPJLambdaWrapper<BusinessAssayTaskDataDO> mpjLambdaWrapper = new MPJLambdaWrapper<BusinessAssayTaskDataDO>()
|
||||
.leftJoin(ConfigAssayMethodDO.class, ConfigAssayMethodDO::getId, BusinessAssayTaskDataDO::getConfigAssayMethodId)
|
||||
|
||||
@@ -27,6 +27,7 @@ public interface BusinessSubSampleAnalysisGroupMapper extends BaseMapperX<Busine
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getAssayDepartmentId, reqVO.getAssayDepartmentId())
|
||||
.likeIfPresent(BusinessSubSampleAnalysisGroupDO::getAssayDepartmentName, reqVO.getAssayDepartmentName())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getSampleStatus, reqVO.getSampleStatus())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getIsSend, reqVO.getIsSend())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getSampleReceiver, reqVO.getSampleReceiver())
|
||||
.betweenIfPresent(BusinessSubSampleAnalysisGroupDO::getSampleReceiveTime, reqVO.getSampleReceiveTime())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
|
||||
|
||||
@@ -144,6 +144,7 @@ public interface BusinessSubSampleMapper extends BaseMapperX<BusinessSubSampleDO
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getAssayDepartmentId, reqVO.getAssayDepartmentId())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getAssayDepartmentName, reqVO.getAssayDepartmentName())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getSampleStatus, reqVO.getAssayDepartmentStatus())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getIsSend, reqVO.getIsSendSample())
|
||||
.orderByDesc(BusinessSubSampleDO::getSampleFlowNodeTime).orderByAsc(BusinessSubSampleDO::getSampleCode));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,16 @@ package com.zt.plat.module.qms.business.bus.liteflow.sample.flow;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ql.util.express.DefaultContext;
|
||||
import com.ql.util.express.ExpressRunner;
|
||||
import com.alibaba.qlexpress4.Express4Runner;
|
||||
import com.alibaba.qlexpress4.QLOptions;
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.zt.plat.framework.common.exception.ServiceException;
|
||||
@@ -41,7 +43,7 @@ public class SampleSubProcessUpdateCmp extends NodeComponent {
|
||||
// private ConfigSubSampleService configSubSampleService;
|
||||
|
||||
@Resource
|
||||
private ExpressRunner expressRunner;
|
||||
private Express4Runner express4Runner;
|
||||
|
||||
@Resource
|
||||
private ConfigRuleMapper configRuleMapper;
|
||||
@@ -89,7 +91,7 @@ public class SampleSubProcessUpdateCmp extends NodeComponent {
|
||||
for (SampleFlowNode flowNode : nextFlowNodeList) {
|
||||
ConfigRuleDO conditionRule = configRuleMapper.selectLatestConfigRuleByCode(flowNode.getCondition());
|
||||
Boolean isMeetCondition = false;
|
||||
DefaultContext<String, Object> context = new DefaultContext<>();
|
||||
Map<String, Object> context = new HashMap<>();
|
||||
ConfigSubSampleDO configSubSample = sampleFlowContext.getConfigSubSampleById(businessSubSample.getConfigSubSampleId());
|
||||
Boolean hasSubSimpleCodeRule = configSubSample != null && StringUtils.isNotBlank(configSubSample.getSimpleCodeRule());
|
||||
Boolean hasSubSampleEncrypt = businessHandoverRecordSubDOList.stream().filter(f -> f.getBusinessSubSampleId().equals(businessSubSample.getId())).anyMatch(m -> QmsCommonConstant.FlOW_NODE_SAMPLE_ENCRYPT.equals(m.getSampleFlowNodeKey()));
|
||||
@@ -105,7 +107,8 @@ public class SampleSubProcessUpdateCmp extends NodeComponent {
|
||||
context.put("hasSubSimpleCodeRule", hasSubSimpleCodeRule);
|
||||
context.put("hasSubSampleEncrypt", hasSubSampleEncrypt);
|
||||
try {
|
||||
isMeetCondition = (Boolean) expressRunner.execute(conditionRule.getExpression(), context, null, false, false);
|
||||
// isMeetCondition = (Boolean) express4Runner.execute(conditionRule.getExpression(), context, null, false, false);
|
||||
isMeetCondition = (Boolean) express4Runner.execute(conditionRule.getExpression(), context, QLOptions.DEFAULT_OPTIONS).getResult();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(1_032_100_000, e.getMessage());
|
||||
@@ -140,6 +143,16 @@ public class SampleSubProcessUpdateCmp extends NodeComponent {
|
||||
}
|
||||
sampleFlowContext.setBusinessSubSampleAnalysisGroupList(curDeptSubSampleAnalysisGroupDOList);
|
||||
}
|
||||
|
||||
//如果是班组送样,需要更新分析班组表
|
||||
if (QmsCommonConstant.FLOW_NODE_ANALYSIS_SEND.equals(currentSampleFlowKey)) {
|
||||
List<BusinessSubSampleAnalysisGroupDO> curDeptSubSampleAnalysisGroupDOList = businessSubSampleAnalysisGroupDOList.stream().filter(f -> f.getAssayDepartmentId().equals(loginUser.getVisitDeptId())).collect(Collectors.toList());
|
||||
for (BusinessSubSampleAnalysisGroupDO businessSubSampleAnalysisGroupDO : curDeptSubSampleAnalysisGroupDOList) {
|
||||
businessSubSampleAnalysisGroupDO.setIsSend(QmsCommonConstant.YES);
|
||||
}
|
||||
sampleFlowContext.setBusinessSubSampleAnalysisGroupList(curDeptSubSampleAnalysisGroupDOList);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ import com.zt.plat.framework.common.pojo.PageParam;
|
||||
*/
|
||||
public interface BusinessSampleEntrustRegistrationService {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建委检登记业务
|
||||
*
|
||||
@@ -56,6 +58,8 @@ public interface BusinessSampleEntrustRegistrationService {
|
||||
*/
|
||||
BusinessSampleEntrustRegistrationDO getBusinessSampleEntrustRegistration(Long id);
|
||||
|
||||
List<BusinessSampleEntrustRegistrationDO> listByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得委检登记业务分页
|
||||
*
|
||||
|
||||
@@ -89,6 +89,11 @@ public class BusinessSampleEntrustRegistrationServiceImpl implements BusinessSam
|
||||
return businessSampleEntrustRegistrationMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BusinessSampleEntrustRegistrationDO> listByIds(List<Long> ids) {
|
||||
return businessSampleEntrustRegistrationMapper.selectByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BusinessSampleEntrustRegistrationExtendRespVO> getBusinessSampleEntrustRegistrationPage(BusinessSampleEntrustRegistrationPageReqVO pageReqVO) {
|
||||
return businessSampleEntrustRegistrationMapper.selectPage(pageReqVO);
|
||||
|
||||
@@ -4,13 +4,10 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.collections4.map.HashedMap;
|
||||
@@ -23,18 +20,17 @@ import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONFactory;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONWriter;
|
||||
import com.alibaba.nacos.shaded.io.grpc.Attributes.Key;
|
||||
import com.alibaba.qlexpress4.Express4Runner;
|
||||
import com.alibaba.qlexpress4.QLOptions;
|
||||
import com.alibaba.qlexpress4.QLResult;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.ql.util.express.DefaultContext;
|
||||
import com.ql.util.express.ExpressRunner;
|
||||
import com.zt.plat.framework.common.exception.ServiceException;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.zt.plat.module.qms.business.bus.controller.vo.*;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayParameterDataDO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayProjectDataDO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayReportDataDO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDataDO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDetailDO;
|
||||
@@ -67,7 +63,6 @@ import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessSubSampleAssessmen
|
||||
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessSubSampleMapper;
|
||||
import com.zt.plat.module.qms.business.config.controller.vo.*;
|
||||
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigAssayMethodProjectAssessmentDO;
|
||||
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigReportFieldDO;
|
||||
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigRuleDO;
|
||||
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigSubSampleDO;
|
||||
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigSubSampleMethodDO;
|
||||
@@ -104,7 +99,7 @@ import jakarta.annotation.Resource;
|
||||
public class SampleAnalysisAuditServiceImpl implements SampleAnalysisAuditService {
|
||||
|
||||
@Resource
|
||||
private ExpressRunner expressRunner;
|
||||
private Express4Runner express4Runner;
|
||||
|
||||
@Resource
|
||||
private AllowanceCalculatorComponent allowanceCalculatorComponent;
|
||||
@@ -991,12 +986,14 @@ public class SampleAnalysisAuditServiceImpl implements SampleAnalysisAuditServic
|
||||
int elementScale = businessSubSampleAssessmentProjectDO.getDecimalPosition();
|
||||
// 计算代表值(均值\)
|
||||
// BigDecimal representativeValue = calculateRepresentativeValue(sortedValues, elementScale);
|
||||
DefaultContext<String, Object> context = new DefaultContext<>();
|
||||
Map<String, Object> context = new HashMap<>();
|
||||
context.put("values", sortedValues);
|
||||
context.put("scale", elementScale);
|
||||
BigDecimal representativeValue = null;
|
||||
try {
|
||||
representativeValue = (BigDecimal) expressRunner.execute(calculateAssessmentValue.getExpression(), context, null, false, false);
|
||||
//representativeValue = (BigDecimal) expressRunner.execute(calculateAssessmentValue.getExpression(), context, null, false, false);
|
||||
QLResult expressResult = express4Runner.execute(calculateAssessmentValue.getExpression(), context, QLOptions.builder().precise(true).build());//高精度计算
|
||||
representativeValue = (BigDecimal) expressResult.getResult();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.async;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Configuration
|
||||
@EnableAsync
|
||||
public class AsyncConfig {
|
||||
@Bean("asyncTaskExecutor")
|
||||
public Executor asyncTaskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(5);
|
||||
executor.setMaxPoolSize(10);
|
||||
executor.setQueueCapacity(100);
|
||||
executor.setThreadNamePrefix("Async-");
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentTy
|
||||
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.common.data.service.DataTemplateService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -62,16 +63,12 @@ public class ReportDocumentDataController extends AbstractFileUploadController i
|
||||
@GetMapping("/queryReportDetail")
|
||||
@Operation(summary = "查询报告明细数据")
|
||||
@Parameter(name = "mainId", description = "报告id", required = true, example = "1024")
|
||||
public CommonResult<List<JSONObject>> queryReportDetail(@RequestParam("mainId") Long mainId) {
|
||||
public CommonResult<?> queryReportDetail(@RequestParam("mainId") Long mainId, @RequestParam(name = "pageFlag", required = false) String pageFlag) {
|
||||
|
||||
ReportDocumentMainDO mainDO = reportDocumentMainService.getReportDocumentMain(mainId);
|
||||
Long typeId = mainDO.getReportDocumentTypeId();
|
||||
ReportDocumentTypeDO typeDO = reportDocumentTypeService.getReportDocumentType(typeId);
|
||||
Long confId = typeDO.getConfigReportTypeId();
|
||||
// Map<String, Object> param = new HashMap<>();
|
||||
// List<ReportDocumentDataDO> list = reportDocumentDataService.listByMainDataId(mainId).getData();
|
||||
// return success(BeanUtils.toBean(list, ReportDocumentDataRespVO.class));
|
||||
CommonResult<List<JSONObject>> result = reportDocumentDataService.assembleDynamicData(mainDO, typeDO);
|
||||
CommonResult<JSONArray> result = reportDocumentDataService.assembleDynamicData(mainDO, typeDO, pageFlag);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.controller.admin;
|
||||
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFilePageReqVO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFileRespVO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFileSaveReqVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
|
||||
import com.zt.plat.framework.business.annotation.FileUploadController;
|
||||
import com.zt.plat.framework.business.controller.AbstractFileUploadController;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentFileDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.service.ReportDocumentFileService;
|
||||
|
||||
@Tag(name = "管理后台 - 检测报告附件")
|
||||
@RestController
|
||||
@RequestMapping("/qms/report-document-file")
|
||||
@Validated
|
||||
@FileUploadController(source = "qms.reportdocumentfile")
|
||||
public class ReportDocumentFileController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||
|
||||
static {
|
||||
FileUploadController annotation = ReportDocumentFileController.class.getAnnotation(FileUploadController.class);
|
||||
if (annotation != null) {
|
||||
setFileUploadInfo(annotation);
|
||||
}
|
||||
}
|
||||
|
||||
@Resource
|
||||
private ReportDocumentFileService reportDocumentFileService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建检测报告附件")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:create')")
|
||||
public CommonResult<ReportDocumentFileRespVO> createReportDocumentFile(@Valid @RequestBody ReportDocumentFileSaveReqVO createReqVO) {
|
||||
return success(reportDocumentFileService.createReportDocumentFile(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新检测报告附件")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:update')")
|
||||
public CommonResult<Boolean> updateReportDocumentFile(@Valid @RequestBody ReportDocumentFileSaveReqVO updateReqVO) {
|
||||
reportDocumentFileService.updateReportDocumentFile(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除检测报告附件")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:delete')")
|
||||
public CommonResult<Boolean> deleteReportDocumentFile(@RequestParam("id") Long id) {
|
||||
reportDocumentFileService.deleteReportDocumentFile(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除检测报告附件")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:delete')")
|
||||
public CommonResult<Boolean> deleteReportDocumentFileList(@RequestBody BatchDeleteReqVO req) {
|
||||
reportDocumentFileService.deleteReportDocumentFileListByIds(req.getIds());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得检测报告附件")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:query')")
|
||||
public CommonResult<ReportDocumentFileRespVO> getReportDocumentFile(@RequestParam("id") Long id) {
|
||||
ReportDocumentFileDO reportDocumentFile = reportDocumentFileService.getReportDocumentFile(id);
|
||||
return success(BeanUtils.toBean(reportDocumentFile, ReportDocumentFileRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得检测报告附件分页")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:query')")
|
||||
public CommonResult<PageResult<ReportDocumentFileRespVO>> getReportDocumentFilePage(@Valid ReportDocumentFilePageReqVO pageReqVO) {
|
||||
PageResult<ReportDocumentFileDO> pageResult = reportDocumentFileService.getReportDocumentFilePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ReportDocumentFileRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出检测报告附件 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportReportDocumentFileExcel(@Valid ReportDocumentFilePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ReportDocumentFileDO> list = reportDocumentFileService.getReportDocumentFilePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "检测报告附件.xls", "数据", ReportDocumentFileRespVO.class,
|
||||
BeanUtils.toBean(list, ReportDocumentFileRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,26 +14,27 @@ 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.ReportDocumentDataDO;
|
||||
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.common.data.dal.dataobject.DataTemplateDO;
|
||||
import com.zt.plat.module.qms.common.data.service.DataTemplateService;
|
||||
import com.zt.plat.module.qms.enums.QmsCommonConstant;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkOperationRespDTO;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkWorkflowCreateReqDTO;
|
||||
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.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
@@ -59,6 +60,19 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
@Resource private ReportDocumentDataService reportDocumentDataService;
|
||||
@Resource private ReportDocumentTypeService reportDocumentTypeService;
|
||||
@Resource private ConfigUserSignatureService configUserSignatureService;
|
||||
@Resource private DataTemplateService dataTemplateService;
|
||||
|
||||
@RequestMapping("/testAsyncTask")
|
||||
public CommonResult<String> testAsyncTask(@RequestParam Long id) {
|
||||
ReportDocumentMainSaveReqVO reqVO = new ReportDocumentMainSaveReqVO();
|
||||
reqVO.setId(id);
|
||||
reqVO.setFlowStatus("async");
|
||||
reportDocumentMainService.updateReportDocumentMain(reqVO);
|
||||
|
||||
reportDocumentMainService.testAsyncTask(id);
|
||||
return CommonResult.success("success");
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建检测报告")
|
||||
@@ -78,6 +92,11 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
if(typeDO == null){
|
||||
return error(REPORT_DOCUMENT_TYPE_NOT_EXISTS, "报告类型不存在,请刷新后重试");
|
||||
}
|
||||
String dataTemplateKey = typeDO.getReportKey();
|
||||
DataTemplateDO dataTemplateDO = dataTemplateService.getLatestDataByKey(dataTemplateKey);
|
||||
if(dataTemplateDO == null)
|
||||
return error(REPORT_DOCUMENT_TYPE_NOT_EXISTS, "表单编辑器模板不存在,请联系管理员处理");
|
||||
vo.setDataTemplateId(dataTemplateDO.getId());
|
||||
vo.setDocumentTitle(typeDO.getName());
|
||||
vo.setFlowKey(typeDO.getFlowKey());
|
||||
vo.setDocumentType(typeDO.getDocumentType());
|
||||
@@ -189,58 +208,32 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
|
||||
//处理抬头数据
|
||||
|
||||
if("true".equals(editFlag)){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String formData = vo.getFormData();
|
||||
JSONObject formDataJson = new JSONObject();
|
||||
if(!ObjectUtils.isEmpty(formData))
|
||||
formDataJson = JSONObject.parseObject(formData);
|
||||
List<ReportDocumentDataDO> dataList = reportDocumentDataService.listByMainDataId(id).getData();
|
||||
ReportDocumentTypeDO typeDO = reportDocumentTypeService.getReportDocumentType(reportDocumentMain.getReportDocumentTypeId());
|
||||
String customConfig = typeDO.getCustomConfig();
|
||||
String defaultConclusion = "";
|
||||
if(!ObjectUtils.isEmpty(customConfig)){
|
||||
JSONObject config = JSONObject.parseObject(customConfig);
|
||||
defaultConclusion = config.getString("defaultConclusion");
|
||||
}
|
||||
formDataJson.put("conclusion", defaultConclusion);
|
||||
if(!dataList.isEmpty())
|
||||
formDataJson.put("sampleName", dataList.get(0).getSampleName());
|
||||
//处理检测标准
|
||||
String standard = assembleStandard(dataList);
|
||||
formDataJson.put("standard", standard);
|
||||
formDataJson.put("reportTime", sdf.format(new Date()));
|
||||
vo.setFormData(formDataJson.toJSONString());
|
||||
// ReportDocumentMainSaveReqVO updateVO = new ReportDocumentMainSaveReqVO();
|
||||
// updateVO.setId(reportDocumentMain.getId());
|
||||
// updateVO.setFormData(formDataJson.toJSONString());
|
||||
// reportDocumentMainService.updateReportDocumentMain(updateVO);
|
||||
}
|
||||
// if("true".equals(editFlag)){
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// String formData = vo.getFormData();
|
||||
// JSONObject formDataJson = new JSONObject();
|
||||
// if(!ObjectUtils.isEmpty(formData))
|
||||
// formDataJson = JSONObject.parseObject(formData);
|
||||
// List<ReportDocumentDataDO> dataList = reportDocumentDataService.listByMainDataId(id).getData();
|
||||
// ReportDocumentTypeDO typeDO = reportDocumentTypeService.getReportDocumentType(reportDocumentMain.getReportDocumentTypeId());
|
||||
// String customConfig = typeDO.getCustomConfig();
|
||||
// String defaultConclusion = "";
|
||||
// if(!ObjectUtils.isEmpty(customConfig)){
|
||||
// JSONObject config = JSONObject.parseObject(customConfig);
|
||||
// defaultConclusion = config.getString("defaultConclusion");
|
||||
// }
|
||||
// formDataJson.put("conclusion", defaultConclusion);
|
||||
// if(!dataList.isEmpty())
|
||||
// formDataJson.put("sampleName", dataList.get(0).getSampleName());
|
||||
// //处理检测标准
|
||||
// String standard = assembleStandard(dataList);
|
||||
// formDataJson.put("standard", standard);
|
||||
// formDataJson.put("reportTime", sdf.format(new Date()));
|
||||
// vo.setFormData(formDataJson.toJSONString());
|
||||
// }
|
||||
return success(vo);
|
||||
}
|
||||
|
||||
private String assembleStandard(List<ReportDocumentDataDO> dataList){
|
||||
|
||||
Set<String> standardSet = new HashSet<>();
|
||||
for(ReportDocumentDataDO data : dataList){
|
||||
String content = data.getDocumentContent();
|
||||
if(ObjectUtils.isEmpty( content))
|
||||
continue;
|
||||
JSONObject json = JSONObject.parseObject(content);
|
||||
for(String key : json.keySet()){
|
||||
JSONObject obj = json.getJSONObject(key);
|
||||
String methodName = obj.getString("methodName");
|
||||
if(ObjectUtils.isEmpty(methodName))
|
||||
continue;
|
||||
standardSet.add(methodName);
|
||||
}
|
||||
}
|
||||
if(standardSet.isEmpty())
|
||||
return "";
|
||||
return String.join(",", standardSet);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得检测报告业务分页")
|
||||
//@PreAuthorize("@ss.hasPermission('qms:report-document-main:query')")
|
||||
@@ -261,4 +254,23 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
ExcelUtils.write(response, "检测报告业务.xls", "数据", ReportDocumentMainRespVO.class, list);
|
||||
}
|
||||
|
||||
@GetMapping("/testCreateIworkWorkflow")
|
||||
@Operation(summary = "测试发起iwork流程")
|
||||
//@PreAuthorize("@ss.hasPermission('qms:report-document-main:query')")
|
||||
public CommonResult<IWorkOperationRespDTO> createIworkWorkflow() {
|
||||
IWorkWorkflowCreateReqDTO req = new IWorkWorkflowCreateReqDTO();
|
||||
req.setJbr("1001");
|
||||
req.setYybm("2001");
|
||||
req.setFb("3001");
|
||||
req.setSqsj("2025-01-01");
|
||||
req.setYyqx("对外邮寄");
|
||||
// req.setYyfkUrl("https://files.example.com/evidence.pdf");
|
||||
req.setYysy("与客户合同用印");
|
||||
req.setXyywjUrl("http://172.16.46.63:30002/yudao/20251204/%E6%B5%8B%E8%AF%95pdf_1764818842846.pdf?response-cache-control=no-cache%2C%20no-store%2C%20must-revalidate&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20251209T093343Z&X-Amz-SignedHeaders=host&X-Amz-Credential=EKplIEnbNgfYBAZbEJNa%2F20251209%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Expires=86400&X-Amz-Signature=37d63249667ea855f9a51bdf47bbb044d5860c302721f52fff2ba644985bae4c");
|
||||
req.setYysx("检测报告用印");
|
||||
req.setYwxtdjbh("JY-20251209-0001");
|
||||
// CommonResult<IWorkOperationRespDTO> ret = reportDocumentMainService.createIWorkflow(req);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,4 +43,16 @@ public class ReportDocumentDataPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "样品大类名称")
|
||||
private String baseSampleName;
|
||||
|
||||
@Schema(description = "样品类型key")
|
||||
private String sampleTypeKey;
|
||||
|
||||
@Schema(description = "委托样品名称")
|
||||
private String entrustSampleName;
|
||||
|
||||
@Schema(description = "委托样品编号")
|
||||
private String entrustSampleCode;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -56,6 +56,22 @@ public class ReportDocumentDataRespVO {
|
||||
@ExcelProperty("样品大类名称")
|
||||
private String baseSampleName;
|
||||
|
||||
@Schema(description = "样品类型key")
|
||||
@ExcelProperty("样品类型key")
|
||||
private String sampleTypeKey;
|
||||
|
||||
@Schema(description = "委托样品名称")
|
||||
@ExcelProperty("委托样品名称")
|
||||
private String entrustSampleName;
|
||||
|
||||
@Schema(description = "委托样品编号")
|
||||
@ExcelProperty("委托样品编号")
|
||||
private String entrustSampleCode;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
//==================扩展字段===========
|
||||
|
||||
@Schema(description = "样品创建时间")
|
||||
|
||||
@@ -40,4 +40,16 @@ public class ReportDocumentDataSaveReqVO {
|
||||
@Schema(description = "样品大类名称")
|
||||
private String baseSampleName;
|
||||
|
||||
@Schema(description = "样品类型key")
|
||||
private String sampleTypeKey;
|
||||
|
||||
@Schema(description = "委托样品名称")
|
||||
private String entrustSampleName;
|
||||
|
||||
@Schema(description = "委托样品编号")
|
||||
private String entrustSampleCode;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.controller.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 检测报告附件分页 Request VO")
|
||||
@Data
|
||||
public class ReportDocumentFilePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "报告id", example = "20899")
|
||||
private Long mainId;
|
||||
|
||||
@Schema(description = "文件表ID", example = "25498")
|
||||
private Long fileId;
|
||||
|
||||
@Schema(description = "文件名称", example = "李四")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "路径")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "文件地址", example = "https://www.iocoder.cn")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "文件类型", example = "1")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "版本")
|
||||
private Integer version;
|
||||
|
||||
@Schema(description = "所属部门")
|
||||
private String systemDepartmentCode;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.controller.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 检测报告附件 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ReportDocumentFileRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29698")
|
||||
@ExcelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "报告id", example = "20899")
|
||||
@ExcelProperty("报告id")
|
||||
private Long mainId;
|
||||
|
||||
@Schema(description = "文件表ID", example = "25498")
|
||||
@ExcelProperty("文件表ID")
|
||||
private Long fileId;
|
||||
|
||||
@Schema(description = "文件名称", example = "李四")
|
||||
@ExcelProperty("文件名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "路径")
|
||||
@ExcelProperty("路径")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "文件地址", example = "https://www.iocoder.cn")
|
||||
@ExcelProperty("文件地址")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "文件类型", example = "1")
|
||||
@ExcelProperty("文件类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "版本")
|
||||
@ExcelProperty("版本")
|
||||
private Integer version;
|
||||
|
||||
@Schema(description = "所属部门")
|
||||
@ExcelProperty("所属部门")
|
||||
private String systemDepartmentCode;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "备注")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.controller.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
@Schema(description = "管理后台 - 检测报告附件新增/修改 Request VO")
|
||||
@Data
|
||||
public class ReportDocumentFileSaveReqVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29698")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "报告id", example = "20899")
|
||||
private Long mainId;
|
||||
|
||||
@Schema(description = "文件表ID", example = "25498")
|
||||
private Long fileId;
|
||||
|
||||
@Schema(description = "文件名称", example = "李四")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "路径")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "文件地址", example = "https://www.iocoder.cn")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "文件类型", example = "1")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "版本")
|
||||
private Integer version;
|
||||
|
||||
@Schema(description = "所属部门")
|
||||
private String systemDepartmentCode;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -88,4 +88,10 @@ public class ReportDocumentMainPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "表单设计器模板id")
|
||||
private Long dataTemplateId;
|
||||
|
||||
@Schema(description = "附件版本")
|
||||
private Integer documentVersion;
|
||||
|
||||
@Schema(description = "异步执行状态")
|
||||
private String executionStatus;
|
||||
}
|
||||
@@ -115,6 +115,13 @@ public class ReportDocumentMainRespVO {
|
||||
@ExcelProperty("表单设计器模板id")
|
||||
private Long dataTemplateId;
|
||||
|
||||
@Schema(description = "附件版本")
|
||||
@ExcelProperty("附件版本")
|
||||
private Integer documentVersion;
|
||||
|
||||
@Schema(description = "异步执行状态")
|
||||
@ExcelProperty("异步执行状态")
|
||||
private String executionStatus;
|
||||
//==============================扩展字段=======================================
|
||||
@Schema(description = "记录数")
|
||||
@ExcelProperty("记录数")
|
||||
|
||||
@@ -90,6 +90,11 @@ public class ReportDocumentMainSaveReqVO {
|
||||
@Schema(description = "表单设计器模板id")
|
||||
private Long dataTemplateId;
|
||||
|
||||
@Schema(description = "附件版本")
|
||||
private Integer documentVersion;
|
||||
|
||||
@Schema(description = "异步执行状态")
|
||||
private String executionStatus;
|
||||
|
||||
//====================附加属性==============================
|
||||
@Schema(description = "委托id,支持多值")
|
||||
|
||||
@@ -75,8 +75,26 @@ public class ReportDocumentDataDO extends BusinessBaseDO {
|
||||
@TableField("BSE_SMP_NAME")
|
||||
private String baseSampleName;
|
||||
|
||||
//样品类型key
|
||||
@TableField("SMP_TP_KY")
|
||||
private String sampleTypeKey;
|
||||
|
||||
/**
|
||||
* 委托样品名称
|
||||
*/
|
||||
@TableField("ENTT_SMP_NAME")
|
||||
private String entrustSampleName;
|
||||
/**
|
||||
* 委托样品编号
|
||||
*/
|
||||
@TableField("ENTT_SMP_CD")
|
||||
private String entrustSampleCode;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField("SRT")
|
||||
private Integer sort;
|
||||
//==================扩展字段===========
|
||||
|
||||
//样品创建时间
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.dal.dataobject;
|
||||
|
||||
import lombok.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
|
||||
/**
|
||||
* 检测报告附件 DO
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@TableName("t_rpt_doc_file")
|
||||
@KeySequence("t_rpt_doc_file_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
/**
|
||||
* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO
|
||||
*/
|
||||
public class ReportDocumentFileDO extends BusinessBaseDO {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 报告id
|
||||
*/
|
||||
@TableField("MAIN_ID")
|
||||
private Long mainId;
|
||||
/**
|
||||
* 文件表ID
|
||||
*/
|
||||
@TableField("FILE_ID")
|
||||
private Long fileId;
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
@TableField("NAME")
|
||||
private String name;
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
@TableField("PATH")
|
||||
private String path;
|
||||
/**
|
||||
* 文件地址
|
||||
*/
|
||||
@TableField("URL")
|
||||
private String url;
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
@TableField("TP")
|
||||
private String type;
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
@TableField("VER")
|
||||
private Integer version;
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
@TableField("SYS_DEPT_CD")
|
||||
private String systemDepartmentCode;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField("RMK")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -141,4 +141,12 @@ public class ReportDocumentMainDO extends BusinessBaseDO {
|
||||
//表单设计器模板id
|
||||
@TableField("DAT_TMPL_ID")
|
||||
private Long dataTemplateId;
|
||||
|
||||
//表单设计器模板id
|
||||
@TableField("DOC_VER")
|
||||
private Integer documentVersion;
|
||||
|
||||
//异步执行状态
|
||||
@TableField("EXC_STS")
|
||||
private String executionStatus;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.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.module.qms.business.reportdoc.controller.vo.ReportDocumentFilePageReqVO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentFileDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 检测报告附件 Mapper
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@Mapper
|
||||
public interface ReportDocumentFileMapper extends BaseMapperX<ReportDocumentFileDO> {
|
||||
|
||||
default PageResult<ReportDocumentFileDO> selectPage(ReportDocumentFilePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ReportDocumentFileDO>()
|
||||
.eqIfPresent(ReportDocumentFileDO::getMainId, reqVO.getMainId())
|
||||
.eqIfPresent(ReportDocumentFileDO::getFileId, reqVO.getFileId())
|
||||
.likeIfPresent(ReportDocumentFileDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ReportDocumentFileDO::getPath, reqVO.getPath())
|
||||
.eqIfPresent(ReportDocumentFileDO::getUrl, reqVO.getUrl())
|
||||
.eqIfPresent(ReportDocumentFileDO::getType, reqVO.getType())
|
||||
.eqIfPresent(ReportDocumentFileDO::getVersion, reqVO.getVersion())
|
||||
.eqIfPresent(ReportDocumentFileDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
|
||||
.betweenIfPresent(ReportDocumentFileDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(ReportDocumentFileDO::getRemark, reqVO.getRemark())
|
||||
.orderByDesc(ReportDocumentFileDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.service;
|
||||
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zt.plat.framework.common.exception.ServiceException;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.security.core.LoginUser;
|
||||
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.zt.plat.module.infra.api.file.FileApi;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileCreateReqDTO;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileRespDTO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFileSaveReqVO;
|
||||
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.common.data.dal.dataobject.DataTemplateDO;
|
||||
import com.zt.plat.module.qms.common.data.service.DataTemplateService;
|
||||
import com.zt.plat.module.qms.core.code.SequenceUtil;
|
||||
import com.zt.plat.module.system.api.iwork.IWorkIntegrationApi;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkOperationRespDTO;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkWorkflowCreateReqDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.REPORT_DOCUMENT_FILE_NOT_EXISTS;
|
||||
|
||||
/*
|
||||
* 处理报告附件和发起iwork流程
|
||||
* */
|
||||
@Service("reportDocumentAssistService")
|
||||
@Slf4j
|
||||
public class ReportDocumentAssistService {
|
||||
@Resource
|
||||
private IWorkIntegrationApi iWorkIntegrationApi;
|
||||
|
||||
@Value("${zzjc.html2pdf.addr:}")
|
||||
private String html2pdfAddr;
|
||||
|
||||
@Resource private ReportDocumentDataService reportDocumentDataService;
|
||||
@Resource private ReportDocumentTypeService reportDocumentTypeService;
|
||||
@Resource private ReportDocumentFileService reportDocumentFileService;
|
||||
@Resource private DataTemplateService dataTemplateService;
|
||||
@Resource private SequenceUtil sequenceUtil;
|
||||
@Resource private FileApi fileApi;
|
||||
|
||||
private String sequenceKey = "QMS_REPORT_IWORK_CODE";
|
||||
|
||||
// todo 判断是否更新pdf
|
||||
public boolean checkUpdateDocFile(JSONObject variables){
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* 更新报告附件,并发起iwork流程*/
|
||||
public void updateDocFileAndCreateIWorkflow(JSONObject variables, ReportDocumentMainDO entity) throws IOException {
|
||||
// boolean updateDocFileFlag = true;
|
||||
boolean createIworkWorkflowFlag = false;
|
||||
JSONArray bpmFieldExtensions = variables.getJSONArray("bpmFieldExtensions");
|
||||
if(bpmFieldExtensions == null)
|
||||
bpmFieldExtensions = new JSONArray();
|
||||
for(int i = 0; i < bpmFieldExtensions.size(); i++){
|
||||
JSONObject extension = bpmFieldExtensions.getJSONObject(i);
|
||||
String fieldName = extension.getString("fieldName");
|
||||
String stringValue = extension.getString("stringValue");
|
||||
if(fieldName.equals("creatIWorkFlow") && stringValue.equals("1")){
|
||||
createIworkWorkflowFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ReportDocumentFileDO docFile = generatePdf(entity);
|
||||
if(createIworkWorkflowFlag){
|
||||
createIWorkflow(entity, docFile);
|
||||
}
|
||||
// todo 判断是否更新pdf
|
||||
|
||||
// if(!updateDocFileFlag && createIworkWorkflowFlag){
|
||||
// ReportDocumentFileDO docFile = reportDocumentFileService.getReportDocumentFile(entity.getId());
|
||||
// createIWorkflow(entity, docFile);
|
||||
// return;
|
||||
// }
|
||||
|
||||
//更新报告pdf
|
||||
|
||||
// if(updateDocFileFlag){
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
/*
|
||||
* 发起iwork用印*/
|
||||
public CommonResult<IWorkOperationRespDTO> createIWorkflow(ReportDocumentMainDO entity, ReportDocumentFileDO docFile) {
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
IWorkWorkflowCreateReqDTO dto = new IWorkWorkflowCreateReqDTO();
|
||||
dto.setJbr(String.valueOf(loginUser.getId()));
|
||||
dto.setYybm(String.valueOf(loginUser.getVisitDeptId()));
|
||||
dto.setFb(String.valueOf(loginUser.getVisitCompanyId()));
|
||||
dto.setSqsj(sdf.format(new Date()));
|
||||
dto.setYyqx("检测报告用印");
|
||||
dto.setYysy("检测报告用印");
|
||||
// dto.setXyywjUrl(docFile.getUrl());
|
||||
dto.setXyywjUrl("http://172.16.46.63:30002/yudao/20251204/%E6%B5%8B%E8%AF%95pdf_1764818842846.pdf?response-cache-control=no-cache%2C%20no-store%2C%20must-revalidate&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20251209T093343Z&X-Amz-SignedHeaders=host&X-Amz-Credential=EKplIEnbNgfYBAZbEJNa%2F20251209%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Expires=86400&X-Amz-Signature=37d63249667ea855f9a51bdf47bbb044d5860c302721f52fff2ba644985bae4c");
|
||||
dto.setYwxtdjbh(sequenceUtil.genCode(sequenceKey));
|
||||
return iWorkIntegrationApi.createWorkflow(dto);
|
||||
}
|
||||
|
||||
/*
|
||||
* 生成新版pdf文件
|
||||
* 在reportDocumentFile创建新pdf文件
|
||||
* */
|
||||
public ReportDocumentFileDO generatePdf(ReportDocumentMainDO mainDO) throws IOException {
|
||||
String pageFlag = "1"; //分页处理
|
||||
Long typeId = mainDO.getReportDocumentTypeId();
|
||||
ReportDocumentTypeDO typeDO = reportDocumentTypeService.getReportDocumentType(typeId);
|
||||
DataTemplateDO templateDO = dataTemplateService.getDataTemplate(mainDO.getDataTemplateId());
|
||||
CommonResult<JSONArray> result = reportDocumentDataService.assembleDynamicData(mainDO, typeDO, pageFlag);
|
||||
JSONArray data = result.getData();
|
||||
String templateContent = templateDO.getFormContent();
|
||||
JSONObject templateData = new JSONObject();
|
||||
JSONArray tableList = data.getJSONArray(0);
|
||||
templateData.put("headerData", tableList.getJSONObject(0).clone());
|
||||
templateData.put("tableList", tableList);
|
||||
templateData.put("formData", mainDO.getFormData());
|
||||
templateData.put("signatureData", mainDO.getDocumentSignature());
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("Template", templateContent);
|
||||
bodyJson.put("Data", templateData.toJSONString());
|
||||
String bodyStr = bodyJson.toJSONString();
|
||||
log.info("html2pdf body: " + bodyStr);
|
||||
log.info("html2pdf--start at {}", LocalDateTime.now());
|
||||
HttpResponse response = HttpUtil.createPost(html2pdfAddr)
|
||||
.body(bodyStr)
|
||||
.timeout(15000)
|
||||
.execute();
|
||||
log.info("html2pdf--end at {}", LocalDateTime.now());
|
||||
InputStream inputStream = response.bodyStream(); // 关键:返回原始 InputStream
|
||||
|
||||
//尝试从响应头中提取文件名
|
||||
String contentDisposition = response.header("Content-Disposition");
|
||||
String defaultName = "检测报告.pdf";
|
||||
String filename = extractFilename(contentDisposition).orElse(defaultName);
|
||||
//inputStream转byte[]
|
||||
byte[] fileBytes = IOUtils.toByteArray(inputStream);
|
||||
|
||||
//上传到文件服务
|
||||
FileCreateReqDTO fileCreateReqDTO = new FileCreateReqDTO();
|
||||
fileCreateReqDTO.setName(filename);
|
||||
fileCreateReqDTO.setDirectory(null);
|
||||
fileCreateReqDTO.setType(null);
|
||||
fileCreateReqDTO.setContent(fileBytes);
|
||||
CommonResult<FileRespDTO> fileResult = fileApi.createFileWithReturn(fileCreateReqDTO);
|
||||
if (fileResult == null || !fileResult.isSuccess() || fileResult.getData() == null) {
|
||||
throw new ServiceException(REPORT_DOCUMENT_FILE_NOT_EXISTS.getCode(), "通过文件服务创建附件失败: " + Optional.ofNullable(fileResult).map(CommonResult::getMsg).orElse("未知错误"));
|
||||
}
|
||||
FileRespDTO fileRespDTO = fileResult.getData();
|
||||
//写入ReportDocumentFile
|
||||
ReportDocumentFileSaveReqVO fileSaveReqVO = new ReportDocumentFileSaveReqVO();
|
||||
fileSaveReqVO.setMainId(mainDO.getId());
|
||||
fileSaveReqVO.setFileId(fileRespDTO.getId());
|
||||
fileSaveReqVO.setName(filename);
|
||||
fileSaveReqVO.setPath(fileRespDTO.getDirectory());
|
||||
fileSaveReqVO.setUrl(fileRespDTO.getUrl());
|
||||
fileSaveReqVO.setVersion(mainDO.getDocumentVersion());
|
||||
reportDocumentFileService.createReportDocumentFile(fileSaveReqVO);
|
||||
return BeanUtils.toBean(fileRespDTO, ReportDocumentFileDO.class);
|
||||
}
|
||||
|
||||
private Optional<String> extractFilename(String contentDisposition) {
|
||||
if (contentDisposition != null && contentDisposition.contains("filename=")) {
|
||||
String filename = contentDisposition.substring(contentDisposition.indexOf("filename=") + 9);
|
||||
filename = filename.replaceAll("\"", "").trim();
|
||||
return Optional.of(filename);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
// private String encodeFilename(String filename) {
|
||||
// try {
|
||||
// return URLEncoder.encode(filename, StandardCharsets.UTF_8.toString())
|
||||
// .replaceAll("\\+", "%20");
|
||||
// } catch (Exception e) {
|
||||
// return "download.bin";
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface ReportDocumentDataService {
|
||||
|
||||
CommonResult<List<JSONObject>> assembleDynamicData(ReportDocumentMainDO mainData, ReportDocumentTypeDO reportConfig);
|
||||
CommonResult<JSONArray> assembleDynamicData(ReportDocumentMainDO mainData, ReportDocumentTypeDO reportConfig, String pageFlag);
|
||||
|
||||
CommonResult<List<ReportDocumentDataDO>> listByMainDataId(Long mainDataId);
|
||||
CommonResult<Long> countMainDataId(Long mainDataId);
|
||||
|
||||
@@ -27,6 +27,7 @@ import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.e
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.REPORT_DOCUMENT_DATA_NOT_EXISTS;
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.REPORT_DOCUMENT_TYPE_NOT_EXISTS;
|
||||
import static com.zt.plat.module.qms.enums.QmsCommonConstant.FIELD_DYNAMIC;
|
||||
import static com.zt.plat.module.qms.enums.QmsCommonConstant.FIELD_CALCULATED;
|
||||
import static com.zt.plat.module.qms.enums.QmsCommonConstant.FIELD_FIXED;
|
||||
|
||||
/**
|
||||
@@ -43,10 +44,13 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
private final String colPrefix = "col";
|
||||
private final String sampleCodeKey = "SMP_CD";
|
||||
private final String sampleNameKey = "SMP_NAME";
|
||||
private final String name_code_merge = "merge";
|
||||
private final String name_code_name = "name";
|
||||
private final String name_code_code = "code";
|
||||
private final String name_code_split = "split";
|
||||
private final String sampleNameAndCodeKey = "SMP_NAME_CD";
|
||||
private final String entrustSampleNameKey = "ENTT_SMP_NAME";
|
||||
private final String entrustSampleCodeKey = "ENTT_SMP_CD";
|
||||
private final String entrustSampleNameCodeKey = "ENTT_SMP_NAME_CD";
|
||||
private final String rowTypeKey = "rowType"; //行类型
|
||||
private final String rowTypeTitle = "title"; //行类型-标题
|
||||
private final String rowTypeLimit = "limit"; //行类型-检出限
|
||||
private final String rangeKey = "minLimitValue";
|
||||
private final String emptyText = "以下为空白";
|
||||
|
||||
@@ -55,10 +59,16 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
* 组装动态报表数据
|
||||
* */
|
||||
@Override
|
||||
public CommonResult<List<JSONObject>> assembleDynamicData(ReportDocumentMainDO mainData, ReportDocumentTypeDO typeDO) {
|
||||
public CommonResult<JSONArray> assembleDynamicData(ReportDocumentMainDO mainData, ReportDocumentTypeDO typeDO, String pageFlag) {
|
||||
if(typeDO == null || typeDO.getConfigReportTypeId() == null)
|
||||
return CommonResult.error(REPORT_DOCUMENT_TYPE_NOT_EXISTS.getCode(), "报告配置为空,或未配置报表类型,请联系管理员处理!");
|
||||
String customConfig = typeDO.getCustomConfig();
|
||||
JSONObject configJson = JSONObject.parseObject(customConfig);
|
||||
String verticalFlag = configJson.getString("verticalFlag");
|
||||
String maxRowCountStr = configJson.getString("maxRowCount"); //最大行数
|
||||
Integer maxRowCount = 3;
|
||||
if(!ObjectUtils.isEmpty(maxRowCountStr))
|
||||
maxRowCount = Integer.parseInt(maxRowCountStr);
|
||||
//查询报表字段配置
|
||||
ConfigReportFieldPageReqVO fieldParam = new ConfigReportFieldPageReqVO();
|
||||
fieldParam.setConfigReportTypeId(typeDO.getConfigReportTypeId());
|
||||
@@ -67,38 +77,167 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
if(fieldListAll.isEmpty())
|
||||
return CommonResult.error(REPORT_DOCUMENT_TYPE_NOT_EXISTS.getCode(), "未配置报表字段,请联系管理员处理!");
|
||||
List<ReportDocumentDataDO> dataList = listByMainDataId(mainData.getId()).getData();
|
||||
//处理字段,提取有数据的字段
|
||||
List<ConfigReportFieldDO> fieldList = new ArrayList<>();
|
||||
List<String> hasFields = new ArrayList<>();
|
||||
for(ConfigReportFieldDO fieldDO : fieldListAll){
|
||||
String field = fieldDO.getField();
|
||||
String fieldName = fieldDO.getFieldName();
|
||||
String fieldType = fieldDO.getFieldType();
|
||||
//先处理固定列
|
||||
if(FIELD_FIXED.equals(fieldType)){
|
||||
if(!hasFields.contains( field)){
|
||||
fieldList.add(fieldDO);
|
||||
hasFields.add(field);
|
||||
|
||||
//拆分dataList,按样品分类key拆分
|
||||
List<List<ReportDocumentDataDO>> dataListGroup = new ArrayList<>();
|
||||
String[] sampleTypeKeys = new String[]{"inspectionAnalysisSample", "comprehensiveInspectionSample"}; //商检分析样、商检综合样
|
||||
for(String sampleTypeKey : sampleTypeKeys){
|
||||
List<ReportDocumentDataDO> dataListByKey = new ArrayList<>();
|
||||
for(ReportDocumentDataDO dataDO: dataList){
|
||||
if(sampleTypeKey.equals(dataDO.getSampleTypeKey())){
|
||||
dataListByKey.add(dataDO);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for(ReportDocumentDataDO dataDO : dataList){
|
||||
String documentContent = dataDO.getDocumentContent();
|
||||
JSONObject dataJson = JSONObject.parseObject(documentContent);
|
||||
if(dataJson == null)
|
||||
continue;
|
||||
if(dataJson.containsKey(field)){
|
||||
if(!hasFields.contains( fieldName)){
|
||||
if(!dataListByKey.isEmpty())
|
||||
dataListGroup.add(dataListByKey);
|
||||
}
|
||||
if(dataListGroup.isEmpty())
|
||||
dataListGroup.add(dataList);
|
||||
JSONArray rowList = new JSONArray();
|
||||
for(int i = 0; i < dataListGroup.size(); i++){
|
||||
List<ReportDocumentDataDO> dataListByKey = dataListGroup.get(i);
|
||||
//处理字段,提取有数据的字段
|
||||
List<ConfigReportFieldDO> fieldList = new ArrayList<>();
|
||||
List<String> hasFields = new ArrayList<>();
|
||||
for(ConfigReportFieldDO fieldDO : fieldListAll){
|
||||
String field = fieldDO.getField();
|
||||
String fieldName = fieldDO.getFieldName();
|
||||
String fieldType = fieldDO.getFieldType();
|
||||
//先处理固定列
|
||||
if(FIELD_FIXED.equals(fieldType)){
|
||||
if(!hasFields.contains( field)){
|
||||
fieldList.add(fieldDO);
|
||||
hasFields.add(fieldName);
|
||||
hasFields.add(field);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for(ReportDocumentDataDO dataDO : dataListByKey){
|
||||
String documentContent = dataDO.getDocumentContent();
|
||||
JSONObject dataJson = JSONObject.parseObject(documentContent);
|
||||
if(dataJson == null)
|
||||
continue;
|
||||
if(dataJson.containsKey(field)){
|
||||
if(!hasFields.contains( fieldName)){
|
||||
fieldList.add(fieldDO);
|
||||
hasFields.add(fieldName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assembleStep1(rowList, fieldList, dataListByKey, customConfig, i); //处理后的组数对象
|
||||
}
|
||||
if(!"1".equals(verticalFlag)){
|
||||
//处理空数据,填充/
|
||||
rowList = assembleEmpty(configJson, rowList);
|
||||
|
||||
//处理数据分页
|
||||
if("1".equals(pageFlag)){
|
||||
JSONArray pageRowList = assemblePageRowList(rowList, configJson);
|
||||
return CommonResult.success(pageRowList);
|
||||
}
|
||||
}
|
||||
//以下为空白
|
||||
if(rowList.size() < maxRowCount){
|
||||
JSONObject t = new JSONObject();
|
||||
t.put(colPrefix + "01", emptyText);
|
||||
rowList.add(t.clone());
|
||||
}
|
||||
while(rowList.size() < maxRowCount){
|
||||
JSONObject t = new JSONObject();
|
||||
t.put(colPrefix + "01", " ");
|
||||
rowList.add(t.clone());
|
||||
}
|
||||
return CommonResult.success(rowList);
|
||||
}
|
||||
|
||||
/*
|
||||
* 处理分页
|
||||
*
|
||||
* */
|
||||
private JSONArray assemblePageRowList(JSONArray rowList, JSONObject configJson){
|
||||
JSONArray pageRowList = new JSONArray();
|
||||
Integer maxRowCount = 20;
|
||||
String maxRowCountStr = configJson.getString("maxRowCount"); //最大行数
|
||||
if(!ObjectUtils.isEmpty(maxRowCountStr)) maxRowCount = Integer.parseInt(maxRowCountStr);
|
||||
int rowLength = rowList.size();
|
||||
if(rowLength <= maxRowCount){
|
||||
pageRowList.add(rowList);
|
||||
return pageRowList;
|
||||
}
|
||||
JSONArray remainingRows = new JSONArray();
|
||||
remainingRows.addAll(rowList);
|
||||
while(remainingRows.size() > 0){
|
||||
JSONArray pageRow = new JSONArray();
|
||||
for(int i = 0; i < maxRowCount ; i++){
|
||||
if(remainingRows.isEmpty())
|
||||
break;
|
||||
pageRow.add(remainingRows.getJSONObject(0));
|
||||
remainingRows.remove(0);
|
||||
}
|
||||
/*
|
||||
在每页开头插入“标题行”
|
||||
如果最后一行是标题,直接移到下一页;如果不是,往上寻找最近的“标题行”
|
||||
*/
|
||||
JSONObject lastTitleRow = pageRow.getJSONObject(pageRow.size() - 1);
|
||||
String rowType = lastTitleRow.getString(rowTypeKey);
|
||||
if(rowTypeTitle.equals(rowType)){
|
||||
//如果最后一行是“标题行”,移除
|
||||
pageRow.remove(pageRow.size() - 1);
|
||||
}else {
|
||||
for(int i = pageRow.size() - 1; i >= 0; i--){
|
||||
JSONObject t = pageRow.getJSONObject(i);
|
||||
rowType = t.getString(rowTypeKey);
|
||||
if(rowTypeTitle.equals(rowType)){
|
||||
lastTitleRow = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!remainingRows.isEmpty()){
|
||||
JSONObject firstRemainingRow = remainingRows.getJSONObject(0);
|
||||
if(!rowTypeTitle.equals(firstRemainingRow.getString(rowTypeKey))){
|
||||
remainingRows.add(0, lastTitleRow);
|
||||
}
|
||||
}
|
||||
pageRowList.add(pageRow);
|
||||
}
|
||||
|
||||
//组装数据
|
||||
List<JSONObject> step1Arr = assembleStep1(fieldList, dataList, customConfig); //处理后的组数对象
|
||||
return CommonResult.success(step1Arr);
|
||||
//在最后一页插入“以下为空”
|
||||
JSONArray pageRow = pageRowList.getJSONArray(pageRowList.size() - 1);
|
||||
if(pageRow.size() < maxRowCount){
|
||||
JSONObject t = new JSONObject();
|
||||
t.put(colPrefix + "01", emptyText);
|
||||
pageRow.add(t.clone());
|
||||
}
|
||||
return pageRowList;
|
||||
}
|
||||
|
||||
private JSONArray assembleEmpty(JSONObject configJson, JSONArray rowList){
|
||||
JSONArray fixedCol = configJson.getJSONArray("fixedCol"); //固定列,举例:["SMP_NAME", "SMP_CD"]
|
||||
if(fixedCol == null) fixedCol = new JSONArray();
|
||||
JSONArray fixedColRight = configJson.getJSONArray("fixedColRight"); //右侧固定列
|
||||
if(fixedColRight == null) fixedColRight = new JSONArray();
|
||||
String dynamicColCountStr = configJson.getString("dynamicColCount"); //动态列(检测项)数量
|
||||
Integer dynamicColCount = 0;
|
||||
Integer fixedColCount_left = 0;
|
||||
Integer fixedColCount_right = 0;
|
||||
if(!ObjectUtils.isEmpty(dynamicColCountStr)) dynamicColCount = Integer.parseInt(dynamicColCountStr);
|
||||
fixedColCount_left = fixedCol.size();
|
||||
fixedColCount_right = fixedColRight.size();
|
||||
|
||||
for(int i = 0; i < rowList.size(); i++){
|
||||
JSONObject row = rowList.getJSONObject(i);
|
||||
if(" ".equals(row.getString(colPrefix + "01")))
|
||||
continue;
|
||||
int colIndex = 1;
|
||||
while(colIndex <= dynamicColCount){
|
||||
String colKey = colPrefix + parseNumToString(colIndex + fixedColCount_left, 2);
|
||||
if(!row.containsKey(colKey))
|
||||
row.put(colKey, "/");
|
||||
colIndex ++;
|
||||
}
|
||||
}
|
||||
return rowList;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,130 +245,193 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
* @param fieldList 要显示的字段列表。固定字段在最前
|
||||
* @param customConfig 报告配置项
|
||||
* */
|
||||
private List<JSONObject> assembleStep1(List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, String customConfig){
|
||||
private JSONArray assembleStep1(JSONArray rowList, List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, String customConfig, int groupIndex){
|
||||
if(dataList.isEmpty())
|
||||
return new ArrayList<>();
|
||||
return new JSONArray();
|
||||
JSONObject jsonObject = JSONObject.parseObject(customConfig);
|
||||
Integer dynamicColCount = 3;
|
||||
Integer fixedColCount = 0;
|
||||
Integer maxRowCount = 3;
|
||||
Integer fixedColCount_left = 0;
|
||||
|
||||
String dynamicColCountStr = jsonObject.getString("dynamicColCount"); //动态列(检测项)数量
|
||||
// String fixedColCountStr = jsonObject.getString("fixedColCount"); //固定列(样品名称、样品编号等)数量
|
||||
JSONArray fixedCol = jsonObject.getJSONArray("fixedCol"); //固定列,举例:["sampleName", "sampleCode"]
|
||||
JSONArray fixedColShow = jsonObject.getJSONArray("fixedColShow"); //固定列,举例:["产品名称", "编 号"]
|
||||
String maxRowCountStr = jsonObject.getString("maxRowCount"); //最大行数
|
||||
// String nameCodeType = jsonObject.getString("nameCodeType"); //名称、编号处理方式:merge-合并, name-只显示名称, code-只显示编号, split-2列分开显示
|
||||
JSONArray fixedCol = jsonObject.getJSONArray("fixedCol"); //固定列,举例:["SMP_NAME", "SMP_CD"]
|
||||
if(fixedCol == null) fixedCol = new JSONArray();
|
||||
JSONArray fixedColRight = jsonObject.getJSONArray("fixedColRight"); //右侧固定列
|
||||
if(fixedColRight == null) fixedColRight = new JSONArray();
|
||||
String hasRemark = jsonObject.getString("hasRemark"); //是否有备注
|
||||
String hasRange = jsonObject.getString("hasRange"); //是否有检出限
|
||||
String verticalFlag = jsonObject.getString("verticalFlag"); //vertical-纵表, 否则为横表
|
||||
String fixedFields = jsonObject.getString("fixedFields"); //固定检测项。如果固定检测项,则以检测项作为数据Key
|
||||
if("1".equals(verticalFlag)){ //纵表
|
||||
return assembleVerticalData(fieldList, dataList, customConfig);
|
||||
return assembleVerticalData(rowList, fieldList, dataList, customConfig);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(fixedFields)){ //固定列
|
||||
return assembleFixedFieldsData(fieldList, dataList, customConfig);
|
||||
return assembleFixedFieldsData(rowList, fieldList, dataList, customConfig);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(dynamicColCountStr)) dynamicColCount = Integer.parseInt(dynamicColCountStr);
|
||||
if(fixedCol != null) fixedColCount = fixedCol.size();
|
||||
|
||||
if(!ObjectUtils.isEmpty(maxRowCountStr)) maxRowCount = Integer.parseInt(maxRowCountStr);
|
||||
Integer eleCount = 0; //元素数量,即元素列总数
|
||||
|
||||
for(ConfigReportFieldDO fieldDO : fieldList){
|
||||
String fieldType = fieldDO.getFieldType();
|
||||
if(FIELD_DYNAMIC.equals(fieldType))
|
||||
eleCount ++;
|
||||
}
|
||||
Integer rowCountOneSample = eleCount / dynamicColCount + (eleCount % dynamicColCount == 0 ? 0 : 1); //每个样品要占的行数
|
||||
Integer colCountOneSample = fixedColCount + dynamicColCount; //每个样品要占的列数
|
||||
Integer dataLength = dataList.size();
|
||||
Integer emptyRowCount = dataLength < maxRowCount ? 1 : 0; //空行数
|
||||
// Integer allRowCount = 1 + dataLength + emptyRowCount + 1; //标题 + 样品数 + 空行
|
||||
|
||||
if("1".equals(hasRange))
|
||||
emptyRowCount ++;
|
||||
|
||||
// if(rowCountOneSample > 1){
|
||||
// allRowCount = (1 + dataLength + emptyRowCount + 9) * rowCountOneSample + emptyRowCount; //(标题 + 样品数 + 空行) * 但样品行数 + 末尾行
|
||||
// }
|
||||
List<JSONObject> rowList = new ArrayList<>();
|
||||
for(int i = 0; i < maxRowCount; i++){
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("col01", " ");
|
||||
rowList.add( row);
|
||||
}
|
||||
|
||||
|
||||
fixedColCount_left = fixedCol.size();
|
||||
Integer colCountOneSample = fixedColCount_left + dynamicColCount; //每个样品要占的列数
|
||||
//=============处理表头============
|
||||
JSONObject t = new JSONObject();
|
||||
JSONObject r = new JSONObject(); //检出限
|
||||
int rowAssist = 1;
|
||||
int colIndex = fixedColCount + 1;
|
||||
boolean lastObjFlag = true;
|
||||
//取第一行数据,用来处理检出限
|
||||
JSONObject firstData = new JSONObject(); //取第一行数据,用于处理检出限
|
||||
if(dataLength > 0)
|
||||
firstData = JSONObject.parseObject(dataList.get(0).getDocumentContent());
|
||||
JSONObject firstData = JSONObject.parseObject(dataList.get(0).getDocumentContent()); //取第一行数据,用于处理检出限
|
||||
if("1".equals(hasRemark)){
|
||||
//在最后一列增加备注
|
||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), "备注");
|
||||
}
|
||||
for(ConfigReportFieldDO fieldDO : fieldList){
|
||||
//取fieldList的动态字段,并分组
|
||||
List<List<ConfigReportFieldDO>> dynamicFieldListGroup = new ArrayList<>();
|
||||
int fieldIndex = 1;
|
||||
List<ConfigReportFieldDO> list = new ArrayList<>();
|
||||
for(int i = 0; i < fieldList.size(); i++){
|
||||
ConfigReportFieldDO fieldDO = fieldList.get(i);
|
||||
String fieldType = fieldDO.getFieldType();
|
||||
String field = fieldDO.getField();
|
||||
if(FIELD_FIXED.equals(fieldType)){ //这里只处理动态列。固定列在 addTitleToRowList 处理
|
||||
if(FIELD_FIXED.equals(fieldType))
|
||||
continue;
|
||||
list.add(fieldDO);
|
||||
if(fieldIndex % dynamicColCount == 0){
|
||||
dynamicFieldListGroup.add(list);
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
String fieldName = fieldDO.getFieldName();
|
||||
String colKey = parseNumToString(colIndex, 2);
|
||||
t.put(colPrefix + colKey, fieldName);
|
||||
//查询当前字段的检出限
|
||||
JSONObject fieldObj = firstData.getJSONObject( field);
|
||||
String rangeVal = "";
|
||||
if(fieldObj != null){
|
||||
rangeVal = fieldObj.getString(rangeKey);
|
||||
}
|
||||
r.put(colPrefix + colKey, rangeVal);
|
||||
r.put(colPrefix + "01", "方法检出限");
|
||||
lastObjFlag = true;
|
||||
if(colIndex % colCountOneSample == 0){
|
||||
addTitleToRowList(fixedCol, rowAssist, t, dataLength, emptyRowCount, rowList, fieldList);
|
||||
if("1".equals(hasRange))
|
||||
addRangeToRowList(rowAssist, r, dataLength, emptyRowCount, rowList);
|
||||
t = new JSONObject();
|
||||
r = new JSONObject();
|
||||
|
||||
if("1".equals(hasRemark)){
|
||||
//在最后一列增加备注
|
||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), "备注");
|
||||
fieldIndex ++;
|
||||
}
|
||||
if(!list.isEmpty())
|
||||
dynamicFieldListGroup.add(list);
|
||||
int colIndex = 1;
|
||||
for(int i = 0; i < dynamicFieldListGroup.size(); i++){
|
||||
List<ConfigReportFieldDO> dynamicFieldList = dynamicFieldListGroup.get(i);
|
||||
t = new JSONObject();
|
||||
t.put(rowTypeKey, rowTypeTitle);
|
||||
r = new JSONObject();
|
||||
r.put(rowTypeKey, rowTypeLimit);
|
||||
colIndex = fixedColCount_left + 1; //第二组以后,从固定列数开始
|
||||
for(ConfigReportFieldDO fieldDO : dynamicFieldList) {
|
||||
String field = fieldDO.getField();
|
||||
String fieldName = fieldDO.getFieldName();
|
||||
String colKey = parseNumToString(colIndex, 2);
|
||||
t.put(colPrefix + colKey, fieldName);
|
||||
//查询当前字段的检出限
|
||||
JSONObject fieldObj = firstData.getJSONObject(field);
|
||||
String rangeVal = "";
|
||||
if (fieldObj != null) {
|
||||
rangeVal = fieldObj.getString(rangeKey);
|
||||
}
|
||||
rowAssist++;
|
||||
colIndex = fixedColCount + 1; //第二组以后,从固定列数开始
|
||||
lastObjFlag = false;
|
||||
continue;
|
||||
r.put(colPrefix + colKey, rangeVal);
|
||||
r.put(colPrefix + "01", "方法检出限");
|
||||
colIndex ++;
|
||||
}
|
||||
//处理备注列
|
||||
if(i == 0 && groupIndex == 0 && "1".equals(hasRemark)){
|
||||
//在最后一列增加备注
|
||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), "备注");
|
||||
}
|
||||
if(i > 0 || groupIndex > 0){ //插入空行
|
||||
JSONObject emptyRow = new JSONObject();
|
||||
emptyRow.put(colPrefix + "01", " ");
|
||||
rowList.add(emptyRow);
|
||||
}
|
||||
addTitleToRowList(fixedCol, fixedColRight, dynamicColCount, t, rowList, fieldList);
|
||||
//插入样品数据
|
||||
addDataToRowList(fixedCol, fixedColRight, dynamicFieldList, dataList, rowList, fixedColCount_left, dynamicColCount, hasRemark);
|
||||
//检出限
|
||||
if("1".equals(hasRange)){
|
||||
rowList.add(r);
|
||||
}
|
||||
colIndex++;
|
||||
}
|
||||
if(lastObjFlag){
|
||||
addTitleToRowList(fixedCol, rowAssist, t, dataLength, emptyRowCount, rowList, fieldList);
|
||||
if("1".equals(hasRange))
|
||||
addRangeToRowList(rowAssist, r, dataLength, emptyRowCount, rowList);
|
||||
}
|
||||
return rowList;
|
||||
}
|
||||
|
||||
//=============处理数据============
|
||||
int dataIndex = 1;
|
||||
/**
|
||||
* @param
|
||||
*
|
||||
* */
|
||||
private void addTitleToRowList(JSONArray fixedCol, JSONArray fixedColRight, Integer dynamicColCount, JSONObject t, JSONArray rowList, List<ConfigReportFieldDO> fieldList){
|
||||
//处理固定列
|
||||
int index = 1;
|
||||
String colKey = "";
|
||||
//固定列-左
|
||||
for(int i=0;i<fixedCol.size();i++) {
|
||||
String col = fixedCol.getString(i);
|
||||
for(ConfigReportFieldDO fieldDO : fieldList) {
|
||||
colKey = "";
|
||||
String fieldName = fieldDO.getFieldName();
|
||||
String fieldType = fieldDO.getFieldType();
|
||||
String field = fieldDO.getField();
|
||||
if (FIELD_DYNAMIC.equals(fieldType) || FIELD_CALCULATED.equals(fieldType))
|
||||
continue;
|
||||
if(sampleNameAndCodeKey.equals( col) && sampleNameAndCodeKey.equals(field)
|
||||
|| sampleNameKey.equals( col) && sampleNameKey.equals(field)
|
||||
|| sampleCodeKey.equals( col) && sampleCodeKey.equals(field)
|
||||
|| entrustSampleNameKey.equals( col) && entrustSampleNameKey.equals(field)
|
||||
|| entrustSampleCodeKey.equals( col) && entrustSampleCodeKey.equals(field)
|
||||
|| entrustSampleNameCodeKey.equals( col) && entrustSampleNameCodeKey.equals(field)){
|
||||
colKey = parseNumToString(index, 2);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(colKey)){
|
||||
t.put(colPrefix + colKey, fieldName);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//固定列-右
|
||||
index = fixedCol.size() + dynamicColCount + 1;
|
||||
for(int i=0;i<fixedColRight.size();i++) {
|
||||
String col = fixedColRight.getString(i);
|
||||
for(ConfigReportFieldDO fieldDO : fieldList) {
|
||||
colKey = "";
|
||||
String fieldName = fieldDO.getFieldName();
|
||||
String fieldType = fieldDO.getFieldType();
|
||||
String field = fieldDO.getField();
|
||||
if (FIELD_DYNAMIC.equals(fieldType) || FIELD_CALCULATED.equals(fieldType))
|
||||
continue;
|
||||
if(sampleNameAndCodeKey.equals( col) && sampleNameAndCodeKey.equals(field)
|
||||
|| sampleNameKey.equals( col) && sampleNameKey.equals(field)
|
||||
|| sampleCodeKey.equals( col) && sampleCodeKey.equals(field)
|
||||
|| entrustSampleNameKey.equals( col) && entrustSampleNameKey.equals(field)
|
||||
|| entrustSampleCodeKey.equals( col) && entrustSampleCodeKey.equals(field)
|
||||
|| entrustSampleNameCodeKey.equals( col) && entrustSampleNameCodeKey.equals(field)){
|
||||
colKey = parseNumToString(index, 2);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(colKey)){
|
||||
t.put(colPrefix + colKey, fieldName);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
rowList.add(t.clone());
|
||||
}
|
||||
|
||||
//添加行数据
|
||||
private void addDataToRowList(JSONArray fixedCol, JSONArray fixedColRight, List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, JSONArray rowList, int fixedColCount, int dynamicColCount, String hasRemark){
|
||||
int colIndex = 0;
|
||||
JSONObject t = new JSONObject();
|
||||
for(ReportDocumentDataDO dataDO : dataList){
|
||||
String documentContent = dataDO.getDocumentContent();
|
||||
String externalContent = dataDO.getExternalContent();
|
||||
JSONObject s = JSONObject.parseObject(documentContent);
|
||||
JSONObject e = new JSONObject();
|
||||
if(!ObjectUtils.isEmpty(externalContent)){
|
||||
e = JSONObject.parseObject(externalContent);
|
||||
//判断样品是否有值,若无值则跳过
|
||||
boolean hasValue = false;
|
||||
for(ConfigReportFieldDO fieldDO : fieldList) {
|
||||
String fieldType = fieldDO.getFieldType();
|
||||
if (FIELD_FIXED.equals(fieldType)) //这里只处理动态列。固定列在 addDataToRowList 处理
|
||||
continue;
|
||||
String field = fieldDO.getField();
|
||||
JSONObject fieldObj = s.getJSONObject(field);
|
||||
String fieldValue = "";
|
||||
if (fieldObj != null)
|
||||
fieldValue = fieldObj.getString("fieldValue");
|
||||
if(!ObjectUtils.isEmpty(fieldValue))
|
||||
hasValue = true;
|
||||
}
|
||||
if(!hasValue)
|
||||
continue;
|
||||
JSONObject e = new JSONObject();
|
||||
if(!ObjectUtils.isEmpty(externalContent))
|
||||
e = JSONObject.parseObject(externalContent);
|
||||
String remark = e.getString("remark");
|
||||
colIndex = fixedColCount + 1;
|
||||
rowAssist = 1;
|
||||
t = new JSONObject();
|
||||
int colCountOneSample = fixedColCount + dynamicColCount;
|
||||
if("1".equals(hasRemark)){
|
||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), remark);
|
||||
}
|
||||
@@ -249,157 +451,63 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(mathSymbol) && !"=".equals(mathSymbol))
|
||||
fieldValue = mathSymbol + fieldValue;
|
||||
if(ObjectUtils.isEmpty(fieldValue))
|
||||
fieldValue = "/";
|
||||
t.put(colPrefix + colKey, fieldValue);
|
||||
lastObjFlag = true;
|
||||
if(colIndex % colCountOneSample == 0){
|
||||
addFixedDataToRowList(fixedCol, dataDO, rowAssist, t, dataLength, emptyRowCount, dataIndex, rowList, fieldList);
|
||||
t = new JSONObject();
|
||||
if("1".equals(hasRemark)){
|
||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), remark);
|
||||
}
|
||||
rowAssist++;
|
||||
colIndex = fixedColCount + 1; //第二组以后,从固定列数开始
|
||||
lastObjFlag = false;
|
||||
continue;
|
||||
}
|
||||
colIndex++;
|
||||
}
|
||||
if(lastObjFlag){
|
||||
addFixedDataToRowList(fixedCol, dataDO, rowAssist, t, dataLength, emptyRowCount, dataIndex, rowList, fieldList);
|
||||
}
|
||||
dataIndex ++;
|
||||
}
|
||||
|
||||
//==============以下为空白=================
|
||||
//实际使用行数小于总行数,显示“”以下为空白“
|
||||
if(dataLength < maxRowCount){
|
||||
String colKey = colPrefix + "01";
|
||||
t = new JSONObject();
|
||||
t.put(colKey, emptyText);
|
||||
int rowIndex = (dataLength + emptyRowCount) * (rowAssist) + 2;
|
||||
if(rowAssist == 1)
|
||||
rowIndex = dataLength + emptyRowCount;
|
||||
if(rowCountOneSample == 1)
|
||||
rowIndex = dataLength + 2;
|
||||
rowList.set(rowIndex, t.clone());
|
||||
}
|
||||
//前面的计数是从1开始,移除第一个元素
|
||||
if(!rowList.isEmpty())
|
||||
rowList.remove(0);
|
||||
return rowList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param
|
||||
*
|
||||
* */
|
||||
private void addTitleToRowList(JSONArray fixedCol, Integer rowAssist, JSONObject t, Integer dataLength, Integer emptyRowCount, List<JSONObject> rowList, List<ConfigReportFieldDO> fieldList){
|
||||
int rowIndex = (1 + dataLength + emptyRowCount) * (rowAssist - 1) + 1; //(标题 + 数据行 + 空行)
|
||||
//处理固定列
|
||||
int index = 1;
|
||||
String colKey = "";
|
||||
for(int i=0;i<fixedCol.size();i++) {
|
||||
String col = fixedCol.getString(i);
|
||||
for(ConfigReportFieldDO fieldDO : fieldList) {
|
||||
String fieldName = fieldDO.getFieldName();
|
||||
String fieldType = fieldDO.getFieldType();
|
||||
String field = fieldDO.getField();
|
||||
if (FIELD_DYNAMIC.equals(fieldType))
|
||||
continue;
|
||||
if("sampleNameCode".equals( col) && "SMP_NAME_CD".equals(field)){
|
||||
// String sampleNameCode = "样品名称及编号";
|
||||
// String sampleNameCode = fieldName;
|
||||
colKey = parseNumToString(index, 2);
|
||||
t.put(colPrefix + colKey, fieldName);
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
if("sampleName".equals( col) && "SMP_NAME".equals(field)){
|
||||
colKey = parseNumToString(index, 2);
|
||||
t.put(colPrefix + colKey, fieldName);
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
if("sampleCode".equals( col) && "SMP_CD".equals(field)){
|
||||
colKey = parseNumToString(index, 2);
|
||||
t.put(colPrefix + colKey, fieldName);
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
rowList.set(rowIndex, t.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理检出限
|
||||
* 如果是
|
||||
* */
|
||||
private void addRangeToRowList(Integer rowAssist, JSONObject r, Integer dataLength, Integer emptyRowCount, List<JSONObject> rowList){
|
||||
int rowIndex = (dataLength + emptyRowCount + 1 ) * (rowAssist);
|
||||
rowList.set(rowIndex, r.clone());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加固定列的数据
|
||||
* */
|
||||
private void addFixedDataToRowList(JSONArray fixedCol, ReportDocumentDataDO dataDO, Integer rowAssist, JSONObject t, Integer dataLength, Integer emptyRowCount, Integer dataIndex, List<JSONObject> rowList, List<ConfigReportFieldDO> fieldList){
|
||||
int rowIndex = (1 + dataLength + emptyRowCount) * (rowAssist - 1) + dataIndex + 1; //(标题 + 数据行 + 空行)
|
||||
t.put("id", dataDO.getId());
|
||||
//处理固定列
|
||||
int index = 1;
|
||||
//处理固定列
|
||||
String colKey = "";
|
||||
if(fixedCol != null && !fixedCol.isEmpty()){
|
||||
t.put("id", dataDO.getId());
|
||||
//处理固定列-左
|
||||
int index = 1;
|
||||
String colKey = "";
|
||||
for(int i=0;i<fixedCol.size();i++){
|
||||
String col = fixedCol.getString(i);
|
||||
colKey = parseNumToString(index, 2);
|
||||
if("sampleName".equals(col)){
|
||||
if(sampleNameKey.equals(col)){
|
||||
t.put(colPrefix + colKey, dataDO.getSampleName());
|
||||
}
|
||||
else if("sampleCode".equals(col)){
|
||||
else if(sampleCodeKey.equals(col)){
|
||||
t.put(colPrefix + colKey, dataDO.getSampleCode());
|
||||
}
|
||||
else if("sampleNameCode".equals( col)){
|
||||
else if(sampleNameAndCodeKey.equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getSampleName() + " " + dataDO.getSampleCode());
|
||||
}else if(entrustSampleNameKey.equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getEntrustSampleName());
|
||||
}else if(entrustSampleCodeKey.equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getEntrustSampleCode());
|
||||
}else if(entrustSampleNameCodeKey.equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getEntrustSampleName() + " " + dataDO.getEntrustSampleCode());
|
||||
}
|
||||
index ++;
|
||||
}
|
||||
//处理固定列-右
|
||||
index = fixedColRight.size() + dynamicColCount + 1;
|
||||
for(int i=0;i<fixedColRight.size();i++){
|
||||
String col = fixedColRight.getString(i);
|
||||
colKey = parseNumToString(index, 2);
|
||||
if(sampleNameKey.equals(col)){
|
||||
t.put(colPrefix + colKey, dataDO.getSampleName());
|
||||
}
|
||||
else if(sampleCodeKey.equals(col)){
|
||||
t.put(colPrefix + colKey, dataDO.getSampleCode());
|
||||
}
|
||||
else if(sampleNameAndCodeKey.equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getSampleName() + " " + dataDO.getSampleCode());
|
||||
}else if(entrustSampleNameKey.equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getEntrustSampleName());
|
||||
}else if(entrustSampleCodeKey.equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getEntrustSampleCode());
|
||||
}else if(entrustSampleNameCodeKey.equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getEntrustSampleName() + " " + dataDO.getEntrustSampleCode());
|
||||
}
|
||||
index ++;
|
||||
}
|
||||
//添加入行数据
|
||||
rowList.add(t.clone());
|
||||
}
|
||||
// if(name_code_merge.equals(nameCodeType)){
|
||||
// String merge = dataDO.getSampleName() + " " + dataDO.getSampleCode();
|
||||
// t.put(colPrefix + colKey, merge);
|
||||
// rowList.set(rowIndex, t.clone());
|
||||
// return;
|
||||
// }
|
||||
// if(name_code_name.equals(nameCodeType)){
|
||||
// t.put(colPrefix + colKey, dataDO.getSampleName());
|
||||
// rowList.set(rowIndex, t.clone());
|
||||
// return;
|
||||
// }
|
||||
// if(name_code_code.equals(nameCodeType)){
|
||||
// t.put(colPrefix + colKey, dataDO.getSampleCode());
|
||||
// rowList.set(rowIndex, t.clone());
|
||||
// return;
|
||||
// }
|
||||
// for(ConfigReportFieldDO fieldDO : fieldList){
|
||||
// String fieldName = fieldDO.getFieldName();
|
||||
// String fieldType = fieldDO.getFieldType();
|
||||
// String field = fieldDO.getField();
|
||||
// if(FIELD_FIXED.equals(fieldType)){
|
||||
// colKey = parseNumToString(index, 2);
|
||||
// String val = "";
|
||||
// if(sampleNameKey.equals( field))
|
||||
// val = dataDO.getSampleName();
|
||||
// else if(sampleCodeKey.equals( field))
|
||||
// val = dataDO.getSampleCode();
|
||||
// t.put(colPrefix + colKey, val);
|
||||
// index++;
|
||||
// }
|
||||
// }
|
||||
rowList.set(rowIndex, t.clone());
|
||||
}
|
||||
|
||||
|
||||
private String parseNumToString(int num, int len){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0; i < len - String.valueOf(num).length(); i++){
|
||||
@@ -411,7 +519,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
/**
|
||||
* 组装固定检测项的数据,以检测项作为数据Key
|
||||
* */
|
||||
private List<JSONObject> assembleFixedFieldsData(List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, String customConfig){
|
||||
private JSONArray assembleFixedFieldsData(JSONArray rowList, List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, String customConfig){
|
||||
JSONObject jsonObject = JSONObject.parseObject(customConfig);
|
||||
|
||||
Integer maxRowCount = 3;
|
||||
@@ -421,15 +529,13 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
String fixedFields = jsonObject.getString("fixedFields"); //固定检测项。如果固定检测项,则以检测项作为数据Key
|
||||
JSONArray fixedFieldsArray = JSONArray.parseArray(fixedFields);
|
||||
if(!ObjectUtils.isEmpty(maxRowCountStr)) maxRowCount = Integer.parseInt(maxRowCountStr);
|
||||
|
||||
List<JSONObject> rowList = new ArrayList<>();
|
||||
for(int i = 0; i < maxRowCount; i++){
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("sampleNameCode", " ");
|
||||
row.put("sampleName", " ");
|
||||
row.put("sampleCode", " ");
|
||||
rowList.add( row);
|
||||
}
|
||||
// for(int i = 0; i < maxRowCount; i++){
|
||||
// JSONObject row = new JSONObject();
|
||||
// row.put("sampleNameCode", " ");
|
||||
// row.put("sampleName", " ");
|
||||
// row.put("sampleCode", " ");
|
||||
// rowList.add( row);
|
||||
// }
|
||||
for(ReportDocumentDataDO dataDO : dataList) {
|
||||
JSONObject t = new JSONObject();
|
||||
String documentContent = dataDO.getDocumentContent();
|
||||
@@ -476,6 +582,13 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
t.put("sampleCode", emptyText);
|
||||
rowList.add( t);
|
||||
}
|
||||
while(rowList.size() < maxRowCount){
|
||||
JSONObject t = new JSONObject();
|
||||
t.put("sampleNameCode", " ");
|
||||
t.put("sampleName", " ");
|
||||
t.put("sampleCode", " ");
|
||||
rowList.add( t);
|
||||
}
|
||||
return rowList;
|
||||
}
|
||||
|
||||
@@ -483,17 +596,15 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
* 组装纵表数据
|
||||
* 第1列固定为:元素; 第2列:方法检出限(%);第三列开始为各个样品
|
||||
* */
|
||||
private List<JSONObject> assembleVerticalData(List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, String customConfig){
|
||||
private JSONArray assembleVerticalData(JSONArray rowList, List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, String customConfig){
|
||||
JSONObject jsonObject = JSONObject.parseObject(customConfig);
|
||||
Integer dynamicColCount = 3;
|
||||
Integer fixedColCount = 2;
|
||||
Integer maxRowCount = 3;
|
||||
String dynamicColCountStr = jsonObject.getString("dynamicColCount"); //动态列(检测项)数量
|
||||
String fixedColCountStr = jsonObject.getString("fixedColCount"); //固定列(样品名称、样品编号等)数量
|
||||
String maxRowCountStr = jsonObject.getString("maxRowCount"); //最大行数
|
||||
String nameCodeType = jsonObject.getString("nameCodeType"); //名称、编号处理方式:merge-合并, name-只显示名称, code-只显示编号, split-2列分开显示
|
||||
Integer fixedColCount = 1;
|
||||
Integer maxRowCount = 20;
|
||||
String hasRemark = jsonObject.getString("hasRemark"); //是否有备注
|
||||
String hasRange = jsonObject.getString("hasRange"); //是否有检出限
|
||||
if("1".equals(hasRange))
|
||||
fixedColCount ++;
|
||||
//取数据第一行,用于处理方法检出限
|
||||
String content = "";
|
||||
if(!ObjectUtils.isEmpty(dataList))
|
||||
@@ -502,11 +613,14 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
if(!ObjectUtils.isEmpty(content)){
|
||||
firstData = JSONObject.parseObject(content);
|
||||
}
|
||||
List<JSONObject> rowList = new ArrayList<>();
|
||||
//处理第一行-样品编号
|
||||
int colIndex = fixedColCount + 1;
|
||||
int rowIndex = 1;
|
||||
JSONObject t = new JSONObject();
|
||||
t.put(colPrefix + "01", "元素");
|
||||
if("1".equals(hasRange)){
|
||||
t.put(colPrefix + "02", "方法检出限");
|
||||
}
|
||||
for(ReportDocumentDataDO dataDO : dataList){
|
||||
String colKey = parseNumToString(colIndex, 2);
|
||||
t.put(colPrefix + colKey, dataDO.getSampleCode());
|
||||
@@ -565,7 +679,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
public CommonResult<List<ReportDocumentDataDO>> listByMainDataId(Long mainDataId) {
|
||||
QueryWrapper<ReportDocumentDataDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("MAIN_ID", mainDataId);
|
||||
queryWrapper.orderByAsc("ID");
|
||||
queryWrapper.orderByAsc("SRT");
|
||||
List<ReportDocumentDataDO> list = reportDocumentDataMapper.selectList(queryWrapper);
|
||||
return CommonResult.success(list);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFilePageReqVO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFileRespVO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFileSaveReqVO;
|
||||
import jakarta.validation.*;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentFileDO;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 检测报告附件 Service 接口
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
public interface ReportDocumentFileService {
|
||||
|
||||
ReportDocumentFileDO getByMainIdAndVersion(Long mainId, Integer version);
|
||||
|
||||
|
||||
/**
|
||||
* 创建检测报告附件
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
ReportDocumentFileRespVO createReportDocumentFile(@Valid ReportDocumentFileSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新检测报告附件
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateReportDocumentFile(@Valid ReportDocumentFileSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除检测报告附件
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteReportDocumentFile(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除检测报告附件
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteReportDocumentFileListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得检测报告附件
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 检测报告附件
|
||||
*/
|
||||
ReportDocumentFileDO getReportDocumentFile(Long id);
|
||||
|
||||
/**
|
||||
* 获得检测报告附件分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 检测报告附件分页
|
||||
*/
|
||||
PageResult<ReportDocumentFileDO> getReportDocumentFilePage(ReportDocumentFilePageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFilePageReqVO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFileRespVO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFileSaveReqVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentFileDO;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.mapper.ReportDocumentFileMapper;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 检测报告附件 Service 实现类
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ReportDocumentFileServiceImpl implements ReportDocumentFileService {
|
||||
|
||||
@Resource
|
||||
private ReportDocumentFileMapper reportDocumentFileMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public ReportDocumentFileDO getByMainIdAndVersion(Long mainId, Integer version) {
|
||||
LambdaQueryWrapper<ReportDocumentFileDO> query = new LambdaQueryWrapper<>();
|
||||
query.eq(ReportDocumentFileDO::getMainId, mainId);
|
||||
query.eq(ReportDocumentFileDO::getVersion, version);
|
||||
return reportDocumentFileMapper.selectOne(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportDocumentFileRespVO createReportDocumentFile(ReportDocumentFileSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ReportDocumentFileDO reportDocumentFile = BeanUtils.toBean(createReqVO, ReportDocumentFileDO.class);
|
||||
reportDocumentFileMapper.insert(reportDocumentFile);
|
||||
// 返回
|
||||
return BeanUtils.toBean(reportDocumentFile, ReportDocumentFileRespVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateReportDocumentFile(ReportDocumentFileSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateReportDocumentFileExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ReportDocumentFileDO updateObj = BeanUtils.toBean(updateReqVO, ReportDocumentFileDO.class);
|
||||
reportDocumentFileMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteReportDocumentFile(Long id) {
|
||||
// 校验存在
|
||||
validateReportDocumentFileExists(id);
|
||||
// 删除
|
||||
reportDocumentFileMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteReportDocumentFileListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateReportDocumentFileExists(ids);
|
||||
// 删除
|
||||
reportDocumentFileMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
private void validateReportDocumentFileExists(List<Long> ids) {
|
||||
List<ReportDocumentFileDO> list = reportDocumentFileMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
throw exception(REPORT_DOCUMENT_FILE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateReportDocumentFileExists(Long id) {
|
||||
if (reportDocumentFileMapper.selectById(id) == null) {
|
||||
throw exception(REPORT_DOCUMENT_FILE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportDocumentFileDO getReportDocumentFile(Long id) {
|
||||
return reportDocumentFileMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ReportDocumentFileDO> getReportDocumentFilePage(ReportDocumentFilePageReqVO pageReqVO) {
|
||||
return reportDocumentFileMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,8 @@ public interface ReportDocumentMainCorrelationService {
|
||||
|
||||
void deleteByMainId(Long mainId);
|
||||
|
||||
void insertBatch(List<ReportDocumentMainCorrelationDO> list);
|
||||
|
||||
/**
|
||||
* 创建检测报告关系表
|
||||
*
|
||||
|
||||
@@ -59,6 +59,11 @@ public class ReportDocumentMainCorrelationServiceImpl implements ReportDocumentM
|
||||
reportDocumentMainCorrelationMapper.delete(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertBatch(List<ReportDocumentMainCorrelationDO> list) {
|
||||
reportDocumentMainCorrelationMapper.insertBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateReportDocumentMainCorrelation(ReportDocumentMainCorrelationSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
|
||||
@@ -3,8 +3,11 @@ package com.zt.plat.module.qms.business.reportdoc.service;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayReportDataDO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustRegistrationDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.*;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainDO;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkOperationRespDTO;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkWorkflowCreateReqDTO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
@@ -23,7 +26,7 @@ public interface ReportDocumentMainService {
|
||||
CommonResult<String> execAddDataByEntrust(ReportDocumentMainSaveReqVO reqVO);
|
||||
|
||||
//添加数据到报告-按表表数据
|
||||
CommonResult<String> execAddByBusinessAssayReportData(List<BusinessAssayReportDataDO> assayReportDataList, Long id);
|
||||
CommonResult<String> execAddByBusinessAssayReportData(List<BusinessAssayReportDataDO> assayReportDataList, Long id, List<BusinessSampleEntrustRegistrationDO> entrustList);
|
||||
|
||||
//移除数据
|
||||
CommonResult<String> execRemoveData(ReportDocumentMainSaveReqVO reqVO);
|
||||
@@ -82,4 +85,6 @@ public interface ReportDocumentMainService {
|
||||
//发起流程
|
||||
CommonResult<ReportDocumentMainRespVO> createProcessInstance(ReportDocumentMainSaveReqVO entity);
|
||||
|
||||
|
||||
void testAsyncTask(Long id);
|
||||
}
|
||||
@@ -17,28 +17,34 @@ import com.zt.plat.module.qms.api.task.BMPCallbackInterface;
|
||||
import com.zt.plat.module.qms.api.task.dto.QmsBpmDTO;
|
||||
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayReportDataPageReqVO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayReportDataDO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustRegistrationDO;
|
||||
import com.zt.plat.module.qms.business.bus.service.BusinessAssayReportDataService;
|
||||
import com.zt.plat.module.qms.business.bus.service.BusinessSampleEntrustRegistrationService;
|
||||
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.ReportDocumentDataDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainCorrelationDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentTypeDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.mapper.ReportDocumentMainMapper;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainDO;
|
||||
import com.zt.plat.module.qms.enums.QmsBpmConstant;
|
||||
import com.zt.plat.module.qms.enums.QmsCommonConstant;
|
||||
import com.zt.plat.module.system.api.iwork.IWorkIntegrationApi;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkOperationRespDTO;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkWorkflowCreateReqDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||
@@ -62,7 +68,30 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
@Resource private BpmProcessInstanceApi bpmProcessInstanceApi;
|
||||
@Resource private BpmTaskApi bpmTaskApi;
|
||||
@Resource private ReportDocumentMainCorrelationService reportDocumentMainCorrelationService;
|
||||
@Resource private ReportDocumentTypeService reportDocumentTypeService;
|
||||
@Resource private ConfigUserSignatureService configUserSignatureService;
|
||||
@Resource private BusinessSampleEntrustRegistrationService businessSampleEntrustRegistrationService;
|
||||
@Resource private ReportDocumentAssistService reportDocumentAssistService;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 测试异步执行
|
||||
* */
|
||||
@Async("asyncTaskExecutor")
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void testAsyncTask(Long id) {
|
||||
ReportDocumentMainDO entity = reportDocumentMainMapper.selectById(id);
|
||||
entity.setFlowStatus("success");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
reportDocumentMainMapper.updateById(entity);
|
||||
}
|
||||
|
||||
/***
|
||||
* 增加报表数据(按样品)
|
||||
* 传入:报告id、 报表数据ids
|
||||
@@ -93,14 +122,13 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
}
|
||||
if(isExist)
|
||||
return error(REPORT_DOCUMENT_DATA_NOT_EXISTS.getCode(), "报表数据已在本报告使用,请勿重复添加");
|
||||
// List<BusinessAssayReportDataDO> assayReportDataList = businessAssayReportDataService.listByIds(addReportDataIdList);
|
||||
BusinessAssayReportDataPageReqVO reportDataQueryVo = new BusinessAssayReportDataPageReqVO();
|
||||
reportDataQueryVo.setIdList(addReportDataIdList);
|
||||
reportDataQueryVo.setPageNo(1);
|
||||
reportDataQueryVo.setPageSize(9999);
|
||||
PageResult<BusinessAssayReportDataDO> assayReportPage = businessAssayReportDataService.queryWaitingDataForReport( reportDataQueryVo);
|
||||
List<BusinessAssayReportDataDO> assayReportDataList = assayReportPage.getList();
|
||||
return execAddByBusinessAssayReportData(assayReportDataList, id);
|
||||
return execAddByBusinessAssayReportData(assayReportDataList, id, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,39 +136,44 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
public CommonResult<String> execAddDataByEntrust(ReportDocumentMainSaveReqVO reqVO) {
|
||||
Long id = reqVO.getId();
|
||||
String businessSampleEntrustRegistrationIds = reqVO.getBusinessSampleEntrustRegistrationIds();
|
||||
if(ObjectUtils.isEmpty(businessSampleEntrustRegistrationIds) || id == null)
|
||||
if(id == null)
|
||||
return error(REPORT_DOCUMENT_DATA_NOT_EXISTS.getCode(), "缺少id参数,请刷新后重试");
|
||||
if(ObjectUtils.isEmpty(businessSampleEntrustRegistrationIds))
|
||||
return error(REPORT_DOCUMENT_DATA_NOT_EXISTS.getCode(), "缺少businessSampleEntrustRegistrationIds参数,请刷新后重试");
|
||||
List<ReportDocumentMainCorrelationDO> reportRelationList = reportDocumentMainCorrelationService.listByMainId(id);
|
||||
//todo 判断修改的场景。处理方法:删除reportRelation、ReportDocumentData
|
||||
List<Long> businessSampleEntrustRegistrationIdList = new ArrayList<>();
|
||||
String[] split = businessSampleEntrustRegistrationIds.split(",");
|
||||
for (String s : split) {
|
||||
Long aLong = Long.valueOf(s);
|
||||
businessSampleEntrustRegistrationIdList.add(aLong);
|
||||
}
|
||||
List<BusinessSampleEntrustRegistrationDO> entrustList = businessSampleEntrustRegistrationService.listByIds(businessSampleEntrustRegistrationIdList);
|
||||
BusinessAssayReportDataPageReqVO reportDataQueryVo = new BusinessAssayReportDataPageReqVO();
|
||||
reportDataQueryVo.setBusinessSampleEntrustRegistrationIdList(businessSampleEntrustRegistrationIdList);
|
||||
reportDataQueryVo.setPageNo(1);
|
||||
reportDataQueryVo.setPageSize(9999);
|
||||
PageResult<BusinessAssayReportDataDO> assayReportPage = businessAssayReportDataService.queryWaitingDataForReport( reportDataQueryVo);
|
||||
List<BusinessAssayReportDataDO> assayReportDataList = assayReportPage.getList();
|
||||
CommonResult<String> ret = execAddByBusinessAssayReportData(assayReportDataList, id);
|
||||
CommonResult<String> ret = execAddByBusinessAssayReportData(assayReportDataList, id, entrustList);
|
||||
if(!ret.isSuccess())
|
||||
return ret;
|
||||
//保存报告关系表
|
||||
List<ReportDocumentMainCorrelationDO> correlationList = new ArrayList<>();
|
||||
for(Long businessSampleEntrustRegistrationId : businessSampleEntrustRegistrationIdList){
|
||||
ReportDocumentMainCorrelationSaveReqVO correlationEntity = new ReportDocumentMainCorrelationSaveReqVO();
|
||||
ReportDocumentMainCorrelationDO correlationEntity = new ReportDocumentMainCorrelationDO();
|
||||
correlationEntity.setMainId( id);
|
||||
correlationEntity.setCorrelationId(businessSampleEntrustRegistrationId);
|
||||
correlationEntity.setCorrelationType(ReportDocumentMainCorrelationService.CorrelationType_entrust);
|
||||
reportDocumentMainCorrelationService.createReportDocumentMainCorrelation(correlationEntity);
|
||||
correlationList.add(correlationEntity);
|
||||
}
|
||||
if(!correlationList.isEmpty())
|
||||
reportDocumentMainCorrelationService.insertBatch(correlationList);
|
||||
|
||||
return CommonResult.success("操作成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<String> execAddByBusinessAssayReportData(List<BusinessAssayReportDataDO> assayReportDataList, Long id){
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<String> execAddByBusinessAssayReportData(List<BusinessAssayReportDataDO> assayReportDataList, Long id, List<BusinessSampleEntrustRegistrationDO> entrustList){
|
||||
if(ObjectUtils.isEmpty(assayReportDataList))
|
||||
return error(REPORT_DOCUMENT_DATA_NOT_EXISTS.getCode(), "您选择的委托还没产生可编制报告的数据,请稍后重试!");
|
||||
List<ReportDocumentDataDO> insertList = new ArrayList<>();
|
||||
@@ -152,16 +185,75 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
reportDocumentDataDO.setSampleName(assayReportData.getSampleName());
|
||||
reportDocumentDataDO.setBaseSampleName(assayReportData.getBaseSampleName());
|
||||
reportDocumentDataDO.setDocumentContent(assayReportData.getAssayData());
|
||||
reportDocumentDataDO.setSampleTypeKey(assayReportData.getSampleTypeKey());
|
||||
reportDocumentDataDO.setEntrustSampleCode(assayReportData.getEntrustSampleCode());
|
||||
reportDocumentDataDO.setEntrustSampleName(assayReportData.getEntrustSampleName());
|
||||
reportDocumentDataDO.setSort(assayReportData.getEntrustDetailSort());
|
||||
insertList.add(reportDocumentDataDO);
|
||||
}
|
||||
if(!insertList.isEmpty())
|
||||
reportDocumentDataService.insertBatch(insertList);
|
||||
ReportDocumentMainDO reportDocumentMainDO = reportDocumentMainMapper.selectById(id);
|
||||
updateCommonField(reportDocumentMainDO);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String formData = reportDocumentMainDO.getFormData();
|
||||
JSONObject formDataJson = new JSONObject();
|
||||
if(!ObjectUtils.isEmpty(formData))
|
||||
formDataJson = JSONObject.parseObject(formData);
|
||||
ReportDocumentTypeDO typeDO = reportDocumentTypeService.getReportDocumentType(reportDocumentMainDO.getReportDocumentTypeId());
|
||||
String customConfig = typeDO.getCustomConfig();
|
||||
String defaultConclusion = "";
|
||||
if(!ObjectUtils.isEmpty(customConfig)){
|
||||
JSONObject config = JSONObject.parseObject(customConfig);
|
||||
defaultConclusion = config.getString("defaultConclusion");
|
||||
}
|
||||
formDataJson.put("conclusion", defaultConclusion);
|
||||
if(!assayReportDataList.isEmpty())
|
||||
formDataJson.put("sampleName", assayReportDataList.get(0).getSampleName());
|
||||
//处理检测标准
|
||||
String standard = assembleStandard(assayReportDataList);
|
||||
formDataJson.put("standard", standard);
|
||||
formDataJson.put("reportTime", sdf.format(new Date()));
|
||||
|
||||
//委托单号
|
||||
String entrustCode = "";
|
||||
if(!ObjectUtils.isEmpty(entrustList)){
|
||||
for(BusinessSampleEntrustRegistrationDO entrust : entrustList){
|
||||
entrustCode += entrust.getEntrustNumber() + ",";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(entrustCode))
|
||||
entrustCode = entrustCode.substring(0, entrustCode.length() - 1);
|
||||
formDataJson.put("entrustCode", entrustCode);
|
||||
|
||||
reportDocumentMainDO.setFormData(formDataJson.toJSONString());
|
||||
reportDocumentMainMapper.updateById(reportDocumentMainDO);
|
||||
return CommonResult.success("操作成功");
|
||||
}
|
||||
|
||||
//组装检测标准
|
||||
private String assembleStandard(List<BusinessAssayReportDataDO> dataList){
|
||||
Set<String> standardSet = new HashSet<>();
|
||||
for(BusinessAssayReportDataDO data : dataList){
|
||||
String content = data.getAssayData();
|
||||
if(ObjectUtils.isEmpty( content))
|
||||
continue;
|
||||
JSONObject json = JSONObject.parseObject(content);
|
||||
for(String key : json.keySet()){
|
||||
JSONObject obj = json.getJSONObject(key);
|
||||
String methodName = obj.getString("methodName");
|
||||
if(ObjectUtils.isEmpty(methodName))
|
||||
continue;
|
||||
standardSet.add(methodName);
|
||||
}
|
||||
}
|
||||
if(standardSet.isEmpty())
|
||||
return "";
|
||||
return String.join(",", standardSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommonField(ReportDocumentMainDO reportDocumentMainDO) {
|
||||
if(reportDocumentMainDO == null)
|
||||
@@ -324,12 +416,15 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
return CommonResult.success(respVO);
|
||||
}
|
||||
|
||||
|
||||
//流程回调
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<JSONObject> callback(QmsBpmDTO reqDTO) {
|
||||
JSONObject variables = reqDTO.getVariables();
|
||||
|
||||
//todo 幂等性
|
||||
|
||||
JSONObject variables = reqDTO.getVariables();
|
||||
//流程状态 1-提交(含退回) 4-取消流程
|
||||
String PROCESS_STATUS = variables.getString(QmsBpmConstant.PROCESS_INSTANCE_VARIABLE_STATUS);
|
||||
String mainId = variables.getString("mainId");
|
||||
@@ -357,7 +452,6 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//"RETURN_FLAG_Activity_001": true 标识驳回到发起环节
|
||||
if(variables.containsKey(returnFlagKey) && variables.getString(returnFlagKey).equals("true")){
|
||||
//驳回。流程需要配置退回到发起节点
|
||||
@@ -375,11 +469,29 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
if("1".equals(lastActivityFlag))
|
||||
entity.setFlowStatus(QmsCommonConstant.COMPLETED); //结束审批
|
||||
}
|
||||
boolean updateDocFileFlag = reportDocumentAssistService.checkUpdateDocFile(variables);
|
||||
if(updateDocFileFlag){
|
||||
Integer version = entity.getDocumentVersion();
|
||||
if(version == null)
|
||||
version = 1;
|
||||
else
|
||||
version++;
|
||||
entity.setDocumentVersion(version); //版本+1
|
||||
}
|
||||
reportDocumentMainMapper.updateById(entity);
|
||||
|
||||
try {
|
||||
reportDocumentAssistService.updateDocFileAndCreateIWorkflow( variables, entity);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
JSONObject ret = new JSONObject();
|
||||
return CommonResult.success(ret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void assembleSignature(String currentActivityId, ReportDocumentMainDO entity){
|
||||
if(ObjectUtils.isEmpty(currentActivityId) || "null".equals(currentActivityId))
|
||||
return;
|
||||
@@ -406,4 +518,6 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
entity.setDocumentSignature(signObj.toJSONString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.zt.plat.module.qms.core.code;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
|
||||
public class SampleEncryptUtil {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.zt.plat.module.qms.core.legend.security;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.zt.plat.module.qms.core.qlexpress.cmp;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.ql.util.express.DefaultContext;
|
||||
import com.ql.util.express.ExpressRunner;
|
||||
import com.alibaba.qlexpress4.Express4Runner;
|
||||
import com.alibaba.qlexpress4.QLOptions;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -19,7 +21,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
public class AllowanceCalculatorComponent {
|
||||
|
||||
@Resource
|
||||
private ExpressRunner expressRunner;
|
||||
private Express4Runner express4Runner;
|
||||
|
||||
/**
|
||||
* 计算允差值:支持原生线性公式 和 Express 自定义公式混合模式
|
||||
@@ -80,11 +82,12 @@ public class AllowanceCalculatorComponent {
|
||||
* 使用 Express 执行自定义公式
|
||||
*/
|
||||
private BigDecimal evaluateCustomFormula(String formula, BigDecimal xValue, int scale) {
|
||||
DefaultContext<String, Object> context = new DefaultContext<>();
|
||||
Map<String, Object> context = new HashMap<>();
|
||||
context.put("X", xValue); // 用户公式中使用 X 作为变量名
|
||||
|
||||
try {
|
||||
Object result = expressRunner.execute(formula, context, null, true, false);
|
||||
// Object result = expressRunner.execute(formula, context, null, true, false);
|
||||
Object result = express4Runner.execute(formula, context, QLOptions.builder().precise(true).build());
|
||||
|
||||
if (result == null) {
|
||||
throw new RuntimeException("Express 公式返回结果为 null");
|
||||
|
||||
@@ -3,16 +3,19 @@ package com.zt.plat.module.qms.core.qlexpress.config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.ql.util.express.ExpressRunner;
|
||||
import com.alibaba.qlexpress4.Express4Runner;
|
||||
import com.alibaba.qlexpress4.InitOptions;
|
||||
import com.alibaba.qlexpress4.security.QLSecurityStrategy;
|
||||
import com.zt.plat.module.qms.core.qlexpress.function.RoundToScaleHalfEven;
|
||||
|
||||
@Configuration
|
||||
public class QlExpressRuleEngineConfig {
|
||||
|
||||
@Bean
|
||||
public ExpressRunner expressRunner() {
|
||||
//需要高精度计算支持
|
||||
ExpressRunner expressRunner = new ExpressRunner(true, false);
|
||||
public Express4Runner expressRunner() {
|
||||
//兼容 3 的行为,则在新建 Express4Runner 时, 要将安全策略设置为 “开放”
|
||||
InitOptions initOptions = InitOptions.builder().securityStrategy(QLSecurityStrategy.open()).build();
|
||||
Express4Runner expressRunner = new Express4Runner(initOptions);
|
||||
expressRunner.addFunction("roundToScale", new RoundToScaleHalfEven());
|
||||
return expressRunner;
|
||||
}
|
||||
|
||||
@@ -3,18 +3,20 @@ package com.zt.plat.module.qms.core.qlexpress.function;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import com.ql.util.express.Operator;
|
||||
import com.alibaba.qlexpress4.runtime.Parameters;
|
||||
import com.alibaba.qlexpress4.runtime.QContext;
|
||||
import com.alibaba.qlexpress4.runtime.function.CustomFunction;
|
||||
|
||||
public class RoundToScaleHalfEven extends Operator {
|
||||
|
||||
public class RoundToScaleHalfEven implements CustomFunction {
|
||||
|
||||
@Override
|
||||
public Object executeInner(Object[] list) throws Exception {
|
||||
if (list.length != 2) {
|
||||
public Object call(QContext qContext, Parameters parameters) throws Throwable {
|
||||
if (parameters.size() != 2) {
|
||||
throw new Exception("roundToScale函数需要2个参数:数值和小数位数");
|
||||
}
|
||||
|
||||
double value = Double.parseDouble(list[0].toString());
|
||||
int scale = Integer.parseInt(list[1].toString());
|
||||
double value = Double.parseDouble(parameters.get(0).get().toString());
|
||||
int scale = Integer.parseInt(parameters.get(1).get().toString());
|
||||
|
||||
BigDecimal bd = BigDecimal.valueOf(value);
|
||||
bd = bd.setScale(scale, RoundingMode.HALF_EVEN);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.zt.plat.module.bpm.api.task.BpmProcessInstanceApi;
|
||||
import com.zt.plat.module.bpm.api.task.BpmTaskApi;
|
||||
import com.zt.plat.module.infra.api.file.FileApi;
|
||||
import com.zt.plat.module.system.api.dept.DeptApi;
|
||||
import com.zt.plat.module.system.api.iwork.IWorkIntegrationApi;
|
||||
import com.zt.plat.module.system.api.permission.PermissionApi;
|
||||
import com.zt.plat.module.system.api.sequence.SequenceApi;
|
||||
import com.zt.plat.module.system.api.user.AdminUserApi;
|
||||
@@ -12,6 +13,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(value = "qmsRpcConfiguration", proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = {FileApi.class, SequenceApi.class, AdminUserApi.class, DeptApi.class, BpmProcessInstanceApi.class, BpmTaskApi.class, PermissionApi.class})
|
||||
@EnableFeignClients(clients = {FileApi.class, SequenceApi.class, AdminUserApi.class, DeptApi.class, BpmProcessInstanceApi.class, BpmTaskApi.class, PermissionApi.class, IWorkIntegrationApi.class})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.zt.plat.module.qms.iot.tcpserver;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import tech.zzjc.tio.core.ChannelContext;
|
||||
import tech.zzjc.tio.core.Tio;
|
||||
|
||||
@@ -10,8 +10,9 @@ import com.zt.plat.module.qms.iot.tcpserver.handler.IotDataHander;
|
||||
import com.zt.plat.module.qms.iot.tcpserver.publisher.BalanceDataPublisher;
|
||||
import com.fhs.common.spring.SpringContextUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import tech.zzjc.tio.cluster.TioClusterConfig;
|
||||
import tech.zzjc.tio.cluster.TioClusterVo;
|
||||
@@ -81,7 +82,7 @@ public class IotDeviceBalanceHandler implements IotDataHander {
|
||||
String[] dataArray = analysisData(data, weightUnit);
|
||||
weightData = dataArray[0];
|
||||
weightUnit = dataArray[1];
|
||||
if (!NumberUtils.isNumber(weightData)) {
|
||||
if (!NumberUtils.isParsable(weightData)) {
|
||||
log.error("{},天平接收到的数据不正确!接收到的数据:{} 16进制:{}", realClient, data, IotUtils.bytesToHex(data.getBytes("UTF-8")));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ import com.zt.plat.module.qms.resource.clientManage.service.VersionManagementSer
|
||||
|
||||
@Tag(name = "管理后台 - 客户端版本管理")
|
||||
@RestController
|
||||
@RequestMapping("/qms/system-version-management")
|
||||
@RequestMapping("/qms/version-management")
|
||||
@Validated
|
||||
@FileUploadController(source = "qms.systemversionmanagement")
|
||||
@FileUploadController(source = "qms.versionmanagement")
|
||||
public class VersionManagementController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||
|
||||
static {
|
||||
@@ -54,14 +54,14 @@ public class VersionManagementController extends AbstractFileUploadController im
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建客户端版本管理")
|
||||
@PreAuthorize("@ss.hasPermission('qms:system-version-management:create')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:version-management:create')")
|
||||
public CommonResult<VersionManagementRespVO> createSystemVersionManagement(@Valid @RequestBody VersionManagementSaveReqVO createReqVO) {
|
||||
return success(systemVersionManagementService.createSystemVersionManagement(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新客户端版本管理")
|
||||
@PreAuthorize("@ss.hasPermission('qms:system-version-management:update')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:version-management:update')")
|
||||
public CommonResult<Boolean> updateSystemVersionManagement(@Valid @RequestBody VersionManagementSaveReqVO updateReqVO) {
|
||||
systemVersionManagementService.updateSystemVersionManagement(updateReqVO);
|
||||
return success(true);
|
||||
@@ -70,7 +70,7 @@ public class VersionManagementController extends AbstractFileUploadController im
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除客户端版本管理")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('qms:system-version-management:delete')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:version-management:delete')")
|
||||
public CommonResult<Boolean> deleteSystemVersionManagement(@RequestParam("id") Long id) {
|
||||
systemVersionManagementService.deleteSystemVersionManagement(id);
|
||||
return success(true);
|
||||
@@ -79,7 +79,7 @@ public class VersionManagementController extends AbstractFileUploadController im
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除客户端版本管理")
|
||||
@PreAuthorize("@ss.hasPermission('qms:system-version-management:delete')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:version-management:delete')")
|
||||
public CommonResult<Boolean> deleteSystemVersionManagementList(@RequestBody BatchDeleteReqVO req) {
|
||||
systemVersionManagementService.deleteSystemVersionManagementListByIds(req.getIds());
|
||||
return success(true);
|
||||
@@ -88,7 +88,7 @@ public class VersionManagementController extends AbstractFileUploadController im
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得客户端版本管理")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('qms:system-version-management:query')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:version-management:query')")
|
||||
public CommonResult<VersionManagementRespVO> getSystemVersionManagement(@RequestParam("id") Long id) {
|
||||
VersionManagementDO systemVersionManagement = systemVersionManagementService.getSystemVersionManagement(id);
|
||||
return success(BeanUtils.toBean(systemVersionManagement, VersionManagementRespVO.class));
|
||||
@@ -96,7 +96,7 @@ public class VersionManagementController extends AbstractFileUploadController im
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得客户端版本管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('qms:system-version-management:query')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:version-management:query')")
|
||||
public CommonResult<PageResult<VersionManagementRespVO>> getSystemVersionManagementPage(@Valid VersionManagementPageReqVO pageReqVO) {
|
||||
PageResult<VersionManagementDO> pageResult = systemVersionManagementService.getSystemVersionManagementPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, VersionManagementRespVO.class));
|
||||
@@ -104,7 +104,7 @@ public class VersionManagementController extends AbstractFileUploadController im
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出客户端版本管理 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('qms:system-version-management:export')")
|
||||
@PreAuthorize("@ss.hasPermission('qms:version-management:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportSystemVersionManagementExcel(@Valid VersionManagementPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
@@ -118,7 +118,7 @@ public class VersionManagementController extends AbstractFileUploadController im
|
||||
|
||||
@GetMapping("/get-by-platform")
|
||||
@Operation(summary = "根据更新平台和安装包类型获取最新客户端版本管理信息")
|
||||
//@PreAuthorize("@ss.hasPermission('qms:system-version-management:query')")
|
||||
//@PreAuthorize("@ss.hasPermission('qms:version-management:query')")
|
||||
public CommonResult<PageResult<VersionManagementRespVO>> getSystemVersionManagementByPlatformAndType(@Valid VersionManagementPageReqVO pageReqVO) {
|
||||
|
||||
if (pageReqVO.getCustDeviceCode() == null ) {
|
||||
|
||||
@@ -26,18 +26,20 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.error;
|
||||
|
||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.MATERIAL_BATCH_ASSIGN_NOT_EXISTS;
|
||||
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchAssignDO;
|
||||
import com.zt.plat.module.qms.resource.material.service.MaterialBatchAssignService;
|
||||
|
||||
@Tag(name = "管理后台 - 物料批次分发")
|
||||
@RestController
|
||||
@RequestMapping("/qms/material-batch-assign")
|
||||
@RequestMapping("/qms/resource/material-batch-assign")
|
||||
@Validated
|
||||
@FileUploadController(source = "qms.materialbatchassign")
|
||||
public class MaterialBatchAssignController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||
@@ -94,6 +96,21 @@ public class MaterialBatchAssignController extends AbstractFileUploadController
|
||||
return success(BeanUtils.toBean(materialBatchAssign, MaterialBatchAssignRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/get-by-inf")
|
||||
@Operation(summary = "获得物料批次分发")
|
||||
@Parameter(name = "productId", description = "产品大类编号", required = true)
|
||||
// @PreAuthorize("@ss.hasPermission('qms:material-batch-assign:query')")
|
||||
public CommonResult<PageResult<MaterialBatchAssignRespVO>> getMaterialBatchAssignByInfiId(MaterialBatchAssignPageReqVO pageReqVO) {
|
||||
|
||||
if(pageReqVO.getMaterialInfomationId()==null||pageReqVO.getMaterialInfomationId().length()==0){
|
||||
return error(MATERIAL_BATCH_ASSIGN_NOT_EXISTS,"示例编号不能为空");
|
||||
}
|
||||
|
||||
PageResult<MaterialBatchAssignDO> pageResult = materialBatchAssignService.getMaterialBatchAssignByInfId(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, MaterialBatchAssignRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得物料批次分发分页")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-batch-assign:query')")
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.zt.plat.module.qms.resource.material.controller.admin;
|
||||
|
||||
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.*;
|
||||
import com.zt.plat.module.qms.resource.material.service.MaterialBatchAssignService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -37,11 +36,14 @@ import com.zt.plat.module.qms.resource.material.service.MaterialBatchService;
|
||||
|
||||
@Tag(name = "管理后台 - 物料批次")
|
||||
@RestController
|
||||
@RequestMapping("/qms/material-batch")
|
||||
@RequestMapping("/qms/resource/material-batch")
|
||||
@Validated
|
||||
@FileUploadController(source = "qms.materialbatch")
|
||||
public class MaterialBatchController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||
|
||||
@Resource
|
||||
private MaterialBatchAssignService materialBatchAssignService;
|
||||
|
||||
static {
|
||||
FileUploadController annotation = MaterialBatchController.class.getAnnotation(FileUploadController.class);
|
||||
if (annotation != null) {
|
||||
@@ -115,4 +117,10 @@ public class MaterialBatchController extends AbstractFileUploadController implem
|
||||
BeanUtils.toBean(list, MaterialBatchRespVO.class));
|
||||
}
|
||||
|
||||
@PostMapping("/assign")
|
||||
@Operation(summary = "物料分发")
|
||||
public CommonResult<MaterialBatchAssignRespVO> assign(@Valid @RequestBody MaterialBatchAssignSaveReqVO createReqVO) {
|
||||
return success(materialBatchAssignService.assignLab(createReqVO));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.material.service.MaterialInventoryCheckSe
|
||||
|
||||
@Tag(name = "管理后台 - 库存盘点")
|
||||
@RestController
|
||||
@RequestMapping("/qms/material-inventory-check")
|
||||
@RequestMapping("/qms/resource/material-inventory-check")
|
||||
@Validated
|
||||
@FileUploadController(source = "qms.materialinventorycheck")
|
||||
public class MaterialInventoryCheckController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||
@@ -115,4 +115,21 @@ public class MaterialInventoryCheckController extends AbstractFileUploadControll
|
||||
BeanUtils.toBean(list, MaterialInventoryCheckRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/create-form")
|
||||
@Operation(summary = "创建库存盘点")
|
||||
public CommonResult<MaterialInventoryCheckRespVO> createMaterialInventoryCheckForm(@Valid @RequestBody MaterialInventoryCheckSaveReqVO createReqVO) {
|
||||
|
||||
|
||||
return success(materialInventoryCheckService.createMaterialInventoryCheckForm(createReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/get-form")
|
||||
@Operation(summary = "获得库存盘点")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-check:query')")
|
||||
public CommonResult<MaterialInventoryCheckRespVO> getMaterialInventoryCheckForm(@RequestParam("id") Long id) {
|
||||
|
||||
return success(materialInventoryCheckService.getMaterialInventoryCheckForm(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.zt.plat.module.qms.resource.material.controller.admin;
|
||||
|
||||
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import com.zt.plat.framework.business.annotation.FileUploadController;
|
||||
import com.zt.plat.framework.business.controller.AbstractFileUploadController;
|
||||
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
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.excel.core.util.ExcelUtils;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.*;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryInboundDetailDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO;
|
||||
import com.zt.plat.module.qms.resource.material.service.MaterialInventoryInboundDetailService;
|
||||
import com.zt.plat.module.qms.resource.material.service.MaterialInventoryService;
|
||||
import com.zt.plat.module.qms.resource.material.service.MaterialProductService;
|
||||
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.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 入库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等")
|
||||
@RestController
|
||||
@RequestMapping("/qms/resource/material-inventory")
|
||||
@Validated
|
||||
@FileUploadController(source = "qms.materiainfo")
|
||||
public class MaterialInventoryController extends AbstractFileUploadController implements BusinessControllerMarker {
|
||||
|
||||
static {
|
||||
FileUploadController annotation = MaterialInventoryController.class.getAnnotation(FileUploadController.class);
|
||||
if (annotation != null) {
|
||||
setFileUploadInfo(annotation);
|
||||
}
|
||||
}
|
||||
|
||||
@Resource
|
||||
private MaterialInventoryInboundDetailService materialInventoryInboundDetailService;
|
||||
|
||||
@Resource
|
||||
private MaterialInventoryService mterialInventoryService;
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建入库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound-detail:create')")
|
||||
public CommonResult<MaterialInventoryInboundDetailRespVO> createMaterialInventoryInboundDetail(@Valid @RequestBody MaterialInventoryInboundDetailSaveReqVO createReqVO) {
|
||||
return success(materialInventoryInboundDetailService.createMaterialInventoryInboundDetail(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新入库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound-detail:update')")
|
||||
public CommonResult<Boolean> updateMaterialInventoryInboundDetail(@Valid @RequestBody MaterialInventoryInboundDetailSaveReqVO updateReqVO) {
|
||||
materialInventoryInboundDetailService.updateMaterialInventoryInboundDetail(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除入库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound-detail:delete')")
|
||||
public CommonResult<Boolean> deleteMaterialInventoryInboundDetail(@RequestParam("id") Long id) {
|
||||
materialInventoryInboundDetailService.deleteMaterialInventoryInboundDetail(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除入库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound-detail:delete')")
|
||||
public CommonResult<Boolean> deleteMaterialInventoryInboundDetailList(@RequestBody BatchDeleteReqVO req) {
|
||||
materialInventoryInboundDetailService.deleteMaterialInventoryInboundDetailListByIds(req.getIds());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得入库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound-detail:query')")
|
||||
public CommonResult<MaterialInventoryInboundDetailRespVO> getMaterialInventoryInboundDetail(@RequestParam("id") Long id) {
|
||||
MaterialInventoryInboundDetailDO materialInventoryInboundDetail = materialInventoryInboundDetailService.getMaterialInventoryInboundDetail(id);
|
||||
return success(BeanUtils.toBean(materialInventoryInboundDetail, MaterialInventoryInboundDetailRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得库存明细")
|
||||
// @PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound-detail:query')")
|
||||
public CommonResult<PageResult<MaterialInventoryInboundDetailRespVO>> getMaterialInventoryPage(@Valid MaterialInventoryInboundDetailPageReqVO pageReqVO) {
|
||||
PageResult<MaterialInventoryInboundDetailDO> pageResult = materialInventoryInboundDetailService.getMaterialInventoryInboundDetailPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, MaterialInventoryInboundDetailRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出入库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound-detail:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportMaterialInventoryInboundDetailExcel(@Valid MaterialInventoryInboundDetailPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<MaterialInventoryInboundDetailDO> list = materialInventoryInboundDetailService.getMaterialInventoryInboundDetailPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "入库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等.xls", "数据", MaterialInventoryInboundDetailRespVO.class,
|
||||
BeanUtils.toBean(list, MaterialInventoryInboundDetailRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getList")
|
||||
@Operation(summary = "获得库存列表")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
public CommonResult<PageResult<MaterialInventoryRespVO>> getMaterialProduct(MaterialInventoryRespVO pageReqVO) {
|
||||
|
||||
PageResult<MaterialInventoryDO> pageResult = mterialInventoryService.getMaterialInventoryPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, MaterialInventoryRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get_mtrl_inf")
|
||||
@Operation(summary = "获取实例列表")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
public CommonResult<PageResult<MaterialInventoryRespVO>> getInfomation(MaterialInventoryRespVO pageReqVO) {
|
||||
|
||||
PageResult<MaterialInventoryDO> pageResult = mterialInventoryService.getMaterialInventoryPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, MaterialInventoryRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/agree-out")
|
||||
@Operation(summary = "同意出库")
|
||||
@Parameter(name = "id", description = "出库单id", required = true)
|
||||
public CommonResult<Boolean> agreeOut(@RequestParam("outId") Long outId) {
|
||||
|
||||
// PageResult<MaterialInventoryDO> pageResult = mterialInventoryService.getMaterialInventoryPage(pageReqVO);
|
||||
// return success(BeanUtils.toBean(pageResult, MaterialInventoryRespVO.class));
|
||||
mterialInventoryService.agreeMaterialInventoryOutbound(outId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.zt.plat.module.qms.resource.material.controller.admin;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundRespVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundSaveReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductRespVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -37,7 +38,7 @@ import com.zt.plat.module.qms.resource.material.service.MaterialInventoryInbound
|
||||
|
||||
@Tag(name = "管理后台 - 入库")
|
||||
@RestController
|
||||
@RequestMapping("/qms/material-inventory-inbound")
|
||||
@RequestMapping("/qms/resource/material-inventory-inbound")
|
||||
@Validated
|
||||
@FileUploadController(source = "qms.materialinventoryinbound")
|
||||
public class MaterialInventoryInboundController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||
@@ -115,4 +116,17 @@ public class MaterialInventoryInboundController extends AbstractFileUploadContro
|
||||
BeanUtils.toBean(list, MaterialInventoryInboundRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/multi-put")
|
||||
@Operation(summary = "批量上架")
|
||||
public CommonResult<Boolean> createMaterialInventoryInboundMulti(@Valid @RequestBody MaterialInventoryInboundSaveReqVO createReqVO) {
|
||||
materialInventoryInboundService.multiCreateMaterialInventoryInbound(createReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("single-put")
|
||||
@Operation(summary = "单一上架")
|
||||
public CommonResult<PageResult<MaterialInventoryInboundRespVO>> createMaterialInventoryInboundSingle(@Valid @RequestBody MaterialInventoryInboundSaveReqVO createReqVO) {
|
||||
return success(materialInventoryInboundService.singleCreateMaterialInventoryInbound(createReqVO));
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.material.service.MaterialInventoryInbound
|
||||
|
||||
@Tag(name = "管理后台 - 入库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等")
|
||||
@RestController
|
||||
@RequestMapping("/qms/material-inventory-inbound-detail")
|
||||
@RequestMapping("/qms/resource/material-inventory-inbound-detail")
|
||||
@Validated
|
||||
@FileUploadController(source = "qms.materialinventoryinbounddetail")
|
||||
public class MaterialInventoryInboundDetailController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||
@@ -115,4 +115,10 @@ public class MaterialInventoryInboundDetailController extends AbstractFileUpload
|
||||
BeanUtils.toBean(list, MaterialInventoryInboundDetailRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page-list")
|
||||
@Operation(summary = "获得入库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等分页")
|
||||
public CommonResult<PageResult<MaterialInventoryInboundDetailRespVO>> getMaterialInventoryInboundDetailPageList(@Valid MaterialInventoryInboundDetailPageReqVO pageReqVO) {
|
||||
PageResult<MaterialInventoryInboundDetailRespVO> pageResult = materialInventoryInboundDetailService.getMaterialInventoryInboundDetailPageList(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, MaterialInventoryInboundDetailRespVO.class));
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.material.service.MaterialInventoryOutboun
|
||||
|
||||
@Tag(name = "管理后台 - 出库")
|
||||
@RestController
|
||||
@RequestMapping("/qms/material-inventory-outbound")
|
||||
@RequestMapping("/qms/resource/material-inventory-outbound")
|
||||
@Validated
|
||||
@FileUploadController(source = "qms.materialinventoryoutbound")
|
||||
public class MaterialInventoryOutboundController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||
@@ -115,4 +115,12 @@ public class MaterialInventoryOutboundController extends AbstractFileUploadContr
|
||||
BeanUtils.toBean(list, MaterialInventoryOutboundRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/create-all")
|
||||
@Operation(summary = "创建出库")
|
||||
@PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound:create')")
|
||||
public CommonResult<MaterialInventoryOutboundRespVO> createMaterialInventoryOutboundAll(@Valid @RequestBody MaterialInventoryOutboundSaveReqVO createReqVO) {
|
||||
return success(materialInventoryOutboundService.createMaterialInventoryOutboundAll(createReqVO));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,4 +37,7 @@ public class MaterialBatchAssignPageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "实例ID")
|
||||
private String materialInfomationId;
|
||||
|
||||
}
|
||||
@@ -10,13 +10,13 @@ public class MaterialBatchAssignSaveReqVO {
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "15114")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "源批次ID", example = "23099")
|
||||
@Schema(description = "源批次ID",requiredMode = Schema.RequiredMode.REQUIRED, example = "23099")
|
||||
private Long batchId;
|
||||
|
||||
@Schema(description = "产品id", example = "10774")
|
||||
private String productId;
|
||||
|
||||
@Schema(description = "库房ID", example = "24720")
|
||||
@Schema(description = "库房ID",requiredMode = Schema.RequiredMode.REQUIRED, example = "24720")
|
||||
private Long warehouseId;
|
||||
|
||||
@Schema(description = "数量")
|
||||
|
||||
@@ -78,5 +78,8 @@ public class MaterialInfomationPageReqVO extends PageParam {
|
||||
@Schema(description = "大类ids")
|
||||
List<Long> productIds;
|
||||
|
||||
@Schema(description = "入库id")
|
||||
private Long inventoryInboundId;
|
||||
|
||||
|
||||
}
|
||||
@@ -36,4 +36,7 @@ public class MaterialInventoryCheckBatchSaveReqVO {
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "盘点明细")
|
||||
private List<MaterialInventoryCheckDetailSaveReqVO> detailList;
|
||||
|
||||
}
|
||||
@@ -54,4 +54,6 @@ public class MaterialInventoryCheckPageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
}
|
||||
@@ -68,4 +68,7 @@ public class MaterialInventoryCheckRespVO {
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "盘点项")
|
||||
@ExcelProperty("盘点项")
|
||||
private List<MaterialInventoryCheckBatchRespVO> batchList;
|
||||
}
|
||||
@@ -50,4 +50,7 @@ public class MaterialInventoryCheckSaveReqVO {
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "盘点项")
|
||||
private List<MaterialInventoryCheckBatchSaveReqVO> batchList;
|
||||
|
||||
}
|
||||
@@ -50,4 +50,7 @@ public class MaterialInventoryInboundDetailPageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "物料大类Id")
|
||||
private Long productId;
|
||||
|
||||
}
|
||||
@@ -63,4 +63,6 @@ public class MaterialInventoryInboundDetailRespVO {
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private Long productId;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zt.plat.module.qms.resource.material.controller.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
@@ -45,4 +46,19 @@ public class MaterialInventoryInboundDetailSaveReqVO {
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "申请数量")
|
||||
private Long quantity;
|
||||
|
||||
/**
|
||||
* 存放位置
|
||||
*/
|
||||
@TableField("LOC_ID")
|
||||
private String locationId;
|
||||
|
||||
/**
|
||||
* 物料大类id
|
||||
*/
|
||||
@TableField("PDT_ID")
|
||||
private Long productId;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zt.plat.module.qms.resource.material.controller.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
@@ -51,4 +52,8 @@ public class MaterialInventoryInboundSaveReqVO {
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "详情",requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private MaterialInventoryInboundDetailSaveReqVO detail;
|
||||
|
||||
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 出库 Response VO")
|
||||
@@ -79,4 +81,7 @@ public class MaterialInventoryOutboundRespVO {
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "出库明细")
|
||||
private List<MaterialInventoryOutboundDetailRespVO> detailReqVoList;
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 出库新增/修改 Request VO")
|
||||
@Data
|
||||
@@ -57,4 +58,7 @@ public class MaterialInventoryOutboundSaveReqVO {
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
@Schema(description = "出库明细")
|
||||
private List<MaterialInventoryOutboundDetailSaveReqVO> detailSaveReqVoList;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.zt.plat.module.qms.resource.material.controller.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 库存列表分页 Request VO")
|
||||
@Data
|
||||
public class MaterialInventoryPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.AUTO, example = "32133")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父id", example = "6098")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "id路径")
|
||||
private String idPath;
|
||||
|
||||
@Schema(description = "节点类型,分类|产品", example = "2")
|
||||
private String nodeType;
|
||||
|
||||
@Schema(description = "名称", example = "张三")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "其他配置")
|
||||
private String customConfig;
|
||||
|
||||
@Schema(description = "自定义表单")
|
||||
private String customForm;
|
||||
|
||||
@Schema(description = "扩展数据")
|
||||
private String customData;
|
||||
|
||||
@Schema(description = "标签")
|
||||
private String tag;
|
||||
|
||||
@Schema(description = "标签模板")
|
||||
private String labelTemplateKey;
|
||||
|
||||
@Schema(description = "型号")
|
||||
private String modelNo;
|
||||
|
||||
@Schema(description = "规格")
|
||||
private String specification;
|
||||
|
||||
@Schema(description = "技术参数")
|
||||
private String parameter;
|
||||
|
||||
@Schema(description = "制造商")
|
||||
private String manufacturer;
|
||||
|
||||
@Schema(description = "单位")
|
||||
private String unit;
|
||||
|
||||
@Schema(description = "允许按量领取")
|
||||
private String enablePartial;
|
||||
|
||||
@Schema(description = "保质期(天)")
|
||||
private Integer due;
|
||||
|
||||
@Schema(description = "开封后保质期是否变化")
|
||||
private String openDueFlag;
|
||||
|
||||
@Schema(description = "开封后保质期(天)")
|
||||
private Integer openDueAfter;
|
||||
|
||||
@Schema(description = "是否危险品")
|
||||
private String hazardous;
|
||||
|
||||
@Schema(description = "是否标准溶液")
|
||||
private String standardSolutionFlag;
|
||||
|
||||
@Schema(description = "是否标准物质")
|
||||
private String standardMaterialFlag;
|
||||
|
||||
@Schema(description = "复标周期,单位:天。小于等于0-不复标")
|
||||
private Integer reviewDue;
|
||||
|
||||
@Schema(description = "排序号")
|
||||
private Integer sortNo;
|
||||
|
||||
@Schema(description = "禁用")
|
||||
private String cancelFlag;
|
||||
|
||||
@Schema(description = "所属部门")
|
||||
private String systemDepartmentCode;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.zt.plat.module.qms.resource.material.controller.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import com.zt.plat.module.qms.core.aspect.annotation.Dict;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 库存列表 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class MaterialInventoryRespVO extends PageParam {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32133")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父id", example = "6098")
|
||||
@ExcelProperty("父id")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "id路径")
|
||||
@ExcelProperty("id路径")
|
||||
private String idPath;
|
||||
|
||||
@Schema(description = "节点类型,分类|产品", example = "2")
|
||||
@ExcelProperty("节点类型,分类|产品")
|
||||
private String nodeType;
|
||||
|
||||
@Schema(description = "名称", example = "张三")
|
||||
@ExcelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "其他配置")
|
||||
@ExcelProperty("其他配置")
|
||||
private String customConfig;
|
||||
|
||||
@Schema(description = "自定义表单")
|
||||
@ExcelProperty("自定义表单")
|
||||
private String customForm;
|
||||
|
||||
@Schema(description = "扩展数据")
|
||||
@ExcelProperty("扩展数据")
|
||||
private String customData;
|
||||
|
||||
@Schema(description = "标签")
|
||||
@ExcelProperty("标签")
|
||||
private String tag;
|
||||
|
||||
@Schema(description = "标签模板")
|
||||
@ExcelProperty("标签模板")
|
||||
private String labelTemplateKey;
|
||||
|
||||
@Schema(description = "型号")
|
||||
@ExcelProperty("型号")
|
||||
private String modelNo;
|
||||
|
||||
@Schema(description = "规格")
|
||||
@ExcelProperty("规格")
|
||||
private String specification;
|
||||
|
||||
@Schema(description = "技术参数")
|
||||
@ExcelProperty("技术参数")
|
||||
private String parameter;
|
||||
|
||||
@Schema(description = "制造商")
|
||||
@ExcelProperty("制造商")
|
||||
private String manufacturer;
|
||||
|
||||
@Schema(description = "单位")
|
||||
@ExcelProperty("单位")
|
||||
private String unit;
|
||||
|
||||
@Schema(description = "允许按量领取")
|
||||
@ExcelProperty("允许按量领取")
|
||||
@Dict(dicCode = "yes_or_no")
|
||||
private String enablePartial;
|
||||
|
||||
@Schema(description = "保质期(天)")
|
||||
@ExcelProperty("保质期(天)")
|
||||
private Integer due;
|
||||
|
||||
@Schema(description = "开封后保质期是否变化")
|
||||
@ExcelProperty("开封后保质期是否变化")
|
||||
@Dict(dicCode = "yes_or_no")
|
||||
private String openDueFlag;
|
||||
|
||||
@Schema(description = "开封后保质期(天)")
|
||||
@ExcelProperty("开封后保质期(天)")
|
||||
private Integer openDueAfter;
|
||||
|
||||
@Schema(description = "是否危险品")
|
||||
@ExcelProperty("是否危险品")
|
||||
@Dict(dicCode = "yes_or_no")
|
||||
private String hazardous;
|
||||
|
||||
@Schema(description = "是否标准溶液")
|
||||
@ExcelProperty("是否标准溶液")
|
||||
@Dict(dicCode = "yes_or_no")
|
||||
private String standardSolutionFlag;
|
||||
|
||||
@Schema(description = "是否标准物质")
|
||||
@ExcelProperty("是否标准物质")
|
||||
@Dict(dicCode = "yes_or_no")
|
||||
private String standardMaterialFlag;
|
||||
|
||||
@Schema(description = "复标周期,单位:天。小于等于0-不复标")
|
||||
@ExcelProperty("复标周期")
|
||||
private Integer reviewDue;
|
||||
|
||||
@Schema(description = "排序号")
|
||||
@ExcelProperty("排序号")
|
||||
private Integer sortNo;
|
||||
|
||||
@Schema(description = "禁用")
|
||||
@ExcelProperty("禁用")
|
||||
private String cancelFlag;
|
||||
|
||||
@Schema(description = "所属部门")
|
||||
@ExcelProperty("所属部门")
|
||||
private String systemDepartmentCode;
|
||||
|
||||
@Schema(description = "备注")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 总数量
|
||||
*/
|
||||
@TableField("INB_QTY")
|
||||
@Schema(description = "库存总量")
|
||||
@ExcelProperty("库存总量")
|
||||
private Long inboundQuantity;
|
||||
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class MaterialBatchAssignDO extends BusinessBaseDO {
|
||||
* 产品id
|
||||
*/
|
||||
@TableField("PDT_ID")
|
||||
private String productId;
|
||||
private Long productId;
|
||||
/**
|
||||
* 库房ID
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ public class MaterialBatchAssignDO extends BusinessBaseDO {
|
||||
* 数量
|
||||
*/
|
||||
@TableField("INB_QTY")
|
||||
private String inboundQuantity;
|
||||
private Long inboundQuantity;
|
||||
/**
|
||||
* 暂存位置记录
|
||||
*/
|
||||
@@ -64,4 +64,6 @@ public class MaterialBatchAssignDO extends BusinessBaseDO {
|
||||
@TableField("RMK")
|
||||
private String remark;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -121,4 +121,9 @@ public class MaterialInfomationDO extends BusinessBaseDO {
|
||||
@TableField("RMK")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 库存入库id
|
||||
*/
|
||||
@TableField("INVT_INB_ID")
|
||||
private long inventoryInboundId;
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.zt.plat.module.qms.resource.material.dal.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 物料大类 DO
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@TableName("t_mtrl_pdt")
|
||||
@KeySequence("t_mtrl_pdt_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
/**
|
||||
* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO
|
||||
*/
|
||||
public class MaterialInventoryDO extends BusinessBaseDO {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
@TableField("PRN_ID")
|
||||
private Long parentId;
|
||||
/**
|
||||
* id路径
|
||||
*/
|
||||
@TableField("ID_PATH")
|
||||
private String idPath;
|
||||
/**
|
||||
* 节点类型,分类|产品
|
||||
*/
|
||||
@TableField("NDE_TP")
|
||||
private String nodeType;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField("NAME")
|
||||
private String name;
|
||||
/**
|
||||
* 其他配置
|
||||
*/
|
||||
@TableField("CST_CFG")
|
||||
private String customConfig;
|
||||
/**
|
||||
* 自定义表单
|
||||
*/
|
||||
@TableField("CST_FORM")
|
||||
private String customForm;
|
||||
/**
|
||||
* 扩展数据
|
||||
*/
|
||||
@TableField("CST_DAT")
|
||||
private String customData;
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
@TableField("TAG")
|
||||
private String tag;
|
||||
/**
|
||||
* 标签模板
|
||||
*/
|
||||
@TableField("LBL_TMPL_KY")
|
||||
private String labelTemplateKey;
|
||||
/**
|
||||
* 型号
|
||||
*/
|
||||
@TableField("MDL_NO")
|
||||
private String modelNo;
|
||||
/**
|
||||
* 规格
|
||||
*/
|
||||
@TableField("SPEC")
|
||||
private String specification;
|
||||
/**
|
||||
* 技术参数
|
||||
*/
|
||||
@TableField("PRM")
|
||||
private String parameter;
|
||||
/**
|
||||
* 制造商
|
||||
*/
|
||||
@TableField("MFR")
|
||||
private String manufacturer;
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
@TableField("UNT")
|
||||
private String unit;
|
||||
/**
|
||||
* 允许按量领取,1-领用时输入量,按量领取;0-领用时不能输入量,整个领走
|
||||
*/
|
||||
@TableField("ENB_PRTL")
|
||||
private String enablePartial;
|
||||
/**
|
||||
* 保质期(天)
|
||||
*/
|
||||
@TableField("DUE")
|
||||
private Integer due;
|
||||
/**
|
||||
* 开封后保质期是否变化
|
||||
*/
|
||||
@TableField("OPN_DUE_FLG")
|
||||
private String openDueFlag;
|
||||
/**
|
||||
* 开封后保质期(天)
|
||||
*/
|
||||
@TableField("OPN_DUE_AFT")
|
||||
private Integer openDueAfter;
|
||||
/**
|
||||
* 是否危险品
|
||||
*/
|
||||
@TableField("HZRD")
|
||||
private String hazardous;
|
||||
/**
|
||||
* 是否标准溶液
|
||||
*/
|
||||
@TableField("STD_SOL_FLG")
|
||||
private String standardSolutionFlag;
|
||||
/**
|
||||
* 是否标准物质
|
||||
*/
|
||||
@TableField("STD_MTRL_FLG")
|
||||
private String standardMaterialFlag;
|
||||
/**
|
||||
* 复标周期,单位:天。小于等于0-不复标
|
||||
*/
|
||||
@TableField("RVW_DUE")
|
||||
private Integer reviewDue;
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
@TableField("SRT_NO")
|
||||
private Integer sortNo;
|
||||
/**
|
||||
* 禁用
|
||||
*/
|
||||
@TableField("CNL_FLG")
|
||||
private String cancelFlag;
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
@TableField("SYS_DEPT_CD")
|
||||
private String systemDepartmentCode;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField("RMK")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 总数量
|
||||
*/
|
||||
@TableField("INB_QTY")
|
||||
private Long inboundQuantity;
|
||||
|
||||
}
|
||||
@@ -28,4 +28,10 @@ public interface MaterialBatchAssignMapper extends BaseMapperX<MaterialBatchAssi
|
||||
.orderByDesc(MaterialBatchAssignDO::getId));
|
||||
}
|
||||
|
||||
// default PageResult<MaterialBatchAssignDO> selectByInfId(MaterialBatchAssignPageReqVO reqVO) {
|
||||
// return selectPage(reqVO, new LambdaQueryWrapperX<MaterialBatchAssignDO>()
|
||||
// .eqIfPresent(MaterialBatchAssignDO::getMaterialInfomationId, reqVO.getMaterialInfomationId())
|
||||
// .orderByDesc(MaterialBatchAssignDO::getCreateTime));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -41,4 +41,15 @@ public interface MaterialInfomationMapper extends BaseMapperX<MaterialInfomation
|
||||
.orderByDesc(MaterialInfomationDO::getId));
|
||||
}
|
||||
|
||||
default PageResult<MaterialInfomationDO> selectAll(MaterialInfomationPageReqVO reqVO) {
|
||||
reqVO.setPageSize(-1);
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<MaterialInfomationDO>()
|
||||
.eqIfPresent(MaterialInfomationDO::getProductId, reqVO.getProductId())
|
||||
.eqIfPresent(MaterialInfomationDO::getBatchId, reqVO.getBatchId())
|
||||
.eqIfPresent(MaterialInfomationDO::getUsageStatus, reqVO.getUsageStatus())
|
||||
.eqIfPresent(MaterialInfomationDO::getInventoryInboundId, reqVO.getInventoryInboundId()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,10 +3,19 @@ package com.zt.plat.module.qms.resource.material.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.MPJLambdaWrapperX;
|
||||
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayProjectAndParameterRespVO;
|
||||
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayProjectDataExtendRespVO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayParameterDataDO;
|
||||
import com.zt.plat.module.qms.business.dic.dal.dataobject.DictionaryProjectDO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailRespVO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryInboundDetailDO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailPageReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 入库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等 Mapper
|
||||
*
|
||||
@@ -32,4 +41,13 @@ public interface MaterialInventoryInboundDetailMapper extends BaseMapperX<Materi
|
||||
.orderByDesc(MaterialInventoryInboundDetailDO::getId));
|
||||
}
|
||||
|
||||
default PageResult<MaterialInventoryInboundDetailRespVO> selectPageList(MaterialInventoryInboundDetailPageReqVO reqVO) {
|
||||
return selectJoinPage(reqVO, MaterialInventoryInboundDetailRespVO.class, new MPJLambdaWrapperX<MaterialInventoryInboundDetailDO>()
|
||||
.selectAll(MaterialInventoryInboundDetailDO.class)
|
||||
.selectAs(MaterialInfomationDO::getProductId, MaterialInventoryInboundDetailRespVO::getProductId)
|
||||
.leftJoin(MaterialInfomationDO.class, MaterialInfomationDO::getId, MaterialInventoryInboundDetailDO::getMaterialInfomationId)
|
||||
.eqIfPresent(MaterialInfomationDO::getProductId, reqVO.getProductId())
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.zt.plat.module.qms.resource.material.dal.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
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.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustRegistrationDO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryRespVO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 入库 Mapper
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@Mapper
|
||||
public interface MaterialInventoryMapper extends BaseMapperX<MaterialInventoryDO> {
|
||||
|
||||
// default PageResult<MaterialInventoryDO> selectPage(MaterialInventoryRespVO reqVO) {
|
||||
// return selectPage(reqVO, new LambdaQueryWrapperX<MaterialInventoryDO>()
|
||||
//
|
||||
// .eqIfPresent(MaterialInventoryDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
|
||||
// .eqIfPresent(MaterialInventoryDO::getRemark, reqVO.getRemark())
|
||||
// .betweenIfPresent(MaterialInventoryDO::getCreateTime, reqVO.getCreateTime())
|
||||
// .orderByDesc(MaterialInventoryDO::getId));
|
||||
// }
|
||||
|
||||
IPage<MaterialInventoryDO> selectPageList (IPage<?> page,@Param("param")MaterialInventoryRespVO RespVO);
|
||||
|
||||
}
|
||||
@@ -53,6 +53,14 @@ public interface MaterialBatchAssignService {
|
||||
*/
|
||||
MaterialBatchAssignDO getMaterialBatchAssign(Long id);
|
||||
|
||||
/**
|
||||
* 用物料实例Id获得物料批次
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 物料批次分发
|
||||
*/
|
||||
public PageResult<MaterialBatchAssignDO> getMaterialBatchAssignByInfId(MaterialBatchAssignPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得物料批次分发分页
|
||||
*
|
||||
@@ -61,4 +69,12 @@ public interface MaterialBatchAssignService {
|
||||
*/
|
||||
PageResult<MaterialBatchAssignDO> getMaterialBatchAssignPage(MaterialBatchAssignPageReqVO pageReqVO);
|
||||
|
||||
|
||||
/**
|
||||
* 分发到实验室
|
||||
* @param createReqVO
|
||||
* @return
|
||||
*/
|
||||
MaterialBatchAssignRespVO assignLab(@Valid MaterialBatchAssignSaveReqVO createReqVO);
|
||||
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.zt.plat.module.qms.resource.material.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchAssignPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchAssignRespVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchAssignSaveReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInfomationMapper;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -32,6 +37,9 @@ public class MaterialBatchAssignServiceImpl implements MaterialBatchAssignServic
|
||||
@Resource
|
||||
private MaterialBatchAssignMapper materialBatchAssignMapper;
|
||||
|
||||
@Resource
|
||||
private MaterialInfomationMapper materialInfomationMapper;
|
||||
|
||||
@Override
|
||||
public MaterialBatchAssignRespVO createMaterialBatchAssign(MaterialBatchAssignSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@@ -85,8 +93,42 @@ public class MaterialBatchAssignServiceImpl implements MaterialBatchAssignServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MaterialBatchAssignDO> getMaterialBatchAssignPage(MaterialBatchAssignPageReqVO pageReqVO) {
|
||||
public PageResult<MaterialBatchAssignDO> getMaterialBatchAssignByInfId(MaterialBatchAssignPageReqVO pageReqVO){
|
||||
return materialBatchAssignMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MaterialBatchAssignDO> getMaterialBatchAssignPage(MaterialBatchAssignPageReqVO pageReqVO) {
|
||||
PageResult<MaterialBatchAssignDO> pageResult = materialBatchAssignMapper.selectPage(pageReqVO);
|
||||
|
||||
|
||||
|
||||
/** 统计批次剩余量需要除去已上架(存在实例)的部分 */
|
||||
pageResult.getList().forEach(item -> {
|
||||
MaterialInfomationPageReqVO infomationPageReqVO = new MaterialInfomationPageReqVO();
|
||||
infomationPageReqVO.setBatchId(item.getId());
|
||||
infomationPageReqVO.setProductId(item.getProductId());
|
||||
infomationPageReqVO.setUsageStatus("0");
|
||||
PageResult<MaterialInfomationDO> materialInfomationDOPageResult = materialInfomationMapper.selectAll(infomationPageReqVO);
|
||||
Long totalCount = materialInfomationDOPageResult.getTotalCount();
|
||||
// item.setInboundQuantity(item.getInboundQuantity()-totalCount);
|
||||
// 方案2: 添加边界检查,防止负数
|
||||
long calculatedQuantity = item.getInboundQuantity() - totalCount;
|
||||
item.setInboundQuantity(Math.max(0L, calculatedQuantity));
|
||||
});
|
||||
|
||||
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MaterialBatchAssignRespVO assignLab(MaterialBatchAssignSaveReqVO createReqVO){
|
||||
// 插入
|
||||
MaterialBatchAssignDO materialBatchAssign = BeanUtils.toBean(createReqVO, MaterialBatchAssignDO.class);
|
||||
materialBatchAssignMapper.insert(materialBatchAssign);
|
||||
// 返回
|
||||
return BeanUtils.toBean(materialBatchAssign, MaterialBatchAssignRespVO.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -61,4 +61,20 @@ public interface MaterialInventoryCheckService {
|
||||
*/
|
||||
PageResult<MaterialInventoryCheckDO> getMaterialInventoryCheckPage(MaterialInventoryCheckPageReqVO pageReqVO);
|
||||
|
||||
|
||||
/**
|
||||
* 创建库存盘点表单
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
MaterialInventoryCheckRespVO createMaterialInventoryCheckForm(@Valid MaterialInventoryCheckSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 获得库存盘点表单
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 库存盘点
|
||||
*/
|
||||
MaterialInventoryCheckRespVO getMaterialInventoryCheckForm(Long id);
|
||||
}
|
||||
@@ -1,14 +1,24 @@
|
||||
package com.zt.plat.module.qms.resource.material.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryCheckPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryCheckRespVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryCheckSaveReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryCheckBatchDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryCheckDetailDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInfomationMapper;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryCheckBatchMapper;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryCheckDetailMapper;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.*;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryCheckDO;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
@@ -32,6 +42,16 @@ public class MaterialInventoryCheckServiceImpl implements MaterialInventoryCheck
|
||||
@Resource
|
||||
private MaterialInventoryCheckMapper materialInventoryCheckMapper;
|
||||
|
||||
@Resource
|
||||
private MaterialInventoryCheckBatchMapper materialInventoryCheckBatchMapper;//盘点项目
|
||||
|
||||
@Resource
|
||||
private MaterialInventoryCheckDetailMapper materialInventoryCheckDetailMapper;//盘点明细
|
||||
|
||||
|
||||
@Resource
|
||||
private MaterialInfomationMapper materialInfomationMapper;//物料实例
|
||||
|
||||
@Override
|
||||
public MaterialInventoryCheckRespVO createMaterialInventoryCheck(MaterialInventoryCheckSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@@ -59,12 +79,12 @@ public class MaterialInventoryCheckServiceImpl implements MaterialInventoryCheck
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMaterialInventoryCheckListByIds(List<Long> ids) {
|
||||
public void deleteMaterialInventoryCheckListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateMaterialInventoryCheckExists(ids);
|
||||
// 删除
|
||||
materialInventoryCheckMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateMaterialInventoryCheckExists(List<Long> ids) {
|
||||
List<MaterialInventoryCheckDO> list = materialInventoryCheckMapper.selectByIds(ids);
|
||||
@@ -89,4 +109,75 @@ public class MaterialInventoryCheckServiceImpl implements MaterialInventoryCheck
|
||||
return materialInventoryCheckMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public MaterialInventoryCheckRespVO createMaterialInventoryCheckForm(@Valid MaterialInventoryCheckSaveReqVO createReqVO) {
|
||||
// 校验 batchList 不为空
|
||||
if (CollUtil.isEmpty(createReqVO.getBatchList())) {
|
||||
throw exception(MATERIAL_INVENTORY_CHECK_NOT_EXISTS);
|
||||
}
|
||||
|
||||
/** 插入库存盘点数据 */
|
||||
MaterialInventoryCheckDO materialInventoryCheck = BeanUtils.toBean(createReqVO, MaterialInventoryCheckDO.class);
|
||||
materialInventoryCheckMapper.insert(materialInventoryCheck);
|
||||
|
||||
MaterialInventoryCheckRespVO resultVo = BeanUtils.toBean(materialInventoryCheck, MaterialInventoryCheckRespVO.class);
|
||||
|
||||
// 获取生成的ID作为父ID
|
||||
Long parentId = materialInventoryCheck.getId();
|
||||
|
||||
|
||||
/** 插入库存盘点项目数据 */
|
||||
List<MaterialInventoryCheckBatchSaveReqVO> batchList = createReqVO.getBatchList();
|
||||
List<MaterialInventoryCheckBatchRespVO> BatchRespVOList = new ArrayList<>();
|
||||
for (MaterialInventoryCheckBatchSaveReqVO batchItem : batchList) {
|
||||
batchItem.setCheckId(parentId);
|
||||
// 插入
|
||||
MaterialInventoryCheckBatchDO materialInventoryCheckBatch = BeanUtils.toBean(batchItem, MaterialInventoryCheckBatchDO.class);
|
||||
materialInventoryCheckBatchMapper.insert(materialInventoryCheckBatch);
|
||||
BatchRespVOList.add(BeanUtils.toBean(materialInventoryCheckBatch, MaterialInventoryCheckBatchRespVO.class));
|
||||
}
|
||||
|
||||
/** 根据盘点数据自动填入盘点明细 */
|
||||
for (MaterialInventoryCheckBatchRespVO materialInventoryCheckBatchRespVO : BatchRespVOList) {
|
||||
MaterialInfomationPageReqVO reqVO = new MaterialInfomationPageReqVO();
|
||||
reqVO.setProductId(materialInventoryCheckBatchRespVO.getCheckProductId());
|
||||
|
||||
PageResult<MaterialInfomationDO> materialInfomationDOPageResult = materialInfomationMapper.selectAll(reqVO);
|
||||
|
||||
materialInventoryCheckBatchRespVO.setExpected(String.valueOf(materialInfomationDOPageResult.getList().size()));//以实例数量为应盘数量
|
||||
|
||||
materialInfomationDOPageResult.getList().forEach(materialInfomationDO -> {
|
||||
// 插入
|
||||
MaterialInventoryCheckDetailDO materialInventoryCheckDetail = new MaterialInventoryCheckDetailDO();
|
||||
materialInventoryCheckDetail.setCheckBatchId(materialInventoryCheckBatchRespVO.getId());//盘点项目ID
|
||||
materialInventoryCheckDetail.setInfomationId(materialInfomationDO.getId());//物料实例ID
|
||||
materialInventoryCheckDetail.setStatus("0");//待盘点状态
|
||||
materialInventoryCheckDetailMapper.insert(materialInventoryCheckDetail);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
resultVo.setBatchList(BatchRespVOList);
|
||||
// 返回结果
|
||||
return resultVo;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MaterialInventoryCheckRespVO getMaterialInventoryCheckForm(Long id) {
|
||||
MaterialInventoryCheckDO micDo = materialInventoryCheckMapper.selectById(id);
|
||||
if (micDo == null) {
|
||||
throw exception(MATERIAL_INVENTORY_CHECK_NOT_EXISTS);
|
||||
}
|
||||
List<MaterialInventoryCheckBatchDO> BatchDOList= materialInventoryCheckBatchMapper.selectList(new LambdaQueryWrapperX<MaterialInventoryCheckBatchDO>()
|
||||
.eq(MaterialInventoryCheckBatchDO::getCheckId, micDo.getId()));
|
||||
|
||||
MaterialInventoryCheckRespVO resultVo =BeanUtils.toBean(micDo, MaterialInventoryCheckRespVO.class);
|
||||
resultVo.setBatchList(BeanUtils.toBean(BatchDOList, MaterialInventoryCheckBatchRespVO.class));
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -61,4 +61,9 @@ public interface MaterialInventoryInboundDetailService {
|
||||
*/
|
||||
PageResult<MaterialInventoryInboundDetailDO> getMaterialInventoryInboundDetailPage(MaterialInventoryInboundDetailPageReqVO pageReqVO);
|
||||
|
||||
|
||||
|
||||
|
||||
PageResult<MaterialInventoryInboundDetailRespVO> getMaterialInventoryInboundDetailPageList(MaterialInventoryInboundDetailPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -89,4 +89,8 @@ public class MaterialInventoryInboundDetailServiceImpl implements MaterialInvent
|
||||
return materialInventoryInboundDetailMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MaterialInventoryInboundDetailRespVO> getMaterialInventoryInboundDetailPageList(MaterialInventoryInboundDetailPageReqVO pageReqVO) {
|
||||
return materialInventoryInboundDetailMapper.selectPageList(pageReqVO);
|
||||
}
|
||||
}
|
||||
@@ -61,4 +61,18 @@ public interface MaterialInventoryInboundService {
|
||||
*/
|
||||
PageResult<MaterialInventoryInboundDO> getMaterialInventoryInboundPage(MaterialInventoryInboundPageReqVO pageReqVO);
|
||||
|
||||
|
||||
/***
|
||||
* 批量入库/上架
|
||||
* @param createReqVO
|
||||
* @return
|
||||
*/
|
||||
void multiCreateMaterialInventoryInbound(MaterialInventoryInboundSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 单个入库/上架
|
||||
*/
|
||||
PageResult<MaterialInventoryInboundRespVO>singleCreateMaterialInventoryInbound(MaterialInventoryInboundSaveReqVO createReqVO);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,17 @@
|
||||
package com.zt.plat.module.qms.resource.material.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundRespVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundSaveReqVO;
|
||||
import com.zt.plat.framework.common.exception.ErrorCode;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.*;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchAssignDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryInboundDetailDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialBatchAssignMapper;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInfomationMapper;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryInboundDetailMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
@@ -30,7 +36,16 @@ import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*;
|
||||
public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInboundService {
|
||||
|
||||
@Resource
|
||||
private MaterialInventoryInboundMapper materialInventoryInboundMapper;
|
||||
private MaterialInventoryInboundMapper materialInventoryInboundMapper;//入库
|
||||
|
||||
@Resource
|
||||
private MaterialInventoryInboundDetailMapper materialInventoryInboundDetailMapper;//入库明细
|
||||
|
||||
@Resource
|
||||
private MaterialInfomationMapper materialInfomationMapper;//物料实例
|
||||
|
||||
@Resource
|
||||
private MaterialBatchAssignMapper materialBatchAssignMapper;//批次分配
|
||||
|
||||
@Override
|
||||
public MaterialInventoryInboundRespVO createMaterialInventoryInbound(MaterialInventoryInboundSaveReqVO createReqVO) {
|
||||
@@ -59,12 +74,12 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMaterialInventoryInboundListByIds(List<Long> ids) {
|
||||
public void deleteMaterialInventoryInboundListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateMaterialInventoryInboundExists(ids);
|
||||
// 删除
|
||||
materialInventoryInboundMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateMaterialInventoryInboundExists(List<Long> ids) {
|
||||
List<MaterialInventoryInboundDO> list = materialInventoryInboundMapper.selectByIds(ids);
|
||||
@@ -89,4 +104,88 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb
|
||||
return materialInventoryInboundMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void multiCreateMaterialInventoryInbound(MaterialInventoryInboundSaveReqVO createReqVO) {
|
||||
MaterialInventoryInboundDetailSaveReqVO detail = createReqVO.getDetail();
|
||||
|
||||
//判断输入数量是否大于批次剩余数据
|
||||
this.quantityCheck(detail);
|
||||
//生成入库头数据
|
||||
MaterialInventoryInboundDO materialInventoryInbound = BeanUtils.toBean(createReqVO, MaterialInventoryInboundDO.class);
|
||||
materialInventoryInboundMapper.insert(materialInventoryInbound);
|
||||
|
||||
|
||||
|
||||
//根据入库数量创建实例数据
|
||||
List<MaterialInfomationDO> MaterialInfomationDO = new ArrayList<MaterialInfomationDO>();
|
||||
for (int i = 0; i < detail.getQuantity(); i++) {
|
||||
MaterialInfomationDO materialInfomation = new MaterialInfomationDO();
|
||||
materialInfomation.setBatchId(detail.getBatchAssignId());//分发批次ID
|
||||
materialInfomation.setLocationId(detail.getLocationId());//货位Id
|
||||
materialInfomation.setInventoryInboundId(materialInventoryInbound.getId());//入库ID,批量入库的,所以为同一ID,主要是验收申请入库时不一样
|
||||
materialInfomation.setProductId(detail.getProductId());//分类ID
|
||||
materialInfomation.setPublishStatus("1");//批量入库默认上架
|
||||
MaterialInfomationDO.add(materialInfomation);
|
||||
}
|
||||
|
||||
materialInfomationMapper.insert(MaterialInfomationDO);
|
||||
|
||||
|
||||
//根据实例数据创建入库明细
|
||||
MaterialInfomationPageReqVO InfomationVO = new MaterialInfomationPageReqVO();
|
||||
InfomationVO.setInventoryInboundId(materialInventoryInbound.getId());
|
||||
PageResult<MaterialInfomationDO> InfomationList = materialInfomationMapper.selectPage(InfomationVO);
|
||||
InfomationList.getList().forEach(item -> {
|
||||
MaterialInventoryInboundDetailDO detailDO = new MaterialInventoryInboundDetailDO();
|
||||
detailDO.setInboundId(materialInventoryInbound.getId());
|
||||
detailDO.setMaterialInfomationId(item.getId());
|
||||
detailDO.setInboundWay("批量入库");
|
||||
materialInventoryInboundDetailMapper.insert(detailDO);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MaterialInventoryInboundRespVO> singleCreateMaterialInventoryInbound(MaterialInventoryInboundSaveReqVO createReqVO) {
|
||||
|
||||
MaterialInventoryInboundDetailSaveReqVO detail = createReqVO.getDetail();
|
||||
|
||||
//判断输入数量是否大于批次剩余数据
|
||||
this.quantityCheck(detail);
|
||||
//生成入库头数据
|
||||
MaterialInventoryInboundDO materialInventoryInbound = BeanUtils.toBean(createReqVO, MaterialInventoryInboundDO.class);
|
||||
materialInventoryInboundMapper.insert(materialInventoryInbound);
|
||||
|
||||
//根据实例数据创建入库明细
|
||||
MaterialInfomationPageReqVO InfomationVO = new MaterialInfomationPageReqVO();
|
||||
InfomationVO.setInventoryInboundId(materialInventoryInbound.getId());
|
||||
PageResult<MaterialInfomationDO> InfomationList = materialInfomationMapper.selectPage(InfomationVO);
|
||||
InfomationList.getList().forEach(item -> {
|
||||
MaterialInventoryInboundDetailDO detailDO = new MaterialInventoryInboundDetailDO();
|
||||
detailDO.setInboundId(materialInventoryInbound.getId());
|
||||
detailDO.setMaterialInfomationId(item.getId());
|
||||
detailDO.setInboundWay("采购入库");
|
||||
materialInventoryInboundDetailMapper.insert(detailDO);
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void quantityCheck(MaterialInventoryInboundDetailSaveReqVO detail) {
|
||||
if (detail.getBatchAssignId() == null || detail.getQuantity() == null) {
|
||||
throw exception(MATERIAL_BATCH_ASSIGN_NOT_EXISTS);
|
||||
}
|
||||
|
||||
MaterialBatchAssignDO materialBatchAssignDO = materialBatchAssignMapper.selectById(detail.getBatchAssignId());
|
||||
if (materialBatchAssignDO==null){
|
||||
throw exception(new ErrorCode(1_032_150_000, "批次信息错误-"+detail.getBatchAssignId()));
|
||||
}
|
||||
|
||||
//判断输入数量是否大于批次剩余数据
|
||||
if (materialBatchAssignDO.getInboundQuantity() < detail.getQuantity()) {
|
||||
throw exception(new ErrorCode(1_032_150_000, "批次剩余量不足"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -61,4 +61,14 @@ public interface MaterialInventoryOutboundService {
|
||||
*/
|
||||
PageResult<MaterialInventoryOutboundDO> getMaterialInventoryOutboundPage(MaterialInventoryOutboundPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 创建出库
|
||||
*
|
||||
* 连带出库明细一起创建
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
MaterialInventoryOutboundRespVO createMaterialInventoryOutboundAll(@Valid MaterialInventoryOutboundSaveReqVO createReqVO);
|
||||
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.zt.plat.module.qms.resource.material.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundRespVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundSaveReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.*;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryOutboundDetailDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryOutboundDetailMapper;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
@@ -32,6 +34,9 @@ public class MaterialInventoryOutboundServiceImpl implements MaterialInventoryOu
|
||||
@Resource
|
||||
private MaterialInventoryOutboundMapper materialInventoryOutboundMapper;
|
||||
|
||||
@Resource
|
||||
private MaterialInventoryOutboundDetailMapper materialInventoryOutboundDetailMapper;
|
||||
|
||||
@Override
|
||||
public MaterialInventoryOutboundRespVO createMaterialInventoryOutbound(MaterialInventoryOutboundSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@@ -59,12 +64,12 @@ public class MaterialInventoryOutboundServiceImpl implements MaterialInventoryOu
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMaterialInventoryOutboundListByIds(List<Long> ids) {
|
||||
public void deleteMaterialInventoryOutboundListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateMaterialInventoryOutboundExists(ids);
|
||||
// 删除
|
||||
materialInventoryOutboundMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateMaterialInventoryOutboundExists(List<Long> ids) {
|
||||
List<MaterialInventoryOutboundDO> list = materialInventoryOutboundMapper.selectByIds(ids);
|
||||
@@ -89,4 +94,39 @@ public class MaterialInventoryOutboundServiceImpl implements MaterialInventoryOu
|
||||
return materialInventoryOutboundMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public MaterialInventoryOutboundRespVO createMaterialInventoryOutboundAll(@Valid MaterialInventoryOutboundSaveReqVO createReqVO) {
|
||||
|
||||
|
||||
/** 创建出库头 */
|
||||
// 插入
|
||||
MaterialInventoryOutboundDO materialInventoryOutbound = BeanUtils.toBean(createReqVO, MaterialInventoryOutboundDO.class);
|
||||
materialInventoryOutboundMapper.insert(materialInventoryOutbound);
|
||||
|
||||
MaterialInventoryOutboundRespVO respVO = BeanUtils.toBean(materialInventoryOutbound, MaterialInventoryOutboundRespVO.class);
|
||||
|
||||
/** 创建出出库明细 */
|
||||
// 校验存在
|
||||
if (createReqVO.getDetailSaveReqVoList() == null || createReqVO.getDetailSaveReqVoList().size() == 0)
|
||||
throw exception(MATERIAL_INVENTORY_OUTBOUND_DETAIL_NOT_EXISTS);
|
||||
|
||||
List<MaterialInventoryOutboundDetailRespVO> detailReqVoList = new ArrayList<>();
|
||||
|
||||
for (MaterialInventoryOutboundDetailSaveReqVO itemVo : createReqVO.getDetailSaveReqVoList()) {
|
||||
MaterialInventoryOutboundDetailDO materialInventoryOutboundDetail = BeanUtils.toBean(itemVo, MaterialInventoryOutboundDetailDO.class);
|
||||
|
||||
// 设置出库单id
|
||||
materialInventoryOutboundDetail.setParentId(materialInventoryOutbound.getId());
|
||||
|
||||
materialInventoryOutboundDetailMapper.insert(materialInventoryOutboundDetail);
|
||||
detailReqVoList.add(BeanUtils.toBean(materialInventoryOutboundDetail, MaterialInventoryOutboundDetailRespVO.class));
|
||||
}
|
||||
|
||||
respVO.setDetailReqVoList(detailReqVoList);
|
||||
|
||||
|
||||
// 返回
|
||||
return respVO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.zt.plat.module.qms.resource.material.service;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryRespVO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 库存管理 Service 接口
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
public interface MaterialInventoryService {
|
||||
|
||||
|
||||
/**
|
||||
* 单个入库/上架
|
||||
*/
|
||||
PageResult<MaterialInventoryDO> getMaterialInventoryPage(MaterialInventoryRespVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 同意出库
|
||||
*/
|
||||
|
||||
void agreeMaterialInventoryOutbound(Long id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.zt.plat.module.qms.resource.material.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessSampleEntrustRegistrationExtendRespVO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustRegistrationDO;
|
||||
import com.zt.plat.module.qms.enums.QmsCommonConstant;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundDetailPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryRespVO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryOutboundDetailDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInfomationMapper;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryMapper;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryOutboundDetailMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.MATERIAL_INFOMATION_NOT_EXISTS;
|
||||
|
||||
@Service
|
||||
public class MaterialInventoryServiceImpl implements MaterialInventoryService {
|
||||
@Resource
|
||||
private MaterialInventoryMapper materialInventoryMapper;
|
||||
|
||||
@Resource
|
||||
private MaterialInventoryOutboundDetailMapper materialInventoryOutboundDetailMapper;//出库明细
|
||||
|
||||
@Resource
|
||||
private MaterialInfomationMapper materialInfomationMapper;//物料实例
|
||||
@Override
|
||||
public PageResult<MaterialInventoryDO> getMaterialInventoryPage(MaterialInventoryRespVO pageReqVO) {
|
||||
IPage<MaterialInventoryDO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
||||
|
||||
IPage<MaterialInventoryDO> pageList = materialInventoryMapper.selectPageList(page, pageReqVO);
|
||||
PageResult<MaterialInventoryDO> pageResult = new PageResult<>(pageList.getRecords(), pageList.getTotal());
|
||||
return BeanUtils.toBean(pageResult, MaterialInventoryDO.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void agreeMaterialInventoryOutbound(Long outId) {
|
||||
MaterialInventoryOutboundDetailPageReqVO pageReqVO = new MaterialInventoryOutboundDetailPageReqVO();
|
||||
pageReqVO.setParentId(outId);
|
||||
pageReqVO.setPageSize(-1);//不分页
|
||||
PageResult<MaterialInventoryOutboundDetailDO> materialInventoryOutboundDetailDOPageResult = materialInventoryOutboundDetailMapper.selectPage(pageReqVO);
|
||||
|
||||
List<MaterialInventoryOutboundDetailDO> list = materialInventoryOutboundDetailDOPageResult.getList();
|
||||
for (MaterialInventoryOutboundDetailDO item : list) {
|
||||
// 校验存在
|
||||
validateMaterialInfomationExists(item.getInfomationId());
|
||||
// 更新
|
||||
MaterialInfomationDO updateObj = new MaterialInfomationDO();
|
||||
updateObj.setId(item.getInfomationId());
|
||||
updateObj.setUsageStatus("1");
|
||||
materialInfomationMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void validateMaterialInfomationExists(Long id) {
|
||||
if (materialInfomationMapper.selectById(id) == null) {
|
||||
throw exception(MATERIAL_INFOMATION_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,9 @@ public class XRFDataServiceImpl implements XRFDataService {
|
||||
//获取荧光样品id列表
|
||||
List<String> sampleIdList = xrfDeviceSampleList.stream().map(XRFDeviceSampleReqVO::getSampleId).collect(Collectors.toList());
|
||||
|
||||
//获取荧光样品编号列表
|
||||
List<String> sampleCodeList = xrfDeviceSampleList.stream().map(m -> m.getSampleCode()).collect(Collectors.toList());
|
||||
|
||||
//查询数据库是否已保存了荧光数据
|
||||
BusinessXRFDataReqVO existXRFDataSearch = new BusinessXRFDataReqVO();
|
||||
existXRFDataSearch.setDeviceNo(xrfDeviceSampleFirst.getDeviceNo());
|
||||
@@ -95,6 +98,9 @@ public class XRFDataServiceImpl implements XRFDataService {
|
||||
}
|
||||
//根据设备编号查询荧光元素配置
|
||||
List<ConfigXRFProjectDO> conYgElementList = configXRFProjectMapper.selectByDeviceNo(xrfDeviceSampleFirst.getDeviceNo());
|
||||
|
||||
//根据样品编号及分析方法类型,获取检测任务数据
|
||||
List<BusinessAssayTaskDataExtendRespVO> businessAssayTaskDataList = businessAssayTaskDataMapper.selectBySampleAssayCodesAndConfigAssayMethodDictionaryBusinessKey(sampleCodeList, "xshxyggpf");
|
||||
|
||||
List<BusinessAssayTaskDataDO> businessAssayTaskDataDOList = new ArrayList<>();
|
||||
List<BusinessAssayProjectDataDO> busElementValueList = new ArrayList<>();
|
||||
@@ -128,10 +134,12 @@ public class XRFDataServiceImpl implements XRFDataService {
|
||||
|
||||
//处理匹配
|
||||
List<BusinessAssayProjectDataExtendRespVO> tempBusElementValueList = new ArrayList<>();
|
||||
BusinessAssayTaskDataExtendRespVO businessAssayTaskData = businessAssayTaskDataMapper.selectBySampleCode(ygDeviceSample.getSampleCode());
|
||||
if (businessAssayTaskData != null) {
|
||||
List<BusinessAssayProjectDataExtendRespVO> busElementValues = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataId(businessAssayTaskData.getId());
|
||||
tempBusElementValueList.addAll(busElementValues);
|
||||
List<BusinessAssayTaskDataExtendRespVO> currBusinessAssayTaskDataList = businessAssayTaskDataList.stream().filter(f -> ygDeviceSample.getSampleCode().equals(f.getSampleAssayCode())).collect(Collectors.toList());
|
||||
if (currBusinessAssayTaskDataList != null && currBusinessAssayTaskDataList.size() > 0) {
|
||||
for (BusinessAssayTaskDataExtendRespVO businessAssayTaskData : currBusinessAssayTaskDataList) {
|
||||
List<BusinessAssayProjectDataExtendRespVO> busElementValues = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataId(businessAssayTaskData.getId());
|
||||
tempBusElementValueList.addAll(busElementValues);
|
||||
}
|
||||
}
|
||||
|
||||
//分析元素
|
||||
@@ -142,9 +150,7 @@ public class XRFDataServiceImpl implements XRFDataService {
|
||||
continue;
|
||||
}
|
||||
|
||||
//查询是否有特殊转换率
|
||||
// QmsConYgConverRate conYgConverRate = conYgConverRateService.getOne(Wrappers.<QmsConYgConverRate>query().lambda().eq(QmsConYgConverRate::getDeviceNo, ygDeviceSample.getDeviceNo())
|
||||
// .eq(QmsConYgConverRate::getLineName, ygDeviceSample.getLineName()).eq(QmsConYgConverRate::getElementName, ygDeviceSampleElement.getElementName()));
|
||||
//查询是否有特殊转换率
|
||||
ConfigXRFConversionRateDO conYgConverRate = configXRFConversionRateMapper.selectBy(ygDeviceSample.getDeviceNo(), ygDeviceSample.getLineName(), ygDeviceSampleElement.getXrfProjectName());
|
||||
|
||||
ConfigXRFProjectDO conYgElement = null;
|
||||
@@ -171,16 +177,19 @@ public class XRFDataServiceImpl implements XRFDataService {
|
||||
conYgElementDataType = conYgElement.getDecimalPosition();
|
||||
}
|
||||
Long elementId = conYgElement.getDictionaryProjectId();
|
||||
BusinessAssayProjectDataExtendRespVO busElementValue = tempBusElementValueList.stream().filter(f -> f.getDictionaryProjectId().equals(elementId) && f.getIsEnabled().equals(1)).findFirst().orElse(null);
|
||||
if (busElementValue != null) {
|
||||
//化验数据小数精度四舍六入五单双
|
||||
if("decimal".equals(busElementValue.getDataType())) {
|
||||
busElementValue.setValue(elementValue.setScale(busElementValue.getDecimalPosition(), RoundingMode.HALF_EVEN).toPlainString());
|
||||
} else {
|
||||
busElementValue.setValue(elementValue.setScale(conYgElementDataType, RoundingMode.HALF_EVEN).toPlainString());
|
||||
}
|
||||
busElementValue.setRemark(conYgElement.getShowName() + ": " + busElementValue.getValue());
|
||||
busElementValueList.add(BeanUtils.toBean(busElementValue, BusinessAssayProjectDataDO.class));
|
||||
List<BusinessAssayProjectDataExtendRespVO> currBusElementValueList = tempBusElementValueList.stream().filter(f -> f.getDictionaryProjectId().equals(elementId) && f.getIsEnabled().equals(1)).collect(Collectors.toList());
|
||||
if (currBusElementValueList != null && currBusElementValueList.size() > 0) {
|
||||
for (BusinessAssayProjectDataExtendRespVO busElementValue : currBusElementValueList) {
|
||||
//化验数据小数精度四舍六入五单双
|
||||
if("decimal".equals(busElementValue.getDataType())) {
|
||||
busElementValue.setValue(elementValue.setScale(busElementValue.getDecimalPosition(), RoundingMode.HALF_EVEN).toPlainString());
|
||||
} else {
|
||||
busElementValue.setValue(elementValue.setScale(conYgElementDataType, RoundingMode.HALF_EVEN).toPlainString());
|
||||
}
|
||||
busElementValue.setRemark(conYgElement.getShowName() + ": " + busElementValue.getValue());
|
||||
busElementValueList.add(BeanUtils.toBean(busElementValue, BusinessAssayProjectDataDO.class));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ReportFieldValueData reportFieldValueData = new ReportFieldValueData();
|
||||
@@ -191,11 +200,6 @@ public class XRFDataServiceImpl implements XRFDataService {
|
||||
reportFieldValueData.setUnit(ygDeviceSampleElement.getXrfProjectUnit());
|
||||
assayDataJson.put(conYgElement.getSaveColumn(), reportFieldValueData);
|
||||
|
||||
// if(conYgElementDataType != null && conYgElementDataType.intValue() > -1) {
|
||||
// BeanUtil.setFieldValue(busYgData, conYgElement.getSaveColumn(), elementValue.setScale(conYgElementDataType, BigDecimal.ROUND_HALF_EVEN).toPlainString());//数据格式化-四舍六入五单双
|
||||
// } else {
|
||||
// BeanUtil.setFieldValue(busYgData, conYgElement.getSaveColumn(), elementValue);
|
||||
// }
|
||||
}
|
||||
}
|
||||
//循环元素修改流程节点
|
||||
@@ -209,13 +213,15 @@ public class XRFDataServiceImpl implements XRFDataService {
|
||||
//设置分析数据
|
||||
busYgData.setAssayData(assayDataJson.toJSONString());
|
||||
|
||||
if (businessAssayTaskData != null) {
|
||||
busYgData.setIsMatched(QmsCommonConstant.YES);
|
||||
busYgData.setBusinessBaseSampleId(businessAssayTaskData.getBusinessBaseSampleId());
|
||||
busYgData.setBusinessSubParentSampleId(businessAssayTaskData.getBusinessSubParentSampleId());
|
||||
busYgData.setBusinessSubSampleId(businessAssayTaskData.getBusinessSubSampleId());
|
||||
busYgData.setBusinessAssayTaskDataId(businessAssayTaskData.getId());
|
||||
businessAssayTaskDataDOList.add(BeanUtils.toBean(businessAssayTaskData, BusinessAssayTaskDataDO.class));
|
||||
if (currBusinessAssayTaskDataList != null && currBusinessAssayTaskDataList.size() > 0) {
|
||||
for (BusinessAssayTaskDataExtendRespVO businessAssayTaskData : currBusinessAssayTaskDataList) {
|
||||
busYgData.setIsMatched(QmsCommonConstant.YES);
|
||||
busYgData.setBusinessBaseSampleId(businessAssayTaskData.getBusinessBaseSampleId());
|
||||
busYgData.setBusinessSubParentSampleId(businessAssayTaskData.getBusinessSubParentSampleId());
|
||||
busYgData.setBusinessSubSampleId(businessAssayTaskData.getBusinessSubSampleId());
|
||||
busYgData.setBusinessAssayTaskDataId(businessAssayTaskData.getId());
|
||||
businessAssayTaskDataDOList.add(BeanUtils.toBean(businessAssayTaskData, BusinessAssayTaskDataDO.class));
|
||||
}
|
||||
}
|
||||
|
||||
busYgDataList.add(busYgData);
|
||||
@@ -227,18 +233,13 @@ public class XRFDataServiceImpl implements XRFDataService {
|
||||
} else {
|
||||
conYgLine.setLastSynchronousDataTime(maxSampleTime);
|
||||
}
|
||||
//更新配置时间
|
||||
//更新荧光线配置时间
|
||||
configXRFLineMapper.updateById(conYgLine);
|
||||
if (busYgDataList.size() > 0) {
|
||||
|
||||
//保存荧光数据
|
||||
businessXRFDataMapper.insertBatch(busYgDataList);
|
||||
|
||||
//更新分样子样
|
||||
// if(businessAssayTaskDataDOs.size() > 0) {
|
||||
// busSubCsampleService.updateBatchById(businessAssayTaskDataDOs);
|
||||
// }
|
||||
|
||||
|
||||
//更新分析结果
|
||||
if (busElementValueList.size() > 0) {
|
||||
businessAssayProjectDataMapper.updateBatch(busElementValueList);
|
||||
|
||||
@@ -30,9 +30,14 @@
|
||||
d.DELETED as deleted,
|
||||
s.CREATE_TIME as baseSampleCreateTime,
|
||||
s.SMP_NAME as sampleName,
|
||||
s.BSE_SMP_NAME as baseSampleName
|
||||
s.BSE_SMP_NAME as baseSampleName,
|
||||
ed.ENTT_SMP_NAME as entrustSampleName,
|
||||
ed.ENTT_SMP_CD as entrustSampleCode,
|
||||
ed.SRT as entrustDetailSort,
|
||||
(select KY from T_DIC_BSN dic where dic.id = s.DIC_BSN_ID) as sampleTypeKey
|
||||
FROM T_BSN_ASY_RPT_DAT d
|
||||
inner join T_BSN_BSE_SMP s on d.BSN_BSE_SMP_ID = s.id
|
||||
inner join T_BSN_SMP_ENTT_DTL ed on ed.BSN_BSE_SMP_ID = s.id
|
||||
<where>
|
||||
<if test="param.idList != null and param.idList.size > 0">
|
||||
and d.id in (
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
m.SYS_DEPT_CD as systemDepartmentCode,
|
||||
m.UPD_CNT as updateCount,
|
||||
m.RMK as remark,
|
||||
m.CREATE_TIME as createTime,
|
||||
es.name as configEntrustSourceName
|
||||
FROM T_BSN_SMP_ENTT_REG m
|
||||
left join T_CFG_ENTT_SRC es on m.CFG_ENTT_SRC_ID = es.id
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zt.plat.module.qms.business.reportdoc.dal.mapper.ReportDocumentFileMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user