rev:修改结构

This commit is contained in:
zhangzhiqiang
2023-04-23 14:04:45 +08:00
parent d4a63d1619
commit 1ee9d7362b
41 changed files with 338 additions and 350 deletions

View File

@@ -6,7 +6,7 @@ package org.nl.common;
*/
public class ConstantParam {
//深坑清洗区域编码
public static String SK_REGION = "QSQX";
public static String SK_REGION = "A1_SKQX";
//发货区编码
public static String FHQ = "KQ001";
public static String RK_POINT = "A1_RK01";

View File

@@ -69,6 +69,9 @@ public enum StatusEnum {
IOS_CREATE("01","生成",""),
IOS_RUNNING("02","执行中",""),
IOS_FINISH("99","完成",""),
//载具超限
OVERSTRUCT_STANDARD("1","标准",""),
OVERSTRUCT_LIMIT("2","超限",""),
;
private String code;

View File

@@ -8,6 +8,7 @@ import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
/*
* @author ZZQ
@@ -21,7 +22,7 @@ public class RedissonUtils {
* @param seconds 尝试获取锁的等待时间,允许为空
*/
@SneakyThrows
public static void lock(LockProcess process, String key, Integer seconds){
public static void lock(LockProcess process, String key, Integer seconds){
RedissonClient redissonClient = SpringContextHolder.getBean(RedissonClient.class);
RLock lock = redissonClient.getLock(key);
boolean isLock;

View File

@@ -9,15 +9,11 @@ import java.util.HashMap;
public class CodeUtil{
public static String getNewCode(String ruleCode) {
final String[] code = {""};
HashMap<String,String> map = new HashMap<>();
map.put("flag", "1");
map.put("code", ruleCode);
GenCodeService service = SpringContextHolder.getBean(GenCodeServiceImpl.class);
String codeId = service.queryIdByCode(ruleCode);
RedissonUtils.lock(() -> {
code[0] = service.codeDemo(map);
}, codeId, 3);
return code[0];
return service.codeDemo(map);
}
}

View File

@@ -92,49 +92,24 @@ public class StoragevehicleinfoServiceImpl implements StoragevehicleinfoService
if (!ObjectUtil.isEmpty(jsonObject)) {
throw new BadRequestException("此载具已存在");
}
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String storagevehicle_type = (String) map.get("storagevehicle_type");
String code = "";
switch (storagevehicle_type) {
case "00":
code = "VEHICCLE_CODE_XMTPT";
break;
case "01":
code = "VEHICCLE_CODE_CDMTP";
break;
case "02":
code = "VEHICCLE_CODE_TLD";
break;
case "03":
code = "VEHICCLE_CODE_TTP";
break;
case "04":
code = "VEHICCLE_CODE_XMTPC";
break;
case "05":
code = "VEHICCLE_CODE_LX";
break;
}
JSONArray resultCodeArr = new JSONArray();
int num = MapUtil.getInt(map, "num");
for (int i = 0; i < num; i++) {
StoragevehicleinfoDto dto = new StoragevehicleinfoDto();
dto.setStoragevehicle_id(IdUtil.getSnowflake(1, 1).nextId());
dto.setStoragevehicle_code(CodeUtil.getNewCode(code));
dto.setCreate_id(currentUserId);
dto.setStoragevehicle_code((String) map.get("storagevehicle_code"));
dto.setCreate_id(SecurityUtils.getCurrentUserId());
dto.setStoragevehicle_name(dto.getStoragevehicle_code());
dto.setCreate_name(nickName);
dto.setUpdate_id(currentUserId);
dto.setUpdate_name(nickName);
dto.setCreate_name(SecurityUtils.getCurrentNickName());
dto.setUpdate_id(SecurityUtils.getCurrentUserId());
dto.setUpdate_name(SecurityUtils.getCurrentNickName());
dto.setUpdate_time(DateUtil.now());
dto.setCreate_time(DateUtil.now());
dto.setOverstruct_type((String) map.get("overstruct_type"));
dto.setStoragevehicle_type((String) map.get("storagevehicle_type"));
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
wo.insert(json);
resultCodeArr.add(dto.getStoragevehicle_code());
resultCodeArr.add(dto);
}
return resultCodeArr;
}

View File

@@ -37,9 +37,6 @@ import java.util.Map;
@SaIgnore
public class AcsToWmsController {
private final AcsToWmsService acsToWmsService;
private final SpeMachineryTask speMachineryTask;
private final CacheLineHandService cacheLineHandService;
private final TaskScheduleService taskScheduleService;
private final WashMachineryTask washMachineryTask;
@PostMapping("/apply")

View File

@@ -17,8 +17,10 @@ import org.nl.common.utils.MapOf;
import org.nl.common.utils.RedissonUtils;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.ext.acs.service.AcsToWmsService;
import org.nl.wms.pda.service.CacheLineHandService;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.service.TaskService;
import org.nl.wms.sch.service.dto.TaskDto;
import org.nl.wms.sch.tasks.SpeMachineryTask;
@@ -27,6 +29,7 @@ import org.nl.wms.sch.tasks.callMaterial.WrapCallMaterialTask;
import org.nl.wms.sch.tasks.sendEmpty.WrapSendEmptyTask;
import org.nl.wms.sch.tasks.sendMaterial.PlotterSendMaterialTask;
import org.nl.wms.sch.tasks.WashMachineryTask;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -34,59 +37,45 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.PostConstruct;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Supplier;
@Service
@RequiredArgsConstructor
@Slf4j
public class AcsToWmsServiceImpl implements AcsToWmsService{
private static Map<AcsTaskEnum, AbstractAcsTask> Task_Factory = new HashMap<>();
@Autowired
private TaskService taskService;
@Autowired
private CacheLineHandService cacheLineHandService;
private final CacheLineHandService cacheLineHandService;
private final SpeMachineryTask speMachineryTask;
private final WashMachineryTask washMachineryTask;
private final PlotterSendMaterialTask plotterSendMaterialTask;
private final PlotterCallEmptyTask plotterCallEmptyTask;
private final WrapCallMaterialTask wrapCallMaterialTask;
private final WrapSendEmptyTask wrapSendEmptyTask;
@Override
@Transactional
public Map<String, Object> apply(JSONObject param) {
Assert.notNull(param,"请求参数不存在");
Map result = MapOf.of("status", HttpStatus.OK.value(), "message", "ACS向WMS申请任务成功!");
String type = param.getString("type");
AcsTaskEnum taskEnum = AcsTaskEnum.getType(type, "REQUEST_");
AcsTaskEnum taskEnum = AcsTaskEnum.getType(param.getString("type"), "REQUEST_");
try {
RedissonUtils.lock(() -> {
},"ddd",3);
RedissonUtils.lock(()->{
switch (taskEnum){
//1.专机设备满料请求 2.专机设备缺料请求:专机
case REQUEST_CALLTYPE_FULL: case REQUEST_CALLTYPE_EMP:
speMachineryTask.createTask(param);
break;
//清洗机缺料请求:
case REQUEST_WASH_EMP:
washMachineryTask.createTask(param);
break;
case REQUEST_PLOTTER_SEND_FULL:
plotterSendMaterialTask.createTask(param);
break;
case REQUEST_PLOTTER_CALL_EMP:
plotterCallEmptyTask.createTask(param);
break;
case REQUEST_WARP_CALL_FULL:
wrapCallMaterialTask.createTask(param);
break;
case REQUEST_WARP_SEND_EMP:
wrapSendEmptyTask.createTask(param);
break;
default:
throw new BadRequestException("任务请求类型错误!");
}
},type,5);
//业务处理
Task_Factory.get(taskEnum).createTask(param);
},param.getString("type"),5);
}catch (Exception ex){
result.put("status", HttpStatus.BAD_REQUEST.value());
result.put("message",ex.getMessage());
@@ -94,6 +83,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService{
return result;
}
public static void main(String[] args) {
ArrayList<Object> list = new ArrayList<>();
list.forEach(a->{
a.getClass();
});
}
/**
* 更新缓存线的点位实时任务信息
* ACS给WMS发送缓存线的实时任务编号
@@ -205,7 +201,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService{
public Map<String, Object> washOrderFinish(JSONObject param) {
JSONObject result = new JSONObject();
try {
washMachineryTask.updateTaskStatus(param,StatusEnum.TASK_FINISH.getCode());
SpringContextHolder.getBean(WashMachineryTask.class).updateTaskStatus(param,StatusEnum.TASK_FINISH.getCode());
} catch (Exception e){
result.put("status", 400);
result.put("message", e.getMessage());
@@ -322,5 +318,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService{
wo.update(MapOf.of("real_qty",real_qty),"workorder_id = '"+workorder_id+"'");
}
}
@PostConstruct
public void init() {
Task_Factory.put(AcsTaskEnum.REQUEST_CALLTYPE_FULL, SpringContextHolder.getBean(SpeMachineryTask.class));
Task_Factory.put(AcsTaskEnum.REQUEST_CALLTYPE_EMP, SpringContextHolder.getBean(SpeMachineryTask.class));
Task_Factory.put(AcsTaskEnum.REQUEST_WASH_EMP, SpringContextHolder.getBean(WashMachineryTask.class));
Task_Factory.put(AcsTaskEnum.REQUEST_PLOTTER_SEND_FULL, SpringContextHolder.getBean(PlotterSendMaterialTask.class));
Task_Factory.put(AcsTaskEnum.REQUEST_WARP_CALL_FULL, SpringContextHolder.getBean(WrapCallMaterialTask.class));
Task_Factory.put(AcsTaskEnum.REQUEST_WARP_SEND_EMP, SpringContextHolder.getBean(WrapSendEmptyTask.class));
}
}

View File

@@ -2,41 +2,23 @@ package org.nl.wms.ext.acs.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.MD5;
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.StatusEnum;
import org.nl.common.utils.MapOf;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.utils.PointLockUtils;
import org.nl.wms.sch.tasks.SpeMachineryTask;
import org.redisson.api.RLock;
import org.redisson.api.RReadWriteLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.transaction.support.DefaultTransactionStatus;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Function;
import java.util.stream.Collectors;
/*
@@ -90,7 +72,7 @@ public class AgvInstService {
JSONObject cacheLine = cacheLineSearch.query("region_code = '"+devicePoint.getString("region_code")+"'").uniqueResult(0);
nextPoint = cacheLine.getString("cacheline_code");
//满料请求:查询缓存线空载具列表
cacheVehile = getCacheVehile(nextPoint, null);
cacheVehile = getEmpCacheVehile(nextPoint, null);
if (StringUtils.isBlank(cacheVehile)) {
throw new BadRequestException(OPT_NAME+"缓存线:"+nextPoint+"没有可用空载具");
}
@@ -118,16 +100,15 @@ public class AgvInstService {
WQLObject cacheLineTable = WQLObject.getWQLObject("SCH_cacheLine_region_relation");
WQLObject taskTable = WQLObject.getWQLObject("SCH_base_task");
//参数
String point_code = task.getString("next_point_code");
String material_id = task.getString("material_id");
JSONObject devicePoint = basePointTable.query("point_code = '" + point_code + "' and is_delete = 0 and is_used = 1").uniqueResult(0);
JSONObject devicePoint = basePointTable.query("point_code = '" + task.getString("next_point_code") + "' and is_delete = 0 and is_used = 1").uniqueResult(0);
JSONObject cacheLine = cacheLineTable.query("region_code = '"+devicePoint.getString("region_code")+"' and is_active = '"+StatusEnum.STATUS_TRUE.getCode()+"'").uniqueResult(0);
Assert.notNull(cacheLine, String.format(OPT_NAME+"区域%s对应缓存线信息不存在", devicePoint.getString("region_code")));
//缓存线位置编码 :缺料请求获取缓存线满载具列表
String startPoint = cacheLine.getString("cacheline_code");
String cacheVehile = getCacheVehile(startPoint, material_id);
String cacheVehile = getEmpCacheVehile(startPoint, material_id);
if (StringUtils.isBlank(cacheVehile)) {
throw new BadRequestException(OPT_NAME+"缓存线:"+startPoint+"没有可用载具");
}
@@ -146,9 +127,8 @@ public class AgvInstService {
}
public String getCacheVehile(String cacheLine,String materialId){
public String getEmpCacheVehile(String cacheLine, String materialId){
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.getCode() + "'").getResultJSONArray(0);
String status = StringUtils.isBlank(materialId) ? StatusEnum.CACHE_VEL_EMT.getCode() : StatusEnum.CACHE_VEL_FULL.getCode();
JSONArray result = WQL.getWO("sch_point").addParamMap(MapOf.of("flag", "6", "vehicle_status", status, "material_id", materialId)).process().getResultJSONArray(0);

View File

@@ -2,7 +2,6 @@ package org.nl.wms.sch.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -12,6 +11,7 @@ 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.util.CodeUtil;
@@ -65,29 +65,23 @@ public class SpeMachineryTask extends AbstractAcsTask {
@Override
public String createTask(JSONObject param) {
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
WQLObject workOrder = WQLObject.getWQLObject("PDM_produce_workOrder");
String workorder = param.getString("workorder_code");//
String point_code = param.getString("device_code");
String quantity = param.getString("quantity");
String type = param.getString("type");
JSONObject order = workOrder.query("workorder_code = '" + workorder + "' and is_delete = 0 and workorder_status != "+StatusEnum.TASK_FINISH.getCode()).uniqueResult(0);
Assert.notNull(order, String.format("下发工单%s不存在未完成工单", workorder));
JSONObject order = WQLObject.getWQLObject("PDM_produce_workOrder").query("workorder_code = '" + param.getString("workorder_code") + "' and is_delete = 0 and workorder_status != "+StatusEnum.TASK_FINISH.getCode()).uniqueResult(0);
Assert.notNull(order, String.format("下发工单%s不存在未完成工单", param.getString("workorder_code")));
JSONObject form = null;
if (AcsTaskEnum.REQUEST_CALLTYPE_FULL.getCode().equals(type)){
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);
form = new JSONObject(MapOf.of("start_point_code",point_code,
if (AcsTaskEnum.REQUEST_CALLTYPE_FULL.getCode().equals(param.getString("type"))){
JSONObject empPoint = WQL.getWO("sch_point").addParamMap(MapOf.of("flag", "2", "point_code", param.getString("device_code"), "point_type", StatusEnum.POINT_LOCATION_EMP.getCode())).process().uniqueResult(0);
form = new JSONObject(MapOf.of("start_point_code",param.getString("device_code"),
"next_point_code","","return_point_code", empPoint,"vehicle_code",
"","product_area","quantity", quantity,order.getString("product_area"),"type",type,"material_id", order.getString("material_id")));
"","product_area","quantity", param.getString("quantity"),order.getString("product_area"),"type",param.getString("type"),"material_id", order.getString("material_id")));
}
if (AcsTaskEnum.REQUEST_CALLTYPE_EMP.getCode().equals(type)){
if (AcsTaskEnum.REQUEST_CALLTYPE_EMP.getCode().equals(param.getString("type"))){
form = new JSONObject(MapOf.of("start_point_code","",
"next_point_code",point_code,"return_point_code", "","vehicle_code",
"","product_area","quantity", quantity,order.getString("product_area"),"type",type,"material_id", order.getString("material_id")));
"next_point_code",param.getString("device_code"),"return_point_code", "","vehicle_code",
"","product_area","quantity", param.getString("quantity"),order.getString("product_area"),"type",param.getString("type"),"material_id", order.getString("material_id")));
}
JSONObject task = new JSONObject();
String taskdtl_id = IdUtil.getSnowflake(1, 1).nextId() + "";
packageParam(type, form, task, taskdtl_id);
JSONObject task = packageParam(param.getString("type"), form);
WQLObject.getWQLObject("SCH_BASE_Task").insert(task);
try {
pointConfirm(task);
@@ -95,42 +89,40 @@ public class SpeMachineryTask extends AbstractAcsTask {
}catch (Exception ex){
task.put("task_status",TaskStatusEnum.SURE_START_ERROR.getCode());
task.put("remark",ex.getMessage());
taskTab.update(task);
WQLObject.getWQLObject("sch_base_task").update(task);
}
return taskdtl_id;
return task.getString("task_id");
}
private void packageParam(String type, JSONObject form, JSONObject task, String taskdtl_id) {
private JSONObject packageParam(String type, JSONObject reqestPram) {
JSONObject task = new JSONObject();
参数封装:{
String task_name = form.getString("task_name");
String start_point_code = form.getString("point_code1");
String next_point_code = form.getString("point_code2");
String vehicle_code = form.getString("vehicle_code");
String vehicle_code2 = form.getString("vehicle_code2");
String material_id = form.getString("material_id");
task.put("task_id", taskdtl_id);
task.put("task_name", task_name);
task.put("task_id", IdUtil.getStringId());
task.put("task_name", reqestPram.getString("task_name"));
task.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
task.put("task_type", type);
task.put("task_status", TaskStatusEnum.CREATED.getCode());
task.put("point_code1", start_point_code);
task.put("point_code2", next_point_code);
task.put("vehicle_code2", vehicle_code2);
task.put("vehicle_code", vehicle_code);
task.put("material_id", material_id);
task.put("point_code1", reqestPram.getString("point_code1"));
task.put("point_code2", reqestPram.getString("point_code2"));
task.put("vehicle_code2", reqestPram.getString("vehicle_code2"));
task.put("vehicle_code", reqestPram.getString("vehicle_code"));
task.put("material_id", reqestPram.getString("material_id"));
task.put("handle_class", this.getClass().getName());
task.put("finished_type", "1");
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("update_id", currentUserId);
task.put("update_name", SecurityUtils.getCurrentNickName());
task.put("create_time", DateUtil.now());
task.put("update_time", DateUtil.now());
task.put("priority", "1");}
task.put("priority", "1");
}
return task;
}
@Override
public void cancel(String taskId) {
log.info(OPT_NAME+"cancel taskID:{}",taskId);

View File

@@ -12,6 +12,7 @@ import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.jetbrains.annotations.NotNull;
import org.nl.common.ConstantParam;
import org.nl.common.enums.AcsTaskEnum;
import org.nl.common.enums.InterfaceLogType;
@@ -97,51 +98,26 @@ public class WashMachineryTask extends AbstractAcsTask {
@Override
@SneakyThrows
public String createTask(JSONObject param) {
WQLObject pointTab = WQLObject.getWQLObject("SCH_BASE_Point");
WQLObject materialTab = WQLObject.getWQLObject("md_me_materialbase");
String pointCode = param.getString("device_code");
JSONObject device = WQL.getWO("sch_point").addParamMap(MapOf.of("flag", "8", "point_code", pointCode)).process().uniqueResult(0);
//清洗机设备
JSONObject device = WQL.getWO("sch_point").addParamMap(MapOf.of("flag", "8", "point_code", param.getString("device_code"))).process().uniqueResult(0);
//is_used = '0'人工下料:入料仓上线inupperlimit_qty;is_artificial人工
Double inupperlimitQty = device.getDouble("inupperlimit_qty");
String deviceCode = device.getString("device_code");
String artificial = device.getString("is_artificial").equals("1")?"0":"1";
JSONArray points = pointTab.query("region_code = 'SKQX' and material_id is not null and point_status = '2' and is_used = '"+artificial+"' order by vehicle_qty desc").getResultJSONArray(0);
JSONArray points = WQLObject.getWQLObject("SCH_BASE_Point").query("region_code = "+ConstantParam.SK_REGION+" and material_id is not null and point_status = '2' and is_used = '"+(device.getString("is_artificial").equals("1")?"0":"1")+"' order by vehicle_qty desc").getResultJSONArray(0);
//查询深坑相同物料类型的点位:深坑单位:重量
if (points.size()>0){
Map<String, List<Object>> materialCollent = points.stream().collect(Collectors.groupingBy(o -> ((JSONObject) o).getString("material_id")));
//查询清洗设备最大重量
Resource resource = loader.getResource("classpath:/groovyFile.groovy");
Script script = groovyShell.parse(resource.getFile());
ArrayList<JSONObject> result = (ArrayList)script.invokeMethod("getPoints", new Object[]{points, materialCollent, inupperlimitQty});
//确认acs参数 创建工单下发acs
if (!CollectionUtils.isEmpty(result)){
String material_id = result.get(0).getString("material_id");
JSONObject material = materialTab.query("material_id = '" + material_id + "' and is_delete = 0").uniqueResult(0);
Double qty = result.stream().mapToDouble(value -> value.getDouble("qty")).sum();
PdmProduceWashorder washorder = new PdmProduceWashorder();
washorder.setWorkorderId(IdUtil.getStringId());
washorder.setWorkorderCode(IdUtil.getStringId());
washorder.setIsNeedmove("0");
washorder.setDeviceCode(deviceCode);
washorder.setMaterialWeight(new BigDecimal(qty));
washorder.setMaterialCode(material.getString("material_code"));
washorder.setCreateTime(DateUtil.now());
washorder.setInDevices(result.stream().map(a->a.getString("point_code")).collect(Collectors.joining(",")));
washorder.setProductArea(device.getString("product_area"));
washorder.setCreateId("1");
washorder.setCreateName("acs");
washorder.setStatus(StatusEnum.TASK_CREATE.getCode());
ArrayList<JSONObject> SKPoints = getDistributeSKPoint(device, points);
//确认acs参数 创建工单下发acs
if (!CollectionUtils.isEmpty(SKPoints)){
PdmProduceWashorder washorder = packageParam(device, SKPoints);
//下发"
JSONArray request = new JSONArray();
JSONObject jsonObject = new JSONObject(MapOf.of("workorder_id", washorder.getWorkorderId()
request.add(new JSONObject(MapOf.of("workorder_id", washorder.getWorkorderId()
, "workorder_code", washorder.getWorkorderCode()
, "qty", washorder.getMaterialWeight()
, "material_code", washorder.getMaterialCode()
, "device_code", pointCode
, "device_code", param.getString("device_code")
, "is_needmove", "0"
, "in_devices", washorder.getInDevices()
));
request.add(jsonObject);
)));
Map<String, Object> response = wmsToAcsService.order(request);
if (response.get("status").equals(HttpStatus.BAD_REQUEST)){
washorder.setErrorInfo((String) response.get("message"));
@@ -154,6 +130,38 @@ public class WashMachineryTask extends AbstractAcsTask {
return null;
}
private ArrayList<JSONObject> getDistributeSKPoint(JSONObject device, JSONArray points) throws IOException {
Map<String, List<Object>> materialCollent = points.stream()
.collect(Collectors.groupingBy(o -> ((JSONObject) o)
.getString("material_id")));
//查询清洗设备最大重量
Resource resource = loader.getResource("classpath:/groovyFile.groovy");
Script script = groovyShell.parse(resource.getFile());
ArrayList<JSONObject> result = (ArrayList)script.invokeMethod("getPoints", new Object[]{points, materialCollent, device.getDouble("inupperlimit_qty")});
return result;
}
@NotNull
private PdmProduceWashorder packageParam(JSONObject device, ArrayList<JSONObject> SKPoints) {
JSONObject material = WQLObject.getWQLObject("md_me_materialbase").query("material_id = '" + SKPoints.get(0).getString("material_id") + "' and is_delete = 0").uniqueResult(0);
PdmProduceWashorder washorder = new PdmProduceWashorder();
washorder.setWorkorderId(IdUtil.getStringId());
washorder.setWorkorderCode(IdUtil.getStringId());
washorder.setIsNeedmove("0");
washorder.setDeviceCode(device.getString("device_code"));
washorder.setMaterialWeight(new BigDecimal(SKPoints.stream().mapToDouble(value -> value.getDouble("qty")).sum()));
washorder.setMaterialCode(material.getString("material_code"));
washorder.setCreateTime(DateUtil.now());
washorder.setInDevices(SKPoints.stream().map(a->a.getString("point_code")).collect(Collectors.joining(",")));
washorder.setProductArea(device.getString("product_area"));
washorder.setCreateId("1");
washorder.setCreateName("acs");
washorder.setStatus(StatusEnum.TASK_CREATE.getCode());
return washorder;
}
@Override
public void cancel(String taskId) {

View File

@@ -96,7 +96,7 @@
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
WHERE sch_base_point.lock_type = '0' and is_used = '1'
OPTION 输入.region_code <> ""
sch_base_point.region_code = 输入.region_code
ENDOPTION
@@ -167,7 +167,7 @@
sch_base_point.*
from sch_base_point
left JOIN sch_base_task ON sch_base_point.point_code = point_code2 and task_status < 7
where 1=1
where sch_base_point.lock_type = '0' and is_used = '1'
OPTION 输入.region_code <> ""
sch_base_point.region_code = 输入.region_code
ENDOPTION

View File

@@ -14,7 +14,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.enums.AcsTaskEnum;
import org.nl.common.enums.StatusEnum;
import org.nl.common.handler.LockProcess;
import org.nl.common.utils.MapOf;
import org.nl.common.utils.RedissonUtils;
import org.nl.common.utils.SecurityUtils;
@@ -25,6 +24,7 @@ import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.modules.wql.util.WqlUtil;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.nl.wms.basedata.master.service.StoragevehicleinfoService;
import org.nl.wms.basedata.st.service.StorattrService;
import org.nl.wms.basedata.st.service.StructattrService;
import org.nl.wms.basedata.st.service.dto.StructattrDto;
@@ -38,9 +38,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.*;
/**
* PC端出入库新增
@@ -58,6 +56,8 @@ public class ProductInServiceImpl implements ProductInService {
private final StorPublicService storPublicService;
private final StoragevehicleinfoService storagevehicleinfoService;
@Override
public Map<String, Object> pageQuery(Map whereJson, Pageable page) {
@@ -67,6 +67,7 @@ public class ProductInServiceImpl implements ProductInService {
String begin_time = MapUtil.getStr(whereJson, "begin_time");
String end_time = MapUtil.getStr(whereJson, "end_time");
String bill_status = MapUtil.getStr(whereJson, "bill_status");
String bill_type = MapUtil.getStr(whereJson, "bill_type");
JSONObject map = new JSONObject();
map.put("flag", "1");
@@ -74,7 +75,7 @@ public class ProductInServiceImpl implements ProductInService {
map.put("begin_time",begin_time);
map.put("end_time",end_time);
map.put("bill_status",bill_status);
map.put("bill_type", "0001");
map.put("bill_type", bill_type);
if (ObjectUtil.isNotEmpty(bill_code)) map.put("bill_code","%"+bill_code+"%");
JSONObject jo = WQL.getWO("QST_IVT_PRODUCTIN_01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "create_time desc");
@@ -505,38 +506,23 @@ public class ProductInServiceImpl implements ProductInService {
@Override
public void unDivStruct(JSONObject jo) {
WQLObject dis_wql = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
WQLObject point_table = WQLObject.getWQLObject("SCH_BASE_Point");
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
WQLObject structattrTable = WQLObject.getWQLObject("st_ivt_structattr");
WQLObject vehicleTable = WQLObject.getWQLObject("md_pb_storagevehicleinfo");
JSONArray rows = jo.getJSONArray("tableMater");
JSONObject whereJson = rows.getJSONObject(0);
JSONObject iosInvDisInfo = jo.getJSONArray("tableMater").getJSONObject(0);
String StructCodes = getReleaseStructByVehicleLimit(structattrTable, vehicleTable, iosInvDisInfo);
//解锁原货位点位
JSONObject jsonPoint1 = point_table.query("point_code = '" + whereJson.getString("struct_code") + "'").uniqueResult(0);
jsonPoint1.put("lock_type", StatusEnum.LOCK_OFF.getCode());
point_table.update(jsonPoint1);
// 判断此物料是否超长
JSONObject jsonMater = materTab.query("material_id = '" + whereJson.getString("material_id") + "'").uniqueResult(0);
String length_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MATERIAL_LENGTH_UP").getValue();
double material_length = jsonMater.getDoubleValue("length");
double material_length_up = Double.valueOf(length_up);
if (material_length > material_length_up) {
// 超长则解锁对应点位
JSONObject jsonPoint2 = point_table.query("point_id = '" + jsonPoint1.getString("control_point") + "'").uniqueResult(0);
jsonPoint2.put("lock_type", StatusEnum.LOCK_OFF.getCode());
point_table.update(jsonPoint2);
}
structattrTable.update(MapOf.of("lock_type", StatusEnum.LOCK_OFF.getCode()),"struct_code in ('"+StructCodes+"')");
//减去原货位的待入数
JSONArray dis_rows = dis_wql.query("struct_code = '" + whereJson.get("struct_code") + "' AND work_status < '99'").getResultJSONArray(0);
JSONArray dis_rows = dis_wql.query("struct_code = '" + iosInvDisInfo.get("struct_code") + "' AND work_status < '99'").getResultJSONArray(0);
if (dis_rows.size() <= 0) {
throw new BadRequestException("数据参数有误!");
}
JSONObject mst_jo = WQLObject.getWQLObject("ST_IVT_IOStorInv").query("iostorinv_id = '" + dis_rows.getJSONObject(0).getString("iostorinv_id") + "'").uniqueResult(0);
JSONObject mst_jo = WQLObject.getWQLObject("ST_IVT_IOStorInv").query("iostorinv_id" +
" = '" + dis_rows.getJSONObject(0).getString("iostorinv_id") + "'").uniqueResult(0);
for (int i = 0; i < dis_rows.size(); i++) {
JSONObject i_form = new JSONObject();
JSONObject dis_row = dis_rows.getJSONObject(i);
@@ -562,12 +548,12 @@ public class ProductInServiceImpl implements ProductInService {
map.put("struct_code", "");
map.put("struct_name", "");
map.put("work_status", "00");
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(map, "iostorinvdtl_id = '" + whereJson.getString("iostorinvdtl_id") + "'");
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(map, "iostorinvdtl_id = '" + iosInvDisInfo.getString("iostorinvdtl_id") + "'");
//修改明细状态
HashMap<String, String> dtl_map = new HashMap<>();
dtl_map.put("bill_status", "10");
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").update(dtl_map, "iostorinvdtl_id = '" + whereJson.get("iostorinvdtl_id") + "'");
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").update(dtl_map, "iostorinvdtl_id = '" + iosInvDisInfo.get("iostorinvdtl_id") + "'");
//更新主表状态
JSONArray dtl_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").query("iostorinv_id = '" + mst_jo.get("iostorinv_id") + "' AND bill_status IN ('20','30')").getResultJSONArray(0);
@@ -579,6 +565,17 @@ public class ProductInServiceImpl implements ProductInService {
WQLObject.getWQLObject("ST_IVT_IOStorInv").update(mst_jo);
}
private String getReleaseStructByVehicleLimit(WQLObject structattrTable, WQLObject vehicleTable, JSONObject iosInvDisInfo) {
String StructCode = iosInvDisInfo.getString("struct_code");
if (vehicleTable.query("storagevehicle_code = '" + iosInvDisInfo.getString("storagevehicle_code") + "'").uniqueResult(0).getString("occupystruct_qty").equals(StatusEnum.OVERSTRUCT_STANDARD.getCode())){
String controlStruct = structattrTable.query("struct_code = '" + StructCode + "'").uniqueResult(0).getString("control_point");
if (!StringUtils.isEmpty(controlStruct)){
StructCode = StructCode +"','"+controlStruct;
}
}
return StructCode;
}
@Transactional(rollbackFor = Exception.class)
@Override
public void divPoint(JSONObject whereJson) {
@@ -752,20 +749,20 @@ public class ProductInServiceImpl implements ProductInService {
@Override
@Transactional(rollbackFor = Exception.class)
public void confirmvehicle(JSONObject whereJson) {
public void confirmvehicle(JSONObject form) {
WQLObject vehicleTab = WQLObject.getWQLObject("md_pb_storagevehicleinfo");
WQLObject vehicleMaterialTab = WQLObject.getWQLObject("md_pb_storagevehicleext");
WQLObject disTab = WQLObject.getWQLObject("st_ivt_iostorinvdis");
String storagevehicle_code = whereJson.getString("storagevehicle_code");
// 校验载具是否存在
JSONObject jsonVehicle = vehicleTab.query("storagevehicle_code = '" + storagevehicle_code + "' and is_delete = '0' and is_used = '1'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonVehicle)) throw new BadRequestException("载具不存在");
JSONArray vehicleMaterial = vehicleMaterialTab.query("storagevehicle_code = '" + storagevehicle_code + "' and material_id IS not NULL ").getResultJSONArray(0);
if (vehicleMaterial.size()>0){
throw new BadRequestException("载具已被占用");
JSONObject jsonVehicle;
if (!StringUtils.isEmpty(form.getString("storagevehicle_code"))){
jsonVehicle = vehicleTab.query("storagevehicle_code = '" + form.getString("storagevehicle_code") + "' and is_delete = '0' and is_used = '1'").uniqueResult(0);
checkVehicle(form, jsonVehicle); // 校验载具是否存在
}else {
jsonVehicle = storagevehicleinfoService.create(MapOf.of("overstruct_type", form.getString("overstruct_type"), "storagevehicle_code", UUID.randomUUID().toString(), "storagevehicle_type", "01","num",1)).getJSONObject(0);
}
// 更新分配明细载具号
JSONObject jsonDis = disTab.query("iostorinvdis_id = '" + whereJson.getString("iostorinvdis_id") + "'").uniqueResult(0);
JSONObject jsonDis = disTab.query("iostorinvdis_id = '" + form.getString("iostorinvdis_id") + "'").uniqueResult(0);
// 校验此明细是否已经分配
if (ObjectUtil.isNotEmpty(jsonDis.getString("struct_id"))) {
throw new BadRequestException("此明细已分配不可组盘!");
@@ -775,6 +772,27 @@ public class ProductInServiceImpl implements ProductInService {
disTab.update(jsonDis);
}
private void checkVehicle(JSONObject form, JSONObject jsonVehicle) {
WQLObject vehicleMaterialTab = WQLObject.getWQLObject("md_pb_storagevehicleext");
if (ObjectUtil.isEmpty(jsonVehicle)) {
throw new BadRequestException("载具不存在");
}
JSONArray vehicleMaterial = vehicleMaterialTab.query("storagevehicle_code = '" + form.getString("storagevehicle_code") + "' and material_id IS not NULL ").getResultJSONArray(0);
if (vehicleMaterial.size()>0){
throw new BadRequestException("载具已被占用");
}
}
public static void main(String[] args) {
ArrayList<Object> list = new ArrayList<>();
list.add("a");
list.add("b");
list.add("c");
for (Object o : list) {
list.remove("a");
}
}
@Override
public JSONArray getDisTask(JSONObject whereJson) {
//查询该明细下的所有入库分配明细

View File

@@ -125,7 +125,8 @@
mater.material_code,
mater.material_name,
mater.material_spec,
point.point_code
point.point_code,
'' as overstruct_type
FROM
ST_IVT_IOStorInvDis dis
LEFT JOIN sch_base_point point ON point.point_id = dis.point_id

View File

@@ -49,7 +49,7 @@
ivt.*
FROM
st_ivt_structivt ivt
LEFT JOIN sch_base_point point ON point.point_id = ivt.struct_id
LEFT JOIN st_ivt_structattr point ON point.struct_id = ivt.struct_id
WHERE
1=1
@@ -109,4 +109,4 @@
ENDSELECT
ENDQUERY
ENDIF
ENDIF