add:缓存线任务
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package org.nl.common;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/3/20 11:08 上午
|
||||
*/
|
||||
public class ConstantParam {
|
||||
//深坑清洗区域编码
|
||||
public static String SK_REGION = "SK_REGION";
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.nl.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/3/21 10:04 上午
|
||||
*
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AcsTaskEnum {
|
||||
UNDEFINED("0","未定义类型"),
|
||||
//任务类型
|
||||
PRODUCT_MAC("1","专机-专机任务"),
|
||||
PRODUCT_CACHE("2","专机-缓存线任务"),
|
||||
CACHELINE_OUT("3","缓存线出库任务"),
|
||||
|
||||
//回调状态
|
||||
ACS_RUNDING("1","运行中"),
|
||||
ACS_FINISH("2","完成"),
|
||||
ACS_CANNEL("3","完成"),
|
||||
|
||||
ACS_CALLTYPE_FULL("1","满料请求"),
|
||||
ACS_CALLTYPE_EMP("2","缺料请求"),
|
||||
;
|
||||
private String code;
|
||||
private String desc;
|
||||
|
||||
public static AcsTaskEnum getType(String type){
|
||||
for (AcsTaskEnum value : AcsTaskEnum.values()) {
|
||||
if (value.getCode().equals(type)){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return AcsTaskEnum.UNDEFINED;
|
||||
}
|
||||
}
|
||||
@@ -20,15 +20,26 @@ public enum StatusEnum {
|
||||
//锁状态
|
||||
LOCK_OFF("0","否",""),
|
||||
LOCK_ON("1","是",""),
|
||||
|
||||
//缓存线载具状态00-空位、01-绿色空箱、02-黄色满箱、03-红色异常、04不显示
|
||||
CACHE_VEL_NULL("00","空位",""),
|
||||
CACHE_VEL_EMT("01","绿色空箱",""),
|
||||
CACHE_VEL_FULL("02","黄色满箱",""),
|
||||
CACHE_VEL_ERR("03","红色异常",""),
|
||||
CACHE_VEL_DIS("04","04不显示",""),
|
||||
//任务状态
|
||||
TASK_CrEATE("1","生成",""),
|
||||
TASK_CREATE("1","生成",""),
|
||||
TASK_START_P("2","起点确认",""),
|
||||
TASK_END_P("3","确定终点",""),
|
||||
TASK_START_END_P("4","起点和终点确认",""),
|
||||
TASK_PUBLISH("5","下发",""),
|
||||
TASK_RUNNING("6","运行",""),
|
||||
TASK_FINISH("7","完成",""),
|
||||
TASK_CANNEL("8","取消",""),
|
||||
//点位表位置状态
|
||||
POINT_LOCATION_EMP("1","空料位",""),
|
||||
POINT_LOCATION_REC("2","接料位",""),
|
||||
POINT_LOCATION_FULL("3","满料位",""),
|
||||
POINT_LOCATION_IN("4","上料位",""),
|
||||
;
|
||||
private String code;
|
||||
private String desc;
|
||||
|
||||
@@ -15,6 +15,8 @@ import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -23,7 +25,6 @@ import java.util.Set;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "genCode")
|
||||
public class GenCodeServiceImpl implements GenCodeService {
|
||||
@Override
|
||||
public JSONObject queryAll(Map form, Pageable pageable) {
|
||||
@@ -98,6 +99,7 @@ public class GenCodeServiceImpl implements GenCodeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public String codeDemo(Map form) {
|
||||
String code = (String) form.get("code");
|
||||
String id = this.queryIdByCode(code);
|
||||
|
||||
@@ -2,13 +2,14 @@ package org.nl.modules.system.util;
|
||||
|
||||
import org.nl.modules.system.service.GenCodeService;
|
||||
import org.nl.modules.system.service.impl.GenCodeServiceImpl;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class CodeUtil {
|
||||
|
||||
public static String getNewCode(String ruleCode){
|
||||
GenCodeService service=new GenCodeServiceImpl();
|
||||
public static String getNewCode(String ruleCode){
|
||||
GenCodeService service = SpringContextHolder.getBean(GenCodeServiceImpl.class);
|
||||
String flag = "1";
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
map.put("flag",flag);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.nl.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/3/20 5:04 下午
|
||||
*/
|
||||
@Service
|
||||
public class PointLockUtils {
|
||||
|
||||
private static final String POINT_PRE = "PointLock:";
|
||||
@Autowired
|
||||
StringRedisTemplate redisTemplate;
|
||||
//点位预锁定
|
||||
public void pointTryLock(String point){
|
||||
if (StringUtils.isEmpty(point)){
|
||||
throw new BadRequestException("查询不到当前点位:NULL");
|
||||
}
|
||||
String result = redisTemplate.opsForValue().get(POINT_PRE+point);
|
||||
if (StringUtils.isNotEmpty(result)){
|
||||
throw new BadRequestException("当前点位:"+point+"存在操作,请稍后再试");
|
||||
}else {
|
||||
redisTemplate.opsForValue().set(POINT_PRE+point,"1",5, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
//点位锁定
|
||||
public void pointLock(String taskId, String... point){
|
||||
String sql = Arrays.stream(point).collect(Collectors.joining("','"));
|
||||
WQLObject basePoint = WQLObject.getWQLObject("sch_base_point");
|
||||
basePoint.update(MapOf.of("lock_type",StatusEnum.LOCK_ON,"task_id",taskId),"where point_code in ('"+sql+"')");
|
||||
}
|
||||
//点位校验
|
||||
public void pointCheck(JSONObject point,String query){
|
||||
if (point==null){
|
||||
throw new BadRequestException("设备编号:"+query+"没有维护点位信息");
|
||||
}
|
||||
if (StatusEnum.STATUS_FLASE.getCode().equals(point.getString("lock_type"))){
|
||||
throw new BadRequestException("设备编号对应点位已锁定:"+point.getString("point_code"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,6 +2,7 @@
|
||||
package org.nl.wms.ext.acs.rest;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -32,8 +33,8 @@ public class AcsToWmsController {
|
||||
@PostMapping("/apply")
|
||||
@Log("ACS给WMS发送任务")
|
||||
@ApiOperation("ACS给WMS发送任务")
|
||||
public ResponseEntity<Object> receiveTaskFromAcs(@RequestBody Map whereJson) {
|
||||
return new ResponseEntity<>(acsToWmsService.receiveTaskFromAcs(whereJson), HttpStatus.OK);
|
||||
public ResponseEntity<Object> receiveTaskFromAcs(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(acsToWmsService.apply(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/status")
|
||||
@@ -43,9 +44,9 @@ public class AcsToWmsController {
|
||||
return new ResponseEntity<>(acsToWmsService.receiveTaskStatusAcs(string), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/orderFinish")
|
||||
@Log("ACS给WMS下发工单完成状态")
|
||||
@ApiOperation("ACS给WMS下发工单完成状态")
|
||||
// @PostMapping("/orderFinish")
|
||||
// @Log("ACS给WMS下发工单完成状态")
|
||||
// @ApiOperation("ACS给WMS下发工单完成状态")
|
||||
public ResponseEntity<Object> orderFinish(@RequestBody String string) {
|
||||
return new ResponseEntity<>(acsToWmsService.orderFinish(string), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.nl.wms.ext.acs.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface AcsToWmsService {
|
||||
@@ -12,7 +14,7 @@ public interface AcsToWmsService {
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
|
||||
Map<String, Object> receiveTaskFromAcs(Map<String, String> jsonObject);
|
||||
Map<String, Object> apply(JSONObject jsonObject);
|
||||
|
||||
/**
|
||||
* ACS客户端--->WMS服务端
|
||||
|
||||
@@ -11,7 +11,9 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.anno.Log;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.common.enums.AcsTaskEnum;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.ext.acs.service.AcsToWmsService;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
@@ -23,6 +25,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@@ -30,29 +33,25 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
private final TaskService taskService;
|
||||
private final AgvInstService agvInstService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> receiveTaskFromAcs(Map<String, String> jsonObject) {
|
||||
JSONObject result = new JSONObject();
|
||||
//{"point_code":"1002","container_code":"T666666","param":{"height":2,"weight":0}}
|
||||
//更新分配表生成出入库单局,生成指令
|
||||
JSONObject.parseObject(JSON.toJSONString(jsonObject)).getJSONObject("param");
|
||||
|
||||
//点位编码
|
||||
String point_code = MapUtil.getStr(jsonObject, "device_code");
|
||||
//载具号
|
||||
String vehicle_code = MapUtil.getStr(jsonObject, "container_code");
|
||||
JSONObject param = JSONObject.parseObject(JSON.toJSONString(jsonObject.get("param")));
|
||||
//高度
|
||||
String height = param.getString("height");
|
||||
//重量
|
||||
String weight = param.getString("weight");
|
||||
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
|
||||
result.put("message", "ACS向WMS申请任务成功!");
|
||||
result.put("data", new JSONObject());
|
||||
result.put("errArr", new JSONArray());
|
||||
public Map<String, Object> apply(JSONObject jsonObject) {
|
||||
Map result = MapOf.of("status", HttpStatus.OK.value(), "message", "ACS向WMS申请任务成功!");
|
||||
//1.满料请求
|
||||
//2.缺料请求
|
||||
String type = jsonObject.getString("type");
|
||||
try {
|
||||
if (type.equals(AcsTaskEnum.ACS_CALLTYPE_FULL.getCode())){
|
||||
agvInstService.fullMaster(jsonObject);
|
||||
}
|
||||
if (type.equals(AcsTaskEnum.ACS_CALLTYPE_EMP.getCode())){
|
||||
agvInstService.callMatter(jsonObject);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||
result.put("message",ex.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -79,10 +78,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
String message = "";
|
||||
String status = "";
|
||||
if ("1".equals(acs_task_status)) {
|
||||
status = TaskStatusEnum.EXECUTING.getCode();
|
||||
status = AcsTaskEnum.ACS_RUNDING.getCode();
|
||||
}
|
||||
if ("2".equals(acs_task_status)) {
|
||||
status = TaskStatusEnum.FINISHED.getCode();
|
||||
status = AcsTaskEnum.ACS_FINISH.getCode();
|
||||
}
|
||||
// 任务处理类
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
package org.nl.wms.ext.acs.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.ConstantParam;
|
||||
import org.nl.common.enums.AcsTaskEnum;
|
||||
import org.nl.common.enums.InterfaceLogType;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.service.RedisService;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
import org.nl.utils.PointLockUtils;
|
||||
import org.nl.wms.sch.tasks.PointToPointTask;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/3/15 11:03 上午
|
||||
* 缓存线任务生成器
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AgvInstService {
|
||||
|
||||
private static final String OPT_NAME = "acs回调#";
|
||||
|
||||
@Autowired
|
||||
private PointLockUtils pointLockUtils;
|
||||
//满料请求
|
||||
//1.判断当前设备路由表是否配置下一道路由设备,如果不是则说明直接到清洗
|
||||
//2.是否设置人工搬运(人工搬运之后维护设备状态)
|
||||
//3.判断下一道路由设备是否含有没满的设备料斗
|
||||
//4.有则创建agv指令,
|
||||
// 没有则创建缓存架任务
|
||||
public void fullMaster(JSONObject param){
|
||||
log.info(OPT_NAME+"fullMaster param:{}",JSONObject.toJSONString(param));
|
||||
|
||||
WQLObject workOrder = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
WQLObject basePoint = WQLObject.getWQLObject("sch_base_point");
|
||||
WQLObject cacheLineSearch = WQLObject.getWQLObject("SCH_cacheLine_region_relation");
|
||||
try {
|
||||
String workorder = param.getString("workorder_code");
|
||||
String point_code = param.getString("point_code");
|
||||
String quantity = param.getString("quantity");
|
||||
//1.PDM_produce_workOrder
|
||||
JSONObject order = workOrder.query("workorder_code = '" + workorder + "' and is_delete = 0 and status != "+StatusEnum.TASK_FINISH.getCode()).uniqueResult(0);
|
||||
if (order==null){
|
||||
throw new BadRequestException("下发工单不存在未完成工单:"+workorder);
|
||||
}
|
||||
String needMove = order.getString("is_needmove");
|
||||
String materialprocessSeries = order.getString("materialprocess_series");
|
||||
|
||||
String taskType = AcsTaskEnum.PRODUCT_MAC.getCode();
|
||||
if (StatusEnum.STATUS_TRUE.equals(needMove)){
|
||||
JSONObject devicePoint = basePoint.query("point_code = '" + point_code + "' and is_delete = 0 and is_used = 1").uniqueResult(0);
|
||||
JSONObject empPoint = WQL.getWO("sch_point").addParamMap(MapOf.of("flag", "2", "point_code", point_code, "point_type", StatusEnum.POINT_LOCATION_EMP.getCode())).process().uniqueResult(0);
|
||||
|
||||
String nextPoint = null;
|
||||
//2.进行终点判断
|
||||
JSONArray nextPointList = WQL.getWO("sch_point").addParamMap(MapOf.of("region_code", devicePoint.getString("next_regin_code"),"qty",quantity)).process().getResultJSONArray(0);
|
||||
if (nextPointList.size()>0){
|
||||
//判断缓存线是不是去深坑清洗
|
||||
if (devicePoint.getString("next_regin_code").equals(ConstantParam.SK_REGION)){
|
||||
String deviceSql = nextPointList.stream().map(a -> ((JSONObject) a).getString("device_code")).collect(Collectors.joining("','"));
|
||||
JSONArray runDevs = WQL.getWO("sch_point").addParamMap(MapOf.of("flag","4", "device_code",deviceSql)).process().getResultJSONArray(0);
|
||||
if (runDevs.size()>0){
|
||||
String device_code = runDevs.getJSONObject(0).getString("device_code");
|
||||
JSONObject SKPoint = (JSONObject)nextPointList.stream().filter(o -> ((JSONObject) o).getString("device_code").equals(device_code)).findFirst().get();
|
||||
nextPoint = SKPoint.getString("point_code");
|
||||
}
|
||||
}else {
|
||||
nextPoint = nextPointList.getJSONObject(0).getString("point_code");
|
||||
}
|
||||
}
|
||||
String cacheVehile = "";
|
||||
//根据区域物料对应关系查询缓存线
|
||||
if (StringUtils.isEmpty(nextPoint)){
|
||||
JSONObject cacheLine = cacheLineSearch.query("materialprocess_series = '"+materialprocessSeries+"' and region_code = '"+devicePoint.getString("regin_code")+"'").uniqueResult(0);
|
||||
nextPoint = cacheLine.getString("cacheLine_code");
|
||||
//满料请求:查询缓存线空载具列表
|
||||
cacheVehile = getCacheVehile(nextPoint, null);
|
||||
if (StringUtils.isEmpty(cacheVehile)) {
|
||||
throw new BadRequestException("缓存线:"+nextPoint+"没有可用空载具");
|
||||
}
|
||||
taskType = AcsTaskEnum.CACHELINE_OUT.getCode();
|
||||
}
|
||||
|
||||
//生成任务nextPoint
|
||||
PointToPointTask pointTask = new PointToPointTask();
|
||||
JSONObject taskForm = new JSONObject(MapOf.of("start_device_code",point_code,
|
||||
"next_device_code",nextPoint,"return_device_code", empPoint.getString("point_code"),"vehicle_code",
|
||||
cacheVehile,"quantity", quantity,"product_area",devicePoint.getString("product_area"),"type",taskType));
|
||||
String taskId = pointTask.createTask(taskForm);
|
||||
log.info(OPT_NAME+"fullMaster taskID:{}",taskId);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
log.error(OPT_NAME+"fullMaster error:{}",ex);
|
||||
throw ex;
|
||||
}
|
||||
};
|
||||
//缺料请求:上料位
|
||||
//1.判断当前设备表对应的缓存线是否开放
|
||||
//2.根据当前设备绑定的物料id,从缓存线中获取相同物料对应载具列表
|
||||
//3.agv根据对应载具列表行进扫码匹配:匹配到对应物料则创建点对点任务
|
||||
public void callMatter(JSONObject param){
|
||||
log.info(OPT_NAME+"callMatter param:{}",JSONObject.toJSONString(param));
|
||||
|
||||
WQLObject basePoint = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject workOrder = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
WQLObject cacheLineSearch = WQLObject.getWQLObject("SCH_cacheLine_region_relation");
|
||||
//参数
|
||||
String point_code = param.getString("point_code");
|
||||
String workorder = param.getString("workorder_code");
|
||||
|
||||
JSONObject devicePoint = basePoint.query("point_code = '" + point_code + "' and is_delete = 0 and is_used = 1").uniqueResult(0);
|
||||
JSONObject order = workOrder.query("workorder_code = '" + workorder + "' and is_delete = 0 and status != "+StatusEnum.TASK_FINISH.getCode()).uniqueResult(0);
|
||||
|
||||
try {
|
||||
JSONObject cacheLine = cacheLineSearch.query("materialprocess_series = '"+order.getString("materialprocess_series")+"' and region_code = '"+devicePoint.getString("regin_code")+"'").uniqueResult(0);
|
||||
|
||||
if (cacheLine != null){
|
||||
//缓存线位置编码 :缺料请求获取缓存线满载具列表
|
||||
String startPoint = cacheLine.getString("cacheLine_code");
|
||||
String cacheVehile = getCacheVehile(startPoint, null);
|
||||
if (StringUtils.isEmpty(cacheVehile)) {
|
||||
throw new BadRequestException("缓存线:"+startPoint+"没有可用空载具");
|
||||
}
|
||||
PointToPointTask pointTask = new PointToPointTask();
|
||||
JSONObject taskForm = new JSONObject(MapOf.of("start_device_code",startPoint,
|
||||
"next_device_code",point_code,"return_device_code", startPoint,"vehicle_code",
|
||||
cacheVehile,"product_area",devicePoint.getString("product_area"),"type",AcsTaskEnum.CACHELINE_OUT.getCode()));
|
||||
String taskId = pointTask.createTask(taskForm);
|
||||
log.info(OPT_NAME+"callMatter taskID:{}",taskId);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
log.error(OPT_NAME+"callMatter error:{}",ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public String getCacheVehile(String cacheLine,String materialId){
|
||||
WQLObject cacheLineVehile = WQLObject.getWQLObject("SCH_CacheLine_VehileMaterial");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
StringBuffer sql = new StringBuffer("vehicle_status = '");
|
||||
JSONArray runingTask = taskTable.query("point_code2 = " + cacheLine + "' and task_status < '" + StatusEnum.TASK_FINISH + "'").getResultJSONArray(0);
|
||||
if (StringUtils.isEmpty(materialId)){
|
||||
sql.append(StatusEnum.CACHE_VEL_EMT.getCode()).append("'");
|
||||
}else {
|
||||
sql.append(StatusEnum.CACHE_VEL_FULL.getCode()).append("'").append("material_id = '").append(materialId).append("'");
|
||||
}
|
||||
JSONArray result = cacheLineVehile.query(sql.toString()).getResultJSONArray(0);
|
||||
if (result.size()>0){
|
||||
if (result.size()>runingTask.size()){
|
||||
return result.stream().map(a -> ((JSONObject) a).getString("vehicle_code")).collect(Collectors.joining(","));
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -62,3 +62,11 @@
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "2"
|
||||
PAGEQUERY
|
||||
UPDATE pdm_bi_device
|
||||
SET deviceoutstor_qty = deviceoutstor_qty
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
Binary file not shown.
@@ -1,16 +1,10 @@
|
||||
package org.nl.wms.sch.manage;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.common.utils.AcsUtil;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.sch.tasks.AcsTaskDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Title: AbstractAcsTask.java Description:任务抽象类
|
||||
* <p>
|
||||
@@ -20,136 +14,16 @@ import java.util.List;
|
||||
* @author ldjun
|
||||
* @created 2020年6月12日 下午5:53:28
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class AbstractAcsTask {
|
||||
private static final String OPT_NAME = "acs回调#";
|
||||
|
||||
public abstract void updateTaskStatus(JSONObject taskObj,String status);
|
||||
|
||||
|
||||
/**
|
||||
* @discription 在如果任务无法形成会一直定时刷新判断
|
||||
* @author ldjun
|
||||
* @created 2020年6月12日 下午5:55:25
|
||||
*/
|
||||
public List<AcsTaskDto> schedule() {
|
||||
this.autoCreate();
|
||||
this.findStartPoint();
|
||||
this.findNextPoint();
|
||||
return addTask();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加任务进行下发
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<AcsTaskDto> addTask() {
|
||||
//任务基础表【sch_base_task】
|
||||
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
|
||||
JSONArray tasks = taskTab.query("handle_class = '" + this.getClass().getName() + "' and task_status = '" + TaskStatusEnum.START_AND_POINT.getCode() + "' and is_delete ='0'").getResultJSONArray(0);
|
||||
List<AcsTaskDto> arr = new ArrayList<>();
|
||||
for (int i = 0, j = tasks.size(); i < j; i++) {
|
||||
JSONObject json = tasks.getJSONObject(i);
|
||||
AcsTaskDto taskDto = new AcsTaskDto();
|
||||
taskDto.setTask_id(json.getString("task_id"));
|
||||
taskDto.setTask_code(json.getString("task_code"));
|
||||
taskDto.setTask_type("1");
|
||||
taskDto.setRoute_plan_code("normal");
|
||||
taskDto.setStart_device_code(json.getString("start_point_code"));
|
||||
taskDto.setNext_device_code(json.getString("next_point_code"));
|
||||
taskDto.setVehicle_code(json.getString("vehicle_code"));
|
||||
arr.add(taskDto);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param taskObj 代表一条任务对象
|
||||
* @param status 代表wcs任务完成状态: //1:执行中,2:完成 ,3:acs取消
|
||||
* @return
|
||||
* @discription wcs请求wms任务完成状态反馈接口, 比如agv从a点往b点走。生成任务的时候绑定b的物料信息,任务完成的时候,清除a的物料信息
|
||||
* @author ldjun
|
||||
* @created 2019年4月17日 下午8:51:50
|
||||
*/
|
||||
public abstract void updateTaskStatus(JSONObject taskObj, String status);
|
||||
|
||||
/**
|
||||
* @returninvoke
|
||||
* @discription 确定任务起点
|
||||
* @author ldjun
|
||||
* @created 2020年6月12日 下午6:01:30
|
||||
*/
|
||||
|
||||
public abstract void findStartPoint();
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @discription 确定下一点位
|
||||
* @author ldjun
|
||||
* @created 2020年6月12日 下午6:01:06
|
||||
*/
|
||||
public abstract void findNextPoint();
|
||||
|
||||
/**
|
||||
* @param form 创建任务需要的参数
|
||||
* @return 返回任务标识
|
||||
*/
|
||||
public abstract String createTask(JSONObject form);
|
||||
|
||||
/**
|
||||
* 自动生成任务
|
||||
*/
|
||||
public void autoCreate() {
|
||||
|
||||
}
|
||||
public abstract String createTask(JSONObject param);
|
||||
|
||||
|
||||
/**
|
||||
* @return WCS的任务集合
|
||||
* @discription 重新下发给wcs任务
|
||||
* @author ldjun
|
||||
* @created 2020年6月12日 下午5:52:28
|
||||
*/
|
||||
public JSONObject renotifyAcs(String task_id) {
|
||||
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONArray arr = taskTab.query("task_id = '" + task_id + "'").getResultJSONArray(0);
|
||||
for (int i = 0, j = arr.size(); i < j; i++) {
|
||||
JSONObject json = arr.getJSONObject(i);
|
||||
AcsTaskDto taskDto = new AcsTaskDto();
|
||||
taskDto.setTask_id(json.getString("task_id"));
|
||||
taskDto.setTask_code(json.getString("task_code"));
|
||||
taskDto.setTask_type("1");
|
||||
taskDto.setRoute_plan_code("normal");
|
||||
taskDto.setStart_device_code(json.getString("start_point_code"));
|
||||
taskDto.setNext_device_code(json.getString("next_point_code"));
|
||||
taskDto.setVehicle_code(json.getString("vehicle_code"));
|
||||
jsonArray.add(JSONObject.parse(JSON.toJSONString(taskDto)));
|
||||
|
||||
}
|
||||
return AcsUtil.notifyAcs("api/wms/task", jsonArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param task_id 任务标识
|
||||
* @return
|
||||
* @discription 强制结束完成任务
|
||||
* @author ldjun
|
||||
* @created 2020年6月19日 上午10:34:58
|
||||
*/
|
||||
public abstract void forceFinish(String task_id);
|
||||
|
||||
/**
|
||||
* @param task_id
|
||||
* @return
|
||||
* @discription 任务搬回原起点。
|
||||
* @author ldjun
|
||||
* @created 2020年6月22日 下午8:40:58
|
||||
*/
|
||||
public abstract void pullBack(String task_id);
|
||||
|
||||
/**
|
||||
* 取消任务
|
||||
*
|
||||
* @param task_id
|
||||
*/
|
||||
public abstract void cancel(String task_id);
|
||||
|
||||
|
||||
|
||||
@@ -120,7 +120,6 @@ public class CallMaterialTask extends AbstractAcsTask {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findStartPoint() {
|
||||
String task_status = TaskStatusEnum.SURE_START.getCode();
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
@@ -160,7 +159,6 @@ public class CallMaterialTask extends AbstractAcsTask {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findNextPoint() {
|
||||
|
||||
}
|
||||
@@ -380,13 +378,11 @@ public class CallMaterialTask extends AbstractAcsTask {
|
||||
return task_id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceFinish(String task_id) {
|
||||
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pullBack(String task_id) {
|
||||
|
||||
}
|
||||
|
||||
@@ -4,11 +4,17 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.enums.AcsTaskEnum;
|
||||
import org.nl.common.enums.InterfaceLogType;
|
||||
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.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -16,48 +22,101 @@ import java.util.HashMap;
|
||||
/**
|
||||
* 普通点对点任务
|
||||
*/
|
||||
@Slf4j
|
||||
public class PointToPointTask extends AbstractAcsTask {
|
||||
@Override
|
||||
public void updateTaskStatus(JSONObject taskObj, String status) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
HashMap map = new HashMap();
|
||||
//1:执行中,2:完成 ,3:acs取消
|
||||
if (status.equals("1")) {
|
||||
map.put("task_status", "03");
|
||||
map.put("car_no", taskObj.getString("car_no"));
|
||||
private static String OPT_NAME = "ACS回调# ";
|
||||
|
||||
@Override
|
||||
public void updateTaskStatus(JSONObject param,String status) {
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
|
||||
log.info(InterfaceLogType.ACS_TO_LMS.getDesc());
|
||||
|
||||
//参数:
|
||||
String taskId = param.getString("taskId");
|
||||
String workprocedureCode = param.getString("workorder_code");
|
||||
//入箱条码,出箱条码
|
||||
String inboxtxm = param.getString("inboxtxm");
|
||||
String outboxtxm = param.getString("outboxtxm");
|
||||
|
||||
// 指令执行中
|
||||
JSONObject task = taskTable.query("task_id = '" + taskId + "'").uniqueResult(0);
|
||||
String taskStatus = task.getString("task_status");
|
||||
AcsTaskEnum taskTypeEnum = AcsTaskEnum.getType(task.getString("task_type"));
|
||||
try {
|
||||
if (AcsTaskEnum.ACS_RUNDING.getCode().equals(status)) {
|
||||
if (!taskStatus.equals(StatusEnum.TASK_PUBLISH.getCode())){
|
||||
log.error(OPT_NAME+"任务:{} 状态异常不是处于下发状态:{}",taskId,taskStatus);
|
||||
}
|
||||
// 更新指令为执行中
|
||||
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_RUNNING.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+taskId+"'");
|
||||
//如果是缓存线任务:释放缓存线对应载具
|
||||
// 如果终点是缓存线,出箱的时候代表已经入了满料箱子
|
||||
//根据任务类型确认更新
|
||||
switch (taskTypeEnum){
|
||||
case PRODUCT_MAC:
|
||||
break;
|
||||
case PRODUCT_CACHE:
|
||||
//到缓存线说明需要出一个空箱号
|
||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||
break;
|
||||
case CACHELINE_OUT:
|
||||
//到缓存线说明需要出满箱号
|
||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||
break;
|
||||
default:
|
||||
log.error(OPT_NAME+"未定义任务类型:{}",task.getString("task_type"));
|
||||
throw new BadRequestException(OPT_NAME+"未定义任务类型:"+task.getString("task_type"));
|
||||
}
|
||||
}
|
||||
// 指令完成
|
||||
if (AcsTaskEnum.ACS_FINISH.getCode().equals(status)) {
|
||||
if (!taskStatus.equals(StatusEnum.TASK_RUNNING.getCode())) {
|
||||
log.error(OPT_NAME + "任务:{} 状态异常不是处于运行中状态:{}", taskId, taskStatus);
|
||||
}
|
||||
switch (taskTypeEnum) {
|
||||
case PRODUCT_MAC:case CACHELINE_OUT:
|
||||
//到专机:更新设备上料位物料数量
|
||||
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;
|
||||
case PRODUCT_CACHE:
|
||||
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()
|
||||
//物料规格,物料名称 从物料信息表关联查询
|
||||
));
|
||||
break;
|
||||
default:
|
||||
log.error(OPT_NAME + "未定义任务类型:{}", task.getString("task_type"));
|
||||
throw new BadRequestException(OPT_NAME + "未定义任务类型:" + task.getString("task_type"));
|
||||
}
|
||||
}
|
||||
}catch (Exception ex){
|
||||
log.error(OPT_NAME+"updateStatus error:{}",ex);
|
||||
throw ex;
|
||||
}
|
||||
if (status.equals("2")) {
|
||||
map.put("lock_type", "00");
|
||||
map.put("point_status", "00");
|
||||
map.put("vehicle_code", "");
|
||||
JSONObject task = WQLObject.getWQLObject("SCH_BASE_Task").query("taskdtl_id = '" + taskObj.getString("taskdtl_id") + "'").uniqueResult(0);
|
||||
WQLObject.getWQLObject("SCH_BASE_Point").update(map, "point_code = '" + task.getString("start_point_code") + "'");
|
||||
map.put("task_status", "99");
|
||||
}
|
||||
map.put("update_optid", currentUserId);
|
||||
map.put("update_optname", nickName);
|
||||
map.put("update_time", DateUtil.now());
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").update(map, "taskdtl_id = '" + taskObj.getString("taskdtl_id") + "'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findStartPoint() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findNextPoint() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createTask(JSONObject form) {
|
||||
String start_point_code = form.getString("start_point_code");
|
||||
String next_point_code = form.getString("next_point_code");
|
||||
String vehicle_code = form.getString("vehicle_code");
|
||||
|
||||
String type = form.getString("type");
|
||||
if (StrUtil.isEmpty(start_point_code)) {
|
||||
throw new BadRequestException("起点不能为空!");
|
||||
}
|
||||
@@ -72,8 +131,7 @@ public class PointToPointTask extends AbstractAcsTask {
|
||||
task.put("taskdtl_id", taskdtl_id);
|
||||
task.put("task_id", taskdtl_id);
|
||||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.put("task_type", "11");
|
||||
task.put("taskdtl_type", "10");
|
||||
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);
|
||||
@@ -93,27 +151,15 @@ public class PointToPointTask extends AbstractAcsTask {
|
||||
return taskdtl_id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceFinish(String taskdtl_id) {
|
||||
//任务表
|
||||
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
|
||||
JSONObject task = wo_Task.query("task_status<>'99' and taskdtl_id='" + taskdtl_id + "'").uniqueResult(0);
|
||||
if (task == null) {
|
||||
throw new BadRequestException("查询不到可以完成的任务记录!");
|
||||
}
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("taskdtl_id", taskdtl_id);
|
||||
this.updateTaskStatus(jo, "2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pullBack(String taskdtl_id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String taskdtl_id) {
|
||||
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+"'");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ public class SendMaterialTask extends AbstractAcsTask {
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateTaskStatus(JSONObject taskObj, String status) {
|
||||
/**
|
||||
*改变任务状态
|
||||
@@ -136,53 +135,7 @@ public class SendMaterialTask extends AbstractAcsTask {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findStartPoint() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findNextPoint() {
|
||||
String task_status = TaskStatusEnum.SURE_START.getCode();
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
JSONArray taskArry = taskTab.query("task_status='" + task_status + "' AND handle_class='" + THIS_CLASS + "' AND is_delete='0' ").getResultJSONArray(0);
|
||||
for (int i = 0; i < taskArry.size(); i++) {
|
||||
JSONObject taskObj = taskArry.getJSONObject(i);
|
||||
String task_id = taskObj.getString("task_id");
|
||||
//1 将任务修改为分配 2将终点写入,完成分配,3 加锁点位
|
||||
//找一个合适的仓位
|
||||
WQLObject ProcedureIOStable = WQLObject.getWQLObject("ST_IVT_workProcedureIOS");
|
||||
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") + "'的入库单据!");
|
||||
}
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("material_id", IosObj.getString("material_id"));
|
||||
param.put("area_type", IosObj.getString("end_area"));
|
||||
param.put("vehicle_code", IosObj.getString("vehicle_code"));
|
||||
JSONObject inStructObj = StructFindUtil.getInStruct(param);
|
||||
if (ObjectUtil.isEmpty(inStructObj)) {
|
||||
throw new BadRequestException("未找到合适的入库仓位!");
|
||||
}
|
||||
//修改单据状态,将终点填入
|
||||
IosObj.put("bill_status", "20");
|
||||
IosObj.put("end_point_code", inStructObj.getString("struct_code"));
|
||||
ProcedureIOStable.update(IosObj);
|
||||
//终点加锁
|
||||
HashMap lock_map = new HashMap();
|
||||
lock_map.put("lock_type", "01");
|
||||
WQLObject.getWQLObject("sch_base_point").update(lock_map, "point_code = '" + inStructObj.getString("struct_code") + "'");
|
||||
//修改任务状态
|
||||
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
taskObj.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
taskObj.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -363,17 +316,7 @@ public class SendMaterialTask extends AbstractAcsTask {
|
||||
return task_id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void forceFinish(String task_id) {
|
||||
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pullBack(String task_id) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void cancel(String task_id) {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.nl.wms.sch.tasks;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/3/22 17:14
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TaskScheduleService {
|
||||
|
||||
private ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
@Scheduled(cron = "0/10 * * * * ?")
|
||||
public void taskPublish(){
|
||||
boolean islock = lock.tryLock();
|
||||
try {
|
||||
if (islock){
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
JSONArray array = taskTable.query("task_type < '" + StatusEnum.TASK_PUBLISH + "'").getResultJSONArray(0);
|
||||
|
||||
|
||||
}
|
||||
}finally {
|
||||
if (islock){
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,90 +47,18 @@
|
||||
##########################################
|
||||
|
||||
IF 输入.flag = "1"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
a.*,b.device_name
|
||||
FROM
|
||||
sch_base_point a
|
||||
left join
|
||||
pdm_base_device b on a.device_id = b.device_id
|
||||
WHERE
|
||||
a.is_delete = '0'
|
||||
OPTION 输入.search <> ""
|
||||
(a.point_code like 输入.search or
|
||||
a.point_name like 输入.search)
|
||||
ENDOPTION
|
||||
OPTION 输入.point_type <> ""
|
||||
a.point_type = 输入.point_type
|
||||
ENDOPTION
|
||||
OPTION 输入.area_type <> ""
|
||||
a.area_type = 输入.area_type
|
||||
ENDOPTION
|
||||
OPTION 输入.point_status <> ""
|
||||
a.point_status = 输入.point_status
|
||||
ENDOPTION
|
||||
OPTION 输入.lock_type <> ""
|
||||
a.lock_type = 输入.lock_type
|
||||
ENDOPTION
|
||||
OPTION 输入.is_used <> ""
|
||||
a.is_used = 输入.is_used
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
sch_cacheline_position.*,
|
||||
MD_PB_StorageVehicleExt.material_id,
|
||||
MD_PB_StorageVehicleExt.storage_qty,
|
||||
dev.inupperlimit_qty - dev.deviceinstor_qty as deviceQty,
|
||||
FROM
|
||||
sch_cacheline_position
|
||||
LEFT JOIN pdm_bi_device dev ON sch_cacheline_position.cacheLine_code = dev.cacheLine_code
|
||||
LEFT JOIN MD_PB_StorageVehicleExt ON sch_cacheline_position.vehicle_code = MD_PB_StorageVehicleExt.storagevehicle_code
|
||||
WHERE
|
||||
dev.device_code = 输入.device_code
|
||||
AND MD_PB_StorageVehicleExt.material_id = 输入.material_id
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "2"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
a.*,b.sect_code
|
||||
FROM
|
||||
ST_IVT_StructAttr a
|
||||
left join
|
||||
ST_IVT_SectAttr b on a.sect_id = b.sect_id
|
||||
WHERE
|
||||
a.is_delete = '0'
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "3"
|
||||
PAGEQUERY
|
||||
SELECT DISTINCT
|
||||
structattr.struct_id,
|
||||
structattr.struct_code,
|
||||
structattr.struct_name,
|
||||
point.area_type,
|
||||
point.point_type
|
||||
FROM
|
||||
st_ivt_structattr structattr
|
||||
LEFT JOIN sch_base_point point ON point.point_id = structattr.struct_id
|
||||
LEFT JOIN ST_IVT_StructRelaVehicleType rulevehicle ON rulevehicle.struct_id = structattr.struct_id
|
||||
LEFT JOIN ST_IVT_StructAttributeRules ruledis ON ruledis.struct_id = structattr.struct_id
|
||||
WHERE
|
||||
point.lock_type = '00'
|
||||
AND (point.vehicle_code = '' or point.vehicle_code is null)
|
||||
AND point.point_status = '00'
|
||||
AND point.area_type = 输入.area_type
|
||||
AND rulevehicle.vehicle_type = 输入.vehicle_type
|
||||
OPTION 输入.search <> ""
|
||||
(structattr.struct_code like 输入.search or
|
||||
structattr.struct_name like 输入.search)
|
||||
ENDOPTION
|
||||
OPTION 输入.loadSeries <> ""
|
||||
ruledis.load_series >= 输入.loadSeries
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "4"
|
||||
PAGEQUERY
|
||||
select ca.* from St_CacheLine_Position ca
|
||||
inner join MD_PB_StorageVehicleExt ve on ca.vehicle_code = ve.storagevehicle_code
|
||||
inner PDM_BI_Device dev on dev.cacheLine_code = ca.cacheLine_code
|
||||
where dev.material_id = 输入.material_id
|
||||
and dev.is_delete = 0
|
||||
and ca.is_active =1
|
||||
and dev.is_delete = 0
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
Binary file not shown.
@@ -49,76 +49,70 @@
|
||||
IF 输入.flag = "1"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
a.*,b.device_name
|
||||
next_de.inupperlimit_qty - next_de.deviceinstor_qty - IFNULL( sum( material_qty ), 0 ) AS currentQty,
|
||||
next_de.cacheLine_code,
|
||||
next.*
|
||||
FROM
|
||||
sch_base_point a
|
||||
left join
|
||||
pdm_base_device b on a.device_id = b.device_id
|
||||
sch_base_point p
|
||||
INNER JOIN sch_base_point next ON p.next_region_code = next.region_code
|
||||
LEFT JOIN pdm_bi_device next_de ON next_de.device_code = next.device_code
|
||||
LEFT JOIN sch_base_task ON next.point_code = sch_base_task.point_code2 and next.product_area = sch_base_task.product_area
|
||||
WHERE
|
||||
a.is_delete = '0'
|
||||
OPTION 输入.search <> ""
|
||||
(a.point_code like 输入.search or
|
||||
a.point_name like 输入.search)
|
||||
ENDOPTION
|
||||
OPTION 输入.point_type <> ""
|
||||
a.point_type = 输入.point_type
|
||||
ENDOPTION
|
||||
OPTION 输入.area_type <> ""
|
||||
a.area_type = 输入.area_type
|
||||
ENDOPTION
|
||||
OPTION 输入.point_status <> ""
|
||||
a.point_status = 输入.point_status
|
||||
ENDOPTION
|
||||
OPTION 输入.lock_type <> ""
|
||||
a.lock_type = 输入.lock_type
|
||||
ENDOPTION
|
||||
OPTION 输入.is_used <> ""
|
||||
a.is_used = 输入.is_used
|
||||
ENDOPTION
|
||||
p.device_code = 输入.device_code
|
||||
AND next_de.material_id = 输入.material_id;
|
||||
AND sch_base_task.task_status < 7
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
|
||||
IF 输入.flag = "2"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
a.*,b.sect_code
|
||||
b.*
|
||||
FROM
|
||||
ST_IVT_StructAttr a
|
||||
left join
|
||||
ST_IVT_SectAttr b on a.sect_id = b.sect_id
|
||||
sch_base_point a
|
||||
LEFT JOIN sch_base_point b ON a.device_code = b.device_code
|
||||
WHERE
|
||||
a.is_delete = '0'
|
||||
ENDSELECT
|
||||
a.point_code = 输入.point_code;
|
||||
AND b.point_type = 输入.point_type;
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "3"
|
||||
PAGEQUERY
|
||||
SELECT DISTINCT
|
||||
structattr.struct_id,
|
||||
structattr.struct_code,
|
||||
structattr.struct_name,
|
||||
point.area_type,
|
||||
point.point_type
|
||||
FROM
|
||||
st_ivt_structattr structattr
|
||||
LEFT JOIN sch_base_point point ON point.point_id = structattr.struct_id
|
||||
LEFT JOIN ST_IVT_StructRelaVehicleType rulevehicle ON rulevehicle.struct_id = structattr.struct_id
|
||||
LEFT JOIN ST_IVT_StructAttributeRules ruledis ON ruledis.struct_id = structattr.struct_id
|
||||
WHERE
|
||||
point.lock_type = '00'
|
||||
AND (point.vehicle_code = '' or point.vehicle_code is null)
|
||||
AND point.point_status = '00'
|
||||
AND point.area_type = 输入.area_type
|
||||
AND rulevehicle.vehicle_type = 输入.vehicle_type
|
||||
OPTION 输入.search <> ""
|
||||
(structattr.struct_code like 输入.search or
|
||||
structattr.struct_name like 输入.search)
|
||||
ENDOPTION
|
||||
OPTION 输入.loadSeries <> ""
|
||||
ruledis.load_series >= 输入.loadSeries
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
SELECT
|
||||
pdm_bi_device.inupperlimit_qty - ifnull( sum( sch_base_task.material_qty ), 0 ) - pdm_bi_device.deviceinstor_qty AS currentQty,
|
||||
pdm_bi_device.device_code,
|
||||
sch_base_point.region_code,
|
||||
sch_base_point.point_code
|
||||
FROM
|
||||
sch_base_point
|
||||
LEFT JOIN pdm_bi_device ON sch_base_point.device_code = pdm_bi_device.device_code
|
||||
LEFT JOIN sch_base_task ON sch_base_point.point_code = point_code2 and task_status<7
|
||||
WHERE 1=1
|
||||
OPTION 输入.region_code <> ""
|
||||
ch_base_point.region_code = 输入.region_code
|
||||
ENDOPTION
|
||||
OPTION 输入.device_code <> ""
|
||||
ch_base_point.device_code = 输入.device_code
|
||||
ENDOPTION
|
||||
GROUP BY
|
||||
device_code
|
||||
HAVING currentQty> 输入.qty
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "4"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
( SELECT * FROM pdm_bi_devicerunstatusrecord
|
||||
where device_code in (' 输入.device_code ')
|
||||
ORDER BY order_num DESC LIMIT 999999 ) a
|
||||
GROUP BY
|
||||
device_code
|
||||
HAVING status_type = '02'
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
Reference in New Issue
Block a user