Browse Source

2025-10-17

优化
master
fengyuan_yang 3 months ago
parent
commit
ddcd259ce5
  1. 39
      src/main/java/com/gaotao/modules/productionInbound/service/impl/ProductionInboundServiceImpl.java
  2. 12
      src/main/resources/mapper/productionInbound/ProductionInboundMapper.xml

39
src/main/java/com/gaotao/modules/productionInbound/service/impl/ProductionInboundServiceImpl.java

@ -1,11 +1,13 @@
package com.gaotao.modules.productionInbound.service.impl;
import com.gaotao.common.exception.XJException;
import com.gaotao.modules.inventoryStock.dao.InventoryStockMapper;
import com.gaotao.modules.pms.entity.vo.PartLabelTemplateVo;
import com.gaotao.modules.productionInbound.dao.ProductionInboundMapper;
import com.gaotao.modules.productionInbound.service.ProductionInboundService;
import com.gaotao.modules.inventoryStock.entity.InventoryStock;
import com.gaotao.modules.inventoryStock.service.InventoryStockService;
import com.gaotao.modules.schedule.mapper.ProcedureMapper;
import com.gaotao.modules.sys.entity.SysUserEntity;
import com.gaotao.modules.trans.entity.TransDetail;
import com.gaotao.modules.trans.entity.TransDetailDto;
@ -48,6 +50,9 @@ public class ProductionInboundServiceImpl implements ProductionInboundService {
@Autowired
private TransDetailSubService transDetailSubService;
@Autowired
private ProcedureMapper procedureMapper;
@Override
public List<Map<String, Object>> getQualifiedInboundList(String site, String warehouseId, String searchCode, String status) {
SysUserEntity sysUserEntity = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
@ -81,6 +86,9 @@ public class ProductionInboundServiceImpl implements ProductionInboundService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean confirmInboundStorage(String orderNo, String locationCode, List<Map<String, Object>> labels, String site, String buNo) {
SysUserEntity sysUserEntity = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
String userName = sysUserEntity.getUsername();
logger.info("开始确认生产入库上架,入库单号: {}, 库位号: {}, 标签数量: {}", orderNo, locationCode, labels.size());
try {
// 1. 验证库位是否存在且可用
@ -115,7 +123,18 @@ public class ProductionInboundServiceImpl implements ProductionInboundService {
insertInventoryStock(orderNo, warehouseId, locationCode, labels, site, buNo);
// 6. 生成入库事务记录
generateInboundTransaction(orderNo, warehouseId, locationCode, labels, site, buNo);
String transNo = generateInboundTransaction(orderNo, warehouseId, locationCode, labels, site, buNo);
// // 7. 基于工单BOM生成入库倒冲数据
// // 调用存储过程
// Map<String, Object> resultMap = this.UspBackflushMaterialByOrder(site, buNo, transNo, orderNo, 1, userName);
// //判断是否检验成功
// String resultCode = String.valueOf(resultMap.get("resultCode"));
// if ("400".equalsIgnoreCase(resultCode)) {
// String msg = String.valueOf(resultMap.get("resultMsg"));
// String objectId = String.valueOf(resultMap.get("objectId"));
// throw new XJException(msg,objectId);
// }
// 7. 异步调用ERP接口这里可以发送消息到队列
//asyncCallErpInterface(orderNo, partNo, labels);
@ -128,6 +147,20 @@ public class ProductionInboundServiceImpl implements ProductionInboundService {
}
}
public Map<String, Object> UspBackflushMaterialByOrder(String site, String buNo, String transNo, String orderNo, int inQty, String userName) {
List<Object> params = new ArrayList<>();
params.add(site);
params.add(buNo);
params.add(transNo);
params.add(orderNo);
params.add(inQty);
params.add(userName);
List<Map<String, Object>> resultList = procedureMapper.getProcedureData("UspBackflushMaterialByOrder", params);
//处理返回的结果
return resultList.get(0);
}
/**
* 插入或更新库存数据
*/
@ -264,7 +297,7 @@ public class ProductionInboundServiceImpl implements ProductionInboundService {
/**
* 生成入库事务记录
*/
private void generateInboundTransaction(String orderNo, String warehouseId, String locationCode, List<Map<String, Object>> labels, String site,String buNo) {
private String generateInboundTransaction(String orderNo, String warehouseId, String locationCode, List<Map<String, Object>> labels, String site,String buNo) {
logger.info("开始生成生产入库事务记录,入库单号: {}", orderNo);
// 构建TransDetailDto对象
@ -289,6 +322,8 @@ public class ProductionInboundServiceImpl implements ProductionInboundService {
// 生成事务子明细记录
addSubTransactionDetails(transHeader.getTransno(), labels, site, buNo, transDetailList, warehouseId, locationCode);
logger.info("入库事务子记录生成完成,事务单号: {}, 入库单号: {}, 明细记录数: {}", transHeader.getTransno(), orderNo, labels.size());
return transHeader.getTransno();
}
@Override

12
src/main/resources/mapper/productionInbound/ProductionInboundMapper.xml

@ -14,7 +14,7 @@
SUM(CASE WHEN pr.status = '已入库' THEN 1 ELSE 0 END) AS labelinCount, -- 已入库标签数
COUNT(DISTINCT pr.RollNo) AS totalLabels, -- 需入库标签数
SUM(CASE WHEN pr.status = '已入库' THEN ISNULL(pr.RollQty, 0) ELSE 0 END) AS totalinLabels, -- 已入库物料总数
SUM(CAST(D.required_qty AS float)) as labelCount --需入库总数
D.required_qty as labelCount --需入库总数
FROM inbound_notification_head h
LEFT JOIN inbound_notification_detail d ON h.site = d.site and h.bu_no = d.bu_no and h.order_no = d.order_no
INNER JOIN ShopOrder sh ON d.site = sh.site and d.bu_no = sh.bu_no and d.related_order_no = sh.OrderNo and d.part_no = sh.PartNo
@ -31,7 +31,7 @@
<if test="searchCode == null or searchCode == ''">
AND CONVERT(DATE, h.required_inbound_date) = CONVERT(DATE, GETDATE())
</if>
GROUP BY h.site,h.bu_no, h.order_no, h.required_inbound_date
GROUP BY h.site,h.bu_no, h.order_no, h.required_inbound_date,D.required_qty
ORDER BY h.required_inbound_date DESC
</select>
@ -46,7 +46,7 @@
SUM(CASE WHEN pr.status = '已入库' THEN 1 ELSE 0 END) AS labelinCount, -- 已入库标签数
COUNT(DISTINCT pr.RollNo) AS totalLabels, -- 需入库标签数
SUM(CASE WHEN pr.status = '已入库' THEN ISNULL(pr.RollQty, 0) ELSE 0 END) AS totalinLabels, -- 已入库物料总数
SUM(CAST(D.required_qty AS float)) as labelCount --需入库总数
D.required_qty as labelCount --需入库总数
FROM inbound_notification_head h
LEFT JOIN inbound_notification_detail d ON h.site = d.site and h.bu_no = d.bu_no and h.order_no = d.order_no
INNER JOIN ShopOrder sh ON d.site = sh.site and d.bu_no = sh.bu_no and d.related_order_no = sh.OrderNo and d.part_no = sh.PartNo
@ -55,7 +55,7 @@
h.site = #{site}
AND h.bu_no = #{buNo}
AND h.order_no = #{orderNo}
GROUP BY h.site, h.bu_no, h.order_no, h.required_inbound_date
GROUP BY h.site, h.bu_no, h.order_no, h.required_inbound_date,D.required_qty
</select>
<!-- 验证生产标签与入库单是否匹配 -->
@ -123,7 +123,7 @@
h.bu_no AS buNo,
d.part_no AS partNo,
SUM(CASE WHEN pr.status = '已入库' THEN ISNULL(pr.RollQty, 0) ELSE 0 END) AS totalinLabels, -- 已入库物料总数
SUM(CAST(D.required_qty AS float)) as labelCount --需入库总数
D.required_qty as labelCount --需入库总数
FROM inbound_notification_head h
LEFT JOIN inbound_notification_detail d ON h.site = d.site and h.bu_no = d.bu_no and h.order_no = d.order_no
INNER JOIN ShopOrder sh ON d.site = sh.site and d.bu_no = sh.bu_no and d.related_order_no = sh.OrderNo and d.part_no = sh.PartNo
@ -132,7 +132,7 @@
h.site = #{site}
AND h.bu_no = #{buNo}
AND h.order_no = #{inboundNo}
GROUP BY h.site, h.bu_no,d.part_no
GROUP BY h.site, h.bu_no,d.part_no,D.required_qty
</select>
</mapper>
Loading…
Cancel
Save