Compare commits

...

11 Commits

Author SHA1 Message Date
wxr
dd6df68061 升级liteflow及处理荧光数据上传 2025-12-12 08:48:36 +08:00
FCL
468e939ab1 Merge remote-tracking branch 'origin/test' into test 2025-12-11 17:53:16 +08:00
FCL
90b0aa5202 feat:报告转pdf、发起iwork流程。 开发中 2025-12-11 17:52:59 +08:00
yd
33543e5330 fix:物料管理业务逻辑修改。新增库存数据统计查询 2025-12-11 16:32:57 +08:00
yd
6a3d585802 feat:新增盘点表数据 2025-12-10 14:47:46 +08:00
禁止呵呵
9eec0bb05e feat:领用出库、同意出库 2025-12-09 21:19:31 +08:00
禁止呵呵
8fd750a82f Merge remote-tracking branch 'origin/test' into test 2025-12-09 16:10:46 +08:00
禁止呵呵
2790ed7ea1 feat:库存查询,库存记录查询、入库记录查询 2025-12-09 16:10:37 +08:00
禁止呵呵
1187038ba8 feat:库存管理 2025-12-09 09:39:07 +08:00
禁止呵呵
e2678fe7b4 Merge remote-tracking branch 'origin/test' into test 2025-12-09 09:29:22 +08:00
禁止呵呵
c1b975cca0 feat:入库、批量入库 2025-12-09 09:29:14 +08:00
93 changed files with 2404 additions and 137 deletions

View File

@@ -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, "样品调拨明细不存在");

View File

@@ -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 -->

View File

@@ -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;

View File

@@ -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)

View File

@@ -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());

View File

@@ -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();
}

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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));
}
}

View File

@@ -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());
@@ -235,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;
}
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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("记录数")

View File

@@ -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支持多值")

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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));
}
}

View File

@@ -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";
// }
// }
}

View File

@@ -529,13 +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);
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();
@@ -582,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;
}

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -6,6 +6,8 @@ import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayReportDat
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;
@@ -83,4 +85,6 @@ public interface ReportDocumentMainService {
//发起流程
CommonResult<ReportDocumentMainRespVO> createProcessInstance(ReportDocumentMainSaveReqVO entity);
void testAsyncTask(Long id);
}

View File

@@ -30,13 +30,19 @@ import com.zt.plat.module.qms.business.reportdoc.dal.mapper.ReportDocumentMainMa
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.*;
@@ -65,6 +71,26 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
@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);
}
/***
* 增加报表数据(按样品)
@@ -390,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");
@@ -423,7 +452,6 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
}
}
}
//"RETURN_FLAG_Activity_001": true 标识驳回到发起环节
if(variables.containsKey(returnFlagKey) && variables.getString(returnFlagKey).equals("true")){
//驳回。流程需要配置退回到发起节点
@@ -441,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;
@@ -472,4 +518,6 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
entity.setDocumentSignature(signObj.toJSONString());
}
}

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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");

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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 {
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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')")

View File

@@ -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));
}
}

View File

@@ -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));
}
}

View File

@@ -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);
}
}

View File

@@ -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));
}
}

View File

@@ -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));
}
}

View File

@@ -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));
}
}

View File

@@ -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;
}

View File

@@ -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 = "数量")

View File

@@ -78,5 +78,8 @@ public class MaterialInfomationPageReqVO extends PageParam {
@Schema(description = "大类ids")
List<Long> productIds;
@Schema(description = "入库id")
private Long inventoryInboundId;
}

View File

@@ -36,4 +36,7 @@ public class MaterialInventoryCheckBatchSaveReqVO {
@Schema(description = "备注")
private String remark;
@Schema(description = "盘点明细")
private List<MaterialInventoryCheckDetailSaveReqVO> detailList;
}

View File

@@ -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;
}

View File

@@ -68,4 +68,7 @@ public class MaterialInventoryCheckRespVO {
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "盘点项")
@ExcelProperty("盘点项")
private List<MaterialInventoryCheckBatchRespVO> batchList;
}

View File

@@ -50,4 +50,7 @@ public class MaterialInventoryCheckSaveReqVO {
@Schema(description = "备注")
private String remark;
@Schema(description = "盘点项")
private List<MaterialInventoryCheckBatchSaveReqVO> batchList;
}

View File

@@ -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;
}

View File

@@ -63,4 +63,6 @@ public class MaterialInventoryInboundDetailRespVO {
@ExcelProperty("创建时间")
private LocalDateTime createTime;
private Long productId;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -121,4 +121,9 @@ public class MaterialInfomationDO extends BusinessBaseDO {
@TableField("RMK")
private String remark;
/**
* 库存入库id
*/
@TableField("INVT_INB_ID")
private long inventoryInboundId;
}

View File

@@ -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;
}

View File

@@ -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));
// }
}

View File

@@ -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()
)
);
}
}

View File

@@ -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())
);
}
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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;
}
}

View File

@@ -61,4 +61,9 @@ public interface MaterialInventoryInboundDetailService {
*/
PageResult<MaterialInventoryInboundDetailDO> getMaterialInventoryInboundDetailPage(MaterialInventoryInboundDetailPageReqVO pageReqVO);
PageResult<MaterialInventoryInboundDetailRespVO> getMaterialInventoryInboundDetailPageList(MaterialInventoryInboundDetailPageReqVO pageReqVO);
}

View File

@@ -89,4 +89,8 @@ public class MaterialInventoryInboundDetailServiceImpl implements MaterialInvent
return materialInventoryInboundDetailMapper.selectPage(pageReqVO);
}
@Override
public PageResult<MaterialInventoryInboundDetailRespVO> getMaterialInventoryInboundDetailPageList(MaterialInventoryInboundDetailPageReqVO pageReqVO) {
return materialInventoryInboundDetailMapper.selectPageList(pageReqVO);
}
}

View File

@@ -61,4 +61,18 @@ public interface MaterialInventoryInboundService {
*/
PageResult<MaterialInventoryInboundDO> getMaterialInventoryInboundPage(MaterialInventoryInboundPageReqVO pageReqVO);
/***
* 批量入库/上架
* @param createReqVO
* @return
*/
void multiCreateMaterialInventoryInbound(MaterialInventoryInboundSaveReqVO createReqVO);
/**
* 单个入库/上架
*/
PageResult<MaterialInventoryInboundRespVO>singleCreateMaterialInventoryInbound(MaterialInventoryInboundSaveReqVO createReqVO);
}

View File

@@ -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, "批次剩余量不足"));
}
}
}

View File

@@ -61,4 +61,14 @@ public interface MaterialInventoryOutboundService {
*/
PageResult<MaterialInventoryOutboundDO> getMaterialInventoryOutboundPage(MaterialInventoryOutboundPageReqVO pageReqVO);
/**
* 创建出库
*
* 连带出库明细一起创建
*
* @param createReqVO 创建信息
* @return 编号
*/
MaterialInventoryOutboundRespVO createMaterialInventoryOutboundAll(@Valid MaterialInventoryOutboundSaveReqVO createReqVO);
}

View File

@@ -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;
}
}

View File

@@ -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);
}

View File

@@ -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);
}
}
}

View File

@@ -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);

View File

@@ -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>

View File

@@ -0,0 +1,103 @@
<?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.resource.material.dal.mapper.MaterialInventoryMapper">
<!-- 结果映射 -->
<resultMap id="MaterialInventoryMap"
type="com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryDO">
<!-- 基础字段 -->
<id column="id" property="id"/>
<result column="CRT_ID" property="creator"/>
<result column="CRT_NM" property="creatorName"/>
<result column="CRT_IP" property="createIp"/>
<result column="CRT_TM" property="createTime"/>
<result column="UPD_ID" property="updater"/>
<result column="UPD_NM" property="updaterName"/>
<result column="UPD_IP" property="updateIp"/>
<result column="UPD_TM" property="updateTime"/>
<result column="DEL_FLG" property="deleted"/>
<!-- 业务字段 -->
<result column="PRN_ID" property="parentId"/>
<result column="ID_PATH" property="idPath"/>
<result column="NDE_TP" property="nodeType"/>
<result column="NAME" property="name"/>
<result column="CST_CFG" property="customConfig"/>
<result column="CST_FORM" property="customForm"/>
<result column="CST_DAT" property="customData"/>
<result column="TAG" property="tag"/>
<result column="LBL_TMPL_KY" property="labelTemplateKey"/>
<result column="MDL_NO" property="modelNo"/>
<result column="SPEC" property="specification"/>
<result column="PRM" property="parameter"/>
<result column="MFR" property="manufacturer"/>
<result column="UNT" property="unit"/>
<result column="ENB_PRTL" property="enablePartial"/>
<result column="DUE" property="due"/>
<result column="OPN_DUE_FLG" property="openDueFlag"/>
<result column="OPN_DUE_AFT" property="openDueAfter"/>
<result column="HZRD" property="hazardous"/>
<result column="STD_SOL_FLG" property="standardSolutionFlag"/>
<result column="STD_MTRL_FLG" property="standardMaterialFlag"/>
<result column="RVW_DUE" property="reviewDue"/>
<result column="SRT_NO" property="sortNo"/>
<result column="CNL_FLG" property="cancelFlag"/>
<result column="SYS_DEPT_CD" property="systemDepartmentCode"/>
<result column="RMK" property="remark"/>
<result column="INB_QTY" property="inboundQuantity"/>
</resultMap>
<!-- 查询数据库列表 -->
<select id="selectPageList"
resultMap="MaterialInventoryMap">
SELECT
PDT.id,
PDT.PRN_ID,
PDT.ID_PATH,
PDT.NDE_TP,
PDT.NAME,
PDT.CST_CFG,
PDT.CST_FORM,
PDT.CST_DAT,
PDT.TAG,
PDT.LBL_TMPL_KY,
PDT.MDL_NO,
PDT.SPEC,
PDT.PRM,
PDT.MFR,
PDT.UNT,
PDT.ENB_PRTL,
PDT.DUE,
PDT.OPN_DUE_FLG,
PDT.OPN_DUE_AFT,
PDT.HZRD,
PDT.STD_SOL_FLG,
PDT.STD_MTRL_FLG,
PDT.RVW_DUE,
PDT.SRT_NO,
PDT.CNL_FLG,
PDT.SYS_DEPT_CD,
PDT.RMK,
COALESCE(ASN_SUM.INB_QTY_SUM, 0) AS INB_QTY
FROM
T_MTRL_PDT PDT
LEFT JOIN (
SELECT
PDT_ID,
SUM(INB_QTY) AS INB_QTY_SUM
FROM T_MTRL_BAT_ASN
WHERE DELETED = '0'
GROUP BY PDT_ID
) ASN_SUM ON PDT.id = ASN_SUM.PDT_ID
<where>
PDT.DELETED = '0'
<if test="param != null and param.id != null">
AND PDT.PRN_ID = #{param.id}
</if>
</where>
ORDER BY PDT.id DESC
</select>
</mapper>

View File

@@ -2,39 +2,51 @@ package com.zt.plat.module.qms;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.jupiter.api.Test;
import com.ql.util.express.DefaultContext;
import com.ql.util.express.ExpressRunner;
import com.ql.util.express.IExpressContext;
import com.alibaba.qlexpress4.Express4Runner;
import com.alibaba.qlexpress4.InitOptions;
import com.alibaba.qlexpress4.QLOptions;
import com.alibaba.qlexpress4.security.QLSecurityStrategy;
import com.zt.plat.module.qms.core.qlexpress.function.RoundToScaleHalfEven;
public class QLExpressRunnerTest {
@Test
void roundToScaleTest() throws Exception {
ExpressRunner expressRunner = new ExpressRunner(true, false);
expressRunner.addFunction("roundToScale", new RoundToScaleHalfEven());
// ExpressRunner expressRunner = new ExpressRunner(true, false);
Express4Runner express4Runner = new Express4Runner(InitOptions.DEFAULT_OPTIONS);
express4Runner.addFunction("roundToScale", new RoundToScaleHalfEven());
String express_3 = "roundToScale(0.2434, 3)";
Object result_3 = expressRunner.execute(express_3, null, null, false, false);
// Object result_3 = expressRunner.execute(express_3, null, null, false, false);
Object result_3 = express4Runner.execute(express_3, new HashMap<>(), QLOptions.DEFAULT_OPTIONS).getResult();
System.out.println("四舍0.2434 " + result_3);
String express_4 = "roundToScale(0.2416, 3)";
Object result_4 = expressRunner.execute(express_4, null, null, false, false);
// Object result_4 = expressRunner.execute(express_4, null, null, false, false);
Object result_4 = express4Runner.execute(express_4, new HashMap<>(), QLOptions.DEFAULT_OPTIONS).getResult();
System.out.println("六入0.2416 " + result_4);
String express_1 = "roundToScale(0.2445, 3)";
Object result_1 = expressRunner.execute(express_1, null, null, false, false);
// Object result_1 = expressRunner.execute(express_1, null, null, false, false);
Object result_1 = express4Runner.execute(express_1, new HashMap<>(), QLOptions.DEFAULT_OPTIONS).getResult();
System.out.println("偶不变0.2445 " + result_1);
String express_2 = "roundToScale(0.2455, 3)";
Object result_2 = expressRunner.execute(express_2, null, null, false, false);
System.out.println("奇变0.2445 " + result_2);
// Object result_2 = expressRunner.execute(express_2, null, null, false, false);
Object result_2 = express4Runner.execute(express_2, new HashMap<>(), QLOptions.DEFAULT_OPTIONS).getResult();
System.out.println("奇变0.2455 " + result_2);
}
@Test
void calculateAverageValueTest() throws Exception {
ExpressRunner expressRunner = new ExpressRunner(true, false);
//兼容3 将安全策略设置为 “开放”
InitOptions initOptions = InitOptions.builder().securityStrategy(QLSecurityStrategy.open()).build();
Express4Runner expressRunner = new Express4Runner(initOptions);
// Express4Runner expressRunner = new Express4Runner(InitOptions.DEFAULT_OPTIONS);
/**
String exp = ""
+ "function abc(int a, int b) {"
@@ -77,15 +89,19 @@ public class QLExpressRunnerTest {
int elementScale = 2;
DefaultContext<String, Object> context = new DefaultContext<>();
Map<String, Object> context = new HashMap<>();
context.put("values", valuesList);
context.put("scale", elementScale);
Object result = expressRunner.execute(express, context, null, false, false);
// Object result = expressRunner.execute(express, context, null, false, false);
Object result = expressRunner.execute(express, context, QLOptions.DEFAULT_OPTIONS).getResult();
System.out.println(result);
result = expressRunner.execute(express, context, QLOptions.builder().precise(true).build()).getResult();
System.out.println(result);
String[] names = expressRunner.getOutVarNames(express);
for(String s:names){
// String[] names = expressRunner.getOutVarNames(express);
Set<String> outVarNames = expressRunner.getOutVarNames(express);
for(String s: outVarNames){
System.out.println("var : " + s);
}
}