diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderDetailResultController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderDetailResultController.java index 04f9a76f..653ebcab 100644 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderDetailResultController.java +++ b/src/main/java/com/glxp/api/controller/inout/IoOrderDetailResultController.java @@ -2,6 +2,7 @@ package com.glxp.api.controller.inout; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.github.pagehelper.PageInfo; import com.glxp.api.annotation.AuthRuleAnnotation; import com.glxp.api.common.enums.ResultEnum; @@ -13,19 +14,36 @@ import com.glxp.api.entity.basic.BasicBussinessTypeEntity; import com.glxp.api.entity.inout.IoOrderDetailBizEntity; import com.glxp.api.entity.inout.IoOrderDetailCodeEntity; import com.glxp.api.entity.inout.IoOrderEntity; +import com.glxp.api.entity.system.SysPdfTemplateRelevanceStatemenEntity; +import com.glxp.api.entity.system.SystemPDFTemplateEntity; import com.glxp.api.req.inout.FilterCodeRequest; import com.glxp.api.req.inout.FilterOrderDetailResultRequest; import com.glxp.api.req.inout.FilterOrderRequest; +import com.glxp.api.req.inout.InspectionPDFTemplateRequest; import com.glxp.api.res.inout.IoCodeResponse; import com.glxp.api.res.inout.IoOrderDetailResultResponse; import com.glxp.api.service.basic.IBasicBussinessTypeService; import com.glxp.api.service.inout.*; +import com.glxp.api.service.system.SystemPDFModuleService; +import com.glxp.api.service.system.SystemPDFTemplateService; +import com.glxp.api.util.JasperUtils; +import net.sf.jasperreports.engine.JRException; +import org.springframework.beans.factory.annotation.Value; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 单据扫码明细查询接口 @@ -40,6 +58,12 @@ public class IoOrderDetailResultController extends BaseController { IBasicBussinessTypeService basicBussinessTypeService; @Resource IoCodeService codeService; + @Resource + private SystemPDFTemplateService systemPDFTemplateService; + @Resource + private SystemPDFModuleService systemPDFModuleService; + @Value("${file_path}") + private String filePath; /** * 查询单据扫码明细列表 @@ -140,4 +164,96 @@ public class IoOrderDetailResultController extends BaseController { return ResultVOUtils.success(orderDetailBizEntities); } + + //校验模板是否正确 + @AuthRuleAnnotation("") + @PostMapping("/udiwms/pdf/template/order/result/file") + public BaseResponse inspectionStockOrderPDFFromTemplateFile(@RequestBody InspectionPDFTemplateRequest inspectionPDFTemplateRequest) { + + //查询模板文件是否存在 + SysPdfTemplateRelevanceStatemenEntity sysPdfTemplateRelevanceStatemenEntity = systemPDFModuleService.selectByStatemenId(inspectionPDFTemplateRequest.getId()); + if (null == sysPdfTemplateRelevanceStatemenEntity) { + return ResultVOUtils.error(ResultEnum.DATA_NOT, "所属模块错误"); + } + + SystemPDFTemplateEntity systemPDFTemplateEntity = systemPDFTemplateService.selectById(String.valueOf(sysPdfTemplateRelevanceStatemenEntity.getTemplateId())); + if (null == systemPDFTemplateEntity) { + return ResultVOUtils.error(ResultEnum.DATA_NOT, "模板错误"); + } + return ResultVOUtils.success(sysPdfTemplateRelevanceStatemenEntity.getTemplateId()); + } + + + /** + * 出入库明细打印 + * + * @param filterOrderDetailResultRequest + * @return + */ + @AuthRuleAnnotation("") + @PostMapping("/udiwms/inout/resultDetail/filterOrderPrint") + public BaseResponse filterOrderPrint(@RequestBody FilterOrderDetailResultRequest filterOrderDetailResultRequest, HttpServletRequest request, HttpServletResponse response) throws JRException, IOException { + List ioOrderDetailResultResponseList=new ArrayList<>(); + SystemPDFTemplateEntity systemPDFTemplateEntity = systemPDFTemplateService.selectById(filterOrderDetailResultRequest.getTemplateId()); + //打印单号标签 + Map data = new HashMap<>(1); + List list = new ArrayList<>(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");//定义新的日期格式 + + //按选入打印 + if(filterOrderDetailResultRequest.getList() != null && filterOrderDetailResultRequest.getList().size()>0){ + ioOrderDetailResultResponseList =filterOrderDetailResultRequest.getList(); + }else{ + //按查询打印 + FilterOrderRequest filterOrderRequest = new FilterOrderRequest(); + filterOrderRequest.setVueType(filterOrderDetailResultRequest.getActionType()); + List actions = orderService.setActions(filterOrderRequest); + if (CollUtil.isEmpty(actions)) { + return ResultVOUtils.success(""); + } + filterOrderDetailResultRequest.setActions(actions); + ioOrderDetailResultResponseList = orderDetailResultService.filterOrderList(filterOrderDetailResultRequest); + for (IoOrderDetailResultResponse orderDetailResultResponse : ioOrderDetailResultResponseList) { + if (orderDetailResultResponse.getMainAction().equals(ConstantType.TYPE_OUT)) { + orderDetailResultResponse.setOutCount(orderDetailResultResponse.getReCount()); + orderDetailResultResponse.setInCount(0); + } else { + orderDetailResultResponse.setOutCount(0); + orderDetailResultResponse.setInCount(orderDetailResultResponse.getReCount()); + } + } + } + int i=1; + for (IoOrderDetailResultResponse ioOrderDetailResultResponse : ioOrderDetailResultResponseList) { + //组装数据 + Map ioOrderDetailResultData = new HashMap<>(); + ioOrderDetailResultData.put("index", String.valueOf(i)); + ioOrderDetailResultData.put("nameCode", ioOrderDetailResultResponse.getNameCode() == null ? ' ' : ioOrderDetailResultResponse.getNameCode()); + ioOrderDetailResultData.put("batchNo", ioOrderDetailResultResponse.getBatchNo() == null ? ' ' : ioOrderDetailResultResponse.getBatchNo()); + ioOrderDetailResultData.put("productDate", ioOrderDetailResultResponse.getProductDate() == null ? ' ' : ioOrderDetailResultResponse.getProductDate()); + ioOrderDetailResultData.put("expireDate", ioOrderDetailResultResponse.getExpireDate() == null ? ' ' : ioOrderDetailResultResponse.getExpireDate()); + ioOrderDetailResultData.put("coName", ioOrderDetailResultResponse.getCoName() == null ? ' ' : ioOrderDetailResultResponse.getCoName()); + ioOrderDetailResultData.put("certCode", ioOrderDetailResultResponse.getCertCode() == null ? ' ' : ioOrderDetailResultResponse.getCertCode()); + ioOrderDetailResultData.put("ylqxzcrbarmc", ioOrderDetailResultResponse.getYlqxzcrbarmc() == null ? ' ' : ioOrderDetailResultResponse.getYlqxzcrbarmc()); + ioOrderDetailResultData.put("manufacturer", ioOrderDetailResultResponse.getManufacturer() == null ? ' ' : ioOrderDetailResultResponse.getManufacturer()); + ioOrderDetailResultData.put("measname", ioOrderDetailResultResponse.getMeasname() == null ? ' ' : ioOrderDetailResultResponse.getMeasname()); + ioOrderDetailResultData.put("spec", ioOrderDetailResultResponse.getSpec() == null ? ' ' : ioOrderDetailResultResponse.getSpec()); + ioOrderDetailResultData.put("price", ioOrderDetailResultResponse.getPrice() == null ? ' ' : ioOrderDetailResultResponse.getPrice()); + ioOrderDetailResultData.put("count", ioOrderDetailResultResponse.getCount()); + ioOrderDetailResultData.put("reCount",ioOrderDetailResultResponse.getReCount()); + ioOrderDetailResultData.put("inCount", ioOrderDetailResultResponse.getInCount()); + ioOrderDetailResultData.put("acceptCount", ioOrderDetailResultResponse.getAcceptCount()); + ioOrderDetailResultData.put("fromCorpName", ioOrderDetailResultResponse.getFromCorpName() == null ? ' ' : ioOrderDetailResultResponse.getFromCorpName()); + ioOrderDetailResultData.put("billTypeName", ioOrderDetailResultResponse.getBillTypeName() == null ? ' ' : ioOrderDetailResultResponse.getBillTypeName()); + ioOrderDetailResultData.put("mainAction", ioOrderDetailResultResponse.getMainAction() == null ? ' ' : ioOrderDetailResultResponse.getMainAction()); + ioOrderDetailResultData.put("auditTime", ioOrderDetailResultResponse.getAuditTime() == null ? ' ' : formatter.format(ioOrderDetailResultResponse.getAuditTime())); + list.add(ioOrderDetailResultData); + i++; + } + + String param = JSON.toJSONString(list); + JasperUtils.jasperReport(request, response, param, filePath+"pdf/template/"+systemPDFTemplateEntity.getPath(), "pdf"); + return ResultVOUtils.success(); + } + } diff --git a/src/main/java/com/glxp/api/controller/inv/InvInnerOrderPrintController.java b/src/main/java/com/glxp/api/controller/inv/InvInnerOrderPrintController.java index 49a2cc13..b64f4696 100644 --- a/src/main/java/com/glxp/api/controller/inv/InvInnerOrderPrintController.java +++ b/src/main/java/com/glxp/api/controller/inv/InvInnerOrderPrintController.java @@ -1,5 +1,6 @@ package com.glxp.api.controller.inv; +import com.alibaba.fastjson.JSON; import com.github.pagehelper.PageInfo; import com.glxp.api.annotation.AuthRuleAnnotation; import com.glxp.api.annotation.Log; @@ -12,6 +13,7 @@ import com.glxp.api.entity.inv.InnerOrderEntity; import com.glxp.api.entity.inv.InvInnerOrderPrintEntity; import com.glxp.api.entity.inv.InvInnerOrderPdfTempEntity; import com.glxp.api.entity.system.SysPdfTemplateRelevanceLabelEntity; +import com.glxp.api.entity.system.SysPdfTemplateRelevanceStatemenEntity; import com.glxp.api.entity.system.SystemPDFModuleEntity; import com.glxp.api.entity.system.SystemPDFTemplateEntity; import com.glxp.api.req.inout.InspectionPDFTemplateRequest; @@ -62,6 +64,8 @@ public class InvInnerOrderPrintController { private IoOrderService ioOrderService; @Resource private InnerOrderService innerOrderService; + @Value("${file_path}") + private String filePath; @GetMapping("/udiwms/innerOrderPrint/filter") @@ -171,7 +175,7 @@ public class InvInnerOrderPrintController { innerOrderPdfTempService.insertStockPrintTempEntity(stockPrintTempEntity); stockPrintTempEntities.add(stockPrintTempEntity); } - jaspaperService.printPdfLocal(splits, stockPrintTempEntities, systemPDFTemplateEntity.getPath()); + jaspaperService.printPdfLocal(splits, stockPrintTempEntities, filePath + "/pdf/template/" + systemPDFTemplateEntity.getPath()); PageInfo pageInfo; pageInfo = new PageInfo<>(stockPrintTempEntities); PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); @@ -182,7 +186,7 @@ public class InvInnerOrderPrintController { } else { Map data = new HashMap(); data.put("data", printEntities); - JasperUtils.jasperReport(request, response, data, systemPDFTemplateEntity.getPath(), "pdf"); + JasperUtils.jasperReport(request, response, data, filePath + "/pdf/template/" + systemPDFTemplateEntity.getPath(), "pdf"); } @@ -217,6 +221,94 @@ public class InvInnerOrderPrintController { } + + //-----------打印码 + @AuthRuleAnnotation("") + @PostMapping("/udiwms/pdf/template/inspection/stock/qrcode/text/statement/file") + public BaseResponse inspectionStockQRCodeTextPDFFromTemplateStatementFile( + @RequestBody InspectionPDFTemplateRequest inspectionPDFTemplateRequest) throws Exception { + + //查询模板文件是否存在 + SysPdfTemplateRelevanceStatemenEntity sysPdfTemplateRelevanceStatemenEntity = systemPDFModuleService.selectByStatemenId(inspectionPDFTemplateRequest.getLabelId()+""); + if (null == sysPdfTemplateRelevanceStatemenEntity) { + return ResultVOUtils.error(ResultEnum.DATA_NOT, "所属模块错误"); + } + + SystemPDFTemplateEntity systemPDFTemplateEntity = systemPDFTemplateService.selectById(String.valueOf(sysPdfTemplateRelevanceStatemenEntity.getTemplateId())); + if (null == systemPDFTemplateEntity) { + return ResultVOUtils.error(ResultEnum.DATA_NOT, "模板错误"); + } + return ResultVOUtils.success(sysPdfTemplateRelevanceStatemenEntity.getTemplateId()); + } + + @AuthRuleAnnotation("") + @PostMapping("/udiwms/pdf/template/stock/qrcode/text/statement/file") + public BaseResponse stockQRCodeTextPDFFromTemplateStatementFile( + @RequestBody InnerOrderQRCodeTextPDFTemplateRequest stockQRCodeTextPDFTemplateRequest, + HttpServletRequest request, HttpServletResponse response) throws Exception { + + SysPdfTemplateRelevanceStatemenEntity sysPdfTemplateRelevanceStatemenEntity = systemPDFModuleService.selectByStatemenId(stockQRCodeTextPDFTemplateRequest.getLabelId()+""); + if (sysPdfTemplateRelevanceStatemenEntity == null) return ResultVOUtils.error(500, "未找到单据模板模块设置,请检查"); + + SystemPDFTemplateEntity systemPDFTemplateEntity = + systemPDFTemplateService.selectById(String.valueOf(sysPdfTemplateRelevanceStatemenEntity.getTemplateId())); + if (systemPDFTemplateEntity == null) return ResultVOUtils.error(ResultEnum.DATA_NOT, "模板错误"); + + List printEntities = new ArrayList<>(); + List mStockPrintEntities = new ArrayList<>(); + FilterinnerOrderprintRequest filterinnerOrderprintRequest = new FilterinnerOrderprintRequest(); + if (stockQRCodeTextPDFTemplateRequest.getOrderId() != null) { + filterinnerOrderprintRequest.setSOrderId(stockQRCodeTextPDFTemplateRequest.getOrderId()); + } else { + filterinnerOrderprintRequest.setId(stockQRCodeTextPDFTemplateRequest.getQueryId()); + } + List stockPrintEntities = invInnerOrderPrintService.filterJoinInnerPrint(filterinnerOrderprintRequest); + if (stockPrintEntities != null && stockPrintEntities.size() > 0) { + mStockPrintEntities.addAll(stockPrintEntities); + } + for (InnerOrderPrintResponse InnerOrderPrintResponse : mStockPrintEntities) { + PdfPrintCountEntity pdfPrintCount = getCount(stockQRCodeTextPDFTemplateRequest.getCountList(), InnerOrderPrintResponse); + if (pdfPrintCount != null && pdfPrintCount.getRowCount() > 0) { + for (int i = 0; i < pdfPrintCount.getRowCount(); i++) { + InnerOrderPrintResponse clone = new InnerOrderPrintResponse(); + BeanUtils.copyProperties(InnerOrderPrintResponse, clone); + printEntities.add(clone); + } + } else { + printEntities.add(InnerOrderPrintResponse); + } + } + + + String param = JSON.toJSONString(printEntities); + JasperUtils.jasperReport(request, response, param, filePath + "/pdf/template/" + systemPDFTemplateEntity.getPath(), "pdf"); + + String orderId = ""; + for (InnerOrderPrintResponse InnerOrderPrintResponse : mStockPrintEntities) { + InvInnerOrderPrintEntity innerOrderPrintEntity = new InvInnerOrderPrintEntity(); + innerOrderPrintEntity.setStatus(1); + innerOrderPrintEntity.setId(InnerOrderPrintResponse.getId()); + invInnerOrderPrintService.updateOrder(innerOrderPrintEntity); + orderId = InnerOrderPrintResponse.getId() + ""; + } + + //查询订单id + InvInnerOrderPrintEntity innerOrderPrintEntity = invInnerOrderPrintService.selectById(orderId); + //更新内部码状态 + InnerOrderEntity innerOrderEntity = innerOrderService.findByRecordKey(innerOrderPrintEntity.getOrderIdFk()); + if (innerOrderEntity != null) { + innerOrderEntity.setGenStatus(2); + innerOrderEntity.setId(innerOrderEntity.getId()); + innerOrderService.update(innerOrderEntity); + } + IoOrderEntity ioOrderEntity = new IoOrderEntity(); + ioOrderEntity.setInCodeStatus(1); + ioOrderEntity.setBillNo(innerOrderPrintEntity.getOrderIdFk()); + ioOrderService.updateByBillNo(ioOrderEntity); + return null; + + } + public PdfPrintCountEntity getCount(List countList, InnerOrderPrintResponse InnerOrderPrintResponse) { for (PdfPrintCountEntity pdfPrintCount : countList) { if (pdfPrintCount.getQueryId().equals(InnerOrderPrintResponse.getId() + "")) { diff --git a/src/main/java/com/glxp/api/req/inout/FilterOrderDetailResultRequest.java b/src/main/java/com/glxp/api/req/inout/FilterOrderDetailResultRequest.java index 700c315c..f27320f3 100644 --- a/src/main/java/com/glxp/api/req/inout/FilterOrderDetailResultRequest.java +++ b/src/main/java/com/glxp/api/req/inout/FilterOrderDetailResultRequest.java @@ -1,5 +1,6 @@ package com.glxp.api.req.inout; +import com.glxp.api.res.inout.IoOrderDetailResultResponse; import com.glxp.api.util.page.ListPageRequest; import lombok.Data; @@ -43,7 +44,9 @@ public class FilterOrderDetailResultRequest extends ListPageRequest { private String endAduditTime; //结束日期 private String fromCorp; private String actionType; + private String templateId; private String manufacturer; private String zczbhhzbapzbh; private List actions; + private List list; } diff --git a/src/main/java/com/glxp/api/res/inout/IoOrderDetailResultResponse.java b/src/main/java/com/glxp/api/res/inout/IoOrderDetailResultResponse.java index 2c079da3..56e2da9f 100644 --- a/src/main/java/com/glxp/api/res/inout/IoOrderDetailResultResponse.java +++ b/src/main/java/com/glxp/api/res/inout/IoOrderDetailResultResponse.java @@ -3,6 +3,7 @@ package com.glxp.api.res.inout; import lombok.Data; import java.math.BigDecimal; +import java.util.Date; /** * 单据扫码明细VO @@ -159,6 +160,7 @@ public class IoOrderDetailResultResponse { private String fromCorpName; private String billTypeName; private String mainAction; + private Date auditTime; }