代码修改

This commit is contained in:
lyd
2022-08-15 18:26:24 +08:00
parent 0dece0a99e
commit ea12b5dc48
14 changed files with 0 additions and 2134 deletions

View File

@@ -1,67 +0,0 @@
package org.nl.acs.device_driver.whxr.whxr_ball_mill_device;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* 自动门驱动定义
*/
@Service
public class BallMillDeviceDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "whxr_ball_mill";
}
@Override
public String getDriverName() {
return "武汉新锐-球磨机";
}
@Override
public String getDriverDescription() {
return "武汉新锐-球磨机";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new BallMillDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return BallMillDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.conveyor);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return getReadableItemDtos2();
}
public static List<ItemDto> getReadableItemDtos2() {
List<ItemDto> list = new ArrayList();
return list;
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

View File

@@ -1,68 +0,0 @@
package org.nl.acs.device_driver.whxr.whxr_ball_mill_device;
import cn.hutool.core.util.StrUtil;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.opc.Device;
import org.openscada.opc.lib.da.Server;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
/**
* 武汉新锐-球磨机
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class BallMillDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
}
public static Boolean isExistFieldName(String fieldName, Object obj) throws NoSuchFieldException {
if (obj == null || StrUtil.isEmpty(fieldName)) {
return null;
}
//获取这个类的所有属性
Field[] fields = obj.getClass().getDeclaredFields();
boolean flag = false;
//循环遍历所有的fields
for (int i = 0; i < fields.length; i++) {
if (fields[i].getName().equals(fieldName)) {
flag = true;
break;
}
}
return flag;
}
public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + param;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_param, Integer.parseInt(value));
ReadUtil.write(itemMap, server);
}
}

View File

@@ -1,102 +0,0 @@
package org.nl.acs.device_driver.whxr.whxr_ball_mill_device;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class ItemProtocol {
//喷雾塔故障 0否 1是
public static String item_to_error = "to_error";
//98%酒精选择 0否 1是
public static String item_to_alcohol1 = "to_alcohol1";
//92%酒精选择 0否 1是
public static String item_to_alcohol2 = "to_alcohol2";
//预磨次数设定
public static String item_to_pre_grinding_number = "to_pre_grinding_number";
//预磨1时间设定值小时
public static String item_to_pre_grinding1_time = "to_pre_grinding1_time";
//预磨2时间设定值小时
public static String item_to_pre_grinding2_time = "to_pre_grinding2_time";
//预磨1酒精设定值
public static String item_to_pre_grinding1_alcohol = "to_pre_grinding1_alcohol";
//预磨2酒精设定值
public static String item_to_pre_grinding2_alcohol = "to_pre_grinding2_alcohol";
//预磨时间设定值(小时)
public static String item_to_pre_grinding_time = "to_pre_grinding_time";
//工艺酒精加量设定值
public static String item_to_process_alcohol = "to_process_alcohol";
//第一次续磨时间设定(小时)
public static String item_to_continue1_time = "to_to_continue1_time";
//第二次续磨时间设定(小时)
public static String item_to_continue2_time = "to_to_continue2_time";
//补磨阶段运行时间设置
public static String item_to_supplement_grinding_runningtime = "to_supplement_grinding_runningtime";
//卸料次数设定值
public static String item_to_discharge_time = "to_discharge_time";
//卸料酒精每次加量设定值
public static String item_to_discharge_addalcohol = "to_discharge_addalcohol";
//卸料加酒精间隔时间设定
public static String item_to_discharge_addalcohol_interval = "to_discharge_addalcohol_interval";
//复杂清洗次数设定值
public static String item_to_cleaning_number = "to_to_cleaning_number";
//卸料加酒精间隔时间设定
public static String item_to_cleaning_addalcohol = "to_cleaning_addalcohol";
//复杂清洗间隔时间设定值(分钟)
public static String item_to_cleaning_interval_time = "to_cleaning_interval_time";
private BallMillDeviceDriver driver;
public ItemProtocol(BallMillDeviceDriver driver) {
this.driver = driver;
}
public ItemProtocol() {
}
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) {
log.error("读取错误!");
} else {
return value;
}
return 0;
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_error, "喷雾塔故障", "DB200.D0"));
list.add(new ItemDto(item_to_alcohol1, "98%酒精选择", "DB200.B371.3"));
list.add(new ItemDto(item_to_alcohol2, "92%酒精选择", "DB200.B371.4"));
list.add(new ItemDto(item_to_pre_grinding_number, "预磨次数设定", "DB200.D132"));
list.add(new ItemDto(item_to_pre_grinding1_time, "预磨1时间设定值小时", "DB200.D242"));
list.add(new ItemDto(item_to_pre_grinding2_time, "预磨2时间设定值小时", "DB200.D256"));
list.add(new ItemDto(item_to_pre_grinding1_alcohol, "预磨1酒精设定值", "DB200.D120"));
list.add(new ItemDto(item_to_pre_grinding2_alcohol, "预磨2酒精设定值", "DB200.D124"));
list.add(new ItemDto(item_to_pre_grinding_time, "预磨时间设定值(小时)", "DB200.D24"));
list.add(new ItemDto(item_to_process_alcohol, "工艺酒精加量设定值", "DB200.D20"));
list.add(new ItemDto(item_to_continue1_time, "第一次续磨时间设定(小时)", "DB200.D214"));
list.add(new ItemDto(item_to_continue2_time, "第二次续磨时间设定(小时)", "DB200.D226"));
list.add(new ItemDto(item_to_supplement_grinding_runningtime, "补磨阶段运行时间设置", "DB200.D372"));
list.add(new ItemDto(item_to_discharge_time, "卸料次数设定值", "DB200.D52"));
list.add(new ItemDto(item_to_discharge_addalcohol, "卸料酒精每次加量设定值", "DB200.D44"));
list.add(new ItemDto(item_to_discharge_addalcohol_interval, "卸料加酒精间隔时间设定", "DB200.D350"));
list.add(new ItemDto(item_to_cleaning_number, "复杂清洗次数设定值", "DB200.D88"));
list.add(new ItemDto(item_to_cleaning_addalcohol, "卸料加酒精间隔时间设定", "DB200.D84"));
list.add(new ItemDto(item_to_cleaning_interval_time, "复杂清洗间隔时间设定值(分钟)", "DB200.D64"));
return list;
}
}

View File

@@ -1,96 +0,0 @@
package org.nl.acs.device_driver.whxr.whxr_spary_tower_device;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class ItemProtocol {
// //设备开机 0停机 1开机
// public static String item_open_status = "open_status";
// //设备状态 0待生产 1生产中
// public static String item_running_status = "unning_status";
// //故障停机 0否 1是 
// public static String item_error_pause = "error_pause";
// //上料手自动模式 0手动 1自动
// public static String item_feeding_mode = "feeding_mode";
// //自动上料请求 0否 1是 
// public static String item_auto_feeding = "auto_feeding";
// //手动上料请求 0否 1是 
// public static String item_manual_feeding = "manual_feeding";
// //下料手自动模式 0手动 1自动
// public static String item_blanking_mode = "blanking_mode";
// //下料电磁阀开到位 0否 1是 
// public static String item_blanking_open = "blanking_open";
// //下料电磁阀关到位 0否 1是 
// public static String item_blanking_close = "blanking_close";
//
// //每桶重量 kg
// public static String item_to_everyone_weight = "to_one_weight";
// //是否最后一桶 0否 1是 
// public static String item_to_lastbucket = "to_last_bucket";
// //允许出料 0否 1是 
// public static String item_to_allow_blanking = "to_allow_blanking";
// //超时报警 0否 1是 
// public static String item_to_timeout_alarm = "to_timeout_alarm";
//搅拌槽夹套温度
public static String item_to_temperature1 = "to_temperature1";
//孔板直径 mm 0.0
public static String item_to_diameter = "to_diameter";
//雾化压力 KPa
public static String item_to_pressure = "to_pressure";
//出口温度SV
public static String item_to_temperature2 = "to_temperature2";
private SparyTowerDeviceDriver driver;
public ItemProtocol(SparyTowerDeviceDriver driver) {
this.driver = driver;
}
public String getItem_to_temperature1() {
return this.getOpcStringValue(item_to_temperature1);
}
public String getItem_to_temperature2() {
return this.getOpcStringValue(item_to_temperature1);
}
public String getItem_to_diameter() {
return this.getOpcStringValue(item_to_diameter);
}
public String getItem_to_pressure() {
return this.getOpcStringValue(item_to_pressure);
}
public String getOpcStringValue(String protocol) {
String value = this.driver.getStringValue(protocol);
if (value == null) {
log.error("读取错误!");
} else {
return value;
}
return "0";
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_temperature1, "搅拌槽夹套温度", "DB203.REAL20"));
list.add(new ItemDto(item_to_diameter, "孔板直径", "DB203.REAL24"));
list.add(new ItemDto(item_to_pressure, "雾化压力", "DB203.REAL28"));
list.add(new ItemDto(item_to_temperature2, "出口温度SV", "DB203.REAL32"));
return list;
}
}

View File

@@ -1,67 +0,0 @@
package org.nl.acs.device_driver.whxr.whxr_spary_tower_device;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* 喷雾塔动定义
*/
@Service
public class SparyTowerDeviceDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "whxr_spary_tower";
}
@Override
public String getDriverName() {
return "武汉新锐-喷雾塔";
}
@Override
public String getDriverDescription() {
return "武汉新锐-喷雾塔";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new SparyTowerDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return SparyTowerDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.conveyor);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return getReadableItemDtos2();
}
public static List<ItemDto> getReadableItemDtos2() {
List<ItemDto> list = new ArrayList();
return list;
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

View File

@@ -1,68 +0,0 @@
package org.nl.acs.device_driver.whxr.whxr_spary_tower_device;
import cn.hutool.core.util.StrUtil;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.opc.Device;
import org.openscada.opc.lib.da.Server;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
/**
* 武汉新锐-球磨机
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class SparyTowerDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
}
public static Boolean isExistFieldName(String fieldName, Object obj) throws NoSuchFieldException {
if (obj == null || StrUtil.isEmpty(fieldName)) {
return null;
}
//获取这个类的所有属性
Field[] fields = obj.getClass().getDeclaredFields();
boolean flag = false;
//循环遍历所有的fields
for (int i = 0; i < fields.length; i++) {
if (fields[i].getName().equals(fieldName)) {
flag = true;
break;
}
}
return flag;
}
public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + param;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_param, Integer.parseInt(value));
ReadUtil.write(itemMap, server);
}
}

View File

@@ -1,49 +0,0 @@
package org.nl.acs.device_driver.whxr.whxr_storage_conveyor;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.DeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
/**
* 货架
*/
@Service
public class StorageConveyorDefination implements DeviceDriverDefination {
@Override
public String getDriverCode() {
return "whxr_storage_conveyor";
}
@Override
public String getDriverName() {
return "武汉新锐-立库对接位";
}
@Override
public String getDriverDescription() {
return "武汉新锐-立库对接位";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new StorageConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return StorageConveyorDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.storage);
return types;
}
}

View File

@@ -1,35 +0,0 @@
package org.nl.acs.device_driver.whxr.whxr_storage_conveyor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.StorageDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
/**
* 武汉新锐-立库对接位
*/
@Slf4j
@Data
public class StorageConveyorDeviceDriver extends AbstractDeviceDriver implements RouteableDeviceDriver, StorageDeviceDriver, DeviceDriver {
public StorageConveyorDeviceDriver() {
}
public boolean isTakeReady() {
return true;
}
public boolean isPutReady() {
return true;
}
public boolean fixTypes(Integer type) {
return true;
}
}

View File

@@ -1,157 +0,0 @@
package org.nl.hand.ndxytwo.rest;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.annotation.Log;
import org.nl.annotation.rest.AnonymousPostMapping;
import org.nl.hand.ndxytwo.service.NdxyTwoHandService;
import org.nl.modules.system.service.UserService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @author qxuan
* @date 2021-07-21
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "纽迪希亚手持接口")
@RequestMapping("/api/andxy2/hand")
@Slf4j
public class NdxyHandTwoController {
private final PasswordEncoder passwordEncoder;
private final UserService userService;
private final NdxyTwoHandService HandService;
@PostMapping("/area")
@Log("查询区域")
@ApiOperation("查询区域")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> query(@RequestBody Map<String,String> whereJson) {
return new ResponseEntity<>(HandService.queryArea(whereJson), HttpStatus.OK);
}
@PostMapping("/point")
@Log("查询设备编号及状态")
@ApiOperation("查询设备编号及状态")
//@PreAuthorize("@el.check('sect:list')")
//@RequestBody JSONObject json
public ResponseEntity<Object> queryPoint(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.queryPointByArea(whereJson), HttpStatus.OK);
}
@PostMapping("/point/storage")
@Log("查询设备扩展属性")
@ApiOperation("查询设备扩展属性")
//@PreAuthorize("@el.check('sect:list')")
//@RequestBody JSONObject json
public ResponseEntity<Object> queryDeviceAugmentabilityByCode(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.queryDeviceAugmentabilityByCode(whereJson), HttpStatus.OK);
}
@PostMapping("/task_type")
@Log("查询任务类型")
@ApiOperation("查询任务类型")
//@PreAuthorize("@el.check('sect:list')")
//@RequestBody JSONObject json
public ResponseEntity<Object> queryTaskType() {
return new ResponseEntity<>(HandService.queryTaskType(), HttpStatus.OK);
}
@PostMapping("/tasks")
@Log("查询任务")
@ApiOperation("查询任务")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryTask(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.queryTask(whereJson), HttpStatus.OK);
}
@PostMapping("/insts")
@Log("查询指令")
@ApiOperation("查询指令")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryInst(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.queryInst(whereJson), HttpStatus.OK);
}
@PostMapping("/routeplan_type")
@Log("查询路由类型")
@ApiOperation("查询路由类型")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryRouteplanType() {
return new ResponseEntity<>(HandService.queryRouteplanType(), HttpStatus.OK);
}
@AnonymousPostMapping("/task")
@Log("创建特殊任务")
@ApiOperation("创建特殊任务")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> createTask(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(HandService.createTask(whereJson), HttpStatus.OK);
}
@PostMapping("/inst")
@Log("指令操作")
@ApiOperation("指令操作")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> Instoperation(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.Instoperation(whereJson), HttpStatus.OK);
}
@PostMapping("/taskoperation")
@Log("任务操作")
@ApiOperation("任务操作")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> Taskoperation(@RequestBody Map<String, String> whereJson) throws Exception {
return new ResponseEntity<>(HandService.Taskoperation(whereJson), HttpStatus.OK);
}
@PostMapping("/deviceStatus")
@Log("修改设备状态")
@ApiOperation("修改设备状态")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> updateDeviceStatus(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.updateDeviceStatus(whereJson), HttpStatus.OK);
}
@PostMapping("/handlogin")
@Log("手持登陆验证")
@ApiOperation("手持登陆验证")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> handlogin(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.handleLogin(whereJson), HttpStatus.OK);
}
@PostMapping("/matrial")
@Log("查询物料信息")
@ApiOperation("查询物料信息")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryMaterial() {
return new ResponseEntity<>(HandService.queryMaterial(), HttpStatus.OK);
}
@AnonymousPostMapping("/task2")
@Log("创建普通任务")
@ApiOperation("创建普通任务")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> createTask2(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(HandService.createTask2(whereJson), HttpStatus.OK);
}
}

View File

@@ -1,122 +0,0 @@
package org.nl.hand.ndxytwo.service;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
/**
* @author qxuan
* @description 服务接口
* @date 2021-07-21
**/
public interface NdxyTwoHandService {
/**
* 查询区域
*
* @param whereJson 条件
* @return Map<String, Object>
*/
Map<String, Object> queryArea(Map whereJson);
/**
* 查询设备编号及状态
*
* @return Map<String, Object>
*/
Map<String, Object> queryPointByArea(Map whereJson);
/**
* 查询设备扩展性
*
* @param deviceCode
* @return
*/
Map<String, Object> queryDeviceAugmentabilityByCode(Map deviceCode);
/**
* 查询任务状态
*
* @return
*/
Map<String, Object> queryTaskType();
/**
* 查询路由类型
*
* @return
*/
Map<String, Object> queryRouteplanType();
/**
* 查询指令
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> queryInst(Map<String, String> jsonObject);
/**
* 创建特殊任务
*
* @param jsonObject 条件
* @return JSONObject
*/
Map<String, Object> createTask(JSONObject jsonObject);
/**
* 查询任务
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> queryTask(Map<String, String> jsonObject);
/**
* 修改设备状态
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> updateDeviceStatus(Map<String, String> jsonObject);
/**
* 手持登陆
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> handleLogin(Map<String, String> jsonObject);
/**
* 指令操作
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> Instoperation(Map<String, String> jsonObject);
/**
* 任务操作
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> Taskoperation(Map<String, String> jsonObject) throws Exception;
/**
* 查询物料
*
* @return Map<String, Object>
*/
Map<String, Object> queryMaterial();
/**
* 创建普通任务
*
* @return Map<String, String>
*/
Map<String, Object> createTask2(JSONObject whereJson);
}

View File

@@ -1,80 +0,0 @@
package org.nl.hand.ndxytwo.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author qxuan
* @description /
* @date 2021-07-21
**/
@Data
public class HandDto implements Serializable {
/**
* 库区标识
*/
private String sect_uuid;
/**
* 库区编码
*/
private String sect_code;
/**
* 库区名称
*/
private String sect_name;
/**
* 库区简称
*/
private String simple_name;
/**
* 库区类型
*/
private String sect_type;
/**
* 顺序号
*/
private BigDecimal order_seq;
/**
* 仓库标识
*/
private String store_uuid;
/**
* 是否启用
*/
private String is_active;
/**
* 是否删除
*/
private String is_delete;
/**
* 创建者
*/
private String create_by;
/**
* 创建时间
*/
private String create_time;
/**
* 修改者
*/
private String update_by;
/**
* 修改时间
*/
private String update_time;
}

View File

@@ -1,994 +0,0 @@
package org.nl.hand.ndxytwo.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.agv.server.impl.AgvServiceImpl;
import org.nl.acs.config.rest.AcsConfigController;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.dto.DeviceDto;
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.instruction.service.dto.InstructionDto;
import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.impl.TaskServiceImpl;
import org.nl.config.RsaProperties;
import org.nl.exception.BadRequestException;
import org.nl.hand.ndxytwo.service.NdxyTwoHandService;
import org.nl.modules.system.service.UserService;
import org.nl.modules.system.service.dto.UserDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.RsaUtils;
import org.nl.utils.SpringContextHolder;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.WQLObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author qxuan
* @description 服务实现
* @date 2021-07-21
**/
@Service
@RequiredArgsConstructor
@Slf4j
public class NdxyTwoHandServiceImpl implements NdxyTwoHandService {
private final UserService userService;
private final PasswordEncoder passwordEncoder;
private final DeviceService deviceService;
private final DeviceAppService deviceAppService;
private final RouteLineService routelineserver;
private final TaskService taskService;
@Autowired
AcsConfigController acsConfigService;
InstructionService instructionService = null;
@Override
public Map<String, Object> queryArea(Map map) {
String type = map.get("type").toString();
JSONArray resultJSONArray;
if (StrUtil.equals(type,"1")) {
resultJSONArray = WQL.getWO("QNDXY_QUERY003").addParam("flag", "6").process().getResultJSONArray(0);
} else if (StrUtil.equals(type,"2")) {
resultJSONArray = WQL.getWO("QNDXY_QUERY003").addParam("flag", "7").process().getResultJSONArray(0);
} else {
resultJSONArray = WQL.getWO("QNDXY_QUERY003").addParam("flag", "1").process().getResultJSONArray(0);
}
JSONObject jo = new JSONObject();
jo.put("code", "1");
jo.put("desc", "查询成功");
jo.put("result", resultJSONArray);
return jo;
}
@Override
public Map<String, Object> queryPointByArea(Map map) {
String region = map.get("region").toString();
JSONArray resultArr = new JSONArray();
JSONObject resultJson = new JSONObject();
;
String status = "";
String move = "";
String quantity = "";
String input_material = "";
String remark = "";
String material = "";
String status_name = "";
if (StrUtil.equals(region, "90")) {
JSONArray acs_deviceja = WQLObject.getWQLObject("acs_device").query("region = '1'", "seq_num,device_name").getResultJSONArray(0);
for (int i = 0; i < acs_deviceja.size(); i++) {
JSONObject jo = new JSONObject();
JSONObject devicejo = acs_deviceja.getJSONObject(i);
String device_code = devicejo.getString("device_code");
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device device = appService.findDeviceByCode(device_code);
//普通站点
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
if (device == null) {
jo.put("status", status);
jo.put("device_id", devicejo.getString("device_id"));
jo.put("device_code", devicejo.getString("device_code"));
jo.put("device_name", devicejo.getString("device_code"));
jo.put("allow_update", "1");
} else {
//检测站点
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if (StrUtil.equals(device.getIslock(), "true")) {
status = "3";
move = "有任务";
} else {
if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) {
status = "0";
move = "无货";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 1) {
status = "1";
move = "空载具";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 2) {
status = "2";
move = "有托盘有货";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 3) {
status = "3";
move = "有任务";
}
}
material = device.getMaterial_type();
if (StrUtil.isNullOrUndefined(material)) {
material = "";
}
quantity = device.getQuantity();
if (StrUtil.isNullOrUndefined(quantity)) {
quantity = "";
}
String input_materialflag = (String) device.getExtraValue().get("input_material");
if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("false")) {
input_material = "0";
}
if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("true")) {
input_material = "1";
}
jo.put("material_type", material);
jo.put("quantity", quantity);
jo.put("remark", device.getRemark());
jo.put("status_name", move);
jo.put("status", status);
jo.put("device_id", devicejo.getString("device_id"));
jo.put("device_code", devicejo.getString("device_code"));
jo.put("device_name", devicejo.getString("device_name"));
jo.put("allow_update", "1");
jo.put("input_material", input_material);
jo.put("device_type", devicejo.getString("device_type"));
resultArr.add(jo);
}
}
}
} else if (StrUtil.equals(region,"91")) {
JSONArray acs_deviceja = WQLObject.getWQLObject("acs_device").query("region = '2'", "seq_num,device_name").getResultJSONArray(0);
for (int i = 0; i < acs_deviceja.size(); i++) {
JSONObject jo = new JSONObject();
JSONObject devicejo = acs_deviceja.getJSONObject(i);
String device_code = devicejo.getString("device_code");
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device device = appService.findDeviceByCode(device_code);
//普通站点
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
if (device == null) {
jo.put("status", status);
jo.put("device_id", devicejo.getString("device_id"));
jo.put("device_code", devicejo.getString("device_code"));
jo.put("device_name", devicejo.getString("device_code"));
jo.put("allow_update", "1");
} else {
//检测站点
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if (StrUtil.equals(device.getIslock(), "true")) {
status = "3";
move = "有任务";
} else {
if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) {
status = "0";
move = "无货";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 1) {
status = "1";
move = "空载具";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 2) {
status = "2";
move = "有托盘有货";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 3) {
status = "3";
move = "有任务";
}
}
material = device.getMaterial_type();
if (StrUtil.isNullOrUndefined(material)) {
material = "";
}
quantity = device.getQuantity();
if (StrUtil.isNullOrUndefined(quantity)) {
quantity = "";
}
String input_materialflag = (String) device.getExtraValue().get("input_material");
if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("false")) {
input_material = "0";
}
if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("true")) {
input_material = "1";
}
jo.put("material_type", material);
jo.put("quantity", quantity);
jo.put("remark", device.getRemark());
jo.put("status_name", move);
jo.put("status", status);
jo.put("device_id", devicejo.getString("device_id"));
jo.put("device_code", devicejo.getString("device_code"));
jo.put("device_name", devicejo.getString("device_name"));
jo.put("allow_update", "1");
jo.put("input_material", input_material);
jo.put("device_type", devicejo.getString("device_type"));
resultArr.add(jo);
}
}
}
} else if (StrUtil.equals(region,"92")) {
JSONArray acs_deviceja = WQLObject.getWQLObject("acs_device").query("region = '3'", "seq_num,device_name").getResultJSONArray(0);
for (int i = 0; i < acs_deviceja.size(); i++) {
JSONObject jo = new JSONObject();
JSONObject devicejo = acs_deviceja.getJSONObject(i);
String device_code = devicejo.getString("device_code");
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device device = appService.findDeviceByCode(device_code);
//普通站点
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
if (device == null) {
jo.put("status", status);
jo.put("device_id", devicejo.getString("device_id"));
jo.put("device_code", devicejo.getString("device_code"));
jo.put("device_name", devicejo.getString("device_code"));
jo.put("allow_update", "1");
} else {
//检测站点
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if (StrUtil.equals(device.getIslock(), "true")) {
status = "3";
move = "有任务";
} else {
if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) {
status = "0";
move = "无货";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 1) {
status = "1";
move = "空载具";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 2) {
status = "2";
move = "有托盘有货";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 3) {
status = "3";
move = "有任务";
}
}
material = device.getMaterial_type();
if (StrUtil.isNullOrUndefined(material)) {
material = "";
}
quantity = device.getQuantity();
if (StrUtil.isNullOrUndefined(quantity)) {
quantity = "";
}
String input_materialflag = (String) device.getExtraValue().get("input_material");
if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("false")) {
input_material = "0";
}
if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("true")) {
input_material = "1";
}
jo.put("material_type", material);
jo.put("quantity", quantity);
jo.put("remark", device.getRemark());
jo.put("status_name", move);
jo.put("status", status);
jo.put("device_id", devicejo.getString("device_id"));
jo.put("device_code", devicejo.getString("device_code"));
jo.put("device_name", devicejo.getString("device_name"));
jo.put("allow_update", "1");
jo.put("input_material", input_material);
jo.put("device_type", devicejo.getString("device_type"));
resultArr.add(jo);
}
}
}
}
else if (StrUtil.equals(region,"98")) {
JSONArray acs_deviceja = WQLObject.getWQLObject("acs_device").query("region = '4'", "seq_num,device_name").getResultJSONArray(0);
for (int i = 0; i < acs_deviceja.size(); i++) {
JSONObject jo = new JSONObject();
JSONObject devicejo = acs_deviceja.getJSONObject(i);
String device_code = devicejo.getString("device_code");
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device device = appService.findDeviceByCode(device_code);
//普通站点
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
if (device == null) {
jo.put("status", status);
jo.put("device_id", devicejo.getString("device_id"));
jo.put("device_code", devicejo.getString("device_code"));
jo.put("device_name", devicejo.getString("device_code"));
jo.put("allow_update", "1");
} else {
//检测站点
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if (StrUtil.equals(device.getIslock(), "true")) {
status = "3";
move = "有任务";
} else {
if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) {
status = "0";
move = "无货";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 1) {
status = "1";
move = "空载具";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 2) {
status = "2";
move = "有托盘有货";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 3) {
status = "3";
move = "有任务";
}
}
material = device.getMaterial_type();
if (StrUtil.isNullOrUndefined(material)) {
material = "";
}
quantity = device.getQuantity();
if (StrUtil.isNullOrUndefined(quantity)) {
quantity = "";
}
String input_materialflag = (String) device.getExtraValue().get("input_material");
if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("false")) {
input_material = "0";
}
if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("true")) {
input_material = "1";
}
jo.put("material_type", material);
jo.put("quantity", quantity);
jo.put("remark", device.getRemark());
jo.put("status_name", move);
jo.put("status", status);
jo.put("device_id", devicejo.getString("device_id"));
jo.put("device_code", devicejo.getString("device_code"));
jo.put("device_name", devicejo.getString("device_name"));
jo.put("allow_update", "1");
jo.put("input_material", input_material);
jo.put("device_type", devicejo.getString("device_type"));
resultArr.add(jo);
}
}
}
}
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", resultArr);
return resultJson;
}
@Override
public Map<String, Object> queryDeviceAugmentabilityByCode(Map whereMap) {
String deviceCode = whereMap.get("device_code").toString();
JSONObject resultJson = new JSONObject();
JSONObject jo = new JSONObject();
JSONObject acs_device = WQLObject.getWQLObject("ACS_DEVICE").query("device_code = '" + deviceCode + "'").pageResult();
JSONObject acsDevice = (JSONObject) acs_device.getJSONArray("content").get(0);
//判断设备类型是不是storage
if (!"storage".equals(acsDevice.getString("device_type"))) {
resultJson.put("code", "0");
resultJson.put("desc", "该设备不是货架");
resultJson.put("result", "");
return resultJson;
}
JSONObject jsonObject = deviceService.queryStorageExtra(deviceCode);
jo.put("device_id", acsDevice.getString("device_id"));
jo.put("device_code", deviceCode);
jo.put("device_name", acsDevice.getString("device_name"));
jo.put("device_type", acsDevice.getString("device_type"));
jo.put("maxY", jsonObject.getString("maxY"));
jo.put("minY", jsonObject.getString("minY"));
jo.put("maxZ", jsonObject.getString("maxZ"));
jo.put("minZ", jsonObject.getString("minZ"));
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", jo);
return resultJson;
}
@Override
public Map<String, Object> queryRouteplanType() {
JSONObject resultJson = new JSONObject();
JSONObject jo = WQLObject.getWQLObject("acs_route_plan").query().pageResult();
JSONArray arr = new JSONArray();
JSONArray content = jo.getJSONArray("content");
for (int i = 0; i < content.size(); i++) {
JSONObject jsonObject = (JSONObject) content.get(i);
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("value", jsonObject.getString("plan_code"));
jsonObject1.put("label", jsonObject.getString("plan_name"));
arr.add(jsonObject1);
}
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", arr);
return resultJson;
}
@Override
public Map<String, Object> queryTaskType() {
JSONObject resultJson = new JSONObject();
JSONObject jo = WQLObject.getWQLObject("sys_dict_detail").query("name = 'task_type'").pageResult();
JSONArray arr = new JSONArray();
JSONArray content = jo.getJSONArray("content");
for (int i = 0; i < content.size(); i++) {
JSONObject jsonObject = (JSONObject) content.get(i);
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("value", jsonObject.getString("value"));
jsonObject1.put("label", jsonObject.getString("label"));
arr.add(jsonObject1);
}
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", arr);
return resultJson;
}
@Override
public Map<String, Object> queryInst(Map<String, String> jsonObject) {
//查询位完成的指令
JSONObject resultJson = new JSONObject();
HashMap<String, String> map = new HashMap<>();
String key = jsonObject.get("keyword");
String start_point = jsonObject.get("start_devicecode");
String next_point = jsonObject.get("next_devicecode");
map.put("flag", "4");
if (StrUtil.isNotEmpty(key)) {
map.put("key", "%" + key + "%");
}
if (StrUtil.isNotEmpty(start_point)) {
map.put("start_point", "%" + start_point + "%");
}
if (StrUtil.isNotEmpty(next_point)) {
map.put("next_point", "%" + next_point + "%");
}
JSONArray resultArr = WQL.getWO("QNDXY_QUERY003").addParamMap(map).addParamMap((HashMap) jsonObject).process().getResultJSONArray(0);
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", resultArr);
return resultJson;
}
@Override
public Map<String, Object> createTask(JSONObject whereJson) {
JSONArray array1 = JSONArray.parseArray(JSON.toJSONString(whereJson.get("start_devicecode")));
JSONArray array2 = JSONArray.parseArray(JSON.toJSONString(whereJson.get("next_devicecode")));
JSONObject resultJson = new JSONObject();
boolean isPass = true;
String message = "";
for (int i = 0; i < array1.size(); i++) {
JSONObject json = array1.getJSONObject(i);
JSONObject json2 = array2.getJSONObject(i);
String start_device_code = json.getString("device_code");
String next_device_code = json2.getString("device_code");
DeviceDto startDto = deviceService.findByCode(start_device_code);
DeviceDto nextDto = deviceService.findByCode(next_device_code);
if (StrUtil.equals(startDto.getRegion(),nextDto.getRegion())) {
resultJson.put("code", "2");
resultJson.put("desc", "起点终点不能为同一区域!");
resultJson.put("result", "");
return resultJson;
}
String plan_code = "two";
if (routelineserver.getActivePathLine(start_device_code, next_device_code, plan_code).size() == 0) {
isPass = false;
message += start_device_code + "->" + next_device_code + "路由不通!";
}
}
if (!isPass) {
resultJson.put("code", "2");
resultJson.put("desc", message);
resultJson.put("result", "");
return resultJson;
}
for (int i = 0; i < array1.size(); i++) {
JSONObject arrjo1 = array1.getJSONObject(i);
JSONObject arrjo2 = array2.getJSONObject(i);
String material_type = arrjo1.getString("material_type");
String quantity = arrjo1.getString("quantity");
String remark = arrjo1.getString("remark");
String start_device_code = arrjo1.getString("device_code");
String next_device_code = arrjo2.getString("device_code");
Device start_device = deviceAppService.findDeviceByCode(start_device_code);
Device next_device = deviceAppService.findDeviceByCode(next_device_code);
if (start_device.getHas_goods() == 0) {
resultJson.put("code", "2");
resultJson.put("desc", "该起点没有货物!");
resultJson.put("result", "");
return resultJson;
}
if (next_device.getHas_goods() != 0) {
resultJson.put("code", "2");
resultJson.put("desc", "该终点有货物!");
resultJson.put("result", "");
return resultJson;
}
TaskDto dto = new TaskDto();
dto.setRoute_plan_code("two");
if (ObjectUtil.isNotEmpty(taskService.findByStartCode(start_device_code))
|| ObjectUtil.isNotEmpty(taskService.findByNextCode(next_device_code))) {
resultJson.put("code", "2");
resultJson.put("desc", "已存在该起点或终点的任务!");
resultJson.put("result", "");
return resultJson;
}
if (StrUtil.equals(material_type, "") || StrUtil.equals(quantity, "")) {
resultJson.put("code", "2");
resultJson.put("desc", "请填写物料信息!");
resultJson.put("result", "");
return resultJson;
}
dto.setStart_device_code(start_device_code);
dto.setStart_point_code(start_device_code);
dto.setNext_device_code(next_device_code);
dto.setNext_point_code(next_device_code);
dto.setQuantity(new BigDecimal(quantity));
dto.setRemark(remark);
dto.setMaterial(material_type);
try {
taskService.create(dto);
} catch (Exception e) {
resultJson.put("code", "2");
resultJson.put("desc", e.getMessage());
resultJson.put("result", "");
return resultJson;
}
}
resultJson.put("code", "1");
resultJson.put("desc", "生成成功!");
resultJson.put("result", "");
return resultJson;
}
@Override
public Map<String, Object> queryTask(Map<String, String> jsonObject) {
String key = jsonObject.get("keyword");
String start_point = jsonObject.get("start_devicecode");
String next_point = jsonObject.get("next_devicecode");
HashMap<String, String> map = new HashMap<>();
map.put("flag", "2");
if (StrUtil.isNotEmpty(key)) {
map.put("key", "%" + key + "%");
}
if (StrUtil.isNotEmpty(start_point)) {
map.put("start_point", "%" + start_point + "%");
}
if (StrUtil.isNotEmpty(next_point)) {
map.put("next_point", "%" + next_point + "%");
}
//查询有任务 但是没有指令的任务
JSONArray result = WQL.getWO("QNDXY_QUERY003").addParamMap(map).process().getResultJSONArray(0);
JSONObject resultJson = new JSONObject();
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", result);
return resultJson;
}
@Override
public Map<String, Object> updateDeviceStatus(Map<String, String> jsonObject) {
//修改任务的状态
String device_code = jsonObject.get("device_code");
String type = jsonObject.get("type");
//需要数量
String quantity = jsonObject.get("quantity");
String status = jsonObject.get("status");
//物料类型
String material_type = jsonObject.get("material_type");
String remark = jsonObject.get("remark");
JSONObject resultJson = new JSONObject();
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device device = appService.findDeviceByCode(device_code);
//普通站点
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
if (StrUtil.equals(status,"3")) {
resultJson.put("code", "2");
resultJson.put("desc", "不可手动改为任务状态!");
resultJson.put("result", "");
return resultJson;
}
if (device.getHas_goods() == 3) {
resultJson.put("code", "2");
resultJson.put("desc", "当前站点有任务,无法修改");
resultJson.put("result", "");
return resultJson;
}
//修改
if (type.equals("1")) {
//纽迪希亚专用
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if (Boolean.parseBoolean(device.getIslock())) {
resultJson.put("code", "0");
resultJson.put("desc", "已有任务无法绑定!");
resultJson.put("result", new JSONObject());
}
standardOrdinarySiteDeviceDriver.setHasGoods(Integer.parseInt(status));
device.setHas_goods(Integer.parseInt(status));
standardOrdinarySiteDeviceDriver.setQty(quantity);
standardOrdinarySiteDeviceDriver.setMaterial(material_type);
standardOrdinarySiteDeviceDriver.setRemark(remark);
device.setMaterial_type(material_type);
device.setQuantity(quantity);
device.setRemark(remark);
}
}
//清空
if (type.equals("2")) {
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
standardOrdinarySiteDeviceDriver.setHasGoods(0);
standardOrdinarySiteDeviceDriver.setQty("");
standardOrdinarySiteDeviceDriver.setMaterial("");
standardOrdinarySiteDeviceDriver.setRemark("");
device.setHas_goods(0);
device.setMaterial_type("");
device.setQuantity("");
device.setRemark("");
}
}
resultJson.put("code", "1");
resultJson.put("desc", "更新成功");
resultJson.put("result", new JSONObject());
return resultJson;
}
@SneakyThrows
@Override
public Map<String, Object> handleLogin(Map<String, String> jsonObject) {
JSONObject resultJson = new JSONObject();
String user = jsonObject.get("user");
String password = jsonObject.get("password");
if (StrUtil.isEmpty("user")) {
resultJson.put("code", "1");
resultJson.put("desc", "用户不能为空");
return resultJson;
}
if (StrUtil.isEmpty("password")) {
resultJson.put("code", "1");
resultJson.put("desc", "密码不能为空!");
return resultJson;
}
boolean is_match = false;
Long account_id = 0L;
try {
String pwd = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, password);
UserDto userDto = userService.findByName(user);
account_id = userDto.getId();
is_match = passwordEncoder.matches(pwd, userDto.getPassword());
} catch (Exception e) {
e.printStackTrace();
}
if (is_match) {
resultJson.put("code", "1");
resultJson.put("desc", "登陆成功");
} else {
resultJson.put("code", "2");
resultJson.put("desc", "登陆失败!");
}
JSONObject jo = new JSONObject();
jo.put("user_name", user);
jo.put("account_id", account_id);
resultJson.put("result", jo);
return resultJson;
}
@Override
public Map<String, Object> Instoperation(Map<String, String> jsonObject) {
JSONObject jo = new JSONObject();
String type = jsonObject.get("type");
String inst_uuid = jsonObject.get("inst_uuid");
JSONObject instwo = WQLObject.getWQLObject("acs_instruction").query("instruction_id='" + inst_uuid + "'").uniqueResult(0);
if (instwo == null) {
throw new BadRequestException("未找到该指令!");
}
if (StrUtil.equals(instwo.getString("instruction_status"), "2") ||
StrUtil.equals(instwo.getString("instruction_status"), "3")) {
jo.put("code", "2");
jo.put("desc", "指令已完成或已取消,无法操作");
jo.put("result", "");
return jo;
}
String task_id = instwo.getString("task_id");
Instruction instdto = instwo.toJavaObject(Instruction.class);
AgvService agvService = SpringContextHolder.getBean(AgvServiceImpl.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
/* 1 指令撤销
2 重新下发
3 强制完成*/
if (type.equals("1")) {
//调用agv删除任务的接口
try {
agvService.deleteAgvInst(instwo.getString("instruction_code"));
} catch (Exception e) {
jo.put("code", "2");
jo.put("desc", "下发agv失败");
jo.put("result", "");
return jo;
}
}
if (type.equals("2")) {
try {
agvService.sendAgvInstToMagic(instdto);
} catch (Exception e) {
jo.put("code", "2");
jo.put("desc", "下发agv失败");
jo.put("result", "");
return jo;
}
}
if (type.equals("3")) {
//完成指令
try {
instructionService.finish(inst_uuid);
String next_device_code = instdto.getNext_device_code();
Device device = deviceAppService.findDeviceByCode(next_device_code);
if (ObjectUtil.isNotEmpty(taskService.findByNextCode(next_device_code))) {
device.setHas_goods(3);
}
} catch (Exception e) {
jo.put("code", "2");
jo.put("desc", e.getMessage());
jo.put("result", "");
return jo;
}
}
jo.put("code", "1");
jo.put("desc", "操作成功");
jo.put("result", new JSONObject());
return jo;
}
@Override
public Map<String, Object> Taskoperation(Map<String, String> jsonObject) throws Exception {
JSONObject jo = new JSONObject();
String task_uuid = jsonObject.get("inst_uuid");
String type = jsonObject.get("type");
JSONObject taskjo = WQLObject.getWQLObject("acs_task").query("task_id='" + task_uuid + "'").uniqueResult(0);
String task_code = taskjo.getString("task_code");
String start_point_code = taskjo.getString("start_point_code");
String next_point_code = taskjo.getString("next_point_code");
String task_id = taskjo.getString("task_id");
if (StrUtil.isEmpty(task_uuid)) {
throw new BadRequestException("id不能为空");
}
if (StrUtil.isEmpty(type)) {
throw new BadRequestException("操作类型不能为空!");
}
if (StrUtil.equals(taskjo.getString("task_status"), "2") ||
StrUtil.equals(taskjo.getString("task_status"), "3")) {
jo.put("code", "2");
jo.put("desc", "任务已完成或已取消,无法操作");
jo.put("result", "");
return jo;
}
//重新生成
if (type.equals("1")) {
//重新生产指令
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
instdto.setRemark(taskjo.getString("remark"));
instdto.setMaterial(taskjo.getString("material"));
instdto.setTask_id(taskjo.getString("task_id"));
instdto.setTask_code(taskjo.getString("task_code"));
instdto.setVehicle_code(taskjo.getString("vehicle_code"));
instdto.setRoute_plan_code(taskjo.getString("route_plan_code"));
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by("auto");
instdto.setStart_point_code(taskjo.getString("start_point_code"));
instdto.setNext_point_code(taskjo.getString("next_point_code"));
instdto.setStart_device_code(taskjo.getString("start_device_code"));
instdto.setNext_device_code(taskjo.getString("next_device_code"));
instdto.setInstruction_status("0");
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
JSONObject instcheckjson = instwo.query(" instruction_status <2 and next_point_code= '" + next_point_code + "'" + " and start_point_code = '" + start_point_code + "'" + " and task_id = '" + task_id + "'").uniqueResult(0);
if (instcheckjson != null) {
jo.put("code", "2");
jo.put("desc", "操作失败");
jo.put("result", task_code + ":该任务已存在待完成指令!");
}
List<Instruction> instructions = instructionService.queryAll("instruction_status < 2");
if (instructions.size() >= 1) {
jo.put("code", "2");
jo.put("desc", "当前已有指令,无法生成!");
jo.put("result", "");
return jo;
}
try {
instructionService.create(instdto);
} catch (Exception e) {
jo.put("code", "2");
jo.put("desc", e.getMessage());
jo.put("result", "");
return jo;
}
instdto.setExecute_device_code(taskjo.getString("start_point_code"));
//下发指令给agv
// AgvService agvserver = SpringContextHolder.getBean("agvServiceImpl");
// try {
// agvserver.sendAgvInstToMagic(instdto);
// } catch (Exception e) {
// jo.put("code", "2");
// jo.put("desc", e.getMessage());
// jo.put("result", "");
// return jo;
// }
}
//强制完成
if (type.equals("2")) {
//手工完成
Device deviceByCode = deviceAppService.findDeviceByCode(start_point_code);
Device next_device = deviceAppService.findDeviceByCode(next_point_code);
next_device.setHas_goods(0);
deviceByCode.setHas_goods(2);
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
TaskDto acsTask = taskjo.toJavaObject(TaskDto.class);
InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl");
InstructionDto instdto = instructionservice.findByTaskid(acsTask.getTask_id(), "instruction_status < 2 ");
if (instdto != null){
jo.put("code", "2");
jo.put("desc", "有指令未完成");
jo.put("result", "");
return jo;
}
taskService.finish(acsTask.getTask_id());
if (ObjectUtil.isNotEmpty(taskService.findByNextCode(next_point_code))) {
next_device.setHas_goods(3);
}
}
jo.put("code", "1");
jo.put("desc", "操作成功");
jo.put("result", new JSONObject());
return jo;
}
@Override
public Map<String, Object> queryMaterial() {
JSONArray resultArr = WQL.getWO("QNDXY_QUERY003").addParam("flag", "5").process().getResultJSONArray(0);
JSONObject jo = new JSONObject();
jo.put("code", "1");
jo.put("desc", "查询成功");
jo.put("result", resultArr);
return jo;
}
@Override
public Map<String, Object> createTask2(JSONObject whereJson) {
JSONArray array = JSONArray.parseArray(JSON.toJSONString(whereJson.get("start_devicecode")));
String next_device_code = (String) whereJson.get("next_devicecode");
JSONObject resultJson = new JSONObject();
boolean isPass = true;
String message = "";
for (int i = 0; i < array.size(); i++) {
JSONObject json = array.getJSONObject(i);
String start_device_code = json.getString("device_code");
String plan_code = "one";
if (routelineserver.getActivePathLine(start_device_code, next_device_code, plan_code).size() == 0) {
isPass = false;
message += start_device_code + "->" + next_device_code + "路由不通!";
}
}
if (!isPass) {
resultJson.put("code", "2");
resultJson.put("desc", message);
resultJson.put("result", "");
return resultJson;
}
for (int i = 0; i < array.size(); i++) {
JSONObject arrjo = array.getJSONObject(i);
String material_type = arrjo.getString("material_type");
String quantity = arrjo.getString("quantity");
String remark = arrjo.getString("remark");
String device_code = arrjo.getString("device_code");
TaskDto dto = new TaskDto();
dto.setRoute_plan_code("one");
if (ObjectUtil.isNotEmpty(taskService.findByStartCode(device_code))) {
resultJson.put("code", "2");
resultJson.put("desc", "已存在该起点的任务!");
resultJson.put("result", "");
return resultJson;
}
if (StrUtil.equals(material_type, "") || StrUtil.equals(quantity, "")) {
resultJson.put("code", "2");
resultJson.put("desc", "请填写物料信息!");
resultJson.put("result", "");
return resultJson;
}
dto.setStart_device_code(device_code);
dto.setStart_point_code(device_code);
dto.setNext_device_code(next_device_code);
dto.setNext_point_code(next_device_code);
dto.setQuantity(new BigDecimal(quantity));
dto.setRemark(remark);
dto.setMaterial(material_type);
try {
taskService.create(dto);
} catch (Exception e) {
resultJson.put("code", "2");
resultJson.put("desc", e.getMessage());
resultJson.put("result", resultJson);
return resultJson;
}
}
resultJson.put("code", "1");
resultJson.put("desc", "生成成功!");
resultJson.put("result", "");
return resultJson;
}
}

View File

@@ -1,220 +0,0 @@
[交易说明]
交易名: 手持接口查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.key TYPEAS s_string
输入.keyword TYPEAS s_string
输入.start_point TYPEAS s_string
输入.next_point TYPEAS s_string
输入.detail_id TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
QUERY
SELECT
dtl.detail_id as region_id,
dtl.label as region_name,
dtl.value as region_code
FROM
sys_dict sys
LEFT JOIN sys_dict_detail dtl ON dtl.dict_id = sys.dict_id
WHERE
sys.NAME = "region_type"
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "2"
QUERY
SELECT
task.task_id AS task_uuid,
task.task_code AS task_no,
task.start_point_code AS start_devicecode,
task.next_point_code AS next_devicecode,
task.task_type AS task_type,
task.material AS material_type,
sys2.label AS material_type_name,
task.task_status AS task_status,
sys.label AS task_status_name,
task.vehicle_code AS carrier,
task.create_time,
task.priority
FROM
acs_task task
INNER JOIN sys_dict_detail AS sys ON sys.
VALUE = task.task_status
AND sys.NAME = 'task_status'
LEFT JOIN sys_dict_detail AS sys2 ON sys2.
VALUE = task.material
AND sys2.NAME = 'material_type'
where
( task.task_status ='1' or task.task_status ='0' )
and
( task.task_id IN (select inst.task_id FROM acs_instruction inst where inst.is_delete<>1 and (instruction_status<>'1' and instruction_status <>'2' and instruction_status <>'0')) or task.task_id not in (select inst.task_id FROM acs_instruction inst where inst.is_delete<>1
))
OPTION 输入.key <> ""
(task.task_code like 输入.key
or task.task_status like 输入.key
or task.vehicle_code like 输入.key)
ENDOPTION
OPTION 输入.start_point <> ""
task.start_point_code like 输入.start_point
ENDOPTION
OPTION 输入.next_point <> ""
task.next_point_code like 输入.next_point
ENDOPTION
ORDER BY task.create_time
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "3"
QUERY
SELECT
*
FROM
sys_dict_detail detl
WHERE
1=1
OPTION 输入.detail_id <> ""
detl.detail_id = 输入.detail_id
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "4"
QUERY
SELECT
inst.instruction_id AS inst_uuid,
inst.task_code AS task_no,
inst.instruction_code AS inst_no,
inst.task_code AS task_code,
inst.vehicle_code AS vehicle_code,
inst.start_point_code AS start_devicecode,
inst.next_point_code AS next_devicecode,
inst.instruction_status AS inst_status,
dtl.label AS inst_status_name,
inst.execute_message AS inst_step,
inst.vehicle_code AS carrier,
inst.carno,
inst.priority,
inst.send_status,
inst.create_time,
inst.material AS material_type,
dtl2.label AS material_type_name,
dtl3.label AS send_status_name
FROM
acs_instruction inst
LEFT JOIN sys_dict_detail AS dtl ON dtl.
VALUE
= inst.instruction_status
AND dtl.NAME = 'inst_status'
LEFT JOIN sys_dict_detail dtl2 ON dtl2.
VALUE
= inst.material
AND dtl2.NAME = 'material_type'
LEFT JOIN sys_dict_detail dtl3 ON dtl3.
VALUE
= inst.send_status
AND dtl3.NAME = 'send_status'
WHERE
inst.is_delete = '0'
AND inst.instruction_status <> '2'
AND inst.instruction_status <> '3'
OPTION 输入.key <> ""
(inst.instruction_code like 输入.key
or inst.task_code like 输入.key
or inst.vehicle_code like 输入.key)
ENDOPTION
OPTION 输入.start_point <> ""
inst.start_point_code like 输入.start_point
ENDOPTION
OPTION 输入.next_point <> ""
inst.next_point_code like 输入.next_point
ENDOPTION
ORDER BY
inst.create_time DESC
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "5"
QUERY
SELECT
detl.label AS label,
detl.VALUE AS value
FROM
sys_dict_detail detl
WHERE
detl.name = 'material_type'
order by
dict_sort
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "6"
QUERY
SELECT
dtl.detail_id as region_id,
dtl.label as region_name,
dtl.value as region_code
FROM
sys_dict sys
LEFT JOIN sys_dict_detail dtl ON dtl.dict_id = sys.dict_id
WHERE
sys.NAME = "region_type"
AND dtl.VALUE IN ('2')
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "7"
QUERY
SELECT
dtl.detail_id as region_id,
dtl.label as region_name,
dtl.value as region_code
FROM
sys_dict sys
LEFT JOIN sys_dict_detail dtl ON dtl.dict_id = sys.dict_id
WHERE
sys.NAME = "region_type"
AND dtl.VALUE IN ('1','2','3')
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -1,9 +0,0 @@
//项目协议类型说明
0标准协议荣力营口,杰牌,金力永磁
1新锐
2贤益
3奇达
4广钞厂
5:纽迪希亚
6太钢
7:洁美