7 changed files with 377 additions and 10 deletions
-
32src/main/java/com/heai/modules/app/controller/StockOtherOutController.java
-
70src/main/java/com/heai/modules/app/entity/StockOtherOutLineParam.java
-
39src/main/java/com/heai/modules/app/entity/StockOtherOutSaveParam.java
-
15src/main/java/com/heai/modules/app/service/StockOtherOutService.java
-
152src/main/java/com/heai/modules/app/service/impl/StockOtherOutServiceImpl.java
-
78src/main/resources/static/js/pdaOther/stockOtherOut.js
-
1src/main/resources/templates/pdaOther/stockOtherOut.ftl
@ -0,0 +1,32 @@ |
|||
package com.heai.modules.app.controller; |
|||
|
|||
import com.heai.common.annotation.RepeatSubmit; |
|||
import com.heai.common.utils.R; |
|||
import com.heai.modules.app.entity.StockOtherOutSaveParam; |
|||
import com.heai.modules.app.service.StockOtherOutService; |
|||
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; |
|||
|
|||
/** |
|||
* PDA 其他出库(独立于 PdaOrder)- rqrq |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/pda/stockOtherOut") |
|||
public class StockOtherOutController { |
|||
|
|||
@Autowired |
|||
private StockOtherOutService stockOtherOutService; |
|||
|
|||
/** |
|||
* @Description 保存其他出库 - rqrq |
|||
*/ |
|||
@PostMapping("/save") |
|||
@RepeatSubmit |
|||
public R save(@RequestBody StockOtherOutSaveParam param) { |
|||
stockOtherOutService.saveStockOtherOut(param); |
|||
return R.ok("保存成功!"); |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
package com.heai.modules.app.entity; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* PDA 其他出库明细 - rqrq |
|||
*/ |
|||
public class StockOtherOutLineParam { |
|||
|
|||
private String site; |
|||
|
|||
private String warehouseId; |
|||
|
|||
private String partNo; |
|||
|
|||
private String batchNo; |
|||
|
|||
private String locationId; |
|||
|
|||
/** 出库数量 */ |
|||
private BigDecimal qtyOut; |
|||
|
|||
public String getSite() { |
|||
return site; |
|||
} |
|||
|
|||
public void setSite(String site) { |
|||
this.site = site; |
|||
} |
|||
|
|||
public String getWarehouseId() { |
|||
return warehouseId; |
|||
} |
|||
|
|||
public void setWarehouseId(String warehouseId) { |
|||
this.warehouseId = warehouseId; |
|||
} |
|||
|
|||
public String getPartNo() { |
|||
return partNo; |
|||
} |
|||
|
|||
public void setPartNo(String partNo) { |
|||
this.partNo = partNo; |
|||
} |
|||
|
|||
public String getBatchNo() { |
|||
return batchNo; |
|||
} |
|||
|
|||
public void setBatchNo(String batchNo) { |
|||
this.batchNo = batchNo; |
|||
} |
|||
|
|||
public String getLocationId() { |
|||
return locationId; |
|||
} |
|||
|
|||
public void setLocationId(String locationId) { |
|||
this.locationId = locationId; |
|||
} |
|||
|
|||
public BigDecimal getQtyOut() { |
|||
return qtyOut; |
|||
} |
|||
|
|||
public void setQtyOut(BigDecimal qtyOut) { |
|||
this.qtyOut = qtyOut; |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
package com.heai.modules.app.entity; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* PDA 其他出库保存 - rqrq |
|||
*/ |
|||
public class StockOtherOutSaveParam { |
|||
|
|||
private String userName; |
|||
|
|||
private String remark; |
|||
|
|||
private List<StockOtherOutLineParam> lines; |
|||
|
|||
public String getUserName() { |
|||
return userName; |
|||
} |
|||
|
|||
public void setUserName(String userName) { |
|||
this.userName = userName; |
|||
} |
|||
|
|||
public String getRemark() { |
|||
return remark; |
|||
} |
|||
|
|||
public void setRemark(String remark) { |
|||
this.remark = remark; |
|||
} |
|||
|
|||
public List<StockOtherOutLineParam> getLines() { |
|||
return lines; |
|||
} |
|||
|
|||
public void setLines(List<StockOtherOutLineParam> lines) { |
|||
this.lines = lines; |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
package com.heai.modules.app.service; |
|||
|
|||
import com.heai.modules.app.entity.StockOtherOutSaveParam; |
|||
|
|||
/** |
|||
* PDA 其他出库(库存标签) - rqrq |
|||
*/ |
|||
public interface StockOtherOutService { |
|||
|
|||
/** |
|||
* @Description 生成其他出库主档+明细(专用存储过程)- rqrq |
|||
* @param param 入参 |
|||
*/ |
|||
void saveStockOtherOut(StockOtherOutSaveParam param); |
|||
} |
|||
@ -0,0 +1,152 @@ |
|||
package com.heai.modules.app.service.impl; |
|||
|
|||
import com.heai.common.utils.DateUtil; |
|||
import com.heai.modules.app.entity.StockOtherOutLineParam; |
|||
import com.heai.modules.app.entity.StockOtherOutSaveParam; |
|||
import com.heai.modules.app.service.StockOtherOutService; |
|||
import com.heai.modules.production.dao.FunctionMapper; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.text.ParseException; |
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Description PDA 其他出库:Inventory_Create_TransHeader_other + Inventory_Create_TransDetail_Out_other - rqrq |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class StockOtherOutServiceImpl implements StockOtherOutService { |
|||
|
|||
private static final String TRANS_TYPE_OC = "OC"; |
|||
|
|||
/** 与现存发料出库明细过程参数顺序一致的空成本与订单引用 - rqrq */ |
|||
private static final String COST_GROUP_EMPTY = ""; |
|||
private static final String ORDER_REF_EMPTY = ""; |
|||
private static final String ALLOW_NEGATIVE_N = "N"; |
|||
|
|||
/** 主过程要求往来单位占位 - rqrq */ |
|||
private static final String PARTNER_ID_STAR = "*"; |
|||
|
|||
@Autowired |
|||
private FunctionMapper functionMapper; |
|||
|
|||
/** |
|||
* @Description 对齐 FunctionServiceImpl#saveSaveTrans,改用其他出库专用存储过程 - rqrq |
|||
*/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void saveStockOtherOut(StockOtherOutSaveParam param) { |
|||
if (param == null) { |
|||
throw new RuntimeException("参数不能为空"); |
|||
} |
|||
if (!StringUtils.hasText(param.getUserName())) { |
|||
throw new RuntimeException("用户不能为空"); |
|||
} |
|||
List<StockOtherOutLineParam> lines = param.getLines(); |
|||
if (lines == null || lines.isEmpty()) { |
|||
throw new RuntimeException("没有出库明细"); |
|||
} |
|||
|
|||
StockOtherOutLineParam first = lines.get(0); |
|||
if (!StringUtils.hasText(first.getSite())) { |
|||
throw new RuntimeException("工厂不能为空"); |
|||
} |
|||
if (!StringUtils.hasText(first.getWarehouseId())) { |
|||
throw new RuntimeException("仓库不能为空"); |
|||
} |
|||
|
|||
final String site0 = trim(first.getSite()); |
|||
final String warehouse0 = trim(first.getWarehouseId()); |
|||
|
|||
for (int i = 0; i < lines.size(); i++) { |
|||
StockOtherOutLineParam row = lines.get(i); |
|||
if (!StringUtils.hasText(row.getPartNo())) { |
|||
throw new RuntimeException("第" + (i + 1) + "行物料编码不能为空"); |
|||
} |
|||
if (row.getQtyOut() == null || row.getQtyOut().doubleValue() <= 0) { |
|||
throw new RuntimeException("第" + (i + 1) + "行出库数量无效"); |
|||
} |
|||
if (!site0.equals(trim(row.getSite()))) { |
|||
throw new RuntimeException("明细工厂必须一致"); |
|||
} |
|||
if (!warehouse0.equals(trim(row.getWarehouseId()))) { |
|||
throw new RuntimeException("明细仓库必须与首张标签仓库一致"); |
|||
} |
|||
} |
|||
|
|||
Date transDate; |
|||
try { |
|||
transDate = DateUtil.getDate(DateUtil.getStringDate(new Date())); |
|||
} catch (ParseException e) { |
|||
throw new RuntimeException("业务日期解析失败"); |
|||
} |
|||
|
|||
String user = trim(param.getUserName()); |
|||
String remark = param.getRemark() != null ? param.getRemark() : ""; |
|||
|
|||
List<Object> headerParams = new ArrayList<>(); |
|||
headerParams.add(site0); |
|||
headerParams.add(warehouse0); |
|||
headerParams.add(TRANS_TYPE_OC); |
|||
headerParams.add(transDate); |
|||
headerParams.add(user); |
|||
headerParams.add(user); |
|||
headerParams.add(""); |
|||
headerParams.add(PARTNER_ID_STAR); |
|||
headerParams.add(remark); |
|||
headerParams.add(""); |
|||
headerParams.add(""); |
|||
|
|||
Map<String, Object> map = functionMapper.getProcedure("Inventory_Create_TransHeader_other", headerParams); |
|||
if (map == null) { |
|||
throw new RuntimeException("主档存储过程无返回"); |
|||
} |
|||
String resultCode = String.valueOf(map.get("result_code")).trim(); |
|||
String transNo = String.valueOf(map.get("result_msg")).trim(); |
|||
if (!"200".equals(resultCode)) { |
|||
throw new RuntimeException(transNo); |
|||
} |
|||
if (!StringUtils.hasText(transNo)) { |
|||
throw new RuntimeException("未生成出库单号"); |
|||
} |
|||
|
|||
for (int i = 0; i < lines.size(); i++) { |
|||
StockOtherOutLineParam row = lines.get(i); |
|||
List<Object> detailParams = new ArrayList<>(); |
|||
detailParams.add(site0); |
|||
detailParams.add(transNo); |
|||
detailParams.add(i + 1); |
|||
detailParams.add(trim(row.getPartNo())); |
|||
detailParams.add(row.getBatchNo() != null ? trim(row.getBatchNo()) : ""); |
|||
detailParams.add(row.getLocationId() != null ? trim(row.getLocationId()).toUpperCase() : ""); |
|||
detailParams.add(row.getQtyOut().doubleValue()); |
|||
detailParams.add(COST_GROUP_EMPTY); |
|||
detailParams.add(ORDER_REF_EMPTY); |
|||
detailParams.add(ORDER_REF_EMPTY); |
|||
detailParams.add(ORDER_REF_EMPTY); |
|||
detailParams.add(ALLOW_NEGATIVE_N); |
|||
|
|||
map = functionMapper.getProcedure("Inventory_Create_TransDetail_Out_other", detailParams); |
|||
if (map == null) { |
|||
throw new RuntimeException("明细存储过程无返回:" + row.getPartNo()); |
|||
} |
|||
String dCode = String.valueOf(map.get("result_code")).trim(); |
|||
if (!"200".equals(dCode)) { |
|||
throw new RuntimeException(String.valueOf(map.get("result_msg"))); |
|||
} |
|||
} |
|||
|
|||
log.info("其他出库完成 transNo={}, 行数={} - rqrq", transNo, lines.size()); |
|||
} |
|||
|
|||
private static String trim(String s) { |
|||
return s == null ? "" : s.trim(); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue