明天生产
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package org.nl.acs.device_driver.driver;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @version 1.0
|
||||
* @date 2023年02月01日 11:21
|
||||
* @desc desc
|
||||
*/
|
||||
public class ItemValue {
|
||||
private String item_code;
|
||||
private Object item_value;
|
||||
|
||||
public ItemValue() {
|
||||
}
|
||||
|
||||
public ItemValue(String item_code, Object item_value) {
|
||||
this.item_code = item_code;
|
||||
this.item_value = item_value;
|
||||
}
|
||||
|
||||
public String getItem_code() {
|
||||
return this.item_code;
|
||||
}
|
||||
|
||||
public void setItem_code(String item_code) {
|
||||
this.item_code = item_code;
|
||||
}
|
||||
|
||||
public Object getItem_value() {
|
||||
return this.item_value;
|
||||
}
|
||||
|
||||
public void setItem_value(Object item_value) {
|
||||
this.item_value = item_value;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.order.service.ProduceshiftorderService;
|
||||
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
@@ -55,6 +56,8 @@ public class HfStationDeviceDriver extends AbstractOpcDeviceDriver implements De
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
||||
@Autowired
|
||||
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean("produceshiftorderServiceImpl");
|
||||
@Autowired
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
|
||||
|
||||
String device_code;
|
||||
@@ -488,6 +491,10 @@ public class HfStationDeviceDriver extends AbstractOpcDeviceDriver implements De
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_call_material_time);
|
||||
return false;
|
||||
} else {
|
||||
int status = ((HfStationDeviceDriver) deviceAppService.findDeviceByCode("GT03").getDeviceDriver()).getStatus();
|
||||
if (status != 2) {
|
||||
return false;
|
||||
}
|
||||
logServer.deviceInfo("acs申请任务", this.getDevice_code(), "开始申请压机叫料任务!");
|
||||
this.instruction_call_material_time = date;
|
||||
JSONObject json = new JSONObject();
|
||||
@@ -522,6 +529,7 @@ public class HfStationDeviceDriver extends AbstractOpcDeviceDriver implements De
|
||||
json.put("device_code", device_code);
|
||||
json.put("create_mode", "2");
|
||||
json.put("is_auto_issue", "0");
|
||||
json.put("to_gt01", status == 4);
|
||||
json.put("type", "4");
|
||||
JSONObject resp = acsToWmsService.apply(json);
|
||||
if (StrUtil.equals(resp.getString("status"), "200")) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.nl.acs.ext.wms.rest;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -69,12 +68,20 @@ public class WmsToAcsController {
|
||||
return new ResponseEntity<>(wmstoacsService.forceFinishFromWms(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/queryGT04Status")
|
||||
@Log("查询GT04状态")
|
||||
@ApiOperation("查询GT04状态")
|
||||
@PostMapping("/queryGT01Status")
|
||||
@Log("查询GT01状态")
|
||||
@ApiOperation("查询GT01状态")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> queryGT04Status() throws Exception {
|
||||
return new ResponseEntity<>(wmstoacsService.queryGT04Status(), HttpStatus.OK);
|
||||
public ResponseEntity<Object> queryGT01Status() throws Exception {
|
||||
return new ResponseEntity<>(wmstoacsService.queryGT01Status(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/queryGT03Status")
|
||||
@Log("查询输送线状态")
|
||||
@ApiOperation("查询输送线状态")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> queryGT03Status() {
|
||||
return new ResponseEntity<>(wmstoacsService.queryGT03Status(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ package org.nl.acs.ext.wms.service;
|
||||
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface WmsToAcsService {
|
||||
@@ -41,5 +39,7 @@ public interface WmsToAcsService {
|
||||
Map<String, Object> forceFinishFromWms(String jsonObject) throws Exception;
|
||||
|
||||
|
||||
Map<String, Object> queryGT04Status();
|
||||
Map<String, Object> queryGT01Status();
|
||||
|
||||
Map<String, Object> queryGT03Status();
|
||||
}
|
||||
|
||||
@@ -364,10 +364,18 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryGT04Status() {
|
||||
HfStationDeviceDriver gt04 = (HfStationDeviceDriver) deviceAppService.findDeviceByCode("GT04").getDeviceDriver();
|
||||
public Map<String, Object> queryGT01Status() {
|
||||
HfStationDeviceDriver gt01 = (HfStationDeviceDriver) deviceAppService.findDeviceByCode("GT01").getDeviceDriver();
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("GT04", gt04.getMode() != 0 && gt04.getMove() == 0);
|
||||
result.put("GT01", gt01.getMode() != 0 && gt01.getMove() == 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryGT03Status() {
|
||||
HfStationDeviceDriver gt03 = (HfStationDeviceDriver) deviceAppService.findDeviceByCode("GT03").getDeviceDriver();
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("GT03", gt03.getMode() != 0 && gt03.getStatus() == 2);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,28 @@ import cn.hutool.core.util.NumberUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.*;
|
||||
import org.nl.acs.device_driver.driver.ItemValue;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||
import org.openscada.opc.lib.da.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@Slf4j
|
||||
public class OpcUtl {
|
||||
private static int timeout = 180000;
|
||||
private static int timeout = 1*60*1000;
|
||||
private static String key = "rpc.socketTimeout";
|
||||
public static int successNum=0;
|
||||
public static int errNum=0;
|
||||
|
||||
static {
|
||||
checkTimeout();
|
||||
}
|
||||
|
||||
public static void checkTimeout() {
|
||||
if (Integer.getInteger(key, 0).intValue() != timeout) {
|
||||
@@ -26,9 +35,20 @@ public class OpcUtl {
|
||||
}
|
||||
|
||||
|
||||
public static void writeValue(Group group, WriteRequest... requests) {
|
||||
public static void writeValue(Group group, WriteRequest... requests) throws WDKException {
|
||||
try {
|
||||
Map e = group.write(requests);
|
||||
Map<Item, Integer> e=null;
|
||||
try{
|
||||
e=group.write(requests);
|
||||
group.write(requests);
|
||||
}catch (Exception e1){
|
||||
try{
|
||||
e= group.write(requests);
|
||||
}catch (Exception e2){
|
||||
e= group.write(requests);
|
||||
}
|
||||
}
|
||||
|
||||
boolean is_success = true;
|
||||
StringBuilder message = new StringBuilder();
|
||||
Iterator arg4 = e.keySet().iterator();
|
||||
@@ -50,9 +70,60 @@ public class OpcUtl {
|
||||
|
||||
if (!is_success) {
|
||||
// throw new BusinessException(message.toString());
|
||||
System.out.println("下发信号失败:"+message.toString());
|
||||
System.out.println("下发信号失败原因:"+message.toString());
|
||||
log.info("下发信号失败:"+message.toString());
|
||||
throw new WDKException(message.toString());
|
||||
}
|
||||
} catch (JIException arg7) {
|
||||
// throw new BusinessException(arg7);
|
||||
log.info("下发信号失败:"+arg7.getMessage());
|
||||
System.out.println("下发信号失败原因:"+arg7.getMessage());
|
||||
throw new WDKException(arg7);
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeValue(Group group, ItemValue... values) throws WDKException {
|
||||
try {
|
||||
if (values != null && values.length > 0) {
|
||||
List<WriteRequest> ws = new ArrayList();
|
||||
ItemValue[] var3 = values;
|
||||
int var4 = values.length;
|
||||
|
||||
for(int var5 = 0; var5 < var4; ++var5) {
|
||||
ItemValue value = var3[var5];
|
||||
Item item = group.addItem(value.getItem_code());
|
||||
ws.add(new WriteRequest(item, getVariant(value.getItem_value())));
|
||||
}
|
||||
|
||||
writeValue(group, (WriteRequest[])ws.toArray(new WriteRequest[0]));
|
||||
}
|
||||
|
||||
} catch (AddFailedException | JIException var8) {
|
||||
throw new WDKException(var8);
|
||||
}
|
||||
}
|
||||
|
||||
public static JIVariant getVariant(Object object) {
|
||||
if (object instanceof Integer) {
|
||||
return getIntegerVariant((Integer)object);
|
||||
} else if (object instanceof String) {
|
||||
return getStringVariant((String)object);
|
||||
} else if (object instanceof byte[]) {
|
||||
return getByteArrayVariant((byte[])((byte[])object));
|
||||
} else if (object instanceof Byte[]) {
|
||||
return getByteArrayVariant((Byte[])((Byte[])object));
|
||||
} else if (object instanceof Boolean) {
|
||||
return new JIVariant((Boolean)object);
|
||||
} else if (object instanceof int[]) {
|
||||
return getByteArrayVariantxx((int[])((int[])object));
|
||||
} else if (object instanceof Integer[]) {
|
||||
JIArray array = new JIArray((Integer)object, false);
|
||||
JIVariant value = new JIVariant(array);
|
||||
return value;
|
||||
} else if (object instanceof JIVariant) {
|
||||
return (JIVariant)object;
|
||||
} else {
|
||||
throw new WDKException("未实现目前支持是int,string,byte[]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +131,7 @@ public class OpcUtl {
|
||||
if (NumberUtil.compare(itemState.getQuality(), Short.valueOf(QualityTypeValue.OPC_QUALITY_GOOD)) != 0) {
|
||||
if (item != null) {
|
||||
log.debug("value is not good {} : {}", item.getId(), itemState.getQuality());
|
||||
// throw new WDKException("值不健康进行重连!");
|
||||
} else {
|
||||
log.debug("value is not good {}", itemState.getQuality());
|
||||
}
|
||||
@@ -150,12 +222,27 @@ public class OpcUtl {
|
||||
server = new Server(getConnection(host, clsid, user, password, domain),
|
||||
Executors.newSingleThreadScheduledExecutor());
|
||||
server.connect();
|
||||
successNum++;
|
||||
return server;
|
||||
} catch (Exception e) {
|
||||
throw new WDKException(e);
|
||||
errNum++;
|
||||
throw new WDKException(e.getMessage());
|
||||
}finally{
|
||||
System.out.println("successNum:"+successNum);
|
||||
System.out.println("errNum:"+errNum);
|
||||
System.out.println(11);
|
||||
}
|
||||
}
|
||||
|
||||
public static Server getAutoServer(String host, String clsid, String user, String password, String domain) throws WDKException {
|
||||
checkTimeout();
|
||||
Server server = null;
|
||||
server = new Server(getConnection(host, clsid, user, password, domain), Executors.newSingleThreadScheduledExecutor());
|
||||
AutoReconnectController autoReconnectController = new AutoReconnectController(server);
|
||||
autoReconnectController.connect();
|
||||
return server;
|
||||
}
|
||||
|
||||
public static ConnectionInformation getConnection(String host, String clsid, String user, String password,
|
||||
String domain) {
|
||||
ConnectionInformation connection = new ConnectionInformation();
|
||||
@@ -167,6 +254,44 @@ public class OpcUtl {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public static JIVariant getByteArrayVariantxx(int[] bytes) {
|
||||
Integer[] byte_Data = new Integer[bytes.length];
|
||||
|
||||
for(int i = 0; i < bytes.length; ++i) {
|
||||
byte_Data[i] = bytes[i];
|
||||
}
|
||||
|
||||
JIArray array = new JIArray(byte_Data, false);
|
||||
JIVariant value = new JIVariant(array);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static JIVariant getIntegerVariant(Integer integer) {
|
||||
return new JIVariant(integer);
|
||||
}
|
||||
|
||||
public static JIVariant getStringVariant(String string) {
|
||||
return new JIVariant(string);
|
||||
}
|
||||
|
||||
public static JIVariant getByteArrayVariant(byte[] bytes) {
|
||||
Byte[] byte_Data = new Byte[bytes.length];
|
||||
|
||||
for(int i = 0; i < bytes.length; ++i) {
|
||||
byte_Data[i] = bytes[i];
|
||||
}
|
||||
|
||||
JIArray array = new JIArray(byte_Data, false);
|
||||
JIVariant value = new JIVariant(array);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static JIVariant getByteArrayVariant(Byte[] bytes) {
|
||||
JIArray array = new JIArray(bytes, false);
|
||||
JIVariant value = new JIVariant(array);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String read(String item) throws Exception {
|
||||
System.out.println(item);
|
||||
Server server = getServer("192.168.81.251", "7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729", "administrator", "Huawei@123", "");
|
||||
@@ -180,18 +305,5 @@ public class OpcUtl {
|
||||
String data = OpcUtl.getValue(byteItem, itemState) + "";
|
||||
return data;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Server server = getServer("192.168.81.251", "7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729", "administrator", "Huawei@123", "");
|
||||
String byteItemString = "RD1.RD1.1001.mode";
|
||||
Group group = server.addGroup();
|
||||
Item byteItem = group.addItem(byteItemString);
|
||||
ItemState itemState = null;
|
||||
JIVariant value = null;
|
||||
System.out.println(byteItem.getId());
|
||||
itemState = byteItem.read(true);
|
||||
System.out.println(itemState.getQuality());
|
||||
System.out.println(getValue(byteItem, itemState));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,10 +112,10 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
|
||||
if (ObjectUtil.isEmpty(device)) {
|
||||
throw new BadRequestException("未找到对应设备:" + dto.getDevice_code());
|
||||
}
|
||||
JSONArray resultJSONArray = wo.query("is_deleted = '0' and order_status in ('0', '1') and device_code = '" + dto.getDevice_code() + "'").getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(resultJSONArray)) {
|
||||
throw new BadRequestException("该设备已存在未完成工单,不能下发");
|
||||
}
|
||||
// JSONArray resultJSONArray = wo.query("is_deleted = '0' and order_status in ('0', '1') and device_code = '" + dto.getDevice_code() + "'").getResultJSONArray(0);
|
||||
// if (ObjectUtil.isNotEmpty(resultJSONArray)) {
|
||||
// throw new BadRequestException("该设备已存在未完成工单,不能下发");
|
||||
// }
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
dto.setOrder_id(IdUtil.simpleUUID());
|
||||
@@ -137,9 +137,19 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
|
||||
|
||||
if (device.getDeviceDriver() instanceof HfStationDeviceDriver) {
|
||||
hfStationDeviceDriver = (HfStationDeviceDriver) device.getDeviceDriver();
|
||||
if (StrUtil.isNotBlank(hfStationDeviceDriver.getOrder())) {
|
||||
throw new BadRequestException("设备正在生产");
|
||||
}
|
||||
if (hfStationDeviceDriver.getStatus() != 2) {
|
||||
throw new BadRequestException("设备状态不为自动");
|
||||
}
|
||||
hfStationDeviceDriver.writing("to_order", dto.getOrder_code());
|
||||
hfStationDeviceDriver.writing("to_order_num", String.valueOf(dto.getQty()));
|
||||
hfStationDeviceDriver.writing("to_product_number", dto.getMaterial_code());
|
||||
hfStationDeviceDriver.writing("to_order", dto.getOrder_code());
|
||||
hfStationDeviceDriver.writing("to_order_num", String.valueOf(dto.getQty()));
|
||||
hfStationDeviceDriver.writing("to_product_number", dto.getMaterial_code());
|
||||
hfStationDeviceDriver.writing("to_command", "3");
|
||||
hfStationDeviceDriver.writing("to_command", "3");
|
||||
}
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
@@ -259,13 +269,13 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
|
||||
map1.put("update_time", now);
|
||||
WQLObject wo1 = WQLObject.getWQLObject("acs_produceshiftorder");
|
||||
wo1.update(map1);
|
||||
String device_code = param.getString("device_code");
|
||||
HfStationDeviceDriver hfStationDeviceDriver;
|
||||
Device device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (device.getDeviceDriver() instanceof HfStationDeviceDriver) {
|
||||
hfStationDeviceDriver = (HfStationDeviceDriver) device.getDeviceDriver();
|
||||
hfStationDeviceDriver.writing("to_command", "5");
|
||||
}
|
||||
// String device_code = param.getString("device_code");
|
||||
// HfStationDeviceDriver hfStationDeviceDriver;
|
||||
// Device device = deviceAppService.findDeviceByCode(device_code);
|
||||
// if (device.getDeviceDriver() instanceof HfStationDeviceDriver) {
|
||||
// hfStationDeviceDriver = (HfStationDeviceDriver) device.getDeviceDriver();
|
||||
// hfStationDeviceDriver.writing("to_command", "5");
|
||||
// }
|
||||
Iterator<ProduceshiftorderDto> iterator = order.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ProduceshiftorderDto instruction = iterator.next();
|
||||
@@ -287,13 +297,20 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
|
||||
if (device.getDeviceDriver() instanceof HfStationDeviceDriver) {
|
||||
hfStationDeviceDriver = (HfStationDeviceDriver) device.getDeviceDriver();
|
||||
String order = hfStationDeviceDriver.getOrder();
|
||||
if (StrUtil.isNotEmpty(order)){
|
||||
throw new BadRequestException("该设备已下发工单信息!");
|
||||
if (StrUtil.isNotBlank(order)){
|
||||
throw new BadRequestException("设备正在生产");
|
||||
}
|
||||
hfStationDeviceDriver = (HfStationDeviceDriver) device.getDeviceDriver();
|
||||
if (hfStationDeviceDriver.getStatus() != 2) {
|
||||
throw new BadRequestException("设备状态不为自动");
|
||||
}
|
||||
hfStationDeviceDriver.writing("to_order", produceshiftorderDto.getOrder_code());
|
||||
hfStationDeviceDriver.writing("to_order_num", String.valueOf(produceshiftorderDto.getQty()));
|
||||
hfStationDeviceDriver.writing("to_product_number", produceshiftorderDto.getMaterial_code());
|
||||
hfStationDeviceDriver.writing("to_order", produceshiftorderDto.getOrder_code());
|
||||
hfStationDeviceDriver.writing("to_order_num", String.valueOf(produceshiftorderDto.getQty()));
|
||||
hfStationDeviceDriver.writing("to_product_number", produceshiftorderDto.getMaterial_code());
|
||||
hfStationDeviceDriver.writing("to_command", "3");
|
||||
hfStationDeviceDriver.writing("to_command", "3");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author zhouz
|
||||
@@ -211,6 +212,12 @@ public class MaterialbaseServiceImpl implements MaterialbaseService {
|
||||
JSONArray data = response_body.getJSONArray("data");
|
||||
// WQLObject unit_table = WQLObject.getWQLObject("md_pb_measureunit");
|
||||
WQLObject material_table = WQLObject.getWQLObject("md_me_materialbase");
|
||||
List<Object> material_codes = material_table
|
||||
.query()
|
||||
.getResultJSONArray(0)
|
||||
.stream()
|
||||
.map(o -> ((JSONObject) o).get("material_code"))
|
||||
.collect(Collectors.toList());
|
||||
Long user_id = SecurityUtils.getCurrentUserId();
|
||||
String nick_name = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
@@ -242,10 +249,7 @@ public class MaterialbaseServiceImpl implements MaterialbaseService {
|
||||
|
||||
// 查询是否存在这个物料
|
||||
String material_code = material.getString("material_code");
|
||||
JSONObject existMaterial = material_table
|
||||
.query("material_code = '" + material_code + "'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(existMaterial)) {
|
||||
if (material_codes.contains(material_code)) {
|
||||
// 如果不存在则添加
|
||||
material.put("material_id", IdUtil.getSnowflake(1L, 1L));
|
||||
material.put("is_used", "1");
|
||||
@@ -253,14 +257,15 @@ public class MaterialbaseServiceImpl implements MaterialbaseService {
|
||||
material.put("create_name", nick_name);
|
||||
material.put("create_time", now);
|
||||
material_table.insert(material);
|
||||
material_codes.add(material_code);
|
||||
} else {
|
||||
// 如果存在则修改
|
||||
existMaterial.put("material_name", material.getString("material_name"));
|
||||
material.put("material_name", material.getString("material_name"));
|
||||
// existMaterial.put("unit_code", unit_code);
|
||||
existMaterial.put("update_optid", user_id);
|
||||
existMaterial.put("update_optname", nick_name);
|
||||
existMaterial.put("update_time", now);
|
||||
material_table.update(existMaterial);
|
||||
material.put("update_optid", user_id);
|
||||
material.put("update_optname", nick_name);
|
||||
material.put("update_time", now);
|
||||
material_table.update(material, "material_code = '" + material_code + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,5 +58,7 @@ public interface WmsToAcsService {
|
||||
*/
|
||||
JSONObject getPointStatus(JSONArray whereJson);
|
||||
|
||||
JSONObject queryGT04Status();
|
||||
JSONObject queryGT01Status();
|
||||
|
||||
JSONObject queryGT03Status();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
@@ -256,7 +257,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
String point_code = whereJson.getString("device_code");
|
||||
String create_mode = whereJson.getString("create_mode");
|
||||
String is_auto_issue = whereJson.getString("is_auto_issue");
|
||||
StringBuilder barcode = new StringBuilder(whereJson.getString("barcode"));
|
||||
StringBuilder barcode = new StringBuilder(StrUtil.isBlank(whereJson.getString("barcode")) ? "" : whereJson.getString("barcode"));
|
||||
|
||||
if (ObjectUtil.isEmpty(type)) throw new BadRequestException("类型不能为空");
|
||||
if (ObjectUtil.isEmpty(point_code)) throw new BadRequestException("点位不能为空");
|
||||
@@ -314,6 +315,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
param.put("point_code1", point_code); // 叫料点
|
||||
param.put("create_mode", create_mode);
|
||||
param.put("is_auto_issue", is_auto_issue);
|
||||
param.put("to_gt01", whereJson.getBooleanValue("to_gt01"));
|
||||
// 创建任务
|
||||
KzdjwSendEmpVehicleTask taskBean = SpringContextHolder.getBean(KzdjwSendEmpVehicleTask.class);
|
||||
taskBean.createTask(param);
|
||||
@@ -375,7 +377,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
}
|
||||
structivtDto.setUpdate_time(DateUtil.now());
|
||||
structivtDto.setUpdate_optname("acs");
|
||||
structivtService.update(structivtDto);
|
||||
// structivtService.update(structivtDto);
|
||||
WQLObject
|
||||
.getWQLObject("st_ivt_structivt")
|
||||
.update(JSONObject.parseObject(JSONObject.toJSONString(structivtDto, SerializerFeature.WriteMapNullValue)));
|
||||
//同时修改该工位的点位状态
|
||||
JSONObject pointJson = wo.query("point_code = '" + device_code + "'").uniqueResult(0);
|
||||
pointJson.put("point_status", point_status);
|
||||
|
||||
@@ -61,8 +61,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject queryGT04Status() {
|
||||
String api = "api/wms/queryGT04Status";
|
||||
public JSONObject queryGT01Status() {
|
||||
String api = "api/wms/queryGT01Status";
|
||||
return AcsUtil.notifyAcs(api, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject queryGT03Status() {
|
||||
String api = "api/wms/queryGT03Status";
|
||||
return AcsUtil.notifyAcs(api, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.WQL;
|
||||
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.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.pda.handlingTask.service.HandlingTaskService;
|
||||
import org.nl.wms.sch.tasks.RegionTypeEnum;
|
||||
|
||||
@@ -24,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
public class HandlingTaskServiceImpl implements HandlingTaskService {
|
||||
|
||||
private final AcsToWmsService acsToWmsService;
|
||||
private final WmsToAcsService wmsToAcsService;
|
||||
|
||||
@Override
|
||||
public JSONObject queryPoint() {
|
||||
@@ -63,8 +66,7 @@ public class HandlingTaskServiceImpl implements HandlingTaskService {
|
||||
result.put("desc", "操作失败,不能搬运此任务!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else if (StrUtil.equals(start_region_code, RegionTypeEnum.MLZZCQ.getCode())) {
|
||||
} else if (StrUtil.equals(start_region_code, RegionTypeEnum.MLZZCQ.getCode())) {
|
||||
if (!StrUtil.equals(next_region_code, RegionTypeEnum.YLJQ.getCode())
|
||||
&& !StrUtil.equals(next_region_code, RegionTypeEnum.GT4.getCode())
|
||||
) {
|
||||
@@ -72,8 +74,7 @@ public class HandlingTaskServiceImpl implements HandlingTaskService {
|
||||
result.put("desc", "操作失败,不能搬运此任务!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else if (StrUtil.equals(start_region_code, RegionTypeEnum.GT4.getCode())) {
|
||||
} else if (StrUtil.equals(start_region_code, RegionTypeEnum.GT4.getCode())) {
|
||||
if (!StrUtil.equals(next_region_code, RegionTypeEnum.HNJQ.getCode())
|
||||
&& !StrUtil.equals(next_region_code, RegionTypeEnum.KLZHCQ.getCode())
|
||||
) {
|
||||
@@ -81,8 +82,7 @@ public class HandlingTaskServiceImpl implements HandlingTaskService {
|
||||
result.put("desc", "操作失败,不能搬运此任务!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else if (StrUtil.equals(start_region_code, RegionTypeEnum.HNJQ.getCode())) {
|
||||
} else if (StrUtil.equals(start_region_code, RegionTypeEnum.HNJQ.getCode())) {
|
||||
if (!StrUtil.equals(next_region_code, RegionTypeEnum.GT1.getCode())
|
||||
&& !StrUtil.equals(next_region_code, RegionTypeEnum.KLZHCQ.getCode())
|
||||
) {
|
||||
@@ -90,12 +90,28 @@ public class HandlingTaskServiceImpl implements HandlingTaskService {
|
||||
result.put("desc", "操作失败,不能搬运此任务!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result.put("code", "0");
|
||||
result.put("desc", "操作失败,不能搬运此任务!");
|
||||
return result;
|
||||
}
|
||||
if (RegionTypeEnum.GT1.getCode().equals(next_region_code)) {
|
||||
JSONObject gt01Status = wmsToAcsService.queryGT01Status();
|
||||
if (!gt01Status.getBooleanValue("GT01")) {
|
||||
result.put("code", "0");
|
||||
result.put("desc", "当前一号接驳滚筒区不允许放料盅!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (RegionTypeEnum.MLZZCQ.getCode().equals(start_region_code)
|
||||
|| RegionTypeEnum.MLZZCQ.getCode().equals(next_region_code)) {
|
||||
JSONObject gt03Status = wmsToAcsService.queryGT03Status();
|
||||
if (!gt03Status.getBooleanValue("GT03")) {
|
||||
result.put("code", "0");
|
||||
result.put("desc", "满料盅缓存区正在滚动!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
HandlingTask taskBean = SpringContextHolder.getBean(HandlingTask.class);
|
||||
taskBean.createTask(whereJson);
|
||||
result.put("code", "1");
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
region_name
|
||||
FROM
|
||||
sch_base_region
|
||||
WHERE
|
||||
region_code IN ('KLZHCQ', 'MLZHCQ', 'HNJQ', 'GT1', 'GT4')
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -55,11 +55,11 @@ public class InStructServiceImpl implements InStructService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject confirm(JSONObject param) {
|
||||
String vehicle_code = param.getString("carrier_code");
|
||||
if (StrUtil.isNotBlank(vehicle_code)) {
|
||||
if (StrUtil.isBlank(vehicle_code)) {
|
||||
throw new BadRequestException("载具号不能为空");
|
||||
}
|
||||
VehicleDto vehicle = vehicleService.findByCode(vehicle_code);
|
||||
if (ObjectUtil.isNotEmpty(vehicle)) {
|
||||
if (ObjectUtil.isEmpty(vehicle)) {
|
||||
throw new BadRequestException("载具号不存在");
|
||||
}
|
||||
JSONObject map = new JSONObject();
|
||||
|
||||
@@ -27,11 +27,11 @@ public class OutStructServiceImpl implements OutStructService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject confirm(JSONObject param) {
|
||||
String vehicle_code = param.getString("carrier_code");
|
||||
if (StrUtil.isNotBlank(vehicle_code)) {
|
||||
if (StrUtil.isBlank(vehicle_code)) {
|
||||
throw new BadRequestException("载具号不能为空");
|
||||
}
|
||||
VehicleDto vehicle = vehicleService.findByCode(vehicle_code);
|
||||
if (ObjectUtil.isNotEmpty(vehicle)) {
|
||||
if (ObjectUtil.isEmpty(vehicle)) {
|
||||
throw new BadRequestException("载具号不存在");
|
||||
}
|
||||
WQLObject wo = WQLObject.getWQLObject("ST_IVT_StructIvt");
|
||||
|
||||
@@ -88,7 +88,7 @@ public class KlzhcwUtil {
|
||||
flag = this.equles26(ll, param);
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
return true;
|
||||
}
|
||||
|
||||
//判断是否有手持出库确认的 如果有就移除靠近滚筒1区的一个缓存
|
||||
|
||||
@@ -90,7 +90,7 @@ public class WorkorderServiceImpl implements WorkordeService {
|
||||
}
|
||||
// 工序名称
|
||||
map.put("workorder_procedure", whereJson.get("workorder_procedure"));
|
||||
JSONObject jsonObject = WQL.getWO("MPS_PRODUCEDURE001").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "ShiftOrder.update_time desc");
|
||||
JSONObject jsonObject = WQL.getWO("MPS_PRODUCEDURE001").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "ShiftOrder.create_time desc");
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@@ -425,31 +425,29 @@ public class WorkorderServiceImpl implements WorkordeService {
|
||||
map.put("ext_order_id", workorder_id);
|
||||
map.put("type", "3");
|
||||
array.add(map);
|
||||
Map<String, Object> resp = wmsToAcsService.orderStatusUpdate(array);
|
||||
if (StrUtil.equals(String.valueOf(resp.get("status")), "200")) {
|
||||
JSONObject produceorderMap = JSONObject.parseObject(JSONObject.toJSONString(this.findById(Long.valueOf(workorder_id))));
|
||||
produceorderMap.put("workorder_id", workorder_id);
|
||||
produceorderMap.put("order_status", "5");
|
||||
produceorderMap.put("update_optid", currentUserId);
|
||||
produceorderMap.put("update_optname", nickName);
|
||||
produceorderMap.put("update_time", now);
|
||||
produceorderMap.put("realproduceend_date", now);
|
||||
wo.update(produceorderMap);
|
||||
wmsToAcsService.orderStatusUpdate(array);
|
||||
JSONObject produceorderMap = JSONObject.parseObject(JSONObject.toJSONString(this.findById(Long.valueOf(workorder_id))));
|
||||
produceorderMap.put("workorder_id", workorder_id);
|
||||
produceorderMap.put("order_status", "5");
|
||||
produceorderMap.put("update_optid", currentUserId);
|
||||
produceorderMap.put("update_optname", nickName);
|
||||
produceorderMap.put("update_time", now);
|
||||
produceorderMap.put("realproduceend_date", now);
|
||||
wo.update(produceorderMap);
|
||||
|
||||
// 操作成功后向 MES 反馈
|
||||
ParamDto has_mes = paramService.findByCode("has_mes");
|
||||
if (ObjectUtil.isNotEmpty(has_mes) && StrUtil.equals(has_mes.getValue(), "1")) {
|
||||
JSONObject mes_param = new JSONObject();
|
||||
mes_param.put("material_code", materialbaseService.findById(produceorderMap.getLong("material_id")).getMaterial_code());
|
||||
mes_param.put("workorder_code", produceorderMap.getString("workorder_code"));
|
||||
mes_param.put("workorder_qty", produceorderMap.getString("plan_qty"));
|
||||
mes_param.put("device_code", deviceService.findByCode(produceorderMap.getString("device_code")).getExtend_code());
|
||||
String workorder_uri = paramService.findByCode("mes_url").getValue() + "api/mes/materialIvt";
|
||||
HttpRequest
|
||||
.post(workorder_uri)
|
||||
.body(mes_param.toJSONString())
|
||||
.execute();
|
||||
}
|
||||
// 操作成功后向 MES 反馈
|
||||
ParamDto has_mes = paramService.findByCode("has_mes");
|
||||
if (ObjectUtil.isNotEmpty(has_mes) && StrUtil.equals(has_mes.getValue(), "1")) {
|
||||
JSONObject mes_param = new JSONObject();
|
||||
mes_param.put("material_code", materialbaseService.findById(produceorderMap.getLong("material_id")).getMaterial_code());
|
||||
mes_param.put("workorder_code", produceorderMap.getString("workorder_code"));
|
||||
mes_param.put("workorder_qty", produceorderMap.getString("plan_qty"));
|
||||
mes_param.put("device_code", deviceService.findByCode(produceorderMap.getString("device_code")).getExtend_code());
|
||||
String workorder_uri = paramService.findByCode("mes_url").getValue() + "api/mes/materialIvt";
|
||||
HttpRequest
|
||||
.post(workorder_uri)
|
||||
.body(mes_param.toJSONString())
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,57 +507,65 @@ public class WorkorderServiceImpl implements WorkordeService {
|
||||
JSONArray data = response_body.getJSONArray("data");
|
||||
WQLObject workorder_table = WQLObject.getWQLObject("pdm_bd_workorder");
|
||||
List<String> workorder_codes = workorder_table
|
||||
.query("is_delete = '0'")
|
||||
.query()
|
||||
.getResultJSONArray(0)
|
||||
.stream()
|
||||
.map(o -> ((JSONObject) o).getString("workorder_code"))
|
||||
.collect(Collectors.toList());
|
||||
WQLObject material_table = WQLObject.getWQLObject("md_me_materialbase");
|
||||
List<String> material_codes = material_table
|
||||
.query("is_delete = '0'")
|
||||
.query()
|
||||
.getResultJSONArray(0)
|
||||
.stream()
|
||||
.map(o -> ((JSONObject) o).getString("material_code"))
|
||||
.collect(Collectors.toList());
|
||||
WQLObject device_table = WQLObject.getWQLObject("pdm_bi_device");
|
||||
List<String> device_codes = device_table
|
||||
.query()
|
||||
.getResultJSONArray(0)
|
||||
.stream()
|
||||
.map(o -> ((JSONObject) o).getString("device_code"))
|
||||
.collect(Collectors.toList());
|
||||
for (Object o : data) {
|
||||
JSONObject mes_workorder = (JSONObject) o;
|
||||
|
||||
// 判断工单是否存在,已存在则不处理
|
||||
// 判断工单是否存在
|
||||
String workorder_code = mes_workorder.getString("workorder_code");
|
||||
if (!workorder_codes.contains(workorder_code)) {
|
||||
// 判断物料是否存在,如果不存在则报错,让用户先去同步物料
|
||||
String material_code = mes_workorder.getString("material_code");
|
||||
if (!material_codes.contains(material_code)) {
|
||||
throw new BadRequestException("工单号[" + workorder_code + "]需要生产的物料不存在,请先同步物料");
|
||||
}
|
||||
// 判断物料是否存在,如果不存在则报错,让用户先去同步物料
|
||||
String material_code = mes_workorder.getString("material_code");
|
||||
if (!material_codes.contains(material_code)) {
|
||||
throw new BadRequestException("工单号[" + workorder_code + "]需要生产的物料不存在,请先同步物料");
|
||||
}
|
||||
|
||||
// 处理物料id
|
||||
Long material_id = material_table
|
||||
.query("is_delete = '0' AND material_code = '" + material_code + "'")
|
||||
.uniqueResult(0)
|
||||
.getLong("material_id");
|
||||
// 处理物料id
|
||||
Long material_id = material_table
|
||||
.query("is_delete = '0' AND material_code = '" + material_code + "'")
|
||||
.uniqueResult(0)
|
||||
.getLong("material_id");
|
||||
|
||||
// 处理工单数量
|
||||
int plan_qty = Integer.parseInt(mes_workorder.getString("workorder_qty")) / 1500;
|
||||
// 处理工单数量
|
||||
int plan_qty = Integer.parseInt(mes_workorder.getString("workorder_qty")) / 1500;
|
||||
|
||||
// 处理设备
|
||||
JSONObject device = device_table
|
||||
.query("is_delete = '0' AND extend_code = '" + mes_workorder.getString("device_code") + "'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(device)) {
|
||||
throw new BadRequestException("工单号[" + workorder_code + "]的生产设备不存在");
|
||||
}
|
||||
// 处理设备
|
||||
String device_code = mes_workorder.getString("device_code");
|
||||
if (!device_codes.contains(device_code)) {
|
||||
throw new BadRequestException("工单号[" + workorder_code + "]的生产设备不存在");
|
||||
}
|
||||
JSONObject device = device_table.query("device_code = '" + device_code + "'").uniqueResult(0);
|
||||
|
||||
//添加工单
|
||||
WorkorderDto workorder = new WorkorderDto();
|
||||
workorder.setWorkorder_code(workorder_code);
|
||||
workorder.setMaterial_id(material_id);
|
||||
workorder.setPlan_qty(BigDecimal.valueOf(plan_qty));
|
||||
workorder.setDevice_id(device.getLong("device_id"));
|
||||
workorder.setDevice_code(device.getString("device_code"));
|
||||
//添加工单
|
||||
WorkorderDto workorder = new WorkorderDto();
|
||||
workorder.setWorkorder_code(workorder_code);
|
||||
workorder.setMaterial_id(material_id);
|
||||
workorder.setPlan_qty(BigDecimal.valueOf(plan_qty));
|
||||
workorder.setDevice_id(device.getLong("device_id"));
|
||||
workorder.setDevice_code(device.getString("device_code"));
|
||||
if (workorder_codes.contains(workorder_code)) {
|
||||
workorder_table.update(JSONObject.parseObject(JSONObject.toJSONString(workorder)), "workorder_code = '" + workorder_code + "'");
|
||||
} else {
|
||||
workorder.setOrder_status("1");
|
||||
this.create(workorder);
|
||||
workorder_codes.add(workorder_code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ public class YljCallMaterialTask extends AbstractAcsTask {
|
||||
@Override
|
||||
public String createTask(JSONObject whereJson) {
|
||||
|
||||
String workDevice = "HNJ01";
|
||||
String workDevice = whereJson.getString("point_code2");
|
||||
|
||||
String point_code2 = whereJson.getString("point_code2");
|
||||
String create_mode = whereJson.getString("create_mode");
|
||||
|
||||
@@ -315,18 +315,36 @@ public class HandlingTask extends AbstractAcsTask {
|
||||
|
||||
//任务表【SCH_BASE_Task】
|
||||
//判断当前点是否有未完成的任务
|
||||
JSONObject taskObj2 = taskTab.query("is_delete='0' and point_code2 = '" + next_point_code + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskObj2))
|
||||
throw new BadRequestException("当前点位" + next_point_code + "存在未完成的任务");
|
||||
JSONObject taskObj2;
|
||||
if ("GT04".equals(next_point_code)) {
|
||||
taskObj2 = taskTab.query("is_delete='0' and point_code2 = '" + next_point_code + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskObj2)) {
|
||||
throw new BadRequestException("[" + next_point_code + "]存在未完成的任务");
|
||||
}
|
||||
taskObj2 = taskTab.query("is_delete='0' and point_code1 = '" + next_point_code + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskObj2) && "GT01".equals(taskObj2.getString("point_code2"))) {
|
||||
throw new BadRequestException("请等待[GT04 -> GT01]的任务完成");
|
||||
}
|
||||
} else {
|
||||
taskObj2 = taskTab.query("is_delete='0' and (point_code2 = '" + next_point_code + "' OR point_code1 = '" + next_point_code + "') and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskObj2))
|
||||
throw new BadRequestException("[" + next_point_code + "]存在未完成的任务");
|
||||
}
|
||||
|
||||
JSONObject taskObj1 = taskTab.query("is_delete='0' and point_code1 = '" + start_point_code + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
JSONObject taskObj1 = taskTab.query("is_delete='0' and (point_code1 = '" + start_point_code + "' OR point_code2 = '" + start_point_code + "') and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskObj1))
|
||||
throw new BadRequestException("当前点位" + start_point_code + "存在未完成的任务");
|
||||
throw new BadRequestException("[" + start_point_code + "]存在未完成的任务");
|
||||
|
||||
JSONObject jsonObject = ivtTab.query("point_code = '" + start_point_code + "'").uniqueResult(0);
|
||||
|
||||
JSONObject jsonStart = pointTab.query("is_delete = '0' and is_used = '1' and point_code = '" + start_point_code + "'").uniqueResult(0);
|
||||
JSONObject jsonEnd = pointTab.query("is_delete = '0' and is_used = '1' and point_code = '" + next_point_code + "'").uniqueResult(0);
|
||||
if ("1".equals(jsonStart.getString("point_status"))) {
|
||||
throw new BadRequestException("起点[" + start_point_code + "]是空位");
|
||||
}
|
||||
if (!"1".equals(jsonEnd.getString("point_status")) && !"GT04".equals(next_point_code)) {
|
||||
throw new BadRequestException("终点[" + next_point_code + "]不是空位");
|
||||
}
|
||||
String region_codeS = jsonStart.getString("region_code");
|
||||
String region_codeE = jsonEnd.getString("region_code");
|
||||
if (StrUtil.equals(region_codeE, RegionTypeEnum.GT1.getCode())) {
|
||||
|
||||
@@ -13,7 +13,11 @@ import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.wms.basedata.service.dto.MaterialbaseDto;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl;
|
||||
import org.nl.wms.pda.scanGroup.KlzhcwUtil;
|
||||
import org.nl.wms.pda.scanGroup.MyLinkedListService;
|
||||
import org.nl.wms.sch.SchTaskDto;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
@@ -24,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -93,24 +98,44 @@ public class KzdjwSendEmpVehicleTask extends AbstractAcsTask {
|
||||
taskTab.update(taskObj);
|
||||
|
||||
JSONObject ivtStart = ivtTab.query("point_code = '" + point_code1 + "'").uniqueResult(0);
|
||||
JSONObject ivtEnd = ivtTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
|
||||
//修改终点库存
|
||||
ivtEnd.put("vehicle_type", taskObj.getString("vehicle_type"));
|
||||
ivtEnd.put("vehicle_code", taskObj.getString("vehicle_code"));
|
||||
ivtEnd.put("material_id", "");
|
||||
ivtEnd.put("instorage_time", DateUtil.now());
|
||||
ivtTab.update(ivtEnd);
|
||||
if ("GT01".equals(point_code2)) {
|
||||
LinkedList<JSONObject> ll = MyLinkedListService.getLinkedList();
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("vehicle_type", taskObj.getString("vehicle_type"));
|
||||
param.put("vehicle_code", taskObj.getString("vehicle_code"));
|
||||
param.put("ivt_qty", taskObj.getString("qty"));
|
||||
boolean flag = SpringContextHolder.getBean(KlzhcwUtil.class).judge(ll, param);
|
||||
if (flag) {
|
||||
jsonEnd.put("lock_type", "1");
|
||||
jsonEnd.put("task_id", "");
|
||||
jsonEnd.put("vehicle_type", "");
|
||||
jsonEnd.put("vehicle_code", "");
|
||||
jsonEnd.put("material_id", "");
|
||||
jsonEnd.put("point_status", "1");
|
||||
jsonEnd.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonEnd);
|
||||
}
|
||||
} else {
|
||||
|
||||
//解锁终点
|
||||
jsonEnd.put("lock_type", "1");
|
||||
jsonEnd.put("task_id", "");
|
||||
jsonEnd.put("vehicle_type", "");
|
||||
jsonEnd.put("vehicle_code", "");
|
||||
jsonEnd.put("material_id", "");
|
||||
jsonEnd.put("point_status", "2");
|
||||
jsonEnd.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonEnd);
|
||||
JSONObject ivtEnd = ivtTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
//修改终点库存
|
||||
ivtEnd.put("vehicle_type", taskObj.getString("vehicle_type"));
|
||||
ivtEnd.put("vehicle_code", taskObj.getString("vehicle_code"));
|
||||
ivtEnd.put("material_id", "");
|
||||
ivtEnd.put("instorage_time", DateUtil.now());
|
||||
ivtTab.update(ivtEnd);
|
||||
|
||||
//解锁终点
|
||||
jsonEnd.put("lock_type", "1");
|
||||
jsonEnd.put("task_id", "");
|
||||
jsonEnd.put("vehicle_type", "");
|
||||
jsonEnd.put("vehicle_code", "");
|
||||
jsonEnd.put("material_id", "");
|
||||
jsonEnd.put("point_status", "2");
|
||||
jsonEnd.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonEnd);
|
||||
}
|
||||
|
||||
//修改起点库存
|
||||
ivtStart.put("vehicle_type", "");
|
||||
@@ -140,29 +165,53 @@ public class KzdjwSendEmpVehicleTask extends AbstractAcsTask {
|
||||
*/
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONArray taskArr = taskTab.query("handle_class = '" + THIS_CLASS + "'and is_delete = '0' and task_status = '" + TaskStatusEnum.SURE_START.getCode() + "'").getResultJSONArray(0);
|
||||
WmsToAcsService wmsToAcsService = SpringContextHolder.getBean(WmsToAcsService.class);
|
||||
for (int i = 0; i < taskArr.size(); i++) {
|
||||
JSONObject taskObj = taskArr.getJSONObject(i);
|
||||
//区查询空盅缓存为是否有空位 如果有就生成到空盅缓存位的任务
|
||||
JSONObject json = pointTab.query("is_used = '1' AND is_delete = '0' AND lock_type = '1' AND point_status = '1' AND region_code = '" + RegionTypeEnum.KLZHCQ.getCode() + "' and point_code != 'KLZHC01'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
JSONObject ivtJson = ivtTab.query("point_code = '" + taskObj.getString("point_code1") + "'").uniqueResult(0);
|
||||
json.put("lock_type", "2");
|
||||
json.put("task_id", taskObj.getString("task_id"));
|
||||
json.put("update_time", DateUtil.now());
|
||||
pointTab.update(json);
|
||||
//更改任务表中的终点点位和状态
|
||||
taskObj.put("point_code2", json.getString("point_code"));
|
||||
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
taskObj.put("vehicle_code", ivtJson.getString("vehicle_code"));
|
||||
taskObj.put("vehicle_type", ivtJson.getString("vehicle_type"));
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
if ("klzdjwtogt01".equals(taskObj.getString("task_type"))) {
|
||||
JSONObject jsonObject = taskTab.query("is_delete = '0' AND task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "' AND (point_code1 = 'GT01' OR point_code2 = 'GT01')").uniqueResult(0);
|
||||
JSONObject gt01Status = wmsToAcsService.queryGT01Status();
|
||||
if (ObjectUtil.isEmpty(jsonObject) && gt01Status.getBooleanValue("GT01")) {
|
||||
JSONObject ivtJson = ivtTab.query("point_code = '" + taskObj.getString("point_code1") + "'").uniqueResult(0);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("lock_type", "2");
|
||||
json.put("task_id", taskObj.getString("task_id"));
|
||||
json.put("update_time", DateUtil.now());
|
||||
pointTab.update(json, "point_code = 'GT01'");
|
||||
//更改任务表中的终点点位和状态
|
||||
taskObj.put("point_code2", "GT01");
|
||||
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
taskObj.put("vehicle_code", ivtJson.getString("vehicle_code"));
|
||||
taskObj.put("vehicle_type", ivtJson.getString("vehicle_type"));
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else {
|
||||
taskObj.put("remark", "1号接驳位当前不允许进入");
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
}
|
||||
} else {
|
||||
taskObj.put("remark", "空盅缓存区没有空位!");
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
//区查询空盅缓存为是否有空位 如果有就生成到空盅缓存位的任务
|
||||
JSONObject json = pointTab.query("is_used = '1' AND is_delete = '0' AND lock_type = '1' AND point_status = '1' AND region_code = '" + RegionTypeEnum.KLZHCQ.getCode() + "' and point_code <> 'KLZHC01'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
JSONObject ivtJson = ivtTab.query("point_code = '" + taskObj.getString("point_code1") + "'").uniqueResult(0);
|
||||
json.put("lock_type", "2");
|
||||
json.put("task_id", taskObj.getString("task_id"));
|
||||
json.put("update_time", DateUtil.now());
|
||||
pointTab.update(json);
|
||||
//更改任务表中的终点点位和状态
|
||||
taskObj.put("point_code2", json.getString("point_code"));
|
||||
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
taskObj.put("vehicle_code", ivtJson.getString("vehicle_code"));
|
||||
taskObj.put("vehicle_type", ivtJson.getString("vehicle_type"));
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else {
|
||||
taskObj.put("remark", "空盅缓存区没有空位!");
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,14 +232,22 @@ public class KzdjwSendEmpVehicleTask extends AbstractAcsTask {
|
||||
|
||||
//任务表【SCH_BASE_Task】
|
||||
//判断当前点是否有未完成的任务
|
||||
JSONObject taskObj = taskTab.query("is_delete='0' and point_code1 = '" + point_code1 + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
JSONObject taskObj = taskTab.query("is_delete='0' and (point_code1 = '" + point_code1 + "' OR point_code2 = '" + point_code1 + "') and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskObj))
|
||||
throw new BadRequestException("当前点位" + point_code1 + "存在未完成的任务");
|
||||
String vehicle_code = WQLObject
|
||||
.getWQLObject("st_ivt_structivt")
|
||||
.query("point_code = '" + point_code1 + "'")
|
||||
.uniqueResult(0)
|
||||
.getString("vehicle_code");
|
||||
if (StrUtil.isBlank(vehicle_code)) {
|
||||
throw new BadRequestException("当前点位[" + point_code1 + "]上没有载具");
|
||||
}
|
||||
|
||||
SchTaskDto dto = SchTaskDto.builder()
|
||||
.task_id(IdUtil.getLongId())
|
||||
.task_code(CodeUtil.getNewCode("TASK_CODE"))
|
||||
.task_type("klzdjwsendempty")
|
||||
.task_type(form.getBooleanValue("to_gt01") ? "klzdjwtogt01" : "klzdjwsendempty")
|
||||
.task_name("空料盅对接位呼叫送空盅")
|
||||
.task_status(TaskStatusEnum.SURE_START.getCode())
|
||||
.point_code1(point_code1)
|
||||
|
||||
@@ -230,43 +230,41 @@ public class HnjSendMaterialTask extends AbstractAcsTask {
|
||||
//1、查询未锁定,空料盅,空盅位暂存区的起始点位 如果有取空的点位 再判断取满时 是否有放货位
|
||||
JSONObject json1 = pointTab.query("is_used = '1' AND is_delete = '0' AND lock_type = '1' AND point_status = '2' AND region_code = '" + RegionTypeEnum.KLZHCQ.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json1)) {
|
||||
JSONObject jsonObject = SpringContextHolder.getBean(WmsToAcsService.class).queryGT04Status();
|
||||
if (jsonObject.getBoolean("GT04")) {
|
||||
JSONObject json2 = pointTab.query("is_used = '1' AND is_delete = '0' AND lock_type = '1' AND point_status = '1' AND region_code = '" + RegionTypeEnum.GT1.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json2)) {
|
||||
//锁定取空任务的起点
|
||||
json1.put("lock_type", "2");
|
||||
json1.put("task_id", taskObj.getString("task_id"));
|
||||
json1.put("update_time", DateUtil.now());
|
||||
pointTab.update(json1);
|
||||
JSONObject gt01Status = SpringContextHolder.getBean(WmsToAcsService.class).queryGT01Status();
|
||||
JSONObject json2 = pointTab.query("is_used = '1' AND is_delete = '0' AND lock_type = '1' AND point_status = '1' AND region_code = '" + RegionTypeEnum.GT1.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json2) && gt01Status.getBooleanValue("GT01")) {
|
||||
//锁定取空任务的起点
|
||||
json1.put("lock_type", "2");
|
||||
json1.put("task_id", taskObj.getString("task_id"));
|
||||
json1.put("update_time", DateUtil.now());
|
||||
pointTab.update(json1);
|
||||
|
||||
//锁定取满任务的终点
|
||||
json2.put("lock_type", "2");
|
||||
json2.put("task_id", taskObj.getString("task_id"));
|
||||
json2.put("update_time", DateUtil.now());
|
||||
pointTab.update(json2);
|
||||
//锁定取满任务的终点
|
||||
json2.put("lock_type", "2");
|
||||
json2.put("task_id", taskObj.getString("task_id"));
|
||||
json2.put("update_time", DateUtil.now());
|
||||
pointTab.update(json2);
|
||||
|
||||
//更改取空任务中的载具信息 任务状态
|
||||
JSONObject ivtJson1 = ivtTab.query("point_code = '" + json1.getString("point_code") + "'").uniqueResult(0);
|
||||
taskObj.put("point_code1", json1.getString("point_code"));
|
||||
taskObj.put("vehicle_code", ivtJson1.getString("vehicle_code"));
|
||||
taskObj.put("vehicle_type", ivtJson1.getString("vehicle_type"));
|
||||
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
//更改取空任务中的载具信息 任务状态
|
||||
JSONObject ivtJson1 = ivtTab.query("point_code = '" + json1.getString("point_code") + "'").uniqueResult(0);
|
||||
taskObj.put("point_code1", json1.getString("point_code"));
|
||||
taskObj.put("vehicle_code", ivtJson1.getString("vehicle_code"));
|
||||
taskObj.put("vehicle_type", ivtJson1.getString("vehicle_type"));
|
||||
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
|
||||
//更改取满任务中的载具信息 任务状态
|
||||
JSONObject ivtJson2 = ivtTab.query("point_code = '" + taskObj2.getString("point_code1") + "'").uniqueResult(0);
|
||||
taskObj2.put("point_code2", json2.getString("point_code"));
|
||||
taskObj2.put("vehicle_code", ivtJson2.getString("vehicle_code"));
|
||||
taskObj2.put("vehicle_type", ivtJson2.getString("vehicle_type"));
|
||||
taskObj2.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
taskObj2.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj2);
|
||||
//更改取满任务中的载具信息 任务状态
|
||||
JSONObject ivtJson2 = ivtTab.query("point_code = '" + taskObj2.getString("point_code1") + "'").uniqueResult(0);
|
||||
taskObj2.put("point_code2", json2.getString("point_code"));
|
||||
taskObj2.put("vehicle_code", ivtJson2.getString("vehicle_code"));
|
||||
taskObj2.put("vehicle_type", ivtJson2.getString("vehicle_type"));
|
||||
taskObj2.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
taskObj2.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj2);
|
||||
|
||||
}
|
||||
} else {
|
||||
JSONObject json3 = pointTab.query("is_used = '1' AND is_delete = '0' AND lock_type = '1' AND point_status = '1' AND region_code = '" + RegionTypeEnum.KLZHCQ.getCode() + "' and point_code = 'KLZHC12'").uniqueResult(0);
|
||||
JSONObject json3 = pointTab.query("is_used = '1' AND is_delete = '0' AND lock_type = '1' AND point_status = '1' AND region_code = '" + RegionTypeEnum.KLZHCQ.getCode() + "' and point_code <> 'KLZHC12'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json3)) {
|
||||
//锁定取空任务的起点
|
||||
json1.put("lock_type", "2");
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.wms.basedata.service.dto.MaterialbaseDto;
|
||||
import org.nl.wms.basedata.service.impl.MaterialbaseServiceImpl;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl;
|
||||
import org.nl.wms.pda.scanGroup.KlzhcwUtil;
|
||||
import org.nl.wms.pda.scanGroup.MyLinkedListService;
|
||||
@@ -341,6 +342,10 @@ public class TimingSendMaterialTask extends AbstractAcsTask {
|
||||
String point_id = jsonObject.getString("point_id");
|
||||
JSONObject jsonObject1 = wo_point.query("point_id = '" + point_id + "' and is_delete = '0' and is_used = '1' and lock_type = '1' and point_status = '3'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonObject1)) {
|
||||
JSONObject gt01Status = SpringContextHolder.getBean(WmsToAcsService.class).queryGT01Status();
|
||||
if (!gt01Status.getBooleanValue("GT01")) {
|
||||
return;
|
||||
}
|
||||
JSONObject jsonObject2 = wo_point.query("region_code = '" + RegionTypeEnum.GT1.getCode() + "' and is_delete = '0' and is_used = '1' and lock_type = '1'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonObject2)) {
|
||||
JSONObject map = new JSONObject();
|
||||
|
||||
@@ -147,16 +147,25 @@ public class StructivtServiceImpl implements StructivtService {
|
||||
&& ObjectUtil.isNotEmpty(dto.getMaterial_id())) {
|
||||
throw new BadRequestException("选择物料编码必须选择托盘编号");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(dto.getVehicle_code())
|
||||
&& ObjectUtil.isNotEmpty(dto.getMaterial_id())) {
|
||||
redisUtils.set(dto.getVehicle_code(), dto.getMaterial_id().toString());
|
||||
redisUtils.set(dto.getVehicle_code() + "-ivt_qty", "1");
|
||||
if (StrUtil.isNotBlank(dto.getVehicle_code())) {
|
||||
if (ObjectUtil.isNotEmpty(dto.getMaterial_id())) {
|
||||
redisUtils.set(dto.getVehicle_code(), dto.getMaterial_id().toString());
|
||||
redisUtils.set(dto.getVehicle_code() + "-ivt_qty", "1");
|
||||
} else {
|
||||
redisUtils.del(dto.getVehicle_code());
|
||||
redisUtils.del(dto.getVehicle_code() + "-ivt_qty");
|
||||
}
|
||||
}
|
||||
WQLObject wo_point = WQLObject.getWQLObject("sch_base_point");
|
||||
// 找主表获取之前的数据
|
||||
StructivtDto structivtDto = this.findById(dto.getStockrecord_id());
|
||||
String region_code = structivtDto.getRegion_code();
|
||||
if (structivtDto == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
String region_code = structivtDto.getRegion_code();
|
||||
if (StrUtil.isBlank(dto.getVehicle_code())
|
||||
|| !dto.getVehicle_code().equals(structivtDto.getVehicle_code())) {
|
||||
redisUtils.del(structivtDto.getVehicle_code());
|
||||
redisUtils.del(structivtDto.getVehicle_code() + "-ivt_qty");
|
||||
}
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
Reference in New Issue
Block a user