完善项目

This commit is contained in:
张江玮
2022-09-26 14:35:36 +08:00
parent 8b014360c6
commit 0bd8060be0
16 changed files with 718 additions and 93 deletions

View File

@@ -38,7 +38,7 @@ public class SendMaterialController {
@PostMapping("/confirm")
@Log("送料确定")
@ApiOperation("送料确定")
public ResponseEntity<JSONObject> confirm(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(sendMaterialService.confirm(whereJson), HttpStatus.OK);
public ResponseEntity<JSONObject> confirm(@RequestBody JSONObject param) {
return new ResponseEntity<>(sendMaterialService.confirm(param), HttpStatus.OK);
}
}

View File

@@ -14,8 +14,8 @@ public interface SendMaterialService {
/**
* 送料确定
*
* @param whereJson /
* @param param /
* @return JSONObject
*/
JSONObject confirm(JSONObject whereJson);
JSONObject confirm(JSONObject param);
}

View File

@@ -1,12 +1,18 @@
package org.nl.wms.pda.sendmaterial.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.wms.ext.acs.service.AcsToWmsService;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SecurityUtils;
import org.nl.wms.pda.sendmaterial.service.SendMaterialService;
import org.nl.wms.sch.tasks.SendMaterialTask;
import org.nl.wms.st.inbill.service.dto.RegionioDto;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.WQLObject;
import org.nl.wql.core.engine.object.WO;
@@ -18,7 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
@Slf4j
public class SendMaterialServiceImpl implements SendMaterialService {
private final AcsToWmsService acsToWmsService;
private final SendMaterialTask sendMaterialTask;
@Override
public JSONObject queryPoint() {
@@ -26,8 +32,8 @@ public class SendMaterialServiceImpl implements SendMaterialService {
JSONObject resultJSON = new JSONObject();
// 查询所有区域
WO wo = WQL.getWO("PDA_SENDMATERIAL_01");
JSONArray result = wo
JSONArray result = WQL
.getWO("PDA_SENDMATERIAL_01")
.addParam("flag", "1")
.process()
.getResultJSONArray(0);
@@ -35,7 +41,8 @@ public class SendMaterialServiceImpl implements SendMaterialService {
// 遍历所有区域查询区域下的点位
for (Object r : result) {
JSONObject region = (JSONObject) r;
JSONArray pointArr = wo
JSONArray pointArr = WQL
.getWO("PDA_SENDMATERIAL_01")
.addParam("flag", "2")
.addParam("region_id", region.getString("region_id"))
.process()
@@ -50,31 +57,81 @@ public class SendMaterialServiceImpl implements SendMaterialService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject confirm(JSONObject whereJson) {
JSONObject result = new JSONObject();
// 1、准备参数point_code、type2为共挤区域8为豪凯区域
JSONObject param = new JSONObject();
public JSONObject confirm(JSONObject param) {
// 返回值
JSONObject resultJSON = new JSONObject();
String region_id = whereJson.getString("region_id");
JSONObject jsonObject = WQLObject.getWQLObject("sch_base_region").query("region_id ='" + region_id + "'").uniqueResult(0);
String region_code = jsonObject.getString("region_code");
if (StrUtil.equals(region_code, "GJQY01")) param.put("type","2");
if (StrUtil.equals(region_code, "HKQY01")) param.put("type","8");
param.put("point_code",whereJson.getString("point_code"));
param.put("qty",whereJson.getString("qty"));
// 2、调用接口
JSONObject json = acsToWmsService.apply(param);
if (StrUtil.equals(json.getString("status"), "200")) {
result.put("result", "");
result.put("code", "1");
result.put("desc", "操作成功");
} else {
result.put("result", "");
result.put("code", "0");
result.put("desc", "操作失败:"+json.getString("message"));
// 参数校验
String startRegionId = param.getString("start_region_id");
if (StrUtil.isEmpty(startRegionId)) {
resultJSON.put("code", "0");
resultJSON.put("desc", "起点区域不能为空");
return resultJSON;
}
return result;
String startPointCode = param.getString("start_point_code");
if (StrUtil.isEmpty(startPointCode)) {
resultJSON.put("code", "0");
resultJSON.put("desc", "起点不能为空");
return resultJSON;
}
String nextRegionId = param.getString("next_region_id");
if (StrUtil.isEmpty(nextRegionId)) {
resultJSON.put("code", "0");
resultJSON.put("desc", "终点区域不能为空");
return resultJSON;
}
String nextPointCode = param.getString("next_point_code");
if (StrUtil.isEmpty(nextPointCode)) {
resultJSON.put("code", "0");
resultJSON.put("desc", "终点不能为空");
return resultJSON;
}
WQLObject regionIOTable = WQLObject.getWQLObject("st_ivt_regionio");
long id = IdUtil.getSnowflake(1, 1).nextId();
try {
// 创建搬运记录
RegionioDto dto = new RegionioDto();
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
dto.setIostorinv_id(id);
dto.setBill_code(CodeUtil.getNewCode("IN_STORE_CODE"));
dto.setIo_type("0");
dto.setBill_status("10");
dto.setStart_region_id(startRegionId);
dto.setStart_point_code(startPointCode);
dto.setEnd_region_id(nextRegionId);
dto.setEnd_point_code(nextPointCode);
dto.setCreate_mode("02");
dto.setCreate_id(currentUserId);
dto.setCreate_name(nickName);
dto.setUpdate_optid(currentUserId);
dto.setUpdate_optname(nickName);
dto.setUpdate_time(now);
dto.setCreate_time(now);
regionIOTable.insert(JSONObject.parseObject(JSON.toJSONString(dto)));
// 创建任务并自动下发
String taskId = sendMaterialTask.createTask(param);
// 创建并下发成功后更新搬运记录
JSONObject json = new JSONObject();
json.put("task_id", taskId);
json.put("bill_status", "20");
regionIOTable.update(json, "iostorinv_id = " + id);
} catch (Exception e) {
// 报错删除搬运记录任务已在createTask中删除
regionIOTable.delete("iostorinv_id = " + id);
resultJSON.put("code", "0");
resultJSON.put("desc", e.getMessage());
return resultJSON;
}
// 返回
resultJSON.put("code", "1");
resultJSON.put("desc", "搬运任务已生成");
return resultJSON;
}
}

View File

@@ -60,12 +60,14 @@ public class SendMaterialTask extends AbstractAcsTask {
jsonTask.put("update_time", DateUtil.now());
jsonTask.put("car_no", taskObj.getString("car_no"));
taskTab.update(jsonTask);
// HashMap map = new HashMap();
// map.put("update_optid", SecurityUtils.getCurrentUserId());
// map.put("update_optname", SecurityUtils.getNickName());
// map.put("update_time", DateUtil.now());
// map.put("bill_status", "40");
// WQLObject.getWQLObject("ST_IVT_regionIO").update(map, "task_id='" + jsonTask.getString("task_id") + "'");
// 更新搬运记录
JSONObject regionIO = new JSONObject();
regionIO.put("update_optid", SecurityUtils.getCurrentUserId());
regionIO.put("update_optname", SecurityUtils.getNickName());
regionIO.put("update_time", DateUtil.now());
regionIO.put("bill_status", "40");
WQLObject.getWQLObject("st_ivt_regionio").update(regionIO, "task_id = " + task_id);
}
if (TaskStatusEnum.FINISHED.getCode().equals(status)) {
@@ -149,6 +151,14 @@ public class SendMaterialTask extends AbstractAcsTask {
startPointObj.put("point_status", "00");
pointTab.update(startPointObj);
// 更新搬运记录
JSONObject regionIO = new JSONObject();
regionIO.put("update_optid", SecurityUtils.getCurrentUserId());
regionIO.put("update_optname", SecurityUtils.getNickName());
regionIO.put("update_time", DateUtil.now());
regionIO.put("bill_status", "50");
WQLObject.getWQLObject("st_ivt_regionio").update(regionIO, "task_id = " + task_id);
// 更新任务
jsonTask.put("update_optid", SecurityUtils.getCurrentUserId());
jsonTask.put("update_optname", SecurityUtils.getNickName());
@@ -176,7 +186,7 @@ public class SendMaterialTask extends AbstractAcsTask {
WQLObject ProcedureIOStable = WQLObject.getWQLObject("ST_IVT_regionIO");
JSONObject IosObj = ProcedureIOStable.query("task_id='" + task_id + "' and is_delete ='0'").uniqueResult(0);
if (ObjectUtil.isEmpty(IosObj)) {
throw new BadRequestException("未找到任务号为'" + taskObj.getString("task_code") + "'的入库单据");
throw new BadRequestException("未找到任务号为'" + taskObj.getString("task_code") + "'的入库单据");
}
JSONObject param = new JSONObject();
param.put("material_id", IosObj.getString("material_id"));
@@ -184,7 +194,7 @@ public class SendMaterialTask extends AbstractAcsTask {
param.put("vehicle_code", IosObj.getString("vehicle_code"));
JSONObject inStructObj = StructFindUtil.getInStruct(param);
if (ObjectUtil.isEmpty(inStructObj)) {
throw new BadRequestException("未找到合适的入库仓位");
throw new BadRequestException("未找到合适的入库仓位");
}
//修改单据状态,将终点填入
IosObj.put("bill_status", "20");
@@ -211,11 +221,14 @@ public class SendMaterialTask extends AbstractAcsTask {
// 参数校验
String start_point_code = form.getString("start_point_code");
if (StrUtil.isEmpty(start_point_code)) {
throw new BadRequestException("起点不能为空");
throw new BadRequestException("起点不能为空");
}
String next_point_code = form.getString("next_point_code");
if (StrUtil.isEmpty(next_point_code)) {
throw new BadRequestException("终点不能为空");
throw new BadRequestException("终点不能为空");
}
if (StrUtil.equals(start_point_code, next_point_code)) {
throw new BadRequestException("起点和终点不能相同");
}
WQLObject taskTable = WQLObject.getWQLObject("SCH_BASE_Task");
@@ -225,13 +238,13 @@ public class SendMaterialTask extends AbstractAcsTask {
// 起点是空位不能搬
PointDto startPoint = pointService.findByCode(start_point_code);
if (StrUtil.equals(startPoint.getPoint_status(), "00")) {
throw new BadRequestException("起点是空位");
throw new BadRequestException("起点是空位");
}
// 终点不是空位不能搬
PointDto nextPoint = pointService.findByCode(next_point_code);
if (!StrUtil.equals(nextPoint.getPoint_status(), "00")) {
throw new BadRequestException("终点不是空位");
throw new BadRequestException("终点不是空位");
}
// 判断起点有没有未完成的指令
@@ -239,7 +252,7 @@ public class SendMaterialTask extends AbstractAcsTask {
.query("(start_point_code = '" + start_point_code + "' OR next_point_code = '" + start_point_code + "') AND is_delete = '0' AND task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'")
.uniqueResult(0);
if (ObjectUtil.isNotEmpty(startPointTask)) {
throw new BadRequestException("起点存在指令号为'" + startPointTask.getString("task_code") + "'未完成");
throw new BadRequestException("起点存在指令号为'" + startPointTask.getString("task_code") + "'未完成");
}
// 判断起点有没有未完成的指令
@@ -247,7 +260,7 @@ public class SendMaterialTask extends AbstractAcsTask {
.query("(start_point_code = '" + next_point_code + "' OR next_point_code = '" + next_point_code + "') AND is_delete = '0' AND task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'")
.uniqueResult(0);
if (ObjectUtil.isNotEmpty(nextPointTask)) {
throw new BadRequestException("终点存在指令号为'" + nextPointTask.getString("task_code") + "'未完成");
throw new BadRequestException("终点存在指令号为'" + nextPointTask.getString("task_code") + "'未完成");
}
if (StrUtil.equals(startPoint.getPoint_status(), "03") && StrUtil.equals(startPoint.getPoint_type(), "01")) {
@@ -300,11 +313,9 @@ public class SendMaterialTask extends AbstractAcsTask {
JSONObject ACSResult = renotifyAcs(taskId);
if (!StrUtil.equals(ACSResult.getString("status"), "200")) {
// 报错后删除任务
// 报错后抛异常回滚
taskTable.delete("task_id = " + taskId);
String resultMessage = ACSResult.getString("message");
throw new BadRequestException(resultMessage);
throw new BadRequestException(ACSResult.getString("message"));
}
return taskId;

View File

@@ -102,9 +102,7 @@ public class RegionioInServiceImpl implements RegionioInService {
@Override
@Transactional(rollbackFor = Exception.class)
public void create(RegionioDto dto) {
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
WQLObject vehicleTab = WQLObject.getWQLObject("MD_PB_StorageVehicleInfo");
JSONObject jsonMater = materTab.query("material_id = '" + dto.getMaterial_id() + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(dto.getVehicle_code())) {
JSONObject jsonVehicle = vehicleTab.query("storagevehicle_code = '" + dto.getVehicle_code() + "' and is_delete = '0' and is_used= '1'").uniqueResult(0);
@@ -129,7 +127,6 @@ public class RegionioInServiceImpl implements RegionioInService {
dto.setUpdate_optname(nickName);
dto.setUpdate_time(now);
dto.setCreate_time(now);
dto.setQty_unit_id(jsonMater.getLongValue("base_unit_id"));
WQLObject wo = WQLObject.getWQLObject("ST_IVT_regionIO");
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
@@ -177,12 +174,12 @@ public class RegionioInServiceImpl implements RegionioInService {
WQLObject wo = WQLObject.getWQLObject("st_ivt_regionio");
for (Long iostorinv_id: ids) {
JSONObject param = wo.query("iostorinv_id = '" + String.valueOf(iostorinv_id) + "'").uniqueResult(0);
JSONObject param = new JSONObject();
param.put("is_delete", "1");
param.put("update_optid", currentUserId);
param.put("update_optname", nickName);
param.put("update_time", now);
wo.update(param);
wo.update(param, "iostorinv_id = " + iostorinv_id);
}
}