张江玮
2 years ago
19 changed files with 1003 additions and 84 deletions
@ -0,0 +1,65 @@ |
|||
|
|||
package org.nl.hand.rest; |
|||
|
|||
|
|||
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.hand.service.PadService; |
|||
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/axg/hand") |
|||
@Slf4j |
|||
public class PadController { |
|||
private final PadService HandService; |
|||
|
|||
@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("/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) { |
|||
return new ResponseEntity<>(HandService.Taskoperation(whereJson), HttpStatus.OK); |
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
|
|||
package org.nl.hand.service; |
|||
|
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author qxuan |
|||
* @description 服务接口 |
|||
* @date 2021-07-21 |
|||
**/ |
|||
public interface PadService { |
|||
|
|||
/** |
|||
* 查询指令 |
|||
* |
|||
* @param jsonObject 条件 |
|||
* @return Map<String, Object> |
|||
*/ |
|||
Map<String, Object> queryInst(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> Instoperation(Map<String, String> jsonObject); |
|||
|
|||
/** |
|||
* 任务操作 |
|||
* |
|||
* @param jsonObject 条件 |
|||
* @return Map<String, Object> |
|||
*/ |
|||
Map<String, Object> Taskoperation(Map<String, String> jsonObject); |
|||
} |
@ -0,0 +1,80 @@ |
|||
package org.nl.hand.service.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* @author qxuan |
|||
* @description / |
|||
* @date 2021-07-21 |
|||
**/ |
|||
@Data |
|||
public class PadDto 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,218 @@ |
|||
|
|||
package org.nl.hand.service.impl; |
|||
|
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.IdUtil; |
|||
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.extern.slf4j.Slf4j; |
|||
import org.nl.acs.agv.server.AgvService; |
|||
import org.nl.acs.agv.server.NDCAgvService; |
|||
import org.nl.acs.config.AcsConfig; |
|||
import org.nl.acs.config.server.AcsConfigService; |
|||
import org.nl.acs.config.server.impl.AcsConfigServiceImpl; |
|||
import org.nl.acs.instruction.service.InstructionService; |
|||
import org.nl.acs.instruction.service.dto.Instruction; |
|||
import org.nl.acs.instruction.service.impl.InstructionServiceImpl; |
|||
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.exception.BadRequestException; |
|||
import org.nl.hand.service.PadService; |
|||
import org.nl.modules.system.util.CodeUtil; |
|||
import org.nl.utils.SpringContextHolder; |
|||
import org.nl.wql.WQL; |
|||
import org.nl.wql.core.bean.WQLObject; |
|||
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 PadServiceImpl implements PadService { |
|||
|
|||
@Override |
|||
public Map<String, Object> queryInst(Map<String, String> jsonObject) { |
|||
//查询位完成的指令
|
|||
JSONObject resultJson = new JSONObject(); |
|||
JSONArray resultArr = WQL.getWO("QHAND_QUERY").addParam("flag", "4").addParamMap((HashMap) jsonObject).process().getResultJSONArray(0); |
|||
resultJson.put("code", "1"); |
|||
resultJson.put("desc", "查询成功"); |
|||
resultJson.put("result", resultArr); |
|||
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"); |
|||
map.put("key", key); |
|||
map.put("start_point", start_point); |
|||
map.put("next_point", next_point); |
|||
//查询有任务 但是没有指令的任务
|
|||
JSONArray result = WQL.getWO("QHAND_QUERY").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> 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("未找到该指令!"); |
|||
} |
|||
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); |
|||
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); |
|||
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class); |
|||
|
|||
String task_id = instwo.getString("task_id"); |
|||
/* 1 指令撤销 |
|||
2 重新下发 |
|||
3 强制完成*/ |
|||
if (type.equals("1")) { |
|||
//调用agv删除任务的接口
|
|||
agvService = SpringContextHolder.getBean("agvServiceImpl"); |
|||
try { |
|||
agvService.deleteAgvInstToNDC(instwo.toJavaObject(Instruction.class)); |
|||
instructionService.cancel(inst_uuid); |
|||
|
|||
} catch (Exception e) { |
|||
jo.put("code", "2"); |
|||
jo.put("desc", e.getMessage()); |
|||
jo.put("result", ""); |
|||
return jo; |
|||
} |
|||
} |
|||
if (type.equals("2")) { |
|||
Instruction instdto = (Instruction) JSONObject.toJavaObject(instwo, Instruction.class); |
|||
AgvService agvserver = SpringContextHolder.getBean("agvServiceImpl"); |
|||
try { |
|||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { |
|||
|
|||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "1")) { |
|||
agvService.sendAgvInstToNDC(instdto); |
|||
} else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "2")) { |
|||
agvService.sendAgvInstToNDC(instdto); |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
jo.put("code", "2"); |
|||
jo.put("desc", e.getMessage()); |
|||
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) { |
|||
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); |
|||
if (StrUtil.isEmpty(task_uuid)) { |
|||
throw new BadRequestException("id不能为空!"); |
|||
} |
|||
if (StrUtil.isEmpty(type)) { |
|||
throw new BadRequestException("操作类型不能为空!"); |
|||
} |
|||
//重新生成
|
|||
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("taskjo")); |
|||
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"); |
|||
try { |
|||
instructionService.create(instdto); |
|||
TaskDto acsTask = (TaskDto) JSONObject.toJavaObject(taskjo, TaskDto.class); |
|||
acsTask.setTask_status("1"); |
|||
WQLObject taskwo = WQLObject.getWQLObject("acs_task"); |
|||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(acsTask)); |
|||
taskwo.update(json); |
|||
} 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 = (TaskDto) JSONObject.toJavaObject(taskjo, TaskDto.class); |
|||
taskService.finish(acsTask.getTask_id()); |
|||
} |
|||
|
|||
|
|||
jo.put("code", "1"); |
|||
jo.put("desc", "操作成功"); |
|||
jo.put("result", new JSONObject()); |
|||
return jo; |
|||
} |
|||
} |
@ -0,0 +1,176 @@ |
|||
[交易说明] |
|||
交易名: 手持接口查询 |
|||
所属模块: |
|||
功能简述: |
|||
版权所有: |
|||
表引用: |
|||
版本经历: |
|||
|
|||
[数据库] |
|||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 |
|||
|
|||
[IO定义] |
|||
################################################# |
|||
## 表字段对应输入参数 |
|||
################################################# |
|||
输入.flag TYPEAS s_string |
|||
输入.key TYPEAS s_string |
|||
输入.keyword TYPEAS s_string |
|||
输入.start_devicecode TYPEAS s_string |
|||
输入.next_devicecode TYPEAS s_string |
|||
输入.detail_id TYPEAS s_string |
|||
输入.start_point TYPEAS s_string |
|||
输入.next_point 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, |
|||
sys2.VALUE AS material_type_name, |
|||
sys2.label AS material_type, |
|||
sys.VALUE AS task_status_name, |
|||
sys.label AS task_status, |
|||
task.vehicle_code AS carrier, |
|||
task.create_time, |
|||
task.priority |
|||
FROM |
|||
acs_task task |
|||
LEFT JOIN sys_dict_detail sys ON sys.label = task.task_status |
|||
AND sys.NAME = 'task_status' |
|||
LEFT JOIN sys_dict_detail 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) |
|||
ENDOPTION |
|||
OPTION 输入.start_point <> "" |
|||
task.start_point_code = 输入.start_point |
|||
ENDOPTION |
|||
OPTION 输入.next_point <> "" |
|||
task.next_point_code = 输入.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.VALUE AS inst_status_name, |
|||
inst.execute_message AS inst_step, |
|||
inst.vehicle_code AS carrier, |
|||
inst.carno, |
|||
inst.priority, |
|||
inst.create_time, |
|||
inst.material AS material_type, |
|||
dtl2.VALUE AS material_type_name |
|||
FROM |
|||
acs_instruction inst |
|||
LEFT JOIN sys_dict_detail AS dtl ON dtl.label = inst.instruction_status |
|||
AND dtl.NAME = 'task_status' |
|||
LEFT JOIN sys_dict_detail AS dtl2 ON dtl2.label = inst.material |
|||
AND dtl2.NAME = 'material_type' |
|||
WHERE |
|||
inst.is_delete = '0' |
|||
AND (inst.instruction_status ='1' |
|||
OR inst.instruction_status ='0') |
|||
OPTION 输入.keyword <> "" |
|||
(inst.instruction_code like 输入.keyword |
|||
or |
|||
inst.task_code like 输入.keyword |
|||
or inst.execute_device_code like 输入.keyword) |
|||
ENDOPTION |
|||
OPTION 输入.start_devicecode <> "" |
|||
inst.start_point_code = 输入.start_devicecode |
|||
ENDOPTION |
|||
OPTION 输入.next_devicecode <> "" |
|||
inst.next_point_code = 输入.next_devicecode |
|||
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' |
|||
ENDSELECT |
|||
ENDQUERY |
|||
ENDIF |
Binary file not shown.
Loading…
Reference in new issue