rev:优化新增,修改,删除操作时返回的数据格式。

This commit is contained in:
2023-03-30 20:43:33 +08:00
parent 48e033b6df
commit 08d7d1acdb
7 changed files with 194 additions and 220 deletions

View File

@@ -98,7 +98,7 @@ public class CommonResult<T> {
* @param message 提示信息 * @param message 提示信息
*/ */
public static <T> CommonResult<T> validateFailed(String message) { public static <T> CommonResult<T> validateFailed(String message) {
return new CommonResult<>(ResultCode.MISS_PARAMETER.getCode(), message, null); return new CommonResult<>(ResultCode.VALIDATE_FAILED.getCode(), message, null);
} }
/** /**

View File

@@ -8,8 +8,7 @@ package org.nl.common.utils.api;
*/ */
public enum ResultCode implements IErrorCode{ public enum ResultCode implements IErrorCode{
SUCCESS(200, "操作成功"), SUCCESS(200, "操作成功"),
FAILED(0, "操作失败"), FAILED(400, "操作失败"),
MISS_PARAMETER(400, "参数缺失"),
UNAUTHORIZED(401, "暂未登录或token已经过期"), UNAUTHORIZED(401, "暂未登录或token已经过期"),
INVALID_PARAMETER(402, "无效参数"), INVALID_PARAMETER(402, "无效参数"),
FORBIDDEN(403, "没有相关权限"), FORBIDDEN(403, "没有相关权限"),

View File

@@ -47,7 +47,7 @@ public class AcsToWmsController {
public ResponseEntity<Object> receiveTaskIdToCacheLine(@RequestBody JSONObject whereJson) { public ResponseEntity<Object> receiveTaskIdToCacheLine(@RequestBody JSONObject whereJson) {
//参数校验 //参数校验
if(StringUtils.isEmpty(whereJson.getString("task_id")) || StringUtils.isEmpty(whereJson.getString("position_code"))) { if(StringUtils.isEmpty(whereJson.getString("task_id")) || StringUtils.isEmpty(whereJson.getString("position_code"))) {
throw new BizCoreException(ResultCode.MISS_PARAMETER); throw new BizCoreException(ResultCode.VALIDATE_FAILED);
} }
return new ResponseEntity<>(acsToWmsService.receiveTaskIdToCacheLine(whereJson), HttpStatus.OK); return new ResponseEntity<>(acsToWmsService.receiveTaskIdToCacheLine(whereJson), HttpStatus.OK);
} }

View File

@@ -109,7 +109,7 @@ public class CacheLineHandController{
public ResponseEntity<Object> instPageQuery(@RequestBody Map<String,String> param, Pageable page) { public ResponseEntity<Object> instPageQuery(@RequestBody Map<String,String> param, Pageable page) {
log.info("海亮缓存线手持服务 [任务分页查询] 接口被请求, 请求参数-{}", param); log.info("海亮缓存线手持服务 [任务分页查询] 接口被请求, 请求参数-{}", param);
if(null == param) { if(null == param) {
throw new BizCoreException(ResultCode.MISS_PARAMETER); throw new BizCoreException(ResultCode.VALIDATE_FAILED);
} }
return new ResponseEntity<>(cacheLineHandService.instPageQuery(param, page), HttpStatus.OK); return new ResponseEntity<>(cacheLineHandService.instPageQuery(param, page), HttpStatus.OK);
} }
@@ -121,7 +121,7 @@ public class CacheLineHandController{
log.info("海亮缓存线手持服务 [任务操作] 接口被请求, 请求参数-{}", param); log.info("海亮缓存线手持服务 [任务操作] 接口被请求, 请求参数-{}", param);
//任务类型和任务ID校验instruct_uuid为前端参数命名本来应为task_id //任务类型和任务ID校验instruct_uuid为前端参数命名本来应为task_id
if(StringUtils.isEmpty(param.getString("instruct_uuid")) || StringUtils.isEmpty(param.getString("opt_type"))) { if(StringUtils.isEmpty(param.getString("instruct_uuid")) || StringUtils.isEmpty(param.getString("opt_type"))) {
throw new BizCoreException(ResultCode.MISS_PARAMETER); throw new BizCoreException(ResultCode.VALIDATE_FAILED);
} }
return new ResponseEntity<>(cacheLineHandService.instOperation(param), HttpStatus.OK); return new ResponseEntity<>(cacheLineHandService.instOperation(param), HttpStatus.OK);
} }
@@ -133,7 +133,7 @@ public class CacheLineHandController{
log.info("海亮缓存线手持服务 [缓存线出入箱异常-查询] 接口被请求, 请求参数-{}", param); log.info("海亮缓存线手持服务 [缓存线出入箱异常-查询] 接口被请求, 请求参数-{}", param);
//参数校验 //参数校验
if(StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("position_code"))) { if(StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("position_code"))) {
throw new BizCoreException(ResultCode.MISS_PARAMETER); throw new BizCoreException(ResultCode.VALIDATE_FAILED);
} }
return new ResponseEntity<>(cacheLineHandService.cacheLineOutBoxExceptionQuery(param), HttpStatus.OK); return new ResponseEntity<>(cacheLineHandService.cacheLineOutBoxExceptionQuery(param), HttpStatus.OK);
} }
@@ -145,7 +145,7 @@ public class CacheLineHandController{
log.info("海亮缓存线手持服务 [缓存线出箱异常-确认] 接口被请求, 请求参数-{}", param); log.info("海亮缓存线手持服务 [缓存线出箱异常-确认] 接口被请求, 请求参数-{}", param);
//参数校验 //参数校验
if(StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("position_code")) || StringUtils.isEmpty(param.getString("vehicle_code"))) { if(StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("position_code")) || StringUtils.isEmpty(param.getString("vehicle_code"))) {
throw new BizCoreException(ResultCode.MISS_PARAMETER); throw new BizCoreException(ResultCode.VALIDATE_FAILED);
} }
return new ResponseEntity<>(cacheLineHandService.cacheLineOutBoxExceptionConfirm(param), HttpStatus.OK); return new ResponseEntity<>(cacheLineHandService.cacheLineOutBoxExceptionConfirm(param), HttpStatus.OK);
} }
@@ -165,7 +165,7 @@ public class CacheLineHandController{
log.info("海亮缓存线手持服务 [空箱初始化--出入空箱] 接口被请求, 请求参数-{}", param); log.info("海亮缓存线手持服务 [空箱初始化--出入空箱] 接口被请求, 请求参数-{}", param);
//参数校验 //参数校验
if(StringUtils.isEmpty(param.getString("inOut_type")) || StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("vehicle_code"))) { if(StringUtils.isEmpty(param.getString("inOut_type")) || StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("vehicle_code"))) {
throw new BizCoreException(ResultCode.MISS_PARAMETER); throw new BizCoreException(ResultCode.VALIDATE_FAILED);
} }
return new ResponseEntity<>(cacheLineHandService.inOutEmptyBox(param), HttpStatus.OK); return new ResponseEntity<>(cacheLineHandService.inOutEmptyBox(param), HttpStatus.OK);
} }
@@ -185,7 +185,7 @@ public class CacheLineHandController{
log.info("海亮缓存线手持服务 [缓存线出入箱异常指令确认] 接口被请求, 请求参数-{}", param); log.info("海亮缓存线手持服务 [缓存线出入箱异常指令确认] 接口被请求, 请求参数-{}", param);
//参数校验 //参数校验
if(StringUtils.isEmpty(param.getString("instruct_uuid")) || StringUtils.isEmpty(param.getString("inOut_type")) || StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("vehicle_code"))) { if(StringUtils.isEmpty(param.getString("instruct_uuid")) || StringUtils.isEmpty(param.getString("inOut_type")) || StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("vehicle_code"))) {
throw new BizCoreException(ResultCode.MISS_PARAMETER); throw new BizCoreException(ResultCode.VALIDATE_FAILED);
} }
return new ResponseEntity<>(cacheLineHandService.inOutExceptionInstConfirm(param), HttpStatus.OK); return new ResponseEntity<>(cacheLineHandService.inOutExceptionInstConfirm(param), HttpStatus.OK);
} }
@@ -264,7 +264,7 @@ public class CacheLineHandController{
log.info("海亮缓存线手持服务 [缓存线异常处理] 接口被请求, 请求参数-{}", param); log.info("海亮缓存线手持服务 [缓存线异常处理] 接口被请求, 请求参数-{}", param);
//参数校验 //参数校验
if(StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("opt_type"))) { if(StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("opt_type"))) {
throw new BizCoreException(ResultCode.MISS_PARAMETER); throw new BizCoreException(ResultCode.VALIDATE_FAILED);
} }
return new ResponseEntity<>(cacheLineHandService.cacheLineExcepOpt(param), HttpStatus.OK); return new ResponseEntity<>(cacheLineHandService.cacheLineExcepOpt(param), HttpStatus.OK);
} }

View File

@@ -169,10 +169,11 @@ public interface CacheLineHandService{
* 设置满框 * 设置满框
* *
* @param param 查询参数 * @param param 查询参数
* @return
* @author gbx * @author gbx
* @date 2023/3/24 * @date 2023/3/24
*/ */
JSONObject setfullBox(JSONObject param); CommonResult<Integer> setfullBox(JSONObject param);
/** /**
* 设置空框 * 设置空框
@@ -254,10 +255,11 @@ public interface CacheLineHandService{
* 倒料操作 * 倒料操作
* *
* @param param 查询参数 * @param param 查询参数
* @return
* @author gbx * @author gbx
* @date 2023/3/24 * @date 2023/3/24
*/ */
Map<String,Object> pourMaterial(JSONObject param); CommonResult<JSONObject> pourMaterial(JSONObject param);
/** /**
* 缓存线下拉框 * 缓存线下拉框

View File

@@ -27,7 +27,6 @@ import org.nl.wms.pda.service.CacheLineHandService;
import org.nl.wms.sch.tasks.SpeMachineryTask; import org.nl.wms.sch.tasks.SpeMachineryTask;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -53,6 +52,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
private final RedisUtils redisUtils; private final RedisUtils redisUtils;
@Autowired @Autowired
private LocalCache cache; private LocalCache cache;
@Override @Override
public JSONArray dropdownListQuery(String param, String type) { public JSONArray dropdownListQuery(String param, String type) {
//初始化下拉框列表1.物料规格2.工序3.指令状态4.设备 //初始化下拉框列表1.物料规格2.工序3.指令状态4.设备
@@ -318,10 +318,12 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
/** /**
* 设置满箱物料 缓存线编码 wcsdevice_code 料箱码 vehicle_code 工序标识 workprocedure_id 物料标识 material_uuid * 设置满箱物料 缓存线编码 wcsdevice_code 料箱码 vehicle_code 工序标识 workprocedure_id 物料标识 material_uuid
* 数量 quantity 重量 weight * 数量 quantity 重量 weight
*
* @return
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public JSONObject setfullBox(JSONObject param) { public CommonResult<Integer> setfullBox(JSONObject param) {
//物料ID //物料ID
String semimanufactures_uuid = param.getString("material_uuid"); String semimanufactures_uuid = param.getString("material_uuid");
// 缓存线位置编码 // 缓存线位置编码
@@ -329,7 +331,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
// 料箱码 // 料箱码
String vehicle_code = param.getString("vehicle_code"); String vehicle_code = param.getString("vehicle_code");
//工序 //工序
// String workprocedure_code = param.getString("workprocedure_code"); // String workprocedure_code = param.getString("workprocedure_code");
// 缓存线 // 缓存线
String cacheLine_code = param.getString("wcsdevice_code"); String cacheLine_code = param.getString("wcsdevice_code");
String weight = param.getString("weight"); String weight = param.getString("weight");
@@ -345,19 +347,18 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
throw new BadRequestException("位置不存在,设置有误!"); throw new BadRequestException("位置不存在,设置有误!");
} }
//工序表 //工序表
WQLObject wpTab = WQLObject.getWQLObject("pdm_bi_workprocedure"); //WQLObject wpTab = WQLObject.getWQLObject("pdm_bi_workprocedure");
//物料表 //物料表
WQLObject meTab = WQLObject.getWQLObject("md_me_materialbase"); WQLObject meTab = WQLObject.getWQLObject("md_me_materialbase");
// 查询工序信息 // 查询工序信息
// JSONObject wpObj = wpTab.query("workprocedure_code = '" + workprocedure_code + "'").uniqueResult(0); // JSONObject wpObj = wpTab.query("workprocedure_code = '" + workprocedure_code + "'").uniqueResult(0);
// if(ObjectUtil.isEmpty(wpObj)) { // if(ObjectUtil.isEmpty(wpObj)) {
// throw new BadRequestException("工序查询错误,请检查工序"); // throw new BadRequestException("工序查询错误,请检查工序");
// } // }
JSONObject meObj = meTab.query("material_id = '" + semimanufactures_uuid + "'").uniqueResult(0); JSONObject meObj = meTab.query("material_id = '" + semimanufactures_uuid + "'").uniqueResult(0);
if(ObjectUtil.isEmpty(meObj)) { if(ObjectUtil.isEmpty(meObj)) {
throw new BadRequestException("物料查询错误,请检查物料"); throw new BadRequestException("物料查询错误,请检查物料");
} }
String materialId = meObj.getString("material_id");
vehiobj.put("vehicle_code", vehicle_code); vehiobj.put("vehicle_code", vehicle_code);
//2.缓存线位置通过扫码绑定料箱条码 //2.缓存线位置通过扫码绑定料箱条码
positionTab.update(vehiobj, "position_code = '" + position_code + "'"); positionTab.update(vehiobj, "position_code = '" + position_code + "'");
@@ -372,21 +373,19 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
json.put("cacheLine_code", cacheLine_code); json.put("cacheLine_code", cacheLine_code);
json.put("material_id", meObj.getString("material_id")); json.put("material_id", meObj.getString("material_id"));
json.put("weight", weight); json.put("weight", weight);
json.put("material_id", materialId);
json.put("quantity", quantity); json.put("quantity", quantity);
json.put("weight", weight); // json.put("workprocedure_code", wpObj.getString("workprocedure_code"));
// json.put("workprocedure_code", wpObj.getString("workprocedure_code")); // json.put("workprocedure_name", wpObj.getString("workprocedure_name"));
// json.put("workprocedure_name", wpObj.getString("workprocedure_name"));
//有箱有料 //有箱有料
json.put("vehicle_status", StatusEnum.CACHE_VEL_FULL.getCode()); json.put("vehicle_status", StatusEnum.CACHE_VEL_FULL.getCode());
json.put("create_time", DateUtil.now()); json.put("create_time", DateUtil.now());
//4.重新新建该缓存线位置上的料箱为满箱及所属工序,生产区域等信息 //4.重新新建该缓存线位置上的料箱为满箱及所属工序,生产区域等信息
ivtTab.insert(json); return RestBusinessTemplate.execute(() -> ivtTab.insert(json).getSucess());
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public JSONObject setEmptyBox( JSONObject param) { public JSONObject setEmptyBox(JSONObject param) {
// 缓存线位置编码 // 缓存线位置编码
String position_code = param.getString("position_code"); String position_code = param.getString("position_code");
// 载具条码 // 载具条码
@@ -664,8 +663,6 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
* 缓存线位置编码 wcsdevice_code * 缓存线位置编码 wcsdevice_code
* 缓存线点位编码 position_code * 缓存线点位编码 position_code
* 料箱码 vehicle_code * 料箱码 vehicle_code
*
* @return
*/ */
@Override @Override
public CommonResult<Integer> cacheLineOutBoxExceptionConfirm(JSONObject param) { public CommonResult<Integer> cacheLineOutBoxExceptionConfirm(JSONObject param) {
@@ -769,18 +766,18 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
public void agvInBoxExceptionConfirm(JSONObject param) { public void agvInBoxExceptionConfirm(JSONObject param) {
WQLObject instructTab = WQLObject.getWQLObject("sch_base_task"); WQLObject instructTab = WQLObject.getWQLObject("sch_base_task");
String instruct_uuid = param.getString("task_id"); String instruct_uuid = param.getString("task_id");
String cacheLine_code = param.getString("wcsdevice_code");
String empty_vehicle_code = param.getString("empty_vehicle_code"); String empty_vehicle_code = param.getString("empty_vehicle_code");
String full_vehicle_code = param.getString("full_vehicle_code"); String full_vehicle_code = param.getString("full_vehicle_code");
//String cacheLine_code = param.getString("wcsdevice_code");
// 缓存线位置表 // 缓存线位置表
WQLObject positionTab = WQLObject.getWQLObject("sch_cacheline_position"); // WQLObject positionTab = WQLObject.getWQLObject("sch_cacheline_position");
// 缓存线载具物料表 // 缓存线载具物料表
WQLObject ivtTab = WQLObject.getWQLObject("sch_cacheline_vehilematerial"); // WQLObject ivtTab = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
JSONObject instObj = instructTab.query("task_id = '" + instruct_uuid + "'").uniqueResult(0); JSONObject instObj = instructTab.query("task_id = '" + instruct_uuid + "'").uniqueResult(0);
//TOFIX //TOFIX
//AgvTwoInst inst = new AgvTwoInst(); //AgvTwoInst inst = new AgvTwoInst();
instObj.put("inboxtxm", full_vehicle_code); // instObj.put("inboxtxm", full_vehicle_code);
instObj.put("outboxtxm", empty_vehicle_code); // instObj.put("outboxtxm", empty_vehicle_code);
// inst.updateInstStatus(instObj, "1"); // inst.updateInstStatus(instObj, "1");
// inst.updateInstStatus(instObj, "2"); // inst.updateInstStatus(instObj, "2");
} }
@@ -837,16 +834,14 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
} }
@Override @Override
public Map<String,Object> pourMaterial(JSONObject param) { public CommonResult<JSONObject> pourMaterial(JSONObject param) {
// 指令标识 // 指令标识
String instruct_uuid = param.getString("instruct_uuid"); String instruct_uuid = param.getString("instruct_uuid");
// 指令点位表【sch_base_task】 // 指令点位表【sch_base_task】
JSONObject instObj = WQLObject.getWQLObject("sch_base_task") JSONObject instObj = WQLObject.getWQLObject("sch_base_task").query("task_id = '" + instruct_uuid + "'").uniqueResult(0);
.query("task_id = '" + instruct_uuid + "'") JSONArray jsonArray = new JSONArray();
.uniqueResult(0);
int putquantity = instObj.getInteger("material_qty"); int putquantity = instObj.getInteger("material_qty");
String producer = instObj.getString("point_code2"); String producer = instObj.getString("point_code2");
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("producer", producer); jsonObject.put("producer", producer);
jsonObject.put("putquantity", putquantity); jsonObject.put("putquantity", putquantity);
@@ -854,11 +849,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
try { try {
//TOFIX 等确定api后换成下发的url //TOFIX 等确定api后换成下发的url
//return AcsUtil.notifyAcs("/api/cacheLineHand", jsonArray); //return AcsUtil.notifyAcs("/api/cacheLineHand", jsonArray);
JSONObject result = new JSONObject(); return RestBusinessTemplate.execute(() -> new JSONObject());
result.put("status", HttpStatus.OK.value());
result.put("message", "操作成功!");
result.put("data", new JSONObject());
return result;
} }
catch(NullPointerException e) { catch(NullPointerException e) {
throw new BadRequestException(e.toString()); throw new BadRequestException(e.toString());
@@ -869,10 +860,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
public JSONArray getCacheLine(JSONObject param) { public JSONArray getCacheLine(JSONObject param) {
// 生产区域 // 生产区域
String product_area = param.getString("product_area"); String product_area = param.getString("product_area");
JSONArray resultJSONArray = WQL.getWO("PDA_QUERY") JSONArray resultJSONArray = WQL.getWO("PDA_QUERY").addParamMap(MapOf.of("flag", "7", "product_area", product_area)).process().getResultJSONArray(0);
.addParamMap(MapOf.of("flag", "7", "product_area", product_area))
.process()
.getResultJSONArray(0);
return resultJSONArray; return resultJSONArray;
} }
@@ -884,22 +872,14 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
AtomicReference<JSONArray> res = new AtomicReference<>(new JSONArray()); AtomicReference<JSONArray> res = new AtomicReference<>(new JSONArray());
RedissonUtils.lock(() -> { RedissonUtils.lock(() -> {
// 生产区域 // 生产区域
res.set(WQL.getWO("PDA_QUERY") res.set(WQL.getWO("PDA_QUERY").addParamMap(MapOf.of("flag", "8", "product_area", productArea, "cacheLine_code", pointCode)).process().getResultJSONArray(0));
.addParamMap(MapOf.of("flag", "8",
"product_area", productArea,
"cacheLine_code", pointCode))
.process()
.getResultJSONArray(0));
}, pointCode, 3); }, pointCode, 3);
return res.get(); return res.get();
} }
@Override @Override
public JSONArray getProductArea() { public JSONArray getProductArea() {
JSONArray res = WQL.getWO("PDA_QUERY") JSONArray res = WQL.getWO("PDA_QUERY").addParamMap(MapOf.of("flag", "9")).process().getResultJSONArray(0);
.addParamMap(MapOf.of("flag", "9"))
.process()
.getResultJSONArray(0);
return res; return res;
} }

View File

@@ -11,12 +11,11 @@ import org.nl.common.enums.StatusEnum;
import org.nl.common.utils.MapOf; import org.nl.common.utils.MapOf;
import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil; import org.nl.modules.system.util.CodeUtil;
import org.nl.common.utils.SecurityUtils; import org.nl.common.utils.SecurityUtils;
import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.sch.manage.AbstractAcsTask; import org.nl.wms.sch.manage.AbstractAcsTask;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -25,45 +24,45 @@ import java.util.Map;
*/ */
@Slf4j @Slf4j
@Service @Service
public class SpeMachineryTask extends AbstractAcsTask { public class SpeMachineryTask extends AbstractAcsTask{
private final Map<String,SpeStatusHandler > SpeHandles= new HashMap<>(); private final Map<String,SpeStatusHandler> SpeHandles = new HashMap<>();
private static String OPT_NAME = "ACS回调# "; private static String OPT_NAME = "ACS回调# ";
public SpeMachineryTask() { public SpeMachineryTask() {
SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_MAC.name() ,new Spe2Spe()); SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_MAC.name(), new Spe2Spe());
SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_CACHE.name() ,new Spe2Cache()); SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_CACHE.name(), new Spe2Cache());
SpeHandles.put(AcsTaskEnum.TASK_CACHELINE_OUT.name() ,new Cache2Spe()); SpeHandles.put(AcsTaskEnum.TASK_CACHELINE_OUT.name(), new Cache2Spe());
} }
@Override @Override
public void updateTaskStatus(JSONObject param,String status) { public void updateTaskStatus(JSONObject param, String status) {
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
log.info(InterfaceLogType.ACS_TO_LMS.getDesc()); log.info(InterfaceLogType.ACS_TO_LMS.getDesc());
// 指令执行中 // 指令执行中
JSONObject task = taskTable.query("task_id = '" + param.getString("task_id") + "'").uniqueResult(0); JSONObject task = taskTable.query("task_id = '" + param.getString("task_id") + "'").uniqueResult(0);
AcsTaskEnum taskType = AcsTaskEnum.getType(task.getString("task_type"),"TASK_"); AcsTaskEnum taskType = AcsTaskEnum.getType(task.getString("task_type"), "TASK_");
try { try {
SpeHandles.get(taskType.name()).handle(param,status,task); SpeHandles.get(taskType.name()).handle(param, status, task);
}catch (Exception ex){ }
log.error(OPT_NAME+"updateStatus error:{}",ex); catch(Exception ex) {
log.error(OPT_NAME + "updateStatus error:{}", ex);
throw ex; throw ex;
} }
} }
@Override @Override
public String createTask(JSONObject form) { public String createTask(JSONObject form) {
String start_point_code = form.getString("point_code1"); String start_point_code = form.getString("point_code1");
String next_point_code = form.getString("point_code2"); String next_point_code = form.getString("point_code2");
String vehicle_code = form.getString("vehicle_code"); String vehicle_code = form.getString("vehicle_code");
String type = form.getString("type"); String type = form.getString("type");
if (StrUtil.isEmpty(start_point_code)) { if(StrUtil.isEmpty(start_point_code)) {
throw new BadRequestException("起点不能为空!"); throw new BadRequestException("起点不能为空!");
} }
if (StrUtil.isEmpty(next_point_code)) { if(StrUtil.isEmpty(next_point_code)) {
throw new BadRequestException("终点不能为空!"); throw new BadRequestException("终点不能为空!");
} }
if (StrUtil.isEmpty(vehicle_code)) { if(StrUtil.isEmpty(vehicle_code)) {
throw new BadRequestException("载具不能为空!"); throw new BadRequestException("载具不能为空!");
} }
String taskdtl_id = IdUtil.getSnowflake(1, 1).nextId() + ""; String taskdtl_id = IdUtil.getSnowflake(1, 1).nextId() + "";
@@ -90,34 +89,33 @@ public class SpeMachineryTask extends AbstractAcsTask {
return taskdtl_id; return taskdtl_id;
} }
@Override @Override
public void cancel(String taskId) { public void cancel(String taskId) {
log.info(OPT_NAME+"cancel taskID:{}",taskId); log.info(OPT_NAME + "cancel taskID:{}", taskId);
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
//专机-专机 //专机-专机
//专机-缓存线 //专机-缓存线
//缓存线出库 //缓存线出库
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_CANNEL.getCode()),"task_id = '"+taskId+"'"); taskTable.update(MapOf.of("task_status", StatusEnum.TASK_CANNEL.getCode()), "task_id = '" + taskId + "'");
}
}
interface SpeStatusHandler{ interface SpeStatusHandler{
void handle(JSONObject param,String status,JSONObject task); void handle(JSONObject param, String status, JSONObject task);
} }
class Spe2Spe implements SpeStatusHandler{ class Spe2Spe implements SpeStatusHandler{
@Override @Override
public void handle(JSONObject param, String sta,JSONObject task) { public void handle(JSONObject param, String sta, JSONObject task) {
AcsTaskEnum status = AcsTaskEnum.getType(sta,"status_"); AcsTaskEnum status = AcsTaskEnum.getType(sta, "status_");
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point"); WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device"); WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
switch(status) {
switch (status){
case STATUS_START: case STATUS_START:
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_RUNNING.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'"); taskTable.update(MapOf.of("task_status", StatusEnum.TASK_RUNNING.getCode(), "update_name", "acs", "update_time", DateUtil.now()), "task_id = '" + task.getString("task_id") + "'");
break; break;
case STATUS_FINISH: case STATUS_FINISH:
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_FINISH.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'"); taskTable.update(MapOf.of("task_status", StatusEnum.TASK_FINISH.getCode(), "update_name", "acs", "update_time", DateUtil.now()), "task_id = '" + task.getString("task_id") + "'");
//到专机:更新设备上料位物料数量 //到专机:更新设备上料位物料数量
String point_code2 = task.getString("point_code2"); String point_code2 = task.getString("point_code2");
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0); JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
@@ -127,61 +125,56 @@ public class SpeMachineryTask extends AbstractAcsTask {
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'"); deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
break; break;
default: default:
log.error(OPT_NAME+"未定义任务状态:{}",sta); log.error(OPT_NAME + "未定义任务状态:{}", sta);
throw new BadRequestException(OPT_NAME+"未定义任务状态:"+sta); throw new BadRequestException(OPT_NAME + "未定义任务状态:" + sta);
} }
} }
} }
class Spe2Cache implements SpeStatusHandler{ class Spe2Cache implements SpeStatusHandler{
@Override @Override
public void handle(JSONObject param, String sta,JSONObject task) { public void handle(JSONObject param, String sta, JSONObject task) {
AcsTaskEnum status = AcsTaskEnum.getType(sta,"status_"); AcsTaskEnum status = AcsTaskEnum.getType(sta, "status_");
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial"); WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
String workprocedureCode = param.getString("workorder_code"); String workprocedureCode = param.getString("workorder_code");
String inboxtxm = param.getString("inboxtxm"); String inboxtxm = param.getString("inboxtxm");
String outboxtxm = param.getString("outboxtxm"); String outboxtxm = param.getString("outboxtxm");
switch (status){ switch(status) {
case STATUS_START: case STATUS_START:
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_RUNNING.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'"); taskTable.update(MapOf.of("task_status", StatusEnum.TASK_RUNNING.getCode(), "update_name", "acs", "update_time", DateUtil.now()), "task_id = '" + task.getString("task_id") + "'");
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'"); cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
break; break;
case STATUS_FINISH: case STATUS_FINISH:
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_FINISH.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'"); taskTable.update(MapOf.of("task_status", StatusEnum.TASK_FINISH.getCode(), "update_name", "acs", "update_time", DateUtil.now()), "task_id = '" + task.getString("task_id") + "'");
cacheVehTable.insert(MapOf.of("quantity", task.getString("material_qty"), cacheVehTable.insert(MapOf.of("quantity", task.getString("material_qty"), "material_id", task.getString("material_id"), "vehicle_code", inboxtxm, "vehicle_status", StatusEnum.CACHE_VEL_FULL.getCode(),
"material_id", task.getString("material_id"),
"vehicle_code", inboxtxm,
"vehicle_status", StatusEnum.CACHE_VEL_FULL.getCode(),
//工单,工序? //工单,工序?
"workorder_code", workprocedureCode, "workorder_code", workprocedureCode, "create_time", DateUtil.now(), "update_time", DateUtil.now()
"create_time", DateUtil.now(),
"update_time", DateUtil.now()
//物料规格,物料名称 从物料信息表关联查询 //物料规格,物料名称 从物料信息表关联查询
)); ));
break; break;
default: default:
throw new BadRequestException(OPT_NAME+"未定义任务状态:"+sta); throw new BadRequestException(OPT_NAME + "未定义任务状态:" + sta);
} }
} }
} }
class Cache2Spe implements SpeStatusHandler{ class Cache2Spe implements SpeStatusHandler{
@Override @Override
public void handle(JSONObject param, String sta,JSONObject task) { public void handle(JSONObject param, String sta, JSONObject task) {
AcsTaskEnum status = AcsTaskEnum.getType(sta,"status_"); AcsTaskEnum status = AcsTaskEnum.getType(sta, "status_");
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial"); WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point"); WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device"); WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
String outboxtxm = param.getString("outboxtxm"); String outboxtxm = param.getString("outboxtxm");
switch(status) {
switch (status){
case STATUS_START: case STATUS_START:
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_RUNNING.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'"); taskTable.update(MapOf.of("task_status", StatusEnum.TASK_RUNNING.getCode(), "update_name", "acs", "update_time", DateUtil.now()), "task_id = '" + task.getString("task_id") + "'");
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'"); cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
break; break;
case STATUS_FINISH: case STATUS_FINISH:
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_FINISH.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'"); taskTable.update(MapOf.of("task_status", StatusEnum.TASK_FINISH.getCode(), "update_name", "acs", "update_time", DateUtil.now()), "task_id = '" + task.getString("task_id") + "'");
String point_code2 = task.getString("point_code2"); String point_code2 = task.getString("point_code2");
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0); JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0); JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0);
@@ -190,7 +183,7 @@ public class SpeMachineryTask extends AbstractAcsTask {
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'"); deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
break; break;
default: default:
throw new BadRequestException(OPT_NAME+"未定义任务状态:"+sta); throw new BadRequestException(OPT_NAME + "未定义任务状态:" + sta);
} }
} }
} }