opt:代码优化
This commit is contained in:
@@ -45,4 +45,11 @@ public class ErpToWmsController {
|
||||
public ResponseEntity<Object> sendTask(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(erpToWmsService.sendTask(whereJson),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/groupplate")
|
||||
@Log("下发组盘信息")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> sendGroupplate(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(erpToWmsService.sendGroupplate(whereJson),HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,24 @@ public interface ErpToWmsService {
|
||||
* @return ErpResponse
|
||||
*/
|
||||
ErpResponse sendTask(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 下发出库单据
|
||||
* @param whereJson: {
|
||||
* stor_code:仓库编码
|
||||
* inv_code:单据号(可为空)
|
||||
* task_type :业务类型(可为空)
|
||||
* data : [
|
||||
* {
|
||||
* mater_code:物料编码
|
||||
* batch_no:批次号(可为空)
|
||||
* quantity:数量
|
||||
* unit_code:计量单位
|
||||
* unit_name:计量单位名称
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* @return ErpResponse
|
||||
*/
|
||||
ErpResponse sendGroupplate(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -131,4 +131,63 @@ public class ErpToWmsServiceImpl implements ErpToWmsService {
|
||||
log.info("sendTask下发出库任务接口输出参数为:-------------------" + ErpResponse.requestOk().toString());
|
||||
return ErpResponse.requestOk();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErpResponse sendGroupplate(JSONObject whereJson) {
|
||||
log.info("sendTask下发出库任务接口输入参数为:-------------------" + whereJson.toString());
|
||||
// 组织主表数据
|
||||
JSONObject jsonMst = new JSONObject();
|
||||
jsonMst.put("biz_date", DateUtil.now());
|
||||
jsonMst.put("bill_status", IOSEnum.BILL_STATUS.code("生成"));
|
||||
jsonMst.put("source_id", whereJson.getString("inv_code"));
|
||||
jsonMst.put("source_type", whereJson.getString("task_type"));
|
||||
jsonMst.put("bill_type", whereJson.getString("task_type"));
|
||||
jsonMst.put("user", "erp");
|
||||
// 查询仓库
|
||||
BsrealStorattr storDao = iBsrealStorattrService.findByCode(whereJson.getString("stor_code"));
|
||||
if (storDao == null) {
|
||||
throw new BadRequestException("仓库不存在");
|
||||
}
|
||||
jsonMst.put("stor_id", storDao.getStor_id());
|
||||
// 组织明细
|
||||
List<JSONObject> dataList = whereJson.getJSONArray("data").toJavaList(JSONObject.class);
|
||||
// 查询所有物料
|
||||
List<MdMeMaterialbase> materDaoList = iMdMeMaterialbaseService.list(
|
||||
new QueryWrapper<MdMeMaterialbase>().lambda()
|
||||
.in(MdMeMaterialbase::getMaterial_code, dataList.stream()
|
||||
.map(row -> row.getString("mater_code"))
|
||||
.collect(Collectors.toList())
|
||||
)
|
||||
);
|
||||
// 查询所有计量单位
|
||||
List<MdPbMeasureunit> unitDaoList = iMdPbMeasureunitService.list(
|
||||
new QueryWrapper<MdPbMeasureunit>().lambda()
|
||||
.in(MdPbMeasureunit::getUnit_code, dataList.stream()
|
||||
.map(row -> row.getString("unit_code"))
|
||||
.collect(Collectors.toList()))
|
||||
);
|
||||
// 明细集合
|
||||
JSONArray dtlArr = new JSONArray();
|
||||
for (JSONObject json : dataList) {
|
||||
JSONObject jsonDtl = new JSONObject();
|
||||
MdMeMaterialbase materDao = materDaoList.stream()
|
||||
.filter(row -> row.getMaterial_code().equals(json.getString("mater_code")))
|
||||
.findFirst().orElse(null);
|
||||
jsonDtl.put("material_id", materDao.getMaterial_id());
|
||||
jsonDtl.put("pcsn", json.getString("batch_no"));
|
||||
MdPbMeasureunit unitDao = unitDaoList.stream()
|
||||
.filter(row -> row.getUnit_code().equals(json.getString("unit_code")))
|
||||
.findFirst().orElse(null);
|
||||
jsonDtl.put("qty_unit_id", unitDao.getMeasure_unit_id());
|
||||
jsonDtl.put("qty_unit_name", unitDao.getUnit_name());
|
||||
jsonDtl.put("qty", json.getString("quantity"));
|
||||
dtlArr.add(jsonDtl);
|
||||
}
|
||||
jsonMst.put("tableData",dtlArr);
|
||||
// 调用出库单新增服务
|
||||
iOutBillService.insertDtl(jsonMst);
|
||||
|
||||
log.info("sendTask下发出库任务接口输出参数为:-------------------" + ErpResponse.requestOk().toString());
|
||||
return ErpResponse.requestOk();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,9 +52,15 @@
|
||||
storagevehicle_code,
|
||||
gp.material_id,pcsn,
|
||||
qty_unit_id,
|
||||
qty_unit_name,qty,frozen_qty,remark,
|
||||
status,ext_code,ext_type,
|
||||
mater.material_name,mater.material_spec,mater.material_code
|
||||
qty_unit_name,qty,
|
||||
frozen_qty,remark,
|
||||
status,ext_code,
|
||||
ext_type,
|
||||
mater.material_name,
|
||||
mater.material_spec,
|
||||
mater.material_code,
|
||||
gp.ext_code,
|
||||
gp.ext_type
|
||||
FROM md_pb_groupplate gp
|
||||
LEFT JOIN md_me_materialbase mater ON mater.material_id = gp.material_id
|
||||
<where>
|
||||
|
||||
Reference in New Issue
Block a user