This commit is contained in:
2023-03-25 17:18:19 +08:00
parent b83498741d
commit a267bc14ea
9 changed files with 1659 additions and 1539 deletions

View File

@@ -9,7 +9,6 @@ import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.agv.server.impl.NDCAgvServiceImpl;
import org.nl.acs.auto.run.NDCSocketConnectionAutoRun;

View File

@@ -0,0 +1,27 @@
package org.nl.acs.ext.wms.statusEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
/*
* @author ZZQ
* @Date 2023/3/15 4:33 下午
*/
@Getter
@AllArgsConstructor
public enum StatusEnum {
TASK_READY("0", "就绪", ""),
TASK_RUNNING("1", "执行中", "6"),
TASK_FINISH("2", "完成", "7"),
TASK_CANNEL("3", "取消", "8");
private String code;
private String desc;
private String ext;
}

View File

@@ -0,0 +1,36 @@
package org.nl.acs.ext.wms.statusEnum;
/**
* @Author: lyd
* @Description: 工单枚举
* @Date: 2023/3/16
*/
public enum WorkerOrderEnum {
READY("就绪", "0", ""),
PRODUCTING("生产中", "1", "3"),
COMPLETE("完成", "2", "5"),
CANCEL("取消", "3", "3"),
STOP("暂停", "4", "4");
private String name;
private String code;
private String mesCode;
WorkerOrderEnum(String name, String code, String mesCode) {
this.name = name;
this.code = code;
this.mesCode = mesCode;
}
public String getName() {
return name;
}
public String getCode() {
return code;
}
public String getMesCode() {
return mesCode;
}
}

View File

@@ -86,6 +86,8 @@ public interface InstructionService {
*/
Instruction findByTaskcode(String code);
Instruction findByTaskCodeFromCache(String taskCode);
Instruction findByTaskcodeAndStatus(String code);
Instruction findByTaskcodeAndStatus(String code,String status);

View File

@@ -256,6 +256,17 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
return obj;
}
@Override
public Instruction findByTaskCodeFromCache(String taskCode) {
return Optional
.ofNullable(this.instructions)
.orElse(new ArrayList<>())
.stream()
.filter(i -> i.getTask_code().equals(taskCode))
.findFirst()
.orElse(null);
}
@Override
public Instruction findByTaskcodeAndStatus(String code) {
Iterator var3 = instructions.iterator();

View File

@@ -53,6 +53,19 @@ public interface ProduceshiftorderService {
*/
ProduceshiftorderDto findByCode(String code);
/**
* 根据编码从内存查询
* @param code code
* @return Produceshiftorder
*/
ProduceshiftorderDto findByCodeFromCache(String code);
/**
* 根据id从内存查询
* @param id id
* @return Produceshiftorder
*/
ProduceshiftorderDto findByIdFromCache(String id);
/**
* 创建
@@ -102,6 +115,8 @@ public interface ProduceshiftorderService {
ProduceshiftorderDto findOrderByDeviceCode(String device_code);
ProduceshiftorderDto findOrderByExtOrderId(String ext_order_id);
/**
* 工单同步
*/

View File

@@ -6,8 +6,6 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import org.nl.acs.auto.initial.ApplicationAutoInitial;
import org.nl.acs.device.service.DeviceExtraService;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_machine_storage_station.HailiangCleaningMachineStorageStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_machine.HailiangEngravingMachineDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_packer_station.HailiangPackerStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_device.HailiangSpecialDeviceDriver;
@@ -15,6 +13,7 @@ import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_stacking_statio
import org.nl.acs.device_driver.basedriver.hailiang_smart_plc_test.HailiangSmartplcTestDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
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.modules.common.exception.BadRequestException;
@@ -33,6 +32,8 @@ import org.springframework.data.domain.Pageable;
import java.math.BigDecimal;
import java.util.*;
import java.io.IOException;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.date.DateUtil;
@@ -51,10 +52,9 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, ApplicationAutoInitial {
private final org.nl.acs.opc.DeviceAppService deviceAppService;
private final DeviceExtraService deviceExtraService;
private final DeviceAppService deviceAppService;
List<ProduceshiftorderDto> order = new ArrayList();
CopyOnWriteArrayList<ProduceshiftorderDto> order = new CopyOnWriteArrayList<>();
@Autowired
AcsToWmsService acsToWmsService;
@@ -65,13 +65,16 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
}
public synchronized void reload() {
this.order = this.queryAll(" order_status !='2' and order_status !='3' and is_deleted =0");
this.order = (CopyOnWriteArrayList<ProduceshiftorderDto>) this.queryAll("order_status !='2' and order_status != '3' and is_deleted =0");
}
@Override
public List<ProduceshiftorderDto> queryAll(String whereJson) {
WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder");
JSONArray arr = wo.query(whereJson).getResultJSONArray(0);
JSONArray arr = wo.query(whereJson, "create_time").getResultJSONArray(0);
if (ObjectUtil.isEmpty(arr)) {
return null;
}
List<ProduceshiftorderDto> list = arr.toJavaList(ProduceshiftorderDto.class);
return list;
}
@@ -87,7 +90,10 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
@Override
public List<ProduceshiftorderDto> queryAll(Map whereJson) {
WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder");
JSONArray arr = wo.query().getResultJSONArray(0);
JSONArray arr = wo.query("is_deleted = '0'").getResultJSONArray(0);
if (ObjectUtil.isEmpty(arr)) {
return null;
}
List<ProduceshiftorderDto> list = arr.toJavaList(ProduceshiftorderDto.class);
return list;
}
@@ -95,7 +101,10 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
@Override
public ProduceshiftorderDto findById(String order_id) {
WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder");
JSONObject json = wo.query("order_id ='" + order_id + "'").uniqueResult(0);
JSONObject json = wo.query("order_id ='" + order_id + "' and is_deleted = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(json)) {
return null;
}
final ProduceshiftorderDto obj = (ProduceshiftorderDto) JSONObject.toJavaObject(json, ProduceshiftorderDto.class);
return obj;
}
@@ -103,25 +112,39 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
@Override
public ProduceshiftorderDto findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder");
JSONObject json = wo.query("order_code ='" + code + "'").uniqueResult(0);
JSONObject json = wo.query("order_code ='" + code + "' and is_deleted = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(json)) {
return null;
}
final ProduceshiftorderDto obj = (ProduceshiftorderDto) JSONObject.toJavaObject(json, ProduceshiftorderDto.class);
return obj;
}
@Override
public ProduceshiftorderDto findByCodeFromCache(String code) {
return Optional.ofNullable(this.order).orElse(new CopyOnWriteArrayList<>()).stream().filter(o -> o.getOrder_code().equals(code)).findFirst().orElse(null);
}
@Override
public ProduceshiftorderDto findByIdFromCache(String id) {
return Optional.ofNullable(this.order).orElse(new CopyOnWriteArrayList<>()).stream().filter(o -> o.getOrder_id().equals(id)).findFirst().orElse(null);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(ProduceshiftorderDto dto) {
WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder");
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
Device device = deviceAppService.findDeviceByCode(dto.getDevice_code());
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("该设备已存在未完成工单,不能下发");
//判断是否存在该设备未完成的工单信息
ProduceshiftorderDto pdNow = this.findOrderByDeviceCode(dto.getDevice_code());
if (ObjectUtil.isNotEmpty(pdNow)) {
throw new BadRequestException("该设备已存在未完成工单,不能下发!");
}
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
dto.setOrder_id(IdUtil.simpleUUID());
if (StrUtil.isEmpty(dto.getOrder_code())) {
String order_no = CodeUtil.getNewCode("ORDER_NO");
@@ -131,11 +154,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
if (StrUtil.isEmpty(dto.getCreate_by())) {
dto.setCreate_by(currentUsername);
}
if (StrUtil.isEmpty(dto.getUpdate_by())) {
dto.setUpdate_by(currentUsername);
}
dto.setCreate_time(now);
dto.setUpdate_time(now);
String is_needmove = dto.getIs_needmove();
//海亮专机
@@ -151,24 +170,12 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
if (device.getDeviceDriver() instanceof HailiangSpecialDeviceDriver) {
hailiangSpecialDeviceDriver = (HailiangSpecialDeviceDriver) device.getDeviceDriver();
//专机下发工单信号:倒料数量(-99999 当前产量清零1 订单生产总量 每箱接料数量 工单号
String extra_value = hailiangSpecialDeviceDriver.getExtraValue().get("one_qty").toString();
if (StrUtil.equals(is_needmove, "1")) {
if (ObjectUtil.isEmpty(extra_value)) {
throw new BadRequestException("满料框数量为空");
}
} else {
extra_value = "99999";
}
if (!hailiangSpecialDeviceDriver.getItemProtocol().getIsonline()){
if (!hailiangSpecialDeviceDriver.getItemProtocol().getIsonline()) {
throw new BadRequestException("设备未开机,开工失败!");
}
dto.setOne_qty(BigDecimal.valueOf((Long.parseLong(extra_value))));
hailiangSpecialDeviceDriver.writing("to_clear", "1");
hailiangSpecialDeviceDriver.writing("to_order", dto.getOrder_code());
hailiangSpecialDeviceDriver.writing("to_one_box_num", extra_value);
hailiangSpecialDeviceDriver.writing("to_one_box_num", String.valueOf(dto.getOne_qty()));
hailiangSpecialDeviceDriver.writing("to_order_prod_num", dto.getQty().toString());
hailiangSpecialDeviceDriver.writing("to_out_num", "0");
hailiangSpecialDeviceDriver.writing("to_pause", "0");
@@ -176,36 +183,30 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
if (device.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver) {
hailiangEngravingMachineDeviceDriver = (HailiangEngravingMachineDeviceDriver) device.getDeviceDriver();
String extra_value = hailiangEngravingMachineDeviceDriver.getExtraValue().get("one_qty").toString();
if (StrUtil.equals(is_needmove, "1")) {
if (ObjectUtil.isEmpty(extra_value)) {
throw new BadRequestException("满料框数量为空");
}
} else {
extra_value = "99999";
}
dto.setOne_qty(BigDecimal.valueOf((Long.parseLong(extra_value))));
if (!hailiangEngravingMachineDeviceDriver.getItemProtocol().getIsonline()){
if (!hailiangEngravingMachineDeviceDriver.getItemProtocol().getIsonline()) {
throw new BadRequestException("设备未开机,工单下发失败!");
}
hailiangEngravingMachineDeviceDriver.writing("to_clear", "1");
hailiangEngravingMachineDeviceDriver.writing("to_order", dto.getOrder_code());
hailiangEngravingMachineDeviceDriver.writing("to_one_box_num", extra_value);
hailiangEngravingMachineDeviceDriver.writing("to_order_prod_num", dto.getQty().toString());
hailiangEngravingMachineDeviceDriver.writing("to_one_box_num", String.valueOf(dto.getOne_qty()));
hailiangEngravingMachineDeviceDriver.writing("to_order_prod_num", String.valueOf(dto.getQty()));
}
if (device.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver) {
hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver();
if (!hailiangPackerStationDeviceDriver.getItemProtocol().getIsonline()){
if (!hailiangPackerStationDeviceDriver.getItemProtocol().getIsonline()) {
throw new BadRequestException("设备未开机,工单下发失败");
}
hailiangPackerStationDeviceDriver.writing("to_clear", "1");
hailiangPackerStationDeviceDriver.writing("to_order", dto.getOrder_code());
hailiangPackerStationDeviceDriver.writing("to_order_prod_num", dto.getQty().toString());
hailiangPackerStationDeviceDriver.writing("to_order_prod_num", String.valueOf(dto.getQty()));
}
if (device.getDeviceDriver() instanceof HailiangSmartplcTestDeviceDriver) {
hailiangSmartplcTestDeviceDriver = (HailiangSmartplcTestDeviceDriver) device.getDeviceDriver();
if (!hailiangSmartplcTestDeviceDriver.getItemProtocol().getIsonline()) {
throw new BadRequestException("设备未开机,工单下发失败");
}
hailiangSmartplcTestDeviceDriver.writing("to_clear", "1");
hailiangSmartplcTestDeviceDriver.writing("to_task", dto.getOrder_code());
hailiangSmartplcTestDeviceDriver.writing("to_qty", dto.getQty().toString());
@@ -213,27 +214,27 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
hailiangSmartplcTestDeviceDriver.writing("to_pause", "0");
}
if (device.getDeviceDriver() instanceof HailiangStackingStationDriver){
if (device.getDeviceDriver() instanceof HailiangStackingStationDriver) {
String lane_tray_template = dto.getLane_tray_template();
String to_tray_info = "";
if (lane_tray_template.equals("1")){
if (lane_tray_template.equals("1")) {
to_tray_info = lane_tray_template + "12";
}
if (lane_tray_template.equals("2")){
if (lane_tray_template.equals("2")) {
to_tray_info = lane_tray_template + "24";
}
if (StrUtil.isEmpty(dto.getTray_num())){
if (StrUtil.isEmpty(dto.getTray_num())) {
dto.setTray_num("1");
}
hailiangStackingStationDriver = (HailiangStackingStationDriver) device.getDeviceDriver();
if (!hailiangStackingStationDriver.getItemProtocol().getIsonline()){
if (!hailiangStackingStationDriver.getItemProtocol().getIsonline()) {
throw new BadRequestException("设备未开机,工单下发失败");
}
hailiangStackingStationDriver.writing("to_clear","1");
hailiangStackingStationDriver.writing("to_order",dto.getOrder_code());
hailiangStackingStationDriver.writing("to_order_prod_num",dto.getQty().toString());
hailiangStackingStationDriver.writing("to_tray_num",dto.getTray_num());
hailiangStackingStationDriver.writing("to_tray_info",to_tray_info);
hailiangStackingStationDriver.writing("to_clear", "1");
hailiangStackingStationDriver.writing("to_order", dto.getOrder_code());
hailiangStackingStationDriver.writing("to_order_prod_num", dto.getQty().toString());
hailiangStackingStationDriver.writing("to_tray_num", dto.getTray_num());
hailiangStackingStationDriver.writing("to_tray_info", to_tray_info);
}
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
@@ -254,30 +255,26 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder");
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.update(json);
Iterator<ProduceshiftorderDto> iterator = order.iterator();
while (iterator.hasNext()) {
ProduceshiftorderDto instruction = iterator.next();
if (instruction.getOrder_code().equals(dto.getOrder_code())) {
iterator.remove();
}
}
this.order.removeIf(o -> {
return o.getOrder_code().equals(dto.getOrder_code());
});
if (StrUtil.equals(dto.getOrder_status(), "0") || StrUtil.equals(dto.getOrder_status(), "1")) {
order.add(dto);
this.order.add(dto);
}
if (StrUtil.equals(dto.getOrder_status(), "3")) {
WQLObject wo1 = WQLObject.getWQLObject("acs_deviceisonline");
String device_code = dto.getDevice_code();
JSONObject jsonObject = wo1.query("device_code = '" + device_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonObject)){
if (ObjectUtil.isEmpty(jsonObject)) {
jsonObject = new JSONObject();
}
JSONObject map = new JSONObject();
map.put("online_id",IdUtil.simpleUUID());
map.put("device_code",device_code);
map.put("online_id", IdUtil.simpleUUID());
map.put("device_code", device_code);
map.put("order_code", dto.getOrder_code());
map.put("online_status","0");
map.put("create_by",currentUsername);
map.put("create_time",now);
map.put("online_status", "0");
map.put("create_by", currentUsername);
map.put("create_time", now);
Device device = deviceAppService.findDeviceByCode(device_code);
HailiangEngravingMachineDeviceDriver hailiangEngravingMachineDeviceDriver;
HailiangPackerStationDeviceDriver hailiangPackerStationDeviceDriver;
@@ -285,61 +282,61 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
HailiangStackingStationDriver hailiangStackingStationDriver;
if (device.getDeviceDriver() instanceof HailiangSpecialDeviceDriver) {
hailiangSpecialDeviceDriver = (HailiangSpecialDeviceDriver) device.getDeviceDriver();
if (hailiangSpecialDeviceDriver.getStatus_type() == 1){
if (ObjectUtil.isEmpty(jsonObject)){
if (hailiangSpecialDeviceDriver.getStatus_type() == 1) {
if (ObjectUtil.isEmpty(jsonObject)) {
wo1.insert(map);
} else {
jsonObject.put("online_status","0");
jsonObject.put("order_code",dto.getOrder_code());
jsonObject.put("update_by",currentUsername);
jsonObject.put("update_time",now);
jsonObject.put("online_status", "0");
jsonObject.put("order_code", dto.getOrder_code());
jsonObject.put("update_by", currentUsername);
jsonObject.put("update_time", now);
wo1.update(jsonObject);
}
}else {
hailiangSpecialDeviceDriver.writing("to_order_compel_finished","1");
} else {
hailiangSpecialDeviceDriver.writing("to_order_compel_finished", "1");
hailiangSpecialDeviceDriver.writing("to_confirm_finished", "1");
hailiangSpecialDeviceDriver.writing("to_order", "0");
hailiangSpecialDeviceDriver.writing("to_clear", "1");
}
} else if (device.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver) {
hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver();
if (hailiangPackerStationDeviceDriver.getStatus_type() == 1){
if (ObjectUtil.isEmpty(jsonObject)){
if (hailiangPackerStationDeviceDriver.getStatus_type() == 1) {
if (ObjectUtil.isEmpty(jsonObject)) {
wo1.insert(map);
} else {
jsonObject.put("online_status","0");
jsonObject.put("order_code",dto.getOrder_code());
jsonObject.put("update_by",currentUsername);
jsonObject.put("update_time",now);
jsonObject.put("online_status", "0");
jsonObject.put("order_code", dto.getOrder_code());
jsonObject.put("update_by", currentUsername);
jsonObject.put("update_time", now);
wo1.update(jsonObject);
}
}else {
hailiangPackerStationDeviceDriver.writing("to_order_compel_finished","1");
} else {
hailiangPackerStationDeviceDriver.writing("to_order_compel_finished", "1");
hailiangPackerStationDeviceDriver.writing("to_confirm_finished", "1");
hailiangPackerStationDeviceDriver.writing("to_order", "0");
hailiangPackerStationDeviceDriver.writing("to_clear", "1");
}
} else if (device.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver) {
hailiangEngravingMachineDeviceDriver = (HailiangEngravingMachineDeviceDriver) device.getDeviceDriver();
if (hailiangEngravingMachineDeviceDriver.getStatus_type() == 1){
if (ObjectUtil.isEmpty(jsonObject)){
if (hailiangEngravingMachineDeviceDriver.getStatus_type() == 1) {
if (ObjectUtil.isEmpty(jsonObject)) {
wo1.insert(map);
} else {
jsonObject.put("online_status","0");
jsonObject.put("order_code",dto.getOrder_code());
jsonObject.put("update_by",currentUsername);
jsonObject.put("update_time",now);
jsonObject.put("online_status", "0");
jsonObject.put("order_code", dto.getOrder_code());
jsonObject.put("update_by", currentUsername);
jsonObject.put("update_time", now);
wo1.update(jsonObject);
}
}else {
hailiangEngravingMachineDeviceDriver.writing("to_order_compel_finished","1");
} else {
hailiangEngravingMachineDeviceDriver.writing("to_order_compel_finished", "1");
hailiangEngravingMachineDeviceDriver.writing("to_confirm_finished", "1");
hailiangEngravingMachineDeviceDriver.writing("to_order", "0");
hailiangEngravingMachineDeviceDriver.writing("to_clear", "1");
}
} else if (device.getDeviceDriver() instanceof HailiangStackingStationDriver){
} else if (device.getDeviceDriver() instanceof HailiangStackingStationDriver) {
hailiangStackingStationDriver = (HailiangStackingStationDriver) device.getDeviceDriver();
hailiangStackingStationDriver.writing("to_compel_finish","1");
hailiangStackingStationDriver.writing("to_compel_finish", "1");
}
}
}
@@ -357,13 +354,9 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder");
JSONObject json = (JSONObject) JSONObject.toJSON(entity);
wo.update(json, "order_code = '" + dto.getOrder_code() + "'");
Iterator<ProduceshiftorderDto> iterator = order.iterator();
while (iterator.hasNext()) {
ProduceshiftorderDto oneorder = iterator.next();
if (oneorder.getOrder_code().equals(dto.getOrder_code())) {
iterator.remove();
}
}
this.order.removeIf(o -> {
return o.getOrder_code().equals(dto.getOrder_code());
});
if (StrUtil.equals(dto.getOrder_status(), "0") || StrUtil.equals(dto.getOrder_status(), "1")) {
order.add(dto);
}
@@ -373,15 +366,12 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
@Transactional(rollbackFor = Exception.class)
public void deleteAll(String[] ids) {
WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder");
String order_ids = Arrays.stream(Optional.ofNullable(ids).orElse(new String[0])).map(String::valueOf).collect(Collectors.joining(","));
wo.delete("order_id in '" + order_ids + "'");
for (String order_id : ids) {
wo.delete("order_id = '" + order_id + "'");
Iterator<ProduceshiftorderDto> iterator = order.iterator();
while (iterator.hasNext()) {
ProduceshiftorderDto instruction = iterator.next();
if (instruction.getOrder_id().equals(order_id)) {
iterator.remove();
}
}
this.order.removeIf(o -> {
return o.getOrder_id().equals(order_id);
});
}
}
@@ -432,26 +422,26 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
HailiangEngravingMachineDeviceDriver hailiangEngravingMachineDeviceDriver;
HailiangStackingStationDriver hailiangStackingStationDriver;
JSONObject jsonObject = wo.query("device_code = '" + device_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonObject)){
if (ObjectUtil.isEmpty(jsonObject)) {
jsonObject = new JSONObject();
}
JSONObject map = new JSONObject();
map.put("online_id",IdUtil.simpleUUID());
map.put("device_code",device_code);
map.put("order_code",order_code);
map.put("online_status","0");
map.put("create_by",currentUsername);
map.put("create_time",now);
map.put("online_id", IdUtil.simpleUUID());
map.put("device_code", device_code);
map.put("order_code", order_code);
map.put("online_status", "0");
map.put("create_by", currentUsername);
map.put("create_time", now);
if (device.getDeviceDriver() instanceof HailiangSpecialDeviceDriver) {
hailiangSpecialDeviceDriver = (HailiangSpecialDeviceDriver) device.getDeviceDriver();
if (hailiangSpecialDeviceDriver.getStatus_type() == 1) {
if (ObjectUtil.isEmpty(jsonObject)){
if (ObjectUtil.isEmpty(jsonObject)) {
wo.insert(map);
} else {
jsonObject.put("online_status","0");
jsonObject.put("order_code",order_code);
jsonObject.put("update_by",currentUsername);
jsonObject.put("update_time",now);
jsonObject.put("online_status", "0");
jsonObject.put("order_code", order_code);
jsonObject.put("update_by", currentUsername);
jsonObject.put("update_time", now);
wo.update(jsonObject);
}
} else {
@@ -464,13 +454,13 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
if (device.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver) {
hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver();
if (hailiangPackerStationDeviceDriver.getStatus_type() == 1) {
if (ObjectUtil.isEmpty(jsonObject)){
if (ObjectUtil.isEmpty(jsonObject)) {
wo.insert(map);
} else {
jsonObject.put("online_status","0");
jsonObject.put("order_code",order_code);
jsonObject.put("update_by",currentUsername);
jsonObject.put("update_time",now);
jsonObject.put("online_status", "0");
jsonObject.put("order_code", order_code);
jsonObject.put("update_by", currentUsername);
jsonObject.put("update_time", now);
wo.update(jsonObject);
}
} else {
@@ -482,14 +472,14 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
}
if (device.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver) {
hailiangEngravingMachineDeviceDriver = (HailiangEngravingMachineDeviceDriver) device.getDeviceDriver();
if (hailiangEngravingMachineDeviceDriver.getStatus_type() == 1){
if (ObjectUtil.isEmpty(jsonObject)){
if (hailiangEngravingMachineDeviceDriver.getStatus_type() == 1) {
if (ObjectUtil.isEmpty(jsonObject)) {
wo.insert(map);
} else {
jsonObject.put("online_status","0");
jsonObject.put("order_code",order_code);
jsonObject.put("update_by",currentUsername);
jsonObject.put("update_time",now);
jsonObject.put("online_status", "0");
jsonObject.put("order_code", order_code);
jsonObject.put("update_by", currentUsername);
jsonObject.put("update_time", now);
wo.update(jsonObject);
}
} else {
@@ -501,7 +491,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
}
if (device.getDeviceDriver() instanceof HailiangStackingStationDriver) {
hailiangStackingStationDriver = (HailiangStackingStationDriver) device.getDeviceDriver();
hailiangStackingStationDriver.writing("to_compel_finish","1");
hailiangStackingStationDriver.writing("to_compel_finish", "1");
}
JSONObject map1 = new JSONObject();
map1.put("order_id", order_id);
@@ -510,29 +500,36 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
map1.put("update_time", now);
WQLObject wo1 = WQLObject.getWQLObject("acs_produceshiftorder");
wo1.update(map1);
Iterator<ProduceshiftorderDto> iterator = order.iterator();
while (iterator.hasNext()) {
ProduceshiftorderDto instruction = iterator.next();
if (instruction.getOrder_code().equals(order_code)) {
iterator.remove();
}
}
this.order.removeIf(o -> {
return o.getOrder_code().equals(order_code);
});
}
@Override
public List<ProduceshiftorderDto> findAllOrderFromCache() {
return order;
return this.order;
}
@Override
public ProduceshiftorderDto findOrderByDeviceCode(String device_code) {
for (int i = 0; i < this.order.size(); i++) {
ProduceshiftorderDto dto = order.get(i);
if (StrUtil.equals(device_code, dto.getDevice_code())) {
return dto;
}
}
return null;
return Optional
.ofNullable(this.order)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(o -> o.getDevice_code().equals(device_code))
.findFirst()
.orElse(null);
}
@Override
public ProduceshiftorderDto findOrderByExtOrderId(String ext_order_id) {
return Optional
.ofNullable(this.order)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(o -> o.getExt_order_id().equals(ext_order_id))
.findFirst()
.orElse(null);
}
@Override

View File

@@ -74,7 +74,8 @@ public class TaskDto implements Serializable {
/**
* 是否立刻下发
*/
private String is_send;
private String is_send = "0";
private String material;
private String quantity;
@@ -82,7 +83,7 @@ public class TaskDto implements Serializable {
/**
* 任务优先级
*/
private String priority;
private String priority = "1";
/**
* 创建类型
@@ -225,12 +226,12 @@ public class TaskDto implements Serializable {
/**
* 是否启用
*/
private String is_active;
private String is_active = "1";
/**
* 是否删除
*/
private String is_delete;
private String is_delete = "0";
/**
* 创建者