7 changed files with 1371 additions and 22 deletions
@ -0,0 +1,167 @@ |
|||||
|
|
||||
|
package org.nl.hand.amb.rest; |
||||
|
|
||||
|
|
||||
|
import cn.dev33.satoken.annotation.SaIgnore; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.hand.amb.service.HFHandService; |
||||
|
import org.nl.modules.logging.annotation.Log; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
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/hand") |
||||
|
@Slf4j |
||||
|
public class HFHandController { |
||||
|
private final HFHandService HandService; |
||||
|
|
||||
|
@PostMapping("/area") |
||||
|
@Log("查询区域") |
||||
|
@ApiOperation("查询区域") |
||||
|
@SaIgnore |
||||
|
//@PreAuthorize("@el.check('sect:list')")
|
||||
|
public ResponseEntity<Object> query() { |
||||
|
return new ResponseEntity<>(HandService.queryArea(null), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/point") |
||||
|
@Log("查询设备编号及状态") |
||||
|
@ApiOperation("查询设备编号及状态") |
||||
|
@SaIgnore |
||||
|
//@PreAuthorize("@el.check('sect:list')")
|
||||
|
//@RequestBody JSONObject json
|
||||
|
public ResponseEntity<Object> queryPoint(@RequestBody Map<String, String> whereJson) { |
||||
|
String region = (String) whereJson.get("region"); |
||||
|
return new ResponseEntity<>(HandService.queryPointByArea(region), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/point/storage") |
||||
|
@Log("查询设备扩展属性") |
||||
|
@ApiOperation("查询设备扩展属性") |
||||
|
@SaIgnore |
||||
|
//@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("查询任务类型") |
||||
|
@SaIgnore |
||||
|
//@PreAuthorize("@el.check('sect:list')")
|
||||
|
//@RequestBody JSONObject json
|
||||
|
public ResponseEntity<Object> queryTaskType() { |
||||
|
return new ResponseEntity<>(HandService.queryTaskType(), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/tasks") |
||||
|
@Log("查询任务") |
||||
|
@ApiOperation("查询任务") |
||||
|
@SaIgnore |
||||
|
//@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("查询指令") |
||||
|
@SaIgnore |
||||
|
//@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("查询路由类型") |
||||
|
@SaIgnore |
||||
|
//@PreAuthorize("@el.check('sect:list')")
|
||||
|
public ResponseEntity<Object> queryRouteplanType() { |
||||
|
return new ResponseEntity<>(HandService.queryRouteplanType(), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/task") |
||||
|
@Log("创建任务") |
||||
|
@ApiOperation("创建任务") |
||||
|
@SaIgnore |
||||
|
//@PreAuthorize("@el.check('sect:list')")
|
||||
|
public ResponseEntity<Object> createTask(@RequestBody Map<String, String> whereJson) { |
||||
|
return new ResponseEntity<>(HandService.createTask(whereJson), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/inst") |
||||
|
@Log("指令操作") |
||||
|
@ApiOperation("指令操作") |
||||
|
@SaIgnore |
||||
|
//@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("任务操作") |
||||
|
@SaIgnore |
||||
|
//@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("修改设备状态") |
||||
|
@SaIgnore |
||||
|
//@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("手持登陆验证") |
||||
|
@SaIgnore |
||||
|
//@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("查询物料信息") |
||||
|
@SaIgnore |
||||
|
//@PreAuthorize("@el.check('sect:list')")
|
||||
|
public ResponseEntity<Object> queryMaterial() { |
||||
|
return new ResponseEntity<>(HandService.queryMaterial(), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/task2") |
||||
|
@Log("创建任务") |
||||
|
@ApiOperation("创建任务") |
||||
|
@SaIgnore |
||||
|
//@PreAuthorize("@el.check('sect:list')")
|
||||
|
public ResponseEntity<Object> createTask2(@RequestBody Map<String, String> whereJson) { |
||||
|
return new ResponseEntity<>(HandService.createTask2(whereJson), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,115 @@ |
|||||
|
|
||||
|
package org.nl.hand.amb.service; |
||||
|
|
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @author qxuan |
||||
|
* @description 服务接口 |
||||
|
* @date 2021-07-21 |
||||
|
**/ |
||||
|
public interface HFHandService { |
||||
|
|
||||
|
/** |
||||
|
* 查询区域 |
||||
|
* |
||||
|
* @param whereJson 条件 |
||||
|
* @return Map<String, Object> |
||||
|
*/ |
||||
|
Map<String, Object> queryArea(Map whereJson); |
||||
|
|
||||
|
/** |
||||
|
* 查询设备编号及状态 |
||||
|
* |
||||
|
* @return Map<String, Object> |
||||
|
*/ |
||||
|
Map<String, Object> queryPointByArea(String dict_id); |
||||
|
|
||||
|
/** |
||||
|
* 查询设备扩展性 |
||||
|
* |
||||
|
* @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 Map<String, Object> |
||||
|
*/ |
||||
|
Map<String, Object> createTask(Map<String, String> 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(); |
||||
|
|
||||
|
Map<String, Object> createTask2(Map<String, String> whereJson); |
||||
|
} |
@ -0,0 +1,80 @@ |
|||||
|
package org.nl.hand.amb.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; |
||||
|
} |
@ -0,0 +1,767 @@ |
|||||
|
|
||||
|
package org.nl.hand.amb.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.JSONArray; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.SneakyThrows; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.acs.agv.server.MagicAgvService; |
||||
|
import org.nl.acs.agv.server.impl.MagicAgvServiceImpl; |
||||
|
import org.nl.acs.device.service.DeviceService; |
||||
|
import org.nl.acs.device.service.dto.DeviceDto; |
||||
|
import org.nl.acs.device.service.impl.DeviceServiceImpl; |
||||
|
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; |
||||
|
import org.nl.acs.device_driver.basedriver.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.hand.amb.service.HFHandService; |
||||
|
import org.nl.modules.common.config.RsaProperties; |
||||
|
import org.nl.modules.common.exception.BadRequestException; |
||||
|
import org.nl.modules.common.utils.RsaUtils; |
||||
|
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.modules.wql.WQL; |
||||
|
import org.nl.modules.wql.core.bean.WQLObject; |
||||
|
import org.nl.modules.wql.util.SpringContextHolder; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* @author qxuan |
||||
|
* @description 服务实现 |
||||
|
* @date 2021-07-21 |
||||
|
**/ |
||||
|
@Service |
||||
|
@RequiredArgsConstructor |
||||
|
@Slf4j |
||||
|
public class HFHandServiceImpl implements HFHandService { |
||||
|
private final UserService userService; |
||||
|
private final DeviceService deviceService; |
||||
|
private final DeviceAppService deviceAppService; |
||||
|
InstructionService instructionService = null; |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public Map<String, Object> queryArea(Map whereJson) { |
||||
|
JSONObject jo = new JSONObject(); |
||||
|
JSONArray resultJSONArray = WQL.getWO("QJN_QUERY001").addParam("flag", "1").process().getResultJSONArray(0); |
||||
|
jo.put("code", "1"); |
||||
|
jo.put("desc", "查询成功"); |
||||
|
jo.put("result", resultJSONArray); |
||||
|
return jo; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Map<String, Object> queryPointByArea(String dict_id) { |
||||
|
JSONArray resultArr = new JSONArray(); |
||||
|
JSONObject resultJson = new JSONObject(); |
||||
|
JSONObject jo = new JSONObject(); |
||||
|
|
||||
|
if (StrUtil.isEmpty(dict_id)) { |
||||
|
throw new BadRequestException("区域id不能为空!"); |
||||
|
} |
||||
|
String value = ""; |
||||
|
String move = ""; |
||||
|
String status = ""; |
||||
|
String input_material = "0"; |
||||
|
String allow_update = ""; |
||||
|
String material = ""; |
||||
|
String batch = ""; |
||||
|
|
||||
|
//再字典中查询出value
|
||||
|
//JSONObject valuejo = WQLObject.getWQLObject("sys_dict_detail").query("detail_id='" + dict_id + "'").uniqueResult(0);
|
||||
|
JSONObject valuejo = WQL.getWO("QJN_QUERY001").addParam("flag", "3").addParam("detail_id", dict_id).process().uniqueResult(0); |
||||
|
if (!ObjectUtil.isEmpty(valuejo)) { |
||||
|
value = valuejo.getString("value"); |
||||
|
} |
||||
|
//根据value值去查所有的设备
|
||||
|
JSONArray acs_deviceja = WQLObject.getWQLObject("ACS_DEVICE").query("region='" + value + "' and device_type='conveyor' and is_config='true' ", "seq_num,device_name").getResultJSONArray(0); |
||||
|
for (int i = 0; i < acs_deviceja.size(); i++) { |
||||
|
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; |
||||
|
//检测站点
|
||||
|
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; |
||||
|
|
||||
|
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 = "有托盘有货"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
material = device.getMaterial_type(); |
||||
|
//material = standardOrdinarySiteDeviceDriver.getMaterial();
|
||||
|
if (StrUtil.isNullOrUndefined(material)) { |
||||
|
material = ""; |
||||
|
} |
||||
|
batch = device.getBatch(); |
||||
|
//batch = standardOrdinarySiteDeviceDriver.getBatch();
|
||||
|
if (StrUtil.isNullOrUndefined(batch)) { |
||||
|
batch = ""; |
||||
|
} |
||||
|
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("batch", batch); |
||||
|
jo.put("islock", device.getIslock()); |
||||
|
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); |
||||
|
// 特殊驱动
|
||||
|
} |
||||
|
//检测站点
|
||||
|
else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
||||
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
||||
|
|
||||
|
if (StrUtil.equals(device.getIslock(), "true")) { |
||||
|
status = "3"; |
||||
|
move = "有任务"; |
||||
|
} else { |
||||
|
if (standardInspectSiteDeviceDriver.getHasGoods() == 0) { |
||||
|
status = "0"; |
||||
|
move = "无货"; |
||||
|
} else if (standardInspectSiteDeviceDriver.getHasGoods() == 1) { |
||||
|
status = "1"; |
||||
|
move = "有托盘"; |
||||
|
} else if (standardInspectSiteDeviceDriver.getHasGoods() == 2) { |
||||
|
status = "2"; |
||||
|
move = "有托盘有货"; |
||||
|
} |
||||
|
} |
||||
|
jo.put("material_type", standardInspectSiteDeviceDriver.getMaterial()); |
||||
|
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("batch", standardInspectSiteDeviceDriver.getBatch()); |
||||
|
jo.put("input_material", input_material); |
||||
|
|
||||
|
} |
||||
|
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("QJN_QUERY001").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(Map<String, String> jsonObject) { |
||||
|
String start_devicecode = jsonObject.get("start_devicecode"); |
||||
|
String next_devicecode = jsonObject.get("next_devicecode"); |
||||
|
String material_type = jsonObject.get("material_type"); |
||||
|
String task_type = jsonObject.get("task_type"); |
||||
|
String priority = jsonObject.get("priority"); |
||||
|
String carrier = jsonObject.get("carrier"); |
||||
|
|
||||
|
JSONObject resultJson = new JSONObject(); |
||||
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
||||
|
Device startDevice = appService.findDeviceByCode(start_devicecode); |
||||
|
Device nextDevice = appService.findDeviceByCode(next_devicecode); |
||||
|
|
||||
|
if (StrUtil.isEmpty(start_devicecode)) { |
||||
|
resultJson.put("code", "0"); |
||||
|
resultJson.put("desc", "起点不能为空"); |
||||
|
resultJson.put("result", ""); |
||||
|
return resultJson; |
||||
|
} |
||||
|
if (StrUtil.isEmpty(next_devicecode)) { |
||||
|
resultJson.put("code", "0"); |
||||
|
resultJson.put("desc", "终点不能为空"); |
||||
|
resultJson.put("result", ""); |
||||
|
return resultJson; |
||||
|
} |
||||
|
// if (ObjectUtil.isNotEmpty(taskService.findByStartCode(start_devicecode)) ||
|
||||
|
// ObjectUtil.isNotEmpty(taskService.findByStartCode(next_devicecode))) {
|
||||
|
// resultJson.put("code", "2");
|
||||
|
// resultJson.put("desc", "已存在该起点或终点的任务!");
|
||||
|
// resultJson.put("result", "");
|
||||
|
// return resultJson;
|
||||
|
// }
|
||||
|
//判断起点有货,终点为空
|
||||
|
if (ObjectUtil.isEmpty(startDevice.getMaterial_type()) || Integer.parseInt(startDevice.getMaterial_type()) == 0) { |
||||
|
resultJson.put("code", "0"); |
||||
|
resultJson.put("desc", "起点必须有货"); |
||||
|
resultJson.put("result", ""); |
||||
|
return resultJson; |
||||
|
} |
||||
|
if (!ObjectUtil.isEmpty(nextDevice.getMaterial_type()) && !StrUtil.equals(nextDevice.getMaterial_type(), "0")) { |
||||
|
resultJson.put("code", "0"); |
||||
|
resultJson.put("desc", "终点必须为空"); |
||||
|
resultJson.put("result", ""); |
||||
|
return resultJson; |
||||
|
} |
||||
|
if(Boolean.parseBoolean(startDevice.getIslock()) || Boolean.parseBoolean(nextDevice.getIslock())){ |
||||
|
resultJson.put("code", "0"); |
||||
|
resultJson.put("desc", "起点或终点设备已被锁定"); |
||||
|
resultJson.put("result", ""); |
||||
|
return resultJson; |
||||
|
} |
||||
|
if (StrUtil.isEmpty(priority)) { |
||||
|
priority = "1"; |
||||
|
} |
||||
|
|
||||
|
if (start_devicecode.equals(next_devicecode)) { |
||||
|
resultJson.put("code", "0"); |
||||
|
resultJson.put("desc", "起点和终点不能是同一设备【" + next_devicecode + "】"); |
||||
|
resultJson.put("result", ""); |
||||
|
return resultJson; |
||||
|
} |
||||
|
|
||||
|
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class); |
||||
|
TaskDto dto = new TaskDto(); |
||||
|
dto.setIs_active("1"); |
||||
|
dto.setIs_delete("0"); |
||||
|
dto.setMaterial(material_type); |
||||
|
dto.setStart_point_code(start_devicecode); |
||||
|
dto.setNext_point_code(next_devicecode); |
||||
|
dto.setMaterial(material_type); |
||||
|
dto.setTask_type(task_type); |
||||
|
dto.setPriority(priority); |
||||
|
dto.setVehicle_code(carrier); |
||||
|
try { |
||||
|
taskService.create(dto); |
||||
|
startDevice.setIslock("true"); |
||||
|
nextDevice.setIslock("true"); |
||||
|
} 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("QJN_QUERY001").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 status = jsonObject.get("status"); |
||||
|
String material_type = jsonObject.get("material_type"); |
||||
|
String batch = jsonObject.get("batch"); |
||||
|
JSONObject resultJson = new JSONObject(); |
||||
|
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); |
||||
|
|
||||
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
||||
|
Device device = appService.findDeviceByCode(device_code); |
||||
|
//无光电普通站点
|
||||
|
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; |
||||
|
|
||||
|
DeviceDto dto = deviceService.findByCode(device_code); |
||||
|
|
||||
|
if (Boolean.parseBoolean(device.getIslock())) { |
||||
|
resultJson.put("code", "0"); |
||||
|
resultJson.put("desc", "已有任务无法绑定!"); |
||||
|
resultJson.put("result", new JSONObject()); |
||||
|
return resultJson; |
||||
|
} |
||||
|
//修改
|
||||
|
if (type.equals("1")) { |
||||
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
||||
|
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); |
||||
|
|
||||
|
if (StrUtil.equals("0", material_type)) { |
||||
|
status = "0"; |
||||
|
} |
||||
|
if (StrUtil.equals("1", material_type)) { |
||||
|
status = "1"; |
||||
|
} |
||||
|
if ("2,3,4,5".contains(material_type)) { |
||||
|
status = "2"; |
||||
|
} |
||||
|
standardOrdinarySiteDeviceDriver.setHasGoods(Integer.parseInt(status)); |
||||
|
device.setHas_goods(Integer.parseInt(status)); |
||||
|
JSONObject jo = new JSONObject(); |
||||
|
jo.put("device_code", device_code); |
||||
|
jo.put("hasGoodStatus", status); |
||||
|
jo.put("batch", batch); |
||||
|
jo.put("material_type", material_type); |
||||
|
deviceService.changeDeviceStatus(jo); |
||||
|
if (!StrUtil.isEmpty(material_type)) { |
||||
|
standardOrdinarySiteDeviceDriver.setMaterial(material_type); |
||||
|
} |
||||
|
if (!StrUtil.isEmpty(batch)) { |
||||
|
standardOrdinarySiteDeviceDriver.setBatch(batch); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
//清空
|
||||
|
if (type.equals("2")) { |
||||
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
||||
|
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); |
||||
|
standardOrdinarySiteDeviceDriver.setHasGoods(0); |
||||
|
device.setHas_goods(0); |
||||
|
JSONObject jo = new JSONObject(); |
||||
|
jo.put("device_code", device_code); |
||||
|
jo.put("hasGoodStatus", "0"); |
||||
|
jo.put("batch", ""); |
||||
|
jo.put("material_type", ""); |
||||
|
deviceService.changeDeviceStatus(jo); |
||||
|
standardOrdinarySiteDeviceDriver.setMaterial(""); |
||||
|
standardOrdinarySiteDeviceDriver.setBatch(""); |
||||
|
} |
||||
|
} |
||||
|
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) { |
||||
|
jo.put("code", "2"); |
||||
|
jo.put("desc", "未找到该指令!"); |
||||
|
jo.put("result", ""); |
||||
|
return jo; |
||||
|
} |
||||
|
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 = (Instruction) instwo.toJavaObject(Instruction.class); |
||||
|
MagicAgvService agvService = SpringContextHolder.getBean(MagicAgvServiceImpl.class); |
||||
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); |
||||
|
|
||||
|
/* 1 指令撤销 |
||||
|
2 重新下发 |
||||
|
3 强制完成*/ |
||||
|
if (type.equals("1")) { |
||||
|
//调用agv删除任务的接口
|
||||
|
|
||||
|
try { |
||||
|
//agvService.deleteAgvInst(instwo.getString("instruction_code"));
|
||||
|
if (StrUtil.isEmpty(instdto.getAgv_jobno())) { |
||||
|
instructionService.cancelNOSendAgv(inst_uuid); |
||||
|
} else { |
||||
|
agvService.deleteAgvInst(instdto.getInstruction_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); |
||||
|
|
||||
|
} 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")); |
||||
|
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 + ":该任务已存在待完成指令!"); |
||||
|
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")) { |
||||
|
//手工完成
|
||||
|
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class); |
||||
|
TaskDto acsTask = taskjo.toJavaObject(TaskDto.class); |
||||
|
InstructionService instructionservice = SpringContextHolder.getBean(InstructionServiceImpl.class); |
||||
|
InstructionDto instdto = instructionservice.findByTaskid(acsTask.getTask_id(), "instruction_status <2 "); |
||||
|
if (instdto != null){ |
||||
|
jo.put("code", "0"); |
||||
|
jo.put("desc", "有指令未完成!"); |
||||
|
jo.put("result", new JSONObject()); |
||||
|
return jo; |
||||
|
} |
||||
|
taskService.finish(acsTask.getTask_id()); |
||||
|
Device startDevice = deviceAppService.findDeviceByCode(acsTask.getStart_device_code()); |
||||
|
Device nextDevice = deviceAppService.findDeviceByCode(acsTask.getNext_device_code()); |
||||
|
startDevice.setIslock("false"); |
||||
|
nextDevice.setIslock("false"); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
jo.put("code", "1"); |
||||
|
jo.put("desc", "操作成功"); |
||||
|
jo.put("result", new JSONObject()); |
||||
|
return jo; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Map<String, Object> queryMaterial() { |
||||
|
JSONArray resultArr = WQL.getWO("QJN_QUERY001").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(Map<String, String> whereJson) { |
||||
|
String type = whereJson.get("type"); |
||||
|
String material_type = whereJson.get("material_type"); |
||||
|
String batch = whereJson.get("batch"); |
||||
|
String start_device_code = whereJson.get("start_devicecode"); |
||||
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
||||
|
Device startdevice = appService.findDeviceByCode(start_device_code); |
||||
|
if (Boolean.parseBoolean(startdevice.getIslock())) { |
||||
|
JSONObject jo = new JSONObject(); |
||||
|
jo.put("code", "0"); |
||||
|
jo.put("desc", "起点设备已被锁定"); |
||||
|
return jo; |
||||
|
} |
||||
|
if (StrUtil.isEmpty(type)) { |
||||
|
throw new BadRequestException("操作类型不能为空!"); |
||||
|
} |
||||
|
if (StrUtil.isEmpty(start_device_code)) { |
||||
|
throw new BadRequestException("起点不能为空!"); |
||||
|
} |
||||
|
String plan_code = ""; |
||||
|
if (StrUtil.equals(type, "1")) { |
||||
|
plan_code = "normal"; |
||||
|
} else if (StrUtil.equals(type, "2")) { |
||||
|
plan_code = "one"; |
||||
|
} |
||||
|
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); |
||||
|
String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + plan_code + "'").uniqueResult(0).getString("plan_uuid"); |
||||
|
|
||||
|
JSONArray ja = routelineserver.queryNextLine(start_device_code, plan_uuid); |
||||
|
if (ObjectUtil.isEmpty(ja)) { |
||||
|
JSONObject jo = new JSONObject(); |
||||
|
jo.put("code", "0"); |
||||
|
jo.put("desc", "未找到对应路由"); |
||||
|
return jo; |
||||
|
} |
||||
|
JSONObject form = new JSONObject(); |
||||
|
form.put("type", type); |
||||
|
form.put("material_type", material_type); |
||||
|
form.put("batch", batch); |
||||
|
form.put("start_device_code", start_device_code); |
||||
|
|
||||
|
deviceService.autoCreateTask(form); |
||||
|
JSONObject jo = new JSONObject(); |
||||
|
jo.put("code", "1"); |
||||
|
jo.put("desc", "创建成功"); |
||||
|
|
||||
|
// try{
|
||||
|
// Thread.sleep(1000);
|
||||
|
//
|
||||
|
// } catch (InterruptedException e) {
|
||||
|
// e.printStackTrace();
|
||||
|
// }
|
||||
|
|
||||
|
return jo; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,206 @@ |
|||||
|
[交易说明] |
||||
|
交易名: 手持接口查询 |
||||
|
所属模块: |
||||
|
功能简述: |
||||
|
版权所有: |
||||
|
表引用: |
||||
|
版本经历: |
||||
|
|
||||
|
[数据库] |
||||
|
--指定数据库,为空采用默认值,默认为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 |
||||
|
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.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 < '2' |
||||
|
OPTION 输入.key <> "" |
||||
|
inst.instruction_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 |
Loading…
Reference in new issue