Browse Source

add: 新增创建任务策略实现

master
yanps 12 months ago
parent
commit
4960be53d0
  1. 23
      hd/nladmin-system/pom.xml
  2. 8
      hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java
  3. 8
      hd/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java
  4. 29
      hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java
  5. 1
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java
  6. 5
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java
  7. 1
      hd/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageDto.java
  8. 28
      hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

23
hd/nladmin-system/pom.xml

@ -8,7 +8,6 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>nladmin-system</artifactId> <artifactId>nladmin-system</artifactId>
<name>核心模块</name> <name>核心模块</name>
@ -28,6 +27,28 @@
<groupId>org.openscada.utgard</groupId> <groupId>org.openscada.utgard</groupId>
<artifactId>org.openscada.opc.lib</artifactId> <artifactId>org.openscada.opc.lib</artifactId>
<version>1.5.0</version> <version>1.5.0</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>com.hynnet</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12.1</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.50</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.squareup.okhttp3</groupId> <groupId>com.squareup.okhttp3</groupId>

8
hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java

@ -441,4 +441,12 @@ public class DeviceController {
return new ResponseEntity<>(HttpStatus.CREATED); return new ResponseEntity<>(HttpStatus.CREATED);
} }
@Log("惠氏任务生成选择终点")
@ApiOperation("惠氏任务生成选择终点")
@GetMapping(value = "/endPoint")
public ResponseEntity<Object> selectEndPoint(String start_code) throws Exception {
List<String> endPoints = deviceService.selectEndPoint(start_code);
return new ResponseEntity<>(endPoints, HttpStatus.OK);
}
} }

8
hd/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java

@ -296,4 +296,12 @@ public interface DeviceService {
List<Device> findCacheDevice(); List<Device> findCacheDevice();
void updateBarcode(JSONObject json) throws Exception; void updateBarcode(JSONObject json) throws Exception;
/**
* 查询设备终端
*
* @param start_code 设备标识
* @return
*/
List<String> selectEndPoint(String start_code);
} }

29
hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java

@ -34,6 +34,8 @@ import org.nl.acs.device_driver.yzja_special.YzjaSpecialDeviceDriver;
import org.nl.acs.opc.Device; import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.TaskService;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil; import org.nl.modules.system.util.CodeUtil;
@ -75,6 +77,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
private final AcsConfigService acsConfigService; private final AcsConfigService acsConfigService;
@Autowired @Autowired
TaskService taskService; TaskService taskService;
@Autowired
RouteLineService routeLineService;
List<StorageCellDto> storageCells = new ArrayList<>(); List<StorageCellDto> storageCells = new ArrayList<>();
private Map<String, Integer> storage_address = new HashMap(); private Map<String, Integer> storage_address = new HashMap();
@ -496,7 +500,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
@Override @Override
public JSONArray selectDeviceListThree() { public JSONArray selectDeviceListThree() {
//设备基础信息表【acs_device】 //设备基础信息表【acs_device】
JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND region = '1'", "seq_num").getResultJSONArray(0); JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND region IN ('1', '6')", "seq_num").getResultJSONArray(0);
JSONArray result = new JSONArray(); JSONArray result = new JSONArray();
for (int i = 0; i < arr.size(); i++) { for (int i = 0; i < arr.size(); i++) {
JSONObject obj = arr.getJSONObject(i); JSONObject obj = arr.getJSONObject(i);
@ -515,6 +519,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
json.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); json.put("remark", standardOrdinarySiteDeviceDriver.getRemark());
json.put("islock",standardOrdinarySiteDeviceDriver.getIslock()); json.put("islock",standardOrdinarySiteDeviceDriver.getIslock());
json.put("hasGood",standardOrdinarySiteDeviceDriver.getHasGoods()); json.put("hasGood",standardOrdinarySiteDeviceDriver.getHasGoods());
json.put("next_code",standardOrdinarySiteDeviceDriver.getNext_code());
} }
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
@ -523,6 +528,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
json.put("remark", standardInspectSiteDeviceDriver.getRemark()); json.put("remark", standardInspectSiteDeviceDriver.getRemark());
json.put("islock",standardInspectSiteDeviceDriver.getIslock()); json.put("islock",standardInspectSiteDeviceDriver.getIslock());
json.put("hasGood",standardInspectSiteDeviceDriver.getHasGoods()); json.put("hasGood",standardInspectSiteDeviceDriver.getHasGoods());
json.put("next_code",standardInspectSiteDeviceDriver.getNext_code());
} }
result.add(json); result.add(json);
} }
@ -1243,6 +1249,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
//物料类型 //物料类型
String material_type = form.optString("material_type"); String material_type = form.optString("material_type");
String remark = form.optString("remark"); String remark = form.optString("remark");
String next_code = form.optString("next_code");
Integer hasGoods = 0; Integer hasGoods = 0;
if (!StrUtil.equals(material_type,"")) { if (!StrUtil.equals(material_type,"")) {
hasGoods = 2; hasGoods = 2;
@ -1256,10 +1263,12 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
standardOrdinarySiteDeviceDriver.setMaterial(material_type); standardOrdinarySiteDeviceDriver.setMaterial(material_type);
standardOrdinarySiteDeviceDriver.setRemark(remark); standardOrdinarySiteDeviceDriver.setRemark(remark);
standardOrdinarySiteDeviceDriver.setHasGoods(hasGoods); standardOrdinarySiteDeviceDriver.setHasGoods(hasGoods);
standardOrdinarySiteDeviceDriver.setNext_code(next_code);
device.setMaterial_type(material_type); device.setMaterial_type(material_type);
device.setQuantity(quantity); device.setQuantity(quantity);
device.setRemark(remark); device.setRemark(remark);
device.setHas_goods(hasGoods); device.setHas_goods(hasGoods);
device.setNext_code(next_code);
} }
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
@ -1267,10 +1276,12 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
standardInspectSiteDeviceDriver.setMaterial(material_type); standardInspectSiteDeviceDriver.setMaterial(material_type);
standardInspectSiteDeviceDriver.setRemark(remark); standardInspectSiteDeviceDriver.setRemark(remark);
standardInspectSiteDeviceDriver.setHasGoods(hasGoods); standardInspectSiteDeviceDriver.setHasGoods(hasGoods);
standardInspectSiteDeviceDriver.setNext_code(next_code);
device.setMaterial_type(material_type); device.setMaterial_type(material_type);
device.setQuantity(quantity); device.setQuantity(quantity);
device.setRemark(remark); device.setRemark(remark);
device.setHas_goods(hasGoods); device.setHas_goods(hasGoods);
device.setNext_code(next_code);
} }
} }
@ -1501,6 +1512,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
standardOrdinarySiteDeviceDriver.setMaterial(""); standardOrdinarySiteDeviceDriver.setMaterial("");
standardOrdinarySiteDeviceDriver.setQty(""); standardOrdinarySiteDeviceDriver.setQty("");
standardOrdinarySiteDeviceDriver.setRemark(""); standardOrdinarySiteDeviceDriver.setRemark("");
standardOrdinarySiteDeviceDriver.setNext_code("");
JSONObject jsonjo = new JSONObject(); JSONObject jsonjo = new JSONObject();
jsonjo.put("device_code", device_code); jsonjo.put("device_code", device_code);
jsonjo.put("hasGoodStatus", "0"); jsonjo.put("hasGoodStatus", "0");
@ -1511,6 +1523,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
standardInspectSiteDeviceDriver.setMaterial(""); standardInspectSiteDeviceDriver.setMaterial("");
standardInspectSiteDeviceDriver.setQty(""); standardInspectSiteDeviceDriver.setQty("");
standardInspectSiteDeviceDriver.setRemark(""); standardInspectSiteDeviceDriver.setRemark("");
standardInspectSiteDeviceDriver.setNext_code("");
} }
} }
} }
@ -2043,4 +2056,18 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
} }
} }
@Override
public List<String> selectEndPoint(String start_code) {
if(StrUtil.isEmpty(start_code)){
throw new RuntimeException("起点设备为空");
}
List<RouteLineDto> normal = routeLineService.getShortPathLinesByCode(start_code, "normal");
List<String> list = new ArrayList<>();
for (RouteLineDto routeLineDto : normal) {
list.add(routeLineDto.getNext_device_code());
}
return list;
}
} }

1
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java

@ -73,6 +73,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
int last_task = 0; int last_task = 0;
Boolean isonline = true; Boolean isonline = true;
int hasGoods = 0; int hasGoods = 0;
String next_code = "";
String message = null; String message = null;
Boolean iserror = false; Boolean iserror = false;

5
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java

@ -47,6 +47,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
Integer hasGoods = 0; Integer hasGoods = 0;
String next_code = "";
int error = 0; int error = 0;
Boolean iserror = false; Boolean iserror = false;
Boolean islock = false; Boolean islock = false;
@ -107,8 +108,8 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
hasGoods = this.getDevice().getHas_goods(); hasGoods = this.getDevice().getHas_goods();
batch = this.getDevice().getBatch(); batch = this.getDevice().getBatch();
devicecode = this.getDeviceCode(); devicecode = this.getDeviceCode();
if (branchProtocol != last_branchProtocol) { if("WLFZW05".equals(devicecode)){
requireSucess = false; hasGoods = 1;
} }
switch (branchProtocol) { switch (branchProtocol) {
case 1: case 1:

1
hd/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageDto.java

@ -12,6 +12,7 @@ public class DeviceManageDto {
private Boolean is_require_task; private Boolean is_require_task;
private String location; private String location;
private Integer has_goods = 0; private Integer has_goods = 0;
private String next_code;
private String material_type; private String material_type;
private String quantity; private String quantity;
private String remark; private String remark;

28
hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -155,7 +155,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl");
InstructionDto instdto = instructionservice.findByTaskid(entity.getTask_id(), "instruction_status <2 "); InstructionDto instdto = instructionservice.findByTaskid(entity.getTask_id(), "instruction_status <2 ");
if(!ObjectUtil.isEmpty(instdto)){ if (!ObjectUtil.isEmpty(instdto)) {
instructionService.cancel(instdto.getInstruction_id()); instructionService.cancel(instdto.getInstruction_id());
} }
@ -282,7 +282,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
WQLObject wo = WQLObject.getWQLObject("acs_task"); WQLObject wo = WQLObject.getWQLObject("acs_task");
JSONObject json = wo.query("task_code ='" + code + "'").uniqueResult(0); JSONObject json = wo.query("task_code ='" + code + "'").uniqueResult(0);
final TaskDto obj = (TaskDto) JSONObject.toBean(json, TaskDto.class); final TaskDto obj = (TaskDto) JSONObject.toBean(json, TaskDto.class);
if(ObjectUtil.isEmpty(obj)){ if (ObjectUtil.isEmpty(obj)) {
return false; return false;
} }
return true; return true;
@ -626,7 +626,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void hssavetask(JSONObject json) throws Exception { public synchronized void hssavetask(JSONObject json) throws Exception {
JSONArray array = json.optJSONArray("data"); JSONArray array = json.optJSONArray("data");
if (array.size() == 0) { if (array.size() == 0) {
@ -673,11 +673,29 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
// if (ObjectUtil.isNotEmpty(this.findByStartCode(device_code))) { // if (ObjectUtil.isNotEmpty(this.findByStartCode(device_code))) {
// throw new RuntimeException("设备:" + device_code + " 已存在该起点的任务"); // throw new RuntimeException("设备:" + device_code + " 已存在该起点的任务");
// } // }
list.sort(new Comparator<RouteLineDto>() {
@Override
public int compare(RouteLineDto o1, RouteLineDto o2) {
String s1 = o1.getNext_device_code().substring(o1.getNext_device_code().length() - 2);
String s2 = o2.getNext_device_code().substring(o2.getNext_device_code().length() - 2);
return Integer.compare(Integer.parseInt(s1), Integer.parseInt(s2));
}
});
String next_code = arrjo.getString("next_code");
Boolean isFirst = true;
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
for (int j = 0; j < list.size(); j++) { for (int j = 0; j < list.size(); j++) {
RouteLineDto routeLineDto = list.get(j); RouteLineDto routeLineDto = list.get(j);
next_device_code = routeLineDto.getNext_device_code(); next_device_code = routeLineDto.getNext_device_code();
//包材接驳位策略
//包材取货位放到物料放置位的策略
String prefix = "BCQHW";
boolean result = StrUtil.startWithIgnoreCase(device_code, prefix);
if (result && StrUtil.isNotEmpty(next_code) && isFirst) {
next_device_code = next_code;
}
//物料放置位货物放到成品放置位策略
Device device = deviceAppService.findDeviceByCode(next_device_code); Device device = deviceAppService.findDeviceByCode(next_device_code);
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
@ -688,6 +706,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
break; break;
} else { } else {
next_device_code = ""; next_device_code = "";
isFirst = false;
} }
} }
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
@ -723,7 +742,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
try { try {
create(dto); create(dto);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw new RuntimeException("任务生成失败");
// e.printStackTrace();
} }
} }
} }

Loading…
Cancel
Save