销售出货增加打印拣配单、送货单完成
This commit is contained in:
parent
fd1673d6cd
commit
d5ee13a378
@ -1,5 +1,6 @@
|
||||
package com.foreverwin.mom.wms.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -66,4 +67,23 @@ public class SaleOutDetailDTO {
|
||||
|
||||
@ApiModelProperty(value="批次")
|
||||
private String batch;
|
||||
|
||||
//质量检测状态
|
||||
@TableField(exist = false)
|
||||
private String qualityInspectionStatus;
|
||||
|
||||
// 宽度
|
||||
@TableField(exist = false)
|
||||
private String zctKf;
|
||||
|
||||
// 长度
|
||||
@TableField(exist = false)
|
||||
private String zctCd;
|
||||
|
||||
// 客户型号
|
||||
@TableField(exist = false)
|
||||
private String zctKhxh;
|
||||
|
||||
@TableField(exist = false)
|
||||
private BigDecimal quality;
|
||||
}
|
||||
|
||||
@ -206,13 +206,20 @@ public class PickingController {
|
||||
EasyExcel.write(response.getOutputStream(), PickingSuggestDTO.class).registerWriteHandler(widthStyleStrategy).autoCloseStream(Boolean.FALSE).sheet("").doWrite(data);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "拣货打印", notes = "拣货打印")
|
||||
@SysLog("拣货打印")
|
||||
@ApiOperation(value = "销售出货-拣货打印", notes = "销售出货-拣货打印")
|
||||
@SysLog("销售出货-拣货打印")
|
||||
@PostMapping("/print")
|
||||
public R pickingPrint(@RequestBody SaleOutRequestDTO saleOutRequestDTO) {
|
||||
return R.ok(pickingService.printLabel(saleOutRequestDTO.getDocumentNo(), saleOutRequestDTO.getSeqList()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "销售出货-出货单打印", notes = "销售出货-出货单打印")
|
||||
@SysLog("销售出货-出货单打印")
|
||||
@PostMapping("/deliveryPrint")
|
||||
public R deliveryPrint(@RequestBody SaleOutRequestDTO saleOutRequestDTO) {
|
||||
return R.ok(pickingService.printDeliveryLabel(saleOutRequestDTO.getDocumentNo(), saleOutRequestDTO.getSeqList()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "拣货清除记录", notes = "拣货清除记录")
|
||||
@SysLog("拣货清除记录")
|
||||
@PostMapping("/pickingRemove")
|
||||
|
||||
@ -30,6 +30,8 @@ public interface PickingService extends IService<Picking> {
|
||||
|
||||
String printLabel(String documentNo, List<String> seqList);
|
||||
|
||||
String printDeliveryLabel(String documentNo, List<String> seqList);
|
||||
|
||||
void reprint(List<Picking> reprintDtos);
|
||||
|
||||
List<Picking> select(ReprintDto reprintDto);
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
package com.foreverwin.mom.wms.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.foreverwin.iep.prd.entity.SalesOrder;
|
||||
import com.foreverwin.iep.prd.entity.SalesOrderLine;
|
||||
import com.foreverwin.iep.prd.entity.SalesOrderLineConfig;
|
||||
import com.foreverwin.iep.prd.feign.RemoteSalesOrderService;
|
||||
import com.foreverwin.mom.common.core.exception.BusinessException;
|
||||
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
|
||||
import com.foreverwin.mom.wms.constant.Constant;
|
||||
@ -12,6 +17,7 @@ import com.foreverwin.mom.wms.entity.DnOrder;
|
||||
import com.foreverwin.mom.wms.entity.Document;
|
||||
import com.foreverwin.mom.wms.entity.DocumentDetailed;
|
||||
import com.foreverwin.mom.wms.entity.Picking;
|
||||
import com.foreverwin.mom.wms.mapper.DocumentDetailedMapper;
|
||||
import com.foreverwin.mom.wms.mapper.DocumentMapper;
|
||||
import com.foreverwin.mom.wms.mapper.PickingMapper;
|
||||
import com.foreverwin.mom.wms.service.DnOrderService;
|
||||
@ -32,9 +38,11 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.SQLIntegrityConstraintViolationException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -52,7 +60,9 @@ public class PickingServiceImpl extends ServiceImpl<PickingMapper, Picking> impl
|
||||
private final DnOrderService dnOrderService;
|
||||
private final SalseBatchGenService salseBatchGenService;
|
||||
private final DocumentMapper documentMapper;
|
||||
private final DocumentDetailedMapper documentDetailedMapper;
|
||||
private final RemotePrintService remotePrintService;
|
||||
private final RemoteSalesOrderService remoteSalesOrderService;
|
||||
|
||||
|
||||
@Override
|
||||
@ -94,23 +104,76 @@ public class PickingServiceImpl extends ServiceImpl<PickingMapper, Picking> impl
|
||||
return null;
|
||||
}
|
||||
|
||||
private Map<String, Object> assemblePrintData(String site, String documentNo, List<String> seqList) {
|
||||
Map<String, Object> allParam = new HashMap<>();
|
||||
Document documentObj = documentMapper.selectById(Document.genHandle(site, documentNo));
|
||||
// 查询单据明细
|
||||
List<SaleOutDetailDTO> saleOutDetailDTOS = this.baseMapper.selectSaleOutDetail(site, documentNo, documentObj.getExternalDocumentNo());
|
||||
if (saleOutDetailDTOS == null) {
|
||||
throw BusinessException.build("根据外部单号" + documentObj.getExternalDocumentNo() + "和单据号" + documentNo + "未检索到明细数据");
|
||||
}
|
||||
List<SaleOutDetailDTO> newDetailList = new ArrayList<>();
|
||||
BigDecimal totalQty = new BigDecimal(0);
|
||||
BigDecimal totalAppQty = new BigDecimal(0);
|
||||
for (SaleOutDetailDTO saleOutDetailDTO : saleOutDetailDTOS) {
|
||||
if (seqList.contains(saleOutDetailDTO.getSeq())) {
|
||||
saleOutDetailDTO.setApplicationsQuantity(saleOutDetailDTO.getApplicationsQuantity().setScale(2, RoundingMode.HALF_UP));
|
||||
totalAppQty = totalAppQty.add(saleOutDetailDTO.getApplicationsQuantity());
|
||||
// 查找销售订单信息
|
||||
newDetailList.add(saleOutDetailDTO);
|
||||
QueryWrapper<DocumentDetailed> queryWrapper = new QueryWrapper();
|
||||
queryWrapper.lambda().eq(DocumentDetailed::getDocumentNo, documentNo).eq(DocumentDetailed::getSeq, saleOutDetailDTO.getSeq());
|
||||
DocumentDetailed documentDetailed = documentDetailedMapper.selectOne(queryWrapper);
|
||||
if (documentDetailed == null) {
|
||||
throw BusinessException.build("根据单据号" + documentNo + "和行号" + saleOutDetailDTO.getSeq() + "未检索到单据明细数据");
|
||||
}
|
||||
SalesOrder salesOrder = remoteSalesOrderService.getSalesOrderData(documentDetailed).getData();
|
||||
if (salesOrder != null) {
|
||||
List<SalesOrderLine> salesOrderLineList = salesOrder.getSalesOrderLineList();
|
||||
if (salesOrderLineList != null && salesOrderLineList.size() > 0) {
|
||||
SalesOrderLine salesOrderLine = salesOrderLineList.get(0);
|
||||
saleOutDetailDTO.setQualityInspectionStatus(salesOrderLine.getQualityInspectionStatus());
|
||||
List<SalesOrderLineConfig> salesOrderLineConfigList = salesOrderLine.getSalesOrderLineConfigList();
|
||||
if (salesOrderLineConfigList != null && salesOrderLineConfigList.size() > 0) {
|
||||
for (SalesOrderLineConfig salesOrderLineConfig : salesOrderLineConfigList) {
|
||||
if (salesOrderLineConfig.getConfigItem().equals("ZCT_CD")) {
|
||||
// 长度
|
||||
saleOutDetailDTO.setZctCd(salesOrderLineConfig.getConfigItemValue());
|
||||
} else if (salesOrderLineConfig.getConfigItem().equals("ZCT_KF")) {
|
||||
// 宽度
|
||||
saleOutDetailDTO.setZctKf(salesOrderLineConfig.getConfigItemValue());
|
||||
}else if (salesOrderLineConfig.getConfigItem().equals("ZCT_KHXH")) {
|
||||
// 客户型号
|
||||
saleOutDetailDTO.setZctKhxh(salesOrderLineConfig.getConfigItemValue());
|
||||
}
|
||||
}
|
||||
// 计算它的数量 需求数量÷长度
|
||||
if (StringUtil.notEmpty(saleOutDetailDTO.getZctCd())) {
|
||||
saleOutDetailDTO.setQuality(saleOutDetailDTO.getApplicationsQuantity().divide(new BigDecimal(saleOutDetailDTO.getZctCd()), RoundingMode.CEILING));
|
||||
totalQty = totalQty.add(saleOutDetailDTO.getQuality());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allParam.put("sumCount", newDetailList.size());
|
||||
allParam.put("sumLength", totalAppQty.setScale(2, RoundingMode.CEILING));
|
||||
allParam.put("sumQuality", totalQty);
|
||||
allParam.put("detailList", newDetailList);
|
||||
allParam.put("qrCode", JxlsUtil.generateQRCodeImage(documentObj.getExternalDocumentNo()));
|
||||
String createDate = documentObj.getCreateDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
MapUtil.copyPropertiesToMap(documentObj, allParam);
|
||||
allParam.put("createDate", createDate);
|
||||
return allParam;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String printLabel(String documentNo, List<String> seqList) {
|
||||
String base64String = "";
|
||||
String site = TenantContextHolder.getTenantId();
|
||||
Map<String, Object> allParam = new HashMap<>();
|
||||
Document documentObj = documentMapper.selectById(Document.genHandle(site, documentNo));
|
||||
// 查询单据明细
|
||||
List<SaleOutDetailDTO> saleOutDetailDTOS = this.baseMapper.selectSaleOutDetail(site, documentNo, documentObj.getExternalDocumentNo());
|
||||
if(saleOutDetailDTOS==null){
|
||||
throw BusinessException.build("根据外部单号"+documentObj.getExternalDocumentNo()+"和单据号"+documentNo+"未检索到明细数据");
|
||||
}
|
||||
List<SaleOutDetailDTO> newDetailList = new ArrayList<>();
|
||||
|
||||
/*for (SaleOutDetailDTO saleOutDetailDTO : saleOutDetailDTOS) {
|
||||
saleOutDetailDTO.getSeq();
|
||||
}*/
|
||||
Map<String, Object> allParam = assemblePrintData(site, documentNo, seqList);
|
||||
// 拿取模板
|
||||
PrintLabelTemplate printLabelTemplate = new PrintLabelTemplate();
|
||||
printLabelTemplate.setTemplateCode("SALES_OUT_PICK_DOC");
|
||||
@ -118,8 +181,32 @@ public class PickingServiceImpl extends ServiceImpl<PickingMapper, Picking> impl
|
||||
byte[] srcBytes = remotePrintService.getReportByCode(printLabelTemplate).getData();
|
||||
if (srcBytes != null && srcBytes.length > 0) {
|
||||
try {
|
||||
allParam.put("qrCode", JxlsUtil.generateQRCodeImage(documentObj.getExternalDocumentNo()));
|
||||
MapUtil.copyPropertiesToMap(documentObj, allParam);
|
||||
byte[] fileBytes = JxlsUtil.transferExcel(new ByteArrayInputStream(srcBytes), allParam);
|
||||
InputStream byteInputStream = new ByteArrayInputStream(fileBytes);
|
||||
fileBytes = JxlsUtil.callPostConvertFileToPdf(byteInputStream);
|
||||
byteInputStream.close();
|
||||
base64String = Base64.getEncoder().encodeToString(fileBytes);
|
||||
} catch (IOException e) {
|
||||
throw BusinessException.build("JXLS渲染失败:" + e);
|
||||
}
|
||||
} else {
|
||||
throw BusinessException.build("获取打印模板失败");
|
||||
}
|
||||
return base64String;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String printDeliveryLabel(String documentNo, List<String> seqList) {
|
||||
String base64String = "";
|
||||
String site = TenantContextHolder.getTenantId();
|
||||
Map<String, Object> allParam = assemblePrintData(site, documentNo, seqList);
|
||||
// 拿取模板
|
||||
PrintLabelTemplate printLabelTemplate = new PrintLabelTemplate();
|
||||
printLabelTemplate.setTemplateCode("SALES_OUT_DELIVERY_DOC");
|
||||
printLabelTemplate.setSite(site);
|
||||
byte[] srcBytes = remotePrintService.getReportByCode(printLabelTemplate).getData();
|
||||
if (srcBytes != null && srcBytes.length > 0) {
|
||||
try {
|
||||
byte[] fileBytes = JxlsUtil.transferExcel(new ByteArrayInputStream(srcBytes), allParam);
|
||||
InputStream byteInputStream = new ByteArrayInputStream(fileBytes);
|
||||
fileBytes = JxlsUtil.callPostConvertFileToPdf(byteInputStream);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user