|
|
package com.glxp.api.controller.inv;
|
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
import com.glxp.api.annotation.Log;
|
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
import com.glxp.api.constant.BusinessType;
|
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
|
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;
|
|
|
import com.glxp.api.req.inv.*;
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
import com.glxp.api.res.inv.InnerOrderPrintResponse;
|
|
|
import com.glxp.api.service.inout.IoOrderService;
|
|
|
import com.glxp.api.service.inv.InnerOrderService;
|
|
|
import com.glxp.api.service.inv.InvInnerOrderPdfTempService;
|
|
|
import com.glxp.api.service.inv.InvInnerOrderPrintService;
|
|
|
import com.glxp.api.service.inv.JaspaperService;
|
|
|
import com.glxp.api.service.system.SystemPDFModuleService;
|
|
|
import com.glxp.api.service.system.SystemPDFTemplateService;
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
import com.glxp.api.util.FileUtils;
|
|
|
import com.glxp.api.util.JasperUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
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.File;
|
|
|
import java.util.*;
|
|
|
|
|
|
@RestController
|
|
|
public class InvInnerOrderPrintController {
|
|
|
|
|
|
@Resource
|
|
|
private InvInnerOrderPrintService invInnerOrderPrintService;
|
|
|
|
|
|
@Resource
|
|
|
SystemPDFModuleService systemPDFModuleService;
|
|
|
@Resource
|
|
|
SystemPDFTemplateService systemPDFTemplateService;
|
|
|
@Value("${file_path}")
|
|
|
private String dirPath;
|
|
|
@Resource
|
|
|
private JaspaperService jaspaperService;
|
|
|
@Resource
|
|
|
private InvInnerOrderPdfTempService innerOrderPdfTempService;
|
|
|
@Resource
|
|
|
private IoOrderService ioOrderService;
|
|
|
@Resource
|
|
|
private InnerOrderService innerOrderService;
|
|
|
@Value("${file_path}")
|
|
|
private String filePath;
|
|
|
|
|
|
|
|
|
@GetMapping("/udiwms/innerOrderPrint/filter")
|
|
|
public BaseResponse filterList(FilterinnerOrderprintRequest filterinnerOrderprintRequest) {
|
|
|
List<InnerOrderPrintResponse> list = invInnerOrderPrintService.filterJoinInnerPrint(filterinnerOrderprintRequest);
|
|
|
PageInfo<InnerOrderPrintResponse> pageInfo = new PageInfo<>(list);
|
|
|
PageSimpleResponse<InnerOrderPrintResponse> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
|
pageSimpleResponse.setList(pageInfo.getList());
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/udiwms/innerOrderPrint/addOrderPrint")
|
|
|
@Log(title = "内部码", businessType = BusinessType.INSERT)
|
|
|
public BaseResponse addOrderPrint(@RequestBody invInnerOrderprintReques invInnerOrderprintReques) {
|
|
|
|
|
|
if (invInnerOrderprintReques.getOrderIdFk() != null) {
|
|
|
invInnerOrderPrintService.addOrderList(invInnerOrderprintReques.getOrderIdFk());
|
|
|
} else {
|
|
|
return ResultVOUtils.error(999, "参数错误!");
|
|
|
}
|
|
|
return ResultVOUtils.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
//-----------打印码
|
|
|
@AuthRuleAnnotation("")
|
|
|
@PostMapping("/udiwms/pdf/template/inspection/stock/qrcode/text/file")
|
|
|
public BaseResponse inspectionStockQRCodeTextPDFFromTemplateFile(
|
|
|
@RequestBody InspectionPDFTemplateRequest inspectionPDFTemplateRequest) throws Exception {
|
|
|
|
|
|
SysPdfTemplateRelevanceLabelEntity sysPdfTemplateRelevanceLabelEntity = systemPDFModuleService.selectByLabelId(inspectionPDFTemplateRequest.getLabelId() + "");
|
|
|
|
|
|
if (sysPdfTemplateRelevanceLabelEntity == null) return ResultVOUtils.error(500, "未找到单据模板模块设置,请检查");
|
|
|
|
|
|
SystemPDFTemplateEntity systemPDFTemplateEntity =
|
|
|
systemPDFTemplateService.selectById(String.valueOf(sysPdfTemplateRelevanceLabelEntity.getTemplateId()));
|
|
|
if (systemPDFTemplateEntity == null) return ResultVOUtils.error(ResultEnum.DATA_NOT, "模板错误");
|
|
|
|
|
|
return ResultVOUtils.success();
|
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
@PostMapping("/udiwms/pdf/template/stock/qrcode/text/file")
|
|
|
public BaseResponse stockQRCodeTextPDFFromTemplateFile(
|
|
|
@RequestBody InnerOrderQRCodeTextPDFTemplateRequest stockQRCodeTextPDFTemplateRequest,
|
|
|
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
SysPdfTemplateRelevanceLabelEntity sysPdfTemplateRelevanceLabelEntity = systemPDFModuleService.selectByLabelId(stockQRCodeTextPDFTemplateRequest.getLabelId() + "");
|
|
|
|
|
|
if (sysPdfTemplateRelevanceLabelEntity == null) return ResultVOUtils.error(500, "未找到单据模板模块设置,请检查");
|
|
|
|
|
|
SystemPDFTemplateEntity systemPDFTemplateEntity =
|
|
|
systemPDFTemplateService.selectById(String.valueOf(sysPdfTemplateRelevanceLabelEntity.getTemplateId()));
|
|
|
if (systemPDFTemplateEntity == null) return ResultVOUtils.error(ResultEnum.DATA_NOT, "模板错误");
|
|
|
|
|
|
List<InnerOrderPrintResponse> printEntities = new ArrayList<>();
|
|
|
List<InnerOrderPrintResponse> mStockPrintEntities = new ArrayList<>();
|
|
|
FilterinnerOrderprintRequest filterinnerOrderprintRequest = new FilterinnerOrderprintRequest();
|
|
|
if (stockQRCodeTextPDFTemplateRequest.getOrderId() != null) {
|
|
|
filterinnerOrderprintRequest.setSOrderId(stockQRCodeTextPDFTemplateRequest.getOrderId());
|
|
|
} else {
|
|
|
filterinnerOrderprintRequest.setId(stockQRCodeTextPDFTemplateRequest.getQueryId());
|
|
|
}
|
|
|
List<InnerOrderPrintResponse> 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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (printEntities.size() > 1000) { //如果标签打印数据大于1000,则切割生成多个文件
|
|
|
if (!FileUtils.isFileExist(dirPath + "/pdfprint")) {
|
|
|
new File(dirPath + "/pdfprint").mkdirs();
|
|
|
}
|
|
|
List<List<InnerOrderPrintResponse>> splits = CustomUtil.splitList(printEntities, 100);
|
|
|
int index = 0;
|
|
|
List<InvInnerOrderPdfTempEntity> stockPrintTempEntities = new ArrayList<>();
|
|
|
for (int i = 0; i < splits.size(); i++) {
|
|
|
index++;
|
|
|
InvInnerOrderPdfTempEntity stockPrintTempEntity = new InvInnerOrderPdfTempEntity();
|
|
|
if (stockQRCodeTextPDFTemplateRequest.getOrderId() != null) {
|
|
|
String fileName = stockQRCodeTextPDFTemplateRequest.getOrderId() + "__" + index + "__标签打印" + ".pdf";
|
|
|
String filePath = dirPath + "\\pdfprint\\" + fileName;
|
|
|
stockPrintTempEntity.setFileName(fileName);
|
|
|
stockPrintTempEntity.setFilePath(filePath);
|
|
|
stockPrintTempEntity.setStockOrderFk(stockQRCodeTextPDFTemplateRequest.getOrderId());
|
|
|
} else {
|
|
|
String fileName = stockQRCodeTextPDFTemplateRequest.getQueryId() + "__" + index + "__标签打印" + ".pdf";
|
|
|
String filePath = dirPath + "\\pdfprint\\" + fileName;
|
|
|
stockPrintTempEntity.setFileName(fileName);
|
|
|
stockPrintTempEntity.setFilePath(filePath);
|
|
|
stockPrintTempEntity.setPrintCodeIdFk(stockQRCodeTextPDFTemplateRequest.getQueryId());
|
|
|
}
|
|
|
stockPrintTempEntity.setStatus(0);
|
|
|
stockPrintTempEntity.setGenkey(CustomUtil.getId());
|
|
|
innerOrderPdfTempService.insertStockPrintTempEntity(stockPrintTempEntity);
|
|
|
stockPrintTempEntities.add(stockPrintTempEntity);
|
|
|
}
|
|
|
jaspaperService.printPdfLocal(splits, stockPrintTempEntities, filePath + "/pdf/template/" + systemPDFTemplateEntity.getPath());
|
|
|
PageInfo<InvInnerOrderPdfTempEntity> pageInfo;
|
|
|
pageInfo = new PageInfo<>(stockPrintTempEntities);
|
|
|
PageSimpleResponse<InvInnerOrderPdfTempEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
|
pageSimpleResponse.setList(stockPrintTempEntities);
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
|
|
} else {
|
|
|
Map<String, Object> data = new HashMap<String, Object>();
|
|
|
data.put("data", printEntities);
|
|
|
JasperUtils.jasperReport(request, response, data, filePath + "/pdf/template/" + FileUtils.getLastFileName(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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//-----------打印码
|
|
|
@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<InnerOrderPrintResponse> printEntities = new ArrayList<>();
|
|
|
List<InnerOrderPrintResponse> mStockPrintEntities = new ArrayList<>();
|
|
|
FilterinnerOrderprintRequest filterinnerOrderprintRequest = new FilterinnerOrderprintRequest();
|
|
|
if (stockQRCodeTextPDFTemplateRequest.getOrderId() != null) {
|
|
|
filterinnerOrderprintRequest.setSOrderId(stockQRCodeTextPDFTemplateRequest.getOrderId());
|
|
|
} else {
|
|
|
filterinnerOrderprintRequest.setId(stockQRCodeTextPDFTemplateRequest.getQueryId());
|
|
|
}
|
|
|
List<InnerOrderPrintResponse> 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<PdfPrintCountEntity> countList, InnerOrderPrintResponse InnerOrderPrintResponse) {
|
|
|
for (PdfPrintCountEntity pdfPrintCount : countList) {
|
|
|
if (pdfPrintCount.getQueryId().equals(InnerOrderPrintResponse.getId() + "")) {
|
|
|
return pdfPrintCount;
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
@PostMapping("/udiwms/pdf/template/stock/qrcode/text/maxfile")
|
|
|
public BaseResponse stockQRCodeMaxTextPDFFromTemplateFile(@RequestBody InnerOrderQRCodeTextPDFTemplateRequest innerOrderQRCodeTextPDFTemplateRequest) {
|
|
|
|
|
|
PageSimpleResponse pageSimpleResponse = invInnerOrderPrintService.print(innerOrderQRCodeTextPDFTemplateRequest);
|
|
|
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("/spms/stock/qrcode/filterTemp")
|
|
|
public BaseResponse filterTemp(DeleteStPrintTempRequest deleteStPrintTempRequest,
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
}
|
|
|
List<InvInnerOrderPdfTempEntity> stockQRCodeTextEntityList = innerOrderPdfTempService.filterStockPrintTempEntity(deleteStPrintTempRequest);
|
|
|
PageInfo<InvInnerOrderPdfTempEntity> pageInfo;
|
|
|
pageInfo = new PageInfo<>(stockQRCodeTextEntityList);
|
|
|
PageSimpleResponse<InvInnerOrderPdfTempEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
|
pageSimpleResponse.setList(stockQRCodeTextEntityList);
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
}
|
|
|
|
|
|
}
|