Commit bc694f54 authored by chew's avatar chew

通过条码查询客户信息

parent 7b7a9e97
package com.ekingwin.tms_app.module.cargo.outbound.controller;
import com.ekingwin.tms_app.common.dto.Result;
import com.ekingwin.tms_app.module.cargo.outbound.dto.ScanExecuteReq;
import com.ekingwin.tms_app.module.cargo.outbound.dto.ScanExecuteResp;
import com.ekingwin.tms_app.module.cargo.outbound.service.ScanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
@RestController
@RequestMapping("/cargo/outbound/scan")
public class ScanController {
@Autowired
private ScanService scanService;
@PostMapping("/execute")
public Result<ScanExecuteResp> executeScan(@RequestBody @Valid ScanExecuteReq req) {
return Result.success(scanService.executeScan(req));
}
}
\ No newline at end of file
package com.ekingwin.tms_app.module.cargo.outbound.dao;
import org.apache.ibatis.annotations.Mapper;
import java.util.Map;
@Mapper
public interface ScanMapper {
void executeScan(Map<String, Object> params);
}
package com.ekingwin.tms_app.module.cargo.outbound.dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ItemDetail {
// 通用字段
private String itemCode;
private String itemName;
private BigDecimal orderQty;
private BigDecimal tallyQty;
private BigDecimal remainQty;
private String status;
private String matchType; // 可区分 1V1/1VN 等
// 一对一 专用字段
private BigDecimal expectQty; // 箱内应有数
// 订单概况 专用字段
private Long detailId;
private Integer lineNo;
private String barcode;
private String isOddLot;
private String oddLotCn;
private String inBoxes; // LISTAGG 箱号
}
\ No newline at end of file
package com.ekingwin.tms_app.module.cargo.outbound.dto;
import lombok.Data;
@Data
public class ScanExecuteReq {
private Long sessionId;
private String scanCode;
}
package com.ekingwin.tms_app.module.cargo.outbound.dto;
import lombok.Data;
import java.util.List;
@Data
public class ScanExecuteResp {
private String scanType; // 码类型
private String matchType; // 1V1 / 1VN / ORDER_VIEW
private String result; // PASS / FAIL / WARN
private String message; // 提示信息
private List<ItemDetail> items;
}
\ No newline at end of file
package com.ekingwin.tms_app.module.cargo.outbound.service;
import com.ekingwin.tms_app.module.cargo.outbound.dto.ScanExecuteReq;
import com.ekingwin.tms_app.module.cargo.outbound.dto.ScanExecuteResp;
public interface ScanService {
ScanExecuteResp executeScan(ScanExecuteReq req);
}
package com.ekingwin.tms_app.module.cargo.outbound.service.impl;
import com.ekingwin.tms_app.module.cargo.outbound.dao.ScanMapper;
import com.ekingwin.tms_app.module.cargo.outbound.dto.ItemDetail;
import com.ekingwin.tms_app.module.cargo.outbound.dto.ScanExecuteReq;
import com.ekingwin.tms_app.module.cargo.outbound.dto.ScanExecuteResp;
import com.ekingwin.tms_app.module.cargo.outbound.service.ScanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class ScanServiceImpl implements ScanService {
@Autowired
private ScanMapper scanMapper;
@Override
public ScanExecuteResp executeScan(ScanExecuteReq req) {
// 1. 构造参数 Map
Map<String, Object> params = new HashMap<>();
params.put("p_session_id", req.getSessionId());
params.put("p_scan_code", req.getScanCode());
// 输出参数占位,MyBatis 会自动填充
params.put("p_out_scan_type", null);
params.put("p_out_match_type", null);
params.put("p_out_items", null);
params.put("p_out_result", null);
params.put("p_out_message", null);
// 2. 调用存储过程
scanMapper.executeScan(params);
// 3. 提取输出参数
ScanExecuteResp resp = new ScanExecuteResp();
resp.setScanType((String) params.get("p_out_scan_type"));
resp.setMatchType((String) params.get("p_out_match_type"));
resp.setResult((String) params.get("p_out_result"));
resp.setMessage((String) params.get("p_out_message"));
resp.setItems((List<ItemDetail>) params.get("p_out_items"));
return resp;
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ekingwin.tms_app.module.cargo.outbound.dao.ScanMapper">
<!-- 游标结果映射(根据实际返回列定义) -->
<resultMap id="itemDetailMap" type="com.ekingwin.tms_app.module.cargo.outbound.dto.ItemDetail">
<!-- 通用列 -->
<result column="item_code" property="itemCode"/>
<result column="item_name" property="itemName"/>
<result column="order_qty" property="orderQty"/>
<result column="tally_qty" property="tallyQty"/>
<result column="remain_qty" property="remainQty"/>
<result column="status" property="status"/>
<result column="match_type" property="matchType"/>
<!-- ORDER_VIEW 专用 -->
<result column="detail_id" property="detailId"/>
<result column="line_no" property="lineNo"/>
<result column="barcode" property="barcode"/>
<result column="is_odd_lot" property="isOddLot"/>
<result column="odd_lot_cn" property="oddLotCn"/>
<result column="in_boxes" property="inBoxes"/>
<!-- 1V1 专用 -->
<result column="expect_qty" property="expectQty"/>
<!-- 1VN 专用 -->
<result column="batch_no" property="batchNo"/>
<result column="lot_no" property="lotNo"/>
<result column="box_odd_lot" property="boxOddLot"/>
</resultMap>
<!-- 调用存储过程 -->
<select id="executeScan" statementType="CALLABLE" parameterType="map">
{call PAK_OUTBOUND_SCAN.P_SCAN_EXECUTE(
#{p_session_id, mode=IN, jdbcType=NUMERIC},
#{p_scan_code, mode=IN, jdbcType=VARCHAR},
#{p_out_scan_type, mode=OUT, jdbcType=VARCHAR},
#{p_out_match_type, mode=OUT, jdbcType=VARCHAR},
#{p_out_items, mode=OUT, jdbcType=CURSOR, javaType=java.sql.ResultSet, resultMap=itemDetailMap},
#{p_out_result, mode=OUT, jdbcType=VARCHAR},
#{p_out_message, mode=OUT, jdbcType=VARCHAR}
)}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment