rev:优化新增,修改,删除操作时返回的数据格式。
This commit is contained in:
@@ -98,7 +98,7 @@ public class CommonResult<T> {
|
||||
* @param 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,8 +8,7 @@ package org.nl.common.utils.api;
|
||||
*/
|
||||
public enum ResultCode implements IErrorCode{
|
||||
SUCCESS(200, "操作成功"),
|
||||
FAILED(0, "操作失败"),
|
||||
MISS_PARAMETER(400, "参数缺失"),
|
||||
FAILED(400, "操作失败"),
|
||||
UNAUTHORIZED(401, "暂未登录或token已经过期"),
|
||||
INVALID_PARAMETER(402, "无效参数"),
|
||||
FORBIDDEN(403, "没有相关权限"),
|
||||
|
||||
@@ -47,7 +47,7 @@ public class AcsToWmsController {
|
||||
public ResponseEntity<Object> receiveTaskIdToCacheLine(@RequestBody JSONObject whereJson) {
|
||||
//参数校验
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class CacheLineHandController{
|
||||
public ResponseEntity<Object> instPageQuery(@RequestBody Map<String,String> param, Pageable page) {
|
||||
log.info("海亮缓存线手持服务 [任务分页查询] 接口被请求, 请求参数-{}", 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);
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class CacheLineHandController{
|
||||
log.info("海亮缓存线手持服务 [任务操作] 接口被请求, 请求参数-{}", param);
|
||||
//任务类型和任务ID校验,instruct_uuid为前端参数命名,本来应为task_id
|
||||
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);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class CacheLineHandController{
|
||||
log.info("海亮缓存线手持服务 [缓存线出入箱异常-查询] 接口被请求, 请求参数-{}", param);
|
||||
//参数校验
|
||||
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);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class CacheLineHandController{
|
||||
log.info("海亮缓存线手持服务 [缓存线出箱异常-确认] 接口被请求, 请求参数-{}", param);
|
||||
//参数校验
|
||||
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);
|
||||
}
|
||||
@@ -165,7 +165,7 @@ public class CacheLineHandController{
|
||||
log.info("海亮缓存线手持服务 [空箱初始化--出入空箱] 接口被请求, 请求参数-{}", param);
|
||||
//参数校验
|
||||
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);
|
||||
}
|
||||
@@ -185,7 +185,7 @@ public class CacheLineHandController{
|
||||
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"))) {
|
||||
throw new BizCoreException(ResultCode.MISS_PARAMETER);
|
||||
throw new BizCoreException(ResultCode.VALIDATE_FAILED);
|
||||
}
|
||||
return new ResponseEntity<>(cacheLineHandService.inOutExceptionInstConfirm(param), HttpStatus.OK);
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public class CacheLineHandController{
|
||||
log.info("海亮缓存线手持服务 [缓存线异常处理] 接口被请求, 请求参数-{}", param);
|
||||
//参数校验
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -169,10 +169,11 @@ public interface CacheLineHandService{
|
||||
* 设置满框
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return
|
||||
* @author gbx
|
||||
* @date 2023/3/24
|
||||
*/
|
||||
JSONObject setfullBox(JSONObject param);
|
||||
CommonResult<Integer> setfullBox(JSONObject param);
|
||||
|
||||
/**
|
||||
* 设置空框
|
||||
@@ -254,10 +255,11 @@ public interface CacheLineHandService{
|
||||
* 倒料操作
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return
|
||||
* @author gbx
|
||||
* @date 2023/3/24
|
||||
*/
|
||||
Map<String,Object> pourMaterial(JSONObject param);
|
||||
CommonResult<JSONObject> pourMaterial(JSONObject param);
|
||||
|
||||
/**
|
||||
* 缓存线下拉框
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.nl.wms.pda.service.CacheLineHandService;
|
||||
import org.nl.wms.sch.tasks.SpeMachineryTask;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -53,6 +52,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
private final RedisUtils redisUtils;
|
||||
@Autowired
|
||||
private LocalCache cache;
|
||||
|
||||
@Override
|
||||
public JSONArray dropdownListQuery(String param, String type) {
|
||||
//初始化下拉框列表1.物料规格2.工序3.指令状态4.设备
|
||||
@@ -318,10 +318,12 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
/**
|
||||
* 设置满箱物料 缓存线编码 wcsdevice_code 料箱码 vehicle_code 工序标识 workprocedure_id 物料标识 material_uuid
|
||||
* 数量 quantity 重量 weight
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject setfullBox(JSONObject param) {
|
||||
public CommonResult<Integer> setfullBox(JSONObject param) {
|
||||
//物料ID
|
||||
String semimanufactures_uuid = param.getString("material_uuid");
|
||||
// 缓存线位置编码
|
||||
@@ -329,7 +331,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
// 料箱码
|
||||
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 weight = param.getString("weight");
|
||||
@@ -345,19 +347,18 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
throw new BadRequestException("位置不存在,设置有误!");
|
||||
}
|
||||
//工序表
|
||||
WQLObject wpTab = WQLObject.getWQLObject("pdm_bi_workprocedure");
|
||||
//WQLObject wpTab = WQLObject.getWQLObject("pdm_bi_workprocedure");
|
||||
//物料表
|
||||
WQLObject meTab = WQLObject.getWQLObject("md_me_materialbase");
|
||||
// 查询工序信息
|
||||
// JSONObject wpObj = wpTab.query("workprocedure_code = '" + workprocedure_code + "'").uniqueResult(0);
|
||||
// if(ObjectUtil.isEmpty(wpObj)) {
|
||||
// throw new BadRequestException("工序查询错误,请检查工序");
|
||||
// }
|
||||
// JSONObject wpObj = wpTab.query("workprocedure_code = '" + workprocedure_code + "'").uniqueResult(0);
|
||||
// if(ObjectUtil.isEmpty(wpObj)) {
|
||||
// throw new BadRequestException("工序查询错误,请检查工序");
|
||||
// }
|
||||
JSONObject meObj = meTab.query("material_id = '" + semimanufactures_uuid + "'").uniqueResult(0);
|
||||
if(ObjectUtil.isEmpty(meObj)) {
|
||||
throw new BadRequestException("物料查询错误,请检查物料");
|
||||
}
|
||||
String materialId = meObj.getString("material_id");
|
||||
vehiobj.put("vehicle_code", vehicle_code);
|
||||
//2.缓存线位置通过扫码绑定料箱条码
|
||||
positionTab.update(vehiobj, "position_code = '" + position_code + "'");
|
||||
@@ -372,21 +373,19 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
json.put("cacheLine_code", cacheLine_code);
|
||||
json.put("material_id", meObj.getString("material_id"));
|
||||
json.put("weight", weight);
|
||||
json.put("material_id", materialId);
|
||||
json.put("quantity", quantity);
|
||||
json.put("weight", weight);
|
||||
// json.put("workprocedure_code", wpObj.getString("workprocedure_code"));
|
||||
// json.put("workprocedure_name", wpObj.getString("workprocedure_name"));
|
||||
// json.put("workprocedure_code", wpObj.getString("workprocedure_code"));
|
||||
// json.put("workprocedure_name", wpObj.getString("workprocedure_name"));
|
||||
//有箱有料
|
||||
json.put("vehicle_status", StatusEnum.CACHE_VEL_FULL.getCode());
|
||||
json.put("create_time", DateUtil.now());
|
||||
//4.重新新建该缓存线位置上的料箱为满箱及所属工序,生产区域等信息
|
||||
ivtTab.insert(json);
|
||||
return RestBusinessTemplate.execute(() -> ivtTab.insert(json).getSucess());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject setEmptyBox( JSONObject param) {
|
||||
public JSONObject setEmptyBox(JSONObject param) {
|
||||
// 缓存线位置编码
|
||||
String position_code = param.getString("position_code");
|
||||
// 载具条码
|
||||
@@ -664,8 +663,6 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
* 缓存线位置编码 wcsdevice_code
|
||||
* 缓存线点位编码 position_code
|
||||
* 料箱码 vehicle_code
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult<Integer> cacheLineOutBoxExceptionConfirm(JSONObject param) {
|
||||
@@ -769,18 +766,18 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
public void agvInBoxExceptionConfirm(JSONObject param) {
|
||||
WQLObject instructTab = WQLObject.getWQLObject("sch_base_task");
|
||||
String instruct_uuid = param.getString("task_id");
|
||||
String cacheLine_code = param.getString("wcsdevice_code");
|
||||
String empty_vehicle_code = param.getString("empty_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);
|
||||
//TOFIX
|
||||
//AgvTwoInst inst = new AgvTwoInst();
|
||||
instObj.put("inboxtxm", full_vehicle_code);
|
||||
instObj.put("outboxtxm", empty_vehicle_code);
|
||||
// instObj.put("inboxtxm", full_vehicle_code);
|
||||
// instObj.put("outboxtxm", empty_vehicle_code);
|
||||
// inst.updateInstStatus(instObj, "1");
|
||||
// inst.updateInstStatus(instObj, "2");
|
||||
}
|
||||
@@ -837,16 +834,14 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> pourMaterial(JSONObject param) {
|
||||
public CommonResult<JSONObject> pourMaterial(JSONObject param) {
|
||||
// 指令标识
|
||||
String instruct_uuid = param.getString("instruct_uuid");
|
||||
// 指令点位表【sch_base_task】
|
||||
JSONObject instObj = WQLObject.getWQLObject("sch_base_task")
|
||||
.query("task_id = '" + instruct_uuid + "'")
|
||||
.uniqueResult(0);
|
||||
JSONObject instObj = WQLObject.getWQLObject("sch_base_task").query("task_id = '" + instruct_uuid + "'").uniqueResult(0);
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
int putquantity = instObj.getInteger("material_qty");
|
||||
String producer = instObj.getString("point_code2");
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("producer", producer);
|
||||
jsonObject.put("putquantity", putquantity);
|
||||
@@ -854,11 +849,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
try {
|
||||
//TOFIX 等确定api后,换成下发的url
|
||||
//return AcsUtil.notifyAcs("/api/cacheLineHand", jsonArray);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "操作成功!");
|
||||
result.put("data", new JSONObject());
|
||||
return result;
|
||||
return RestBusinessTemplate.execute(() -> new JSONObject());
|
||||
}
|
||||
catch(NullPointerException e) {
|
||||
throw new BadRequestException(e.toString());
|
||||
@@ -869,10 +860,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
public JSONArray getCacheLine(JSONObject param) {
|
||||
// 生产区域
|
||||
String product_area = param.getString("product_area");
|
||||
JSONArray resultJSONArray = WQL.getWO("PDA_QUERY")
|
||||
.addParamMap(MapOf.of("flag", "7", "product_area", product_area))
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
JSONArray resultJSONArray = WQL.getWO("PDA_QUERY").addParamMap(MapOf.of("flag", "7", "product_area", product_area)).process().getResultJSONArray(0);
|
||||
return resultJSONArray;
|
||||
}
|
||||
|
||||
@@ -884,22 +872,14 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
AtomicReference<JSONArray> res = new AtomicReference<>(new JSONArray());
|
||||
RedissonUtils.lock(() -> {
|
||||
// 生产区域
|
||||
res.set(WQL.getWO("PDA_QUERY")
|
||||
.addParamMap(MapOf.of("flag", "8",
|
||||
"product_area", productArea,
|
||||
"cacheLine_code", pointCode))
|
||||
.process()
|
||||
.getResultJSONArray(0));
|
||||
res.set(WQL.getWO("PDA_QUERY").addParamMap(MapOf.of("flag", "8", "product_area", productArea, "cacheLine_code", pointCode)).process().getResultJSONArray(0));
|
||||
}, pointCode, 3);
|
||||
return res.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getProductArea() {
|
||||
JSONArray res = WQL.getWO("PDA_QUERY")
|
||||
.addParamMap(MapOf.of("flag", "9"))
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
JSONArray res = WQL.getWO("PDA_QUERY").addParamMap(MapOf.of("flag", "9")).process().getResultJSONArray(0);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,11 @@ import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
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.wms.sch.manage.AbstractAcsTask;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,173 +24,167 @@ import java.util.Map;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SpeMachineryTask extends AbstractAcsTask {
|
||||
private final Map<String,SpeStatusHandler > SpeHandles= new HashMap<>();
|
||||
private static String OPT_NAME = "ACS回调# ";
|
||||
public class SpeMachineryTask extends AbstractAcsTask{
|
||||
private final Map<String,SpeStatusHandler> SpeHandles = new HashMap<>();
|
||||
private static String OPT_NAME = "ACS回调# ";
|
||||
|
||||
public SpeMachineryTask() {
|
||||
SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_MAC.name() ,new Spe2Spe());
|
||||
SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_CACHE.name() ,new Spe2Cache());
|
||||
SpeHandles.put(AcsTaskEnum.TASK_CACHELINE_OUT.name() ,new Cache2Spe());
|
||||
}
|
||||
public SpeMachineryTask() {
|
||||
SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_MAC.name(), new Spe2Spe());
|
||||
SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_CACHE.name(), new Spe2Cache());
|
||||
SpeHandles.put(AcsTaskEnum.TASK_CACHELINE_OUT.name(), new Cache2Spe());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTaskStatus(JSONObject param,String status) {
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
log.info(InterfaceLogType.ACS_TO_LMS.getDesc());
|
||||
// 指令执行中
|
||||
JSONObject task = taskTable.query("task_id = '" + param.getString("task_id") + "'").uniqueResult(0);
|
||||
AcsTaskEnum taskType = AcsTaskEnum.getType(task.getString("task_type"),"TASK_");
|
||||
try {
|
||||
SpeHandles.get(taskType.name()).handle(param,status,task);
|
||||
}catch (Exception ex){
|
||||
log.error(OPT_NAME+"updateStatus error:{}",ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void updateTaskStatus(JSONObject param, String status) {
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
log.info(InterfaceLogType.ACS_TO_LMS.getDesc());
|
||||
// 指令执行中
|
||||
JSONObject task = taskTable.query("task_id = '" + param.getString("task_id") + "'").uniqueResult(0);
|
||||
AcsTaskEnum taskType = AcsTaskEnum.getType(task.getString("task_type"), "TASK_");
|
||||
try {
|
||||
SpeHandles.get(taskType.name()).handle(param, status, task);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
log.error(OPT_NAME + "updateStatus error:{}", ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createTask(JSONObject form) {
|
||||
String start_point_code = form.getString("point_code1");
|
||||
String next_point_code = form.getString("point_code2");
|
||||
String vehicle_code = form.getString("vehicle_code");
|
||||
String type = form.getString("type");
|
||||
if(StrUtil.isEmpty(start_point_code)) {
|
||||
throw new BadRequestException("起点不能为空!");
|
||||
}
|
||||
if(StrUtil.isEmpty(next_point_code)) {
|
||||
throw new BadRequestException("终点不能为空!");
|
||||
}
|
||||
if(StrUtil.isEmpty(vehicle_code)) {
|
||||
throw new BadRequestException("载具不能为空!");
|
||||
}
|
||||
String taskdtl_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("task_id", taskdtl_id);
|
||||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.put("task_type", type);
|
||||
task.put("task_status", "01");
|
||||
task.put("start_point_code", start_point_code);
|
||||
task.put("next_point_code", next_point_code);
|
||||
task.put("vehicle_code", vehicle_code);
|
||||
task.put("handle_class", this.getClass().getName());
|
||||
task.put("finished_type", "01");
|
||||
task.put("is_delete", "0");
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
task.put("create_id", currentUserId);
|
||||
task.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
task.put("update_optid", currentUserId);
|
||||
task.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
task.put("create_time", DateUtil.now());
|
||||
task.put("update_time", DateUtil.now());
|
||||
task.put("priority", "1");
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").insert(task);
|
||||
return taskdtl_id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createTask(JSONObject form) {
|
||||
String start_point_code = form.getString("point_code1");
|
||||
String next_point_code = form.getString("point_code2");
|
||||
String vehicle_code = form.getString("vehicle_code");
|
||||
String type = form.getString("type");
|
||||
if (StrUtil.isEmpty(start_point_code)) {
|
||||
throw new BadRequestException("起点不能为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(next_point_code)) {
|
||||
throw new BadRequestException("终点不能为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(vehicle_code)) {
|
||||
throw new BadRequestException("载具不能为空!");
|
||||
}
|
||||
String taskdtl_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("task_id", taskdtl_id);
|
||||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.put("task_type", type);
|
||||
task.put("task_status", "01");
|
||||
task.put("start_point_code", start_point_code);
|
||||
task.put("next_point_code", next_point_code);
|
||||
task.put("vehicle_code", vehicle_code);
|
||||
task.put("handle_class", this.getClass().getName());
|
||||
task.put("finished_type", "01");
|
||||
task.put("is_delete", "0");
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
task.put("create_id", currentUserId);
|
||||
task.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
task.put("update_optid", currentUserId);
|
||||
task.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
task.put("create_time", DateUtil.now());
|
||||
task.put("update_time", DateUtil.now());
|
||||
task.put("priority", "1");
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").insert(task);
|
||||
return taskdtl_id;
|
||||
}
|
||||
@Override
|
||||
public void cancel(String taskId) {
|
||||
log.info(OPT_NAME + "cancel taskID:{}", taskId);
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
//专机-专机
|
||||
//专机-缓存线
|
||||
//缓存线出库
|
||||
taskTable.update(MapOf.of("task_status", StatusEnum.TASK_CANNEL.getCode()), "task_id = '" + taskId + "'");
|
||||
}
|
||||
|
||||
interface SpeStatusHandler{
|
||||
void handle(JSONObject param, String status, JSONObject task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String taskId) {
|
||||
log.info(OPT_NAME+"cancel taskID:{}",taskId);
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
//专机-专机
|
||||
//专机-缓存线
|
||||
//缓存线出库
|
||||
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_CANNEL.getCode()),"task_id = '"+taskId+"'");
|
||||
class Spe2Spe implements SpeStatusHandler{
|
||||
@Override
|
||||
public void handle(JSONObject param, String sta, JSONObject task) {
|
||||
AcsTaskEnum status = AcsTaskEnum.getType(sta, "status_");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
|
||||
switch(status) {
|
||||
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") + "'");
|
||||
break;
|
||||
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") + "'");
|
||||
//到专机:更新设备上料位物料数量
|
||||
String point_code2 = task.getString("point_code2");
|
||||
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0);
|
||||
task.getDouble("material_qty");
|
||||
double currentQty = device.getDouble("deviceinstor_qty") + task.getDouble("material_qty");
|
||||
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
|
||||
break;
|
||||
default:
|
||||
log.error(OPT_NAME + "未定义任务状态:{}", sta);
|
||||
throw new BadRequestException(OPT_NAME + "未定义任务状态:" + sta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
interface SpeStatusHandler{
|
||||
void handle(JSONObject param,String status,JSONObject task);
|
||||
}
|
||||
class Spe2Spe implements SpeStatusHandler{
|
||||
@Override
|
||||
public void handle(JSONObject param, String sta,JSONObject task) {
|
||||
AcsTaskEnum status = AcsTaskEnum.getType(sta,"status_");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
|
||||
|
||||
switch (status){
|
||||
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")+"'");
|
||||
break;
|
||||
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")+"'");
|
||||
//到专机:更新设备上料位物料数量
|
||||
String point_code2 = task.getString("point_code2");
|
||||
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0);
|
||||
task.getDouble("material_qty");
|
||||
double currentQty = device.getDouble("deviceinstor_qty") + task.getDouble("material_qty");
|
||||
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
|
||||
break;
|
||||
default:
|
||||
log.error(OPT_NAME+"未定义任务状态:{}",sta);
|
||||
throw new BadRequestException(OPT_NAME+"未定义任务状态:"+sta);
|
||||
}
|
||||
}
|
||||
}
|
||||
class Spe2Cache implements SpeStatusHandler{
|
||||
@Override
|
||||
public void handle(JSONObject param, String sta,JSONObject task) {
|
||||
AcsTaskEnum status = AcsTaskEnum.getType(sta,"status_");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||
String workprocedureCode = param.getString("workorder_code");
|
||||
String inboxtxm = param.getString("inboxtxm");
|
||||
String outboxtxm = param.getString("outboxtxm");
|
||||
switch (status){
|
||||
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")+"'");
|
||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||
break;
|
||||
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")+"'");
|
||||
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(),
|
||||
class Spe2Cache implements SpeStatusHandler{
|
||||
@Override
|
||||
public void handle(JSONObject param, String sta, JSONObject task) {
|
||||
AcsTaskEnum status = AcsTaskEnum.getType(sta, "status_");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||
String workprocedureCode = param.getString("workorder_code");
|
||||
String inboxtxm = param.getString("inboxtxm");
|
||||
String outboxtxm = param.getString("outboxtxm");
|
||||
switch(status) {
|
||||
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") + "'");
|
||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||
break;
|
||||
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") + "'");
|
||||
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(),
|
||||
//工单,工序?
|
||||
"workorder_code", workprocedureCode,
|
||||
"create_time", DateUtil.now(),
|
||||
"update_time", DateUtil.now()
|
||||
"workorder_code", workprocedureCode, "create_time", DateUtil.now(), "update_time", DateUtil.now()
|
||||
//物料规格,物料名称 从物料信息表关联查询
|
||||
));
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException(OPT_NAME+"未定义任务状态:"+sta);
|
||||
}
|
||||
}
|
||||
}
|
||||
class Cache2Spe implements SpeStatusHandler{
|
||||
@Override
|
||||
public void handle(JSONObject param, String sta,JSONObject task) {
|
||||
AcsTaskEnum status = AcsTaskEnum.getType(sta,"status_");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
|
||||
String outboxtxm = param.getString("outboxtxm");
|
||||
));
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException(OPT_NAME + "未定义任务状态:" + sta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (status){
|
||||
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")+"'");
|
||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||
break;
|
||||
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")+"'");
|
||||
|
||||
String point_code2 = task.getString("point_code2");
|
||||
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0);
|
||||
task.getDouble("material_qty");
|
||||
double currentQty = device.getDouble("deviceinstor_qty") + task.getDouble("material_qty");
|
||||
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException(OPT_NAME+"未定义任务状态:"+sta);
|
||||
}
|
||||
}
|
||||
}
|
||||
class Cache2Spe implements SpeStatusHandler{
|
||||
@Override
|
||||
public void handle(JSONObject param, String sta, JSONObject task) {
|
||||
AcsTaskEnum status = AcsTaskEnum.getType(sta, "status_");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
|
||||
String outboxtxm = param.getString("outboxtxm");
|
||||
switch(status) {
|
||||
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") + "'");
|
||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||
break;
|
||||
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") + "'");
|
||||
String point_code2 = task.getString("point_code2");
|
||||
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0);
|
||||
task.getDouble("material_qty");
|
||||
double currentQty = device.getDouble("deviceinstor_qty") + task.getDouble("material_qty");
|
||||
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException(OPT_NAME + "未定义任务状态:" + sta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user