Compare commits

..

2 Commits

Author SHA1 Message Date
曹鹏飞 4b228fa369 feat: bug-884 添加【副产品(拆解)入库】业务 2025-11-12 14:29:31 +08:00
曹鹏飞 578151527a feat: bug-884 添加【副产品(拆解)入库】业务 2025-11-12 10:48:56 +08:00
8 changed files with 129 additions and 44 deletions

View File

@ -195,14 +195,6 @@ public class BarcodePrintingController extends BaseController {
} }
} }
private String generateQRContent(DeliverNormalOrderItemDTO order, String indexNo) {
String content = StrUtil.format("{}${}${}${}${}${}${}${}${}"
, order.getPrintNo(), order.getExternalOrderNo(), order.getRowNo(), order.getMaterialNo(), order.getPrintNum()
, order.getMaterialDesc(), "", order.getBatchNo(), Optional.ofNullable(indexNo).orElse(""));
log.debug("二维码内容:" + content);
return content;
}
/** /**
* 导出物料条码pdf整张或者一张一个 * 导出物料条码pdf整张或者一张一个
* @param request 请求参数 * @param request 请求参数

View File

@ -40,7 +40,6 @@ import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URL; import java.net.URL;
import java.text.DecimalFormat;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
@ -54,8 +53,6 @@ import java.util.stream.Collectors;
@RequestMapping("/in/produce") @RequestMapping("/in/produce")
public class InProduceOrderController extends BaseController { public class InProduceOrderController extends BaseController {
private static final DecimalFormat DF = new DecimalFormat("0.00");
@Resource @Resource
private SapService sapService; private SapService sapService;
@ -255,14 +252,6 @@ public class InProduceOrderController extends BaseController {
} }
} }
private String generateQRContent(DeliverNormalOrderItemDTO order,String indexNo){
String content = StrUtil.format("{}${}${}${}${}${}${}${}${}"
, order.getPrintNo(), order.getExternalOrderNo(),order.getRowNo(),order.getMaterialNo(),order.getPrintNum()
, order.getMaterialDesc(), order.getSupplierCode(), order.getBatchNo(), Optional.ofNullable(indexNo).orElse(""));
log.debug("二维码内容:"+ content);
return content;
}
/** /**
* 导出报工单PDF单个 * 导出报工单PDF单个
* @param id 订单id * @param id 订单id

View File

@ -17,6 +17,7 @@ import com.nflg.wms.admin.util.QRCodeUtil;
import com.nflg.wms.admin.util.ThymeleafUtil; import com.nflg.wms.admin.util.ThymeleafUtil;
import com.nflg.wms.common.pojo.ApiResult; import com.nflg.wms.common.pojo.ApiResult;
import com.nflg.wms.common.pojo.PageData; import com.nflg.wms.common.pojo.PageData;
import com.nflg.wms.common.pojo.dto.DeliverNormalOrderItemDTO;
import com.nflg.wms.common.pojo.dto.InventoryDTO; import com.nflg.wms.common.pojo.dto.InventoryDTO;
import com.nflg.wms.common.pojo.dto.MaterialQRCodeContentDTO; import com.nflg.wms.common.pojo.dto.MaterialQRCodeContentDTO;
import com.nflg.wms.common.pojo.qo.*; import com.nflg.wms.common.pojo.qo.*;
@ -35,10 +36,12 @@ import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URL;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
@ -319,6 +322,52 @@ public class InProduceOrderSurplusController extends BaseController {
return ApiResult.success(vo); return ApiResult.success(vo);
} }
/**
* 导出物料条码pdf
* @param id 订单ID
* @param type 1逐个2一页
*/
@GetMapping("exportMaterialsPdf")
public void exportMaterials(HttpServletResponse response, @Valid @RequestParam @NotNull Long id
, @Valid @RequestParam @NotNull Integer type) throws Exception {
WmsInProduceOrderSurplus order = inProduceOrderSurplusService.getById(id);
VUtil.trueThrowBusinessError(Objects.isNull(order)).throwMessage("订单不存在");
List<WmsInProduceOrderSurplusItem> list = inProduceOrderSurplusItemService.getList(id);
List<DeliverNormalOrderItemDTO> datas = new ArrayList<>();
for (WmsInProduceOrderSurplusItem item : list) {
BigDecimal[] result = item.getNum().divideAndRemainder(BigDecimal.ONE);
for (int i = 0, count = result[0].intValue(); i < count; i++) {
DeliverNormalOrderItemDTO dto = new DeliverNormalOrderItemDTO();
dto.setMaterialNo(item.getMatnr());
dto.setMaterialDesc(item.getMaktx2());
dto.setExternalOrderNo(order.getAufnr());
dto.setRowNo("");
dto.setIndex(i);
dto.setPrintNo(IdUtil.getSnowflakeNextIdStr());
if (i == count - 1 && result[1].compareTo(BigDecimal.ZERO) > 0) {
dto.setPrintNum(DF.format(result[1]));
} else {
dto.setPrintNum(DF.format(BigDecimal.ONE));
}
dto.setSupplierCode("");
dto.setBatchNo("");
dto.setQrCode(QRCodeUtil.generateQRCodeBase64(generateQRContent(dto, ""), 100, 100));
datas.add(dto);
}
}
Map<String, Object> variables = new HashMap<>();
variables.put("list", datas);
if (Objects.equals(type, 1)) {
String html = ThymeleafUtil.generator("/template/qrcode/", "dp-1", ".html", variables);
URL baseUrl = new ClassPathResource("template/qrcode/").getURL();
PdfGeneratorUtil.generatePdf("普通物料条码(逐个)", html, baseUrl.toString(), response);
} else {
String html = ThymeleafUtil.generator("/template/qrcode/", "dp-2", ".html", variables);
URL baseUrl = new ClassPathResource("template/qrcode/").getURL();
PdfGeneratorUtil.generatePdf("普通物料条码(整张)", html, baseUrl.toString(), response);
}
}
/** /**
* 导出拆解单 * 导出拆解单
*/ */

View File

@ -41,7 +41,6 @@ import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URL; import java.net.URL;
import java.text.DecimalFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -60,8 +59,6 @@ public class NormalOrderController extends BaseController {
@Resource @Resource
private IUserSupplierService userSupplierService; private IUserSupplierService userSupplierService;
private static final DecimalFormat DF = new DecimalFormat("0.00");
@Resource @Resource
private IWmsSrmOrderService srmOrderService; private IWmsSrmOrderService srmOrderService;
@ -202,14 +199,6 @@ public class NormalOrderController extends BaseController {
return datas; return datas;
} }
private String generateQRContent(DeliverNormalOrderItemDTO order, String indexNo) {
String content = StrUtil.format("{}${}${}${}${}${}${}${}${}"
, order.getPrintNo(), order.getExternalOrderNo(), order.getRowNo(), order.getMaterialNo(), order.getPrintNum()
, order.getMaterialDesc(), order.getSupplierCode(), order.getBatchNo(), Optional.ofNullable(indexNo).orElse(""));
log.debug("二维码内容:" + content);
return content;
}
/** /**
* 搜索送货单 * 搜索送货单
* @param request 请求参数 * @param request 请求参数

View File

@ -60,7 +60,7 @@ public class SapService {
JCoStructure result = function.getExportParameterList().getStructure("OUTPUT1"); JCoStructure result = function.getExportParameterList().getStructure("OUTPUT1");
VUtil.trueThrowBusinessError(!StrUtil.equals("S", result.getString("TYPE"))) VUtil.trueThrowBusinessError(!StrUtil.equals("S", result.getString("TYPE")))
.throwMessage("SAP错误:" + result.getString("MSG")); .throwMessage("SAP:" + result.getString("MSG"));
return Pair.of(result.getString("MAT_DOC"), result.getString("DOC_YEAR")); return Pair.of(result.getString("MAT_DOC"), result.getString("DOC_YEAR"));
} }
@ -70,7 +70,13 @@ public class SapService {
*/ */
public List<ZWM3A23VO> zwm3a23(ZWM3A23QO request) { public List<ZWM3A23VO> zwm3a23(ZWM3A23QO request) {
Map<String, Object> parameters = new HashMap<>(); Map<String, Object> parameters = new HashMap<>();
parameters.put("i_werks", request.getWerks()); parameters.put("I_WERKS", request.getWerks());
if (Objects.nonNull(request.getStartDate())) {
parameters.put("S_DATE", DateTimeUtil.format(request.getStartDate(), "yyyyMMdd"));
}
if (Objects.nonNull(request.getEndDate())) {
parameters.put("E_DATE", DateTimeUtil.format(request.getEndDate(), "yyyyMMdd"));
}
Map<String, List<Map<String, Object>>> tables = new HashMap<>(); Map<String, List<Map<String, Object>>> tables = new HashMap<>();
if (CollectionUtil.isNotEmpty(request.getArbpls())) { if (CollectionUtil.isNotEmpty(request.getArbpls())) {
@ -98,7 +104,7 @@ public class SapService {
JCoFunction function = exec("ZWM3A23", parameters, tables); JCoFunction function = exec("ZWM3A23", parameters, tables);
VUtil.trueThrowBusinessError(!StrUtil.equals("S", function.getExportParameterList().getString("E_TYPE"))) VUtil.trueThrowBusinessError(!StrUtil.equals("S", function.getExportParameterList().getString("E_TYPE")))
.throwMessage("SAP错误:" + function.getExportParameterList().getString("E_MSG")); .throwMessage("SAP:" + function.getExportParameterList().getString("E_MSG"));
JCoTable table = function.getTableParameterList().getTable("OUTPUT1"); JCoTable table = function.getTableParameterList().getTable("OUTPUT1");
return JCoUtil.toBeanList(table, ZWM3A23VO.class); return JCoUtil.toBeanList(table, ZWM3A23VO.class);
@ -124,7 +130,7 @@ public class SapService {
List<String> errors = lrs.stream().filter(lr -> !StrUtil.equals(lr.getType(), "S")) List<String> errors = lrs.stream().filter(lr -> !StrUtil.equals(lr.getType(), "S"))
.map(ZWM00_MB116ReturnVO::getMessage) .map(ZWM00_MB116ReturnVO::getMessage)
.toList(); .toList();
VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(errors)).throwMessage("SAP错误" + StrUtil.join(",", errors)); VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(errors)).throwMessage("SAP" + StrUtil.join(",", errors));
return new ZWM00_MB116VO() return new ZWM00_MB116VO()
.setMblnr(function.getExportParameterList().getString("E_MBLNR")) .setMblnr(function.getExportParameterList().getString("E_MBLNR"))
@ -150,7 +156,7 @@ public class SapService {
ZWM00MB007DTO dto = JCoUtil.toBean(eOutput, ZWM00MB007DTO.class); ZWM00MB007DTO dto = JCoUtil.toBean(eOutput, ZWM00MB007DTO.class);
if (StrUtil.isBlank(dto.getAufnr())) { if (StrUtil.isBlank(dto.getAufnr())) {
VUtil.trueThrowBusinessError(!StrUtil.equals(eReturn.getString("TYPE"), "S")) VUtil.trueThrowBusinessError(!StrUtil.equals(eReturn.getString("TYPE"), "S"))
.throwMessage("SAP错误:" + eReturn.getString("MESSAGE")); .throwMessage("SAP:" + eReturn.getString("MESSAGE"));
return null; return null;
} else { } else {
return dto; return dto;
@ -188,7 +194,7 @@ public class SapService {
JCoParameterList pl = function.getExportParameterList(); JCoParameterList pl = function.getExportParameterList();
log.info("E_MBLNR:{}", pl.getString("E_MBLNR")); log.info("E_MBLNR:{}", pl.getString("E_MBLNR"));
VUtil.trueThrowBusinessError(StrUtil.isBlank(pl.getString("E_MBLNR"))) VUtil.trueThrowBusinessError(StrUtil.isBlank(pl.getString("E_MBLNR")))
.throwMessage("SAP错误"); .throwMessage("SAP");
VUtil.trueHandle(StrUtil.isBlank(pl.getString("E_MBLNR"))).trueHandle(() -> { VUtil.trueHandle(StrUtil.isBlank(pl.getString("E_MBLNR"))).trueHandle(() -> {
JCoTable table = function.getTableParameterList().getTable("T_RETURN"); JCoTable table = function.getTableParameterList().getTable("T_RETURN");
log.error("SAP错误信息:{}", table); log.error("SAP错误信息:{}", table);
@ -210,7 +216,7 @@ public class SapService {
JCoStructure structure = function.getExportParameterList().getStructure("E_RETURN"); JCoStructure structure = function.getExportParameterList().getStructure("E_RETURN");
VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S")) VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S"))
.throwMessage("SAP错误:" + structure.getString("MSG")); .throwMessage("SAP:" + structure.getString("MSG"));
JCoTable ot1 = function.getTableParameterList().getTable("OUTPUT1"); JCoTable ot1 = function.getTableParameterList().getTable("OUTPUT1");
VUtil.trueThrowBusinessError(ot1.getNumRows() == 0).throwMessage("没有订单数据"); VUtil.trueThrowBusinessError(ot1.getNumRows() == 0).throwMessage("没有订单数据");
@ -252,7 +258,7 @@ public class SapService {
JCoParameterList jparameters = execReturnParameter("ZWM3A06", parameters, tables); JCoParameterList jparameters = execReturnParameter("ZWM3A06", parameters, tables);
JCoStructure structure = jparameters.getStructure("OUTPUT"); JCoStructure structure = jparameters.getStructure("OUTPUT");
VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S")) VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S"))
.throwMessage("SAP错误:" + structure.getString("MSG")); .throwMessage("SAP:" + structure.getString("MSG"));
return Pair.of(structure.getString("MAT_DOC"), structure.getString("DOC_YEAR")); return Pair.of(structure.getString("MAT_DOC"), structure.getString("DOC_YEAR"));
} }
@ -279,7 +285,7 @@ public class SapService {
JCoFunction function = exec("ZWM3A18", parameters, tables); JCoFunction function = exec("ZWM3A18", parameters, tables);
JCoStructure structure = function.getExportParameterList().getStructure("OUTPUT1"); JCoStructure structure = function.getExportParameterList().getStructure("OUTPUT1");
VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S")) VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S"))
.throwMessage("SAP错误" + structure.getString("MSG")); .throwMessage("SAP" + structure.getString("MSG"));
return Pair.of(structure.getString("MAT_DOC"), structure.getString("DOC_YEAR")); return Pair.of(structure.getString("MAT_DOC"), structure.getString("DOC_YEAR"));
} }
@ -304,7 +310,7 @@ public class SapService {
JCoStructure structure = function.getExportParameterList().getStructure("OUTPUT1"); JCoStructure structure = function.getExportParameterList().getStructure("OUTPUT1");
print("OUTPUT1", structure); print("OUTPUT1", structure);
VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S")) VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S"))
.throwMessage("SAP错误" + structure.getString("MSG")); .throwMessage("SAP" + structure.getString("MSG"));
return Pair.of(Pair.of(structure.getString("MAT_DOC_101"), structure.getString("DOC_YEAR_101")) return Pair.of(Pair.of(structure.getString("MAT_DOC_101"), structure.getString("DOC_YEAR_101"))
, Pair.of(structure.getString("MAT_DOC_103"), structure.getString("DOC_YEAR_103"))); , Pair.of(structure.getString("MAT_DOC_103"), structure.getString("DOC_YEAR_103")));
@ -332,7 +338,7 @@ public class SapService {
List<Map<String, Object>> tOut = JCoUtil.toMapList(table); List<Map<String, Object>> tOut = JCoUtil.toMapList(table);
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(tOut)).throwMessage("SAP未返回结果"); VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(tOut)).throwMessage("SAP未返回结果");
VUtil.trueThrowBusinessError(!StrUtil.equals(tOut.get(0).get("E_TYPE").toString(), "S")) VUtil.trueThrowBusinessError(!StrUtil.equals(tOut.get(0).get("E_TYPE").toString(), "S"))
.throwMessage("SAP错误" + tOut.get(0).get("E_MSG")); .throwMessage("SAP" + tOut.get(0).get("E_MSG"));
} }
/** /**
@ -401,7 +407,7 @@ public class SapService {
JCoStructure structure = function.getExportParameterList().getStructure("E_RETURN"); JCoStructure structure = function.getExportParameterList().getStructure("E_RETURN");
VUtil.trueThrow(!StrUtil.equals(structure.getString("TYPE"), "S")) VUtil.trueThrow(!StrUtil.equals(structure.getString("TYPE"), "S"))
.throwMessage(STATE.SAPErr, "SAP错误" + structure.getString("MSG")); .throwMessage(STATE.SAPErr, "SAP" + structure.getString("MSG"));
JCoTable table = function.getTableParameterList().getTable("T_OUT"); JCoTable table = function.getTableParameterList().getTable("T_OUT");
log.info("SAP返回: {}", table); log.info("SAP返回: {}", table);
@ -1289,7 +1295,7 @@ public class SapService {
JCoFunction function = exec("ZWM3A19", parameters, null); JCoFunction function = exec("ZWM3A19", parameters, null);
JCoParameterList structure = function.getExportParameterList(); JCoParameterList structure = function.getExportParameterList();
VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("E_TYPE"), "S")) VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("E_TYPE"), "S"))
.throwMessage("SAP错误:" + structure.getString("E_MSG")); .throwMessage("SAP:" + structure.getString("E_MSG"));
JCoTable ot1 = function.getTableParameterList().getTable("HEAD"); JCoTable ot1 = function.getTableParameterList().getTable("HEAD");
@ -1339,7 +1345,7 @@ public class SapService {
JCoStructure structure = function.getExportParameterList().getStructure("OUTPUT"); JCoStructure structure = function.getExportParameterList().getStructure("OUTPUT");
print("输出参数OUTPUT", structure); print("输出参数OUTPUT", structure);
VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S")) VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S"))
.throwMessage("SAP错误" + structure.getString("MSG")); .throwMessage("SAP" + structure.getString("MSG"));
return Pair.of(structure.getString("MAT_DOC"), structure.getString("DOC_YEAR")); return Pair.of(structure.getString("MAT_DOC"), structure.getString("DOC_YEAR"));
} }

View File

@ -2,7 +2,9 @@ package com.nflg.wms.common.pojo.qo;
import lombok.Data; import lombok.Data;
import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.Objects;
@Data @Data
public class ZWM3A23QO { public class ZWM3A23QO {
@ -26,4 +28,24 @@ public class ZWM3A23QO {
* 工作中心列表 * 工作中心列表
*/ */
private List<String> arbpls; private List<String> arbpls;
/**
* 开始时间
*/
private LocalDate startDate;
/**
* 结束时间
*/
private LocalDate endDate;
public LocalDate getEndDate() {
if (Objects.nonNull(endDate)) {
return endDate;
}
if (Objects.nonNull(startDate)) {
return LocalDate.now();
}
return null;
}
} }

View File

@ -3,6 +3,7 @@ package com.nflg.wms.common.pojo.vo;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.nflg.wms.common.util.BomUtil; import com.nflg.wms.common.util.BomUtil;
import com.nflg.wms.common.util.DateTimeUtil;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive; import jakarta.validation.constraints.Positive;
@ -28,6 +29,10 @@ public class ZWM3A23VO {
*/ */
private String rsnum; private String rsnum;
public String getRsnum() {
return StrUtil.removeAllPrefix(rsnum, "0");
}
/** /**
* 物料号 * 物料号
*/ */
@ -48,6 +53,10 @@ public class ZWM3A23VO {
*/ */
private String vornr; private String vornr;
public String getVornr() {
return StrUtil.removeAllPrefix(vornr, "0");
}
/** /**
* 序列号 * 序列号
*/ */
@ -109,11 +118,19 @@ public class ZWM3A23VO {
*/ */
private String rsnum2; private String rsnum2;
public String getRsnum2() {
return StrUtil.removeAllPrefix(rsnum2, "0");
}
/** /**
* 预留/相关需求的项目编号 * 预留/相关需求的项目编号
*/ */
private String rspos; private String rspos;
public String getRspos() {
return StrUtil.removeAllPrefix(rspos, "0");
}
/** /**
* 库存地点 * 库存地点
*/ */
@ -138,6 +155,10 @@ public class ZWM3A23VO {
*/ */
private String bdter; private String bdter;
public String getBdter() {
return DateTimeUtil.formatFromMillis(bdter);
}
/** /**
* 申请数量 * 申请数量
*/ */

View File

@ -1,9 +1,26 @@
package com.nflg.wms.starter; package com.nflg.wms.starter;
import cn.hutool.core.util.StrUtil;
import com.nflg.wms.common.pojo.dto.DeliverNormalOrderItemDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.text.DecimalFormat;
import java.util.Optional;
@Slf4j
@Validated @Validated
@RestController @RestController
public class BaseController { public class BaseController {
protected final DecimalFormat DF = new DecimalFormat("0.00");
protected String generateQRContent(DeliverNormalOrderItemDTO order, String indexNo) {
String content = StrUtil.format("{}${}${}${}${}${}${}${}${}"
, order.getPrintNo(), order.getExternalOrderNo(), order.getRowNo(), order.getMaterialNo(), order.getPrintNum()
, order.getMaterialDesc(), order.getSupplierCode(), order.getBatchNo(), Optional.ofNullable(indexNo).orElse(""));
log.debug("二维码内容:" + content);
return content;
}
} }