Browse Source

采购入库

master
han\hanst 6 months ago
parent
commit
5de5a3f41e
  1. 37
      src/main/java/com/gaotao/modules/inboundNotification/controller/InboundNotificationController.java
  2. 18
      src/main/java/com/gaotao/modules/inboundNotification/dao/InboundNotificationHeadMapper.java
  3. 14
      src/main/java/com/gaotao/modules/inboundNotification/service/InboundNotificationService.java
  4. 37
      src/main/java/com/gaotao/modules/inboundNotification/service/impl/InboundNotificationServiceImpl.java
  5. 83
      src/main/resources/mapper/inboundNotification/InboundNotificationHeadMapper.xml

37
src/main/java/com/gaotao/modules/inboundNotification/controller/InboundNotificationController.java

@ -41,7 +41,7 @@ public class InboundNotificationController extends AbstractController {
}
List<Map<String, Object>> resultList = inboundNotificationService.getQualifiedInboundList(
site,warehouseId, searchCode, status);
site, warehouseId, searchCode, status);
return R.ok().put("data", resultList);
} catch (Exception e) {
@ -60,6 +60,7 @@ public class InboundNotificationController extends AbstractController {
String partNo = (String) params.get("partNo");
String warehouseId = (String) params.get("warehouseId");
String site = (String) params.get("site");
String buNo = (String) params.get("buNo");
if (inboundNo == null || inboundNo.trim().isEmpty()) {
return R.error("入库单号不能为空");
}
@ -73,7 +74,7 @@ public class InboundNotificationController extends AbstractController {
}
Map<String, Object> result = inboundNotificationService.getInboundDetails(
inboundNo, partNo, warehouseId,site);
inboundNo, partNo, warehouseId,site,buNo);
if (result == null || result.isEmpty()) {
return R.error("未找到入库单详情");
@ -201,4 +202,36 @@ public class InboundNotificationController extends AbstractController {
return R.error("删除失败: " + e.getMessage());
}
}
/**
* 获取物料清单
* 根据sitebuNoinboundNo从po_order_roll_no表获取物料信息
*/
@PostMapping("getMaterialList")
public R getMaterialList(@RequestBody Map<String, Object> params) {
try {
String site = (String) params.get("site");
String buNo = (String) params.get("buNo");
String inboundNo = (String) params.get("inboundNo");
if (site == null || site.trim().isEmpty()) {
return R.error("站点不能为空");
}
if (buNo == null || buNo.trim().isEmpty()) {
return R.error("业务单元不能为空");
}
if (inboundNo == null || inboundNo.trim().isEmpty()) {
return R.error("入库单号不能为空");
}
List<Map<String, Object>> materialList = inboundNotificationService.getMaterialList(site, buNo, inboundNo);
return R.ok().put("data", materialList);
} catch (Exception e) {
logger.error("获取物料清单失败", e);
return R.error("获取物料清单失败: " + e.getMessage());
}
}
}

18
src/main/java/com/gaotao/modules/inboundNotification/dao/InboundNotificationHeadMapper.java

@ -13,12 +13,14 @@ public interface InboundNotificationHeadMapper extends BaseMapper<InboundNotific
/**
* 获取检验合格待入库列表
* @param site 站点
* @param warehouseId 仓库ID
* @param searchCode 搜索条件
* @param status 状态
* @return 待入库列表
*/
List<Map<String, Object>> getQualifiedInboundList(@Param("site")String site,@Param("warehouseId") String warehouseId,
List<Map<String, Object>> getQualifiedInboundList(@Param("site") String site,
@Param("warehouseId") String warehouseId,
@Param("searchCode") String searchCode,
@Param("status") String status);
@ -32,7 +34,8 @@ public interface InboundNotificationHeadMapper extends BaseMapper<InboundNotific
Map<String, Object> getInboundDetails(@Param("orderNo") String orderNo,
@Param("partNo") String partNo,
@Param("warehouseId") String warehouseId,
@Param("site") String site);
@Param("site") String site,
@Param("buNo") String buNo);
/**
* 更新入库单状态
@ -44,4 +47,15 @@ public interface InboundNotificationHeadMapper extends BaseMapper<InboundNotific
int updateInboundStatus(@Param("orderNo") String orderNo,
@Param("partNo") String partNo,
@Param("status") String status,@Param("site") String site,@Param("buNo") String buNo);
/**
* 获取物料清单
* @param site 站点
* @param buNo 业务单元
* @param inboundNo 入库单号
* @return 物料清单
*/
List<Map<String, Object>> getMaterialList(@Param("site") String site,
@Param("buNo") String buNo,
@Param("inboundNo") String inboundNo);
}

14
src/main/java/com/gaotao/modules/inboundNotification/service/InboundNotificationService.java

@ -7,12 +7,13 @@ public interface InboundNotificationService {
/**
* 获取检验合格待入库列表
* @param site 站点
* @param warehouseId 仓库ID
* @param searchCode 搜索条件
* @param status 状态
* @return 待入库列表
*/
List<Map<String, Object>> getQualifiedInboundList(String site,String warehouseId, String searchCode, String status);
List<Map<String, Object>> getQualifiedInboundList(String site, String warehouseId, String searchCode, String status);
/**
* 获取入库单详情
@ -21,7 +22,7 @@ public interface InboundNotificationService {
* @param warehouseId 仓库ID
* @return 入库单详情
*/
Map<String, Object> getInboundDetails(String orderNo, String partNo, String warehouseId,String site);
Map<String, Object> getInboundDetails(String orderNo, String partNo, String warehouseId,String site, String buNo);
/**
* 验证标签与入库单是否匹配
@ -43,4 +44,13 @@ public interface InboundNotificationService {
* @return 处理结果
*/
boolean confirmInboundStorage(String orderNo, String partNo, String warehouseId, String locationCode, List<Map<String, Object>> labels, String site,String buNo);
/**
* 获取物料清单
* @param site 站点
* @param buNo 业务单元
* @param inboundNo 入库单号
* @return 物料清单
*/
List<Map<String, Object>> getMaterialList(String site, String buNo, String inboundNo);
}

37
src/main/java/com/gaotao/modules/inboundNotification/service/impl/InboundNotificationServiceImpl.java

@ -44,13 +44,13 @@ public class InboundNotificationServiceImpl implements InboundNotificationServic
private TransDetailService transDetailService;
@Override
public List<Map<String, Object>> getQualifiedInboundList(String site,String warehouseId, String searchCode, String status) {
return headMapper.getQualifiedInboundList(site,warehouseId, searchCode, status);
public List<Map<String, Object>> getQualifiedInboundList(String site, String warehouseId, String searchCode, String status) {
return headMapper.getQualifiedInboundList(site, warehouseId, searchCode, status);
}
@Override
public Map<String, Object> getInboundDetails(String orderNo, String partNo, String warehouseId,String site) {
return headMapper.getInboundDetails(orderNo, partNo, warehouseId,site);
public Map<String, Object> getInboundDetails(String orderNo, String partNo, String warehouseId,String site, String buNo) {
return headMapper.getInboundDetails(orderNo, partNo, warehouseId,site,buNo);
}
@Override
@ -94,7 +94,7 @@ public class InboundNotificationServiceImpl implements InboundNotificationServic
}
// 4. 插入库存数据
insertInventoryStock(orderNo, partNo, warehouseId, locationCode, labels, site);
insertInventoryStock(orderNo, partNo, warehouseId, locationCode, labels, site, buNo);
// 5. 生成入库事务记录
generateInboundTransaction(orderNo, partNo, warehouseId, labels,site);
@ -113,12 +113,13 @@ public class InboundNotificationServiceImpl implements InboundNotificationServic
/**
* 插入或更新库存数据
*/
private void insertInventoryStock(String orderNo, String partNo, String warehouseId, String locationCode, List<Map<String, Object>> labels, String site) {
private void insertInventoryStock(String orderNo, String partNo, String warehouseId, String locationCode,
List<Map<String, Object>> labels, String site, String buNo) {
logger.info("开始处理库存数据,入库单号: {}, 物料编码: {}, 仓库ID: {}, 标签数量: {}",
orderNo, partNo, warehouseId, labels.size());
// 获取物料基本信息
Map<String, Object> materialInfo = headMapper.getInboundDetails(orderNo, partNo, warehouseId, site);
Map<String, Object> materialInfo = headMapper.getInboundDetails(orderNo, partNo, warehouseId, site,buNo);
if (materialInfo == null) {
logger.error("获取物料信息失败,入库单号: {}, 物料编码: {}", orderNo, partNo);
throw new RuntimeException("获取物料信息失败");
@ -277,6 +278,28 @@ public class InboundNotificationServiceImpl implements InboundNotificationServic
transHeader.getTransno(), orderNo, labels.size());
}
@Override
public List<Map<String, Object>> getMaterialList(String site, String buNo, String inboundNo) {
logger.info("获取物料清单,站点: {}, 业务单元: {}, 入库单号: {}", site, buNo, inboundNo);
try {
List<Map<String, Object>> materialList = headMapper.getMaterialList(site, buNo, inboundNo);
if (materialList == null) {
materialList = new ArrayList<>();
}
logger.info("获取物料清单成功,站点: {}, 业务单元: {}, 入库单号: {}, 记录数: {}",
site, buNo, inboundNo, materialList.size());
return materialList;
} catch (Exception e) {
logger.error("获取物料清单失败,站点: {}, 业务单元: {}, 入库单号: {}, 错误信息: {}",
site, buNo, inboundNo, e.getMessage(), e);
throw new RuntimeException("获取物料清单失败: " + e.getMessage(), e);
}
}
/**
* 生成事务明细记录
*/

83
src/main/resources/mapper/inboundNotification/InboundNotificationHeadMapper.xml

@ -6,29 +6,48 @@
<!-- 获取检验合格待入库列表 -->
<select id="getQualifiedInboundList" resultType="java.util.Map">
SELECT
h.order_no as inboundNo,
d.part_no as partNo,
d.part_desc as partName,
d.unit as unit,
d.in_batch_no as batchNo,
h.required_inbound_date as inspectionDate,
d.required_qty as qualifiedQty,
d.required_qty as totalQty,
COUNT(DISTINCT pr.roll_no) as labelCount,
COUNT(DISTINCT pr.roll_no) as totalLabels
h.order_no AS inboundNo,
d.part_no AS partNo,
h.bu_no AS buNo,
d.part_desc AS partName,
d.unit AS unit,
d.in_batch_no AS batchNo,
h.required_inbound_date AS inspectionDate,
d.required_qty AS qualifiedQty,
d.required_qty AS totalQty,
SUM(CASE WHEN pr.hardtag_in_flag = '已入库' THEN 1 ELSE 0 END) AS labelinCount, -- 已入库标签数
COUNT(DISTINCT pr.roll_no) AS totalLabels, -- 需入库标签数
SUM(CASE WHEN pr.hardtag_in_flag = '已入库' THEN ISNULL(pr.roll_qty, 0) ELSE 0 END) AS totalinLabels, -- 已入库物料总数
ISNULL(d.required_qty, 0) AS labelCount -- 需入库总数
FROM inbound_notification_head h
INNER JOIN inbound_notification_detail d ON h.order_no = d.order_no AND h.site = d.site
LEFT JOIN po_order_roll_no pr ON d.order_no = pr.inspection_no AND d.part_no = pr.part_no
INNER JOIN inbound_notification_detail d
ON h.order_no = d.order_no AND h.site = d.site
LEFT JOIN po_order_roll_no pr
ON d.order_no = pr.inspection_no AND d.part_no = pr.part_no
WHERE h.site = #{site}
AND h.order_status = 'PENDING_INBOUND'
<if test="searchCode != null and searchCode != ''">
AND (h.order_no LIKE CONCAT('%', #{searchCode}, '%')
OR d.part_no LIKE CONCAT('%', #{searchCode}, '%'))
</if>
GROUP BY h.order_no, d.part_no, d.part_desc, d.unit, d.in_batch_no, h.required_inbound_date, d.required_qty
AND h.order_status = '待入库'
<if test="searchCode != null and searchCode != ''">
AND (
h.order_no LIKE CONCAT('%', #{searchCode}, '%')
OR h.related_order_no LIKE CONCAT('%', #{searchCode}, '%')
)
</if>
<if test="searchCode == null or searchCode == ''">
AND CONVERT(DATE, h.required_inbound_date) = CONVERT(DATE, GETDATE())
</if>
GROUP BY
h.bu_no,
h.order_no,
d.part_no,
d.part_desc,
d.unit,
d.in_batch_no,
h.required_inbound_date,
d.required_qty
ORDER BY h.required_inbound_date DESC
</select>
<!-- 获取入库单详情 -->
<select id="getInboundDetails" resultType="java.util.Map">
SELECT
@ -42,14 +61,17 @@
h.required_inbound_date as inspectionDate,
d.required_qty as qualifiedQty,
d.required_qty as totalQty,
COUNT(DISTINCT pr.roll_no) as labelCount,
COUNT(DISTINCT pr.roll_no) as totalLabels
SUM(CASE WHEN hardtag_in_flag = '已入库' then 1 else 0 end) labelinCount, --已入库标签数
COUNT(DISTINCT pr.roll_no) as totalLabels , --需入库标签数
SUM(CASE WHEN hardtag_in_flag = '已入库' then CAST(roll_qty AS float) else 0 end) totalinLabels,--已入库物料总数
SUM(CAST(D.required_qty AS float)) as labelCount --需入库总数
FROM inbound_notification_head h
INNER JOIN inbound_notification_detail d ON h.order_no = d.order_no AND h.site = d.site
LEFT JOIN po_order_roll_no pr ON d.order_no = pr.inspection_no AND d.part_no = pr.part_no
WHERE h.order_no = #{orderNo}
AND d.part_no = #{partNo}
AND h.site = #{site}
INNER JOIN inbound_notification_detail d ON h.order_no = d.order_no AND h.site = d.site
LEFT JOIN po_order_roll_no pr ON d.order_no = pr.inspection_no AND d.part_no = pr.part_no
WHERE
h.site = #{site}
AND h.bu_no = #{buNo}
AND h.order_no = #{orderNo}
GROUP BY h.order_no, h.site, h.bu_no, d.part_no, d.part_desc, d.unit, d.in_batch_no, h.required_inbound_date, d.required_qty
</select>
@ -68,5 +90,16 @@
AND h.bu_no = #{buNo}
</update>
<!-- 获取物料清单 -->
<select id="getMaterialList" resultType="java.util.Map">
SELECT d.part_no as partNo,d.part_desc,
SUM(CASE WHEN hardtag_in_flag = '已入库' then CAST(roll_qty AS float) else 0 end) totalinLabels,--已入库数
SUM(CAST(D.required_qty AS float)) as labelCount --需求数量
FROM inbound_notification_detail d
LEFT JOIN po_order_roll_no pr ON d.order_no = pr.inspection_no AND d.part_no = pr.part_no
WHERE d.SITE =#{site} AND d.bu_no = #{buNo} AND d.order_no =#{inboundNo}
group by d.part_no,d.part_desc
</select>
</mapper>
Loading…
Cancel
Save