rev:代码优化
This commit is contained in:
@@ -251,7 +251,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
if (ObjectUtil.isNotEmpty(device)) {
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
String link_three_lamp = device.getExtraValue().get("link_three_lamp").toString();
|
||||
String link_three_lamp = (String) device.getExtraValue().get("link_three_lamp");
|
||||
if (StrUtil.isNotEmpty(link_three_lamp)) {
|
||||
Device code = deviceAppService.findDeviceByCode(link_three_lamp);
|
||||
if (code.getDeviceDriver() instanceof LampThreecolorDeviceDriver) {
|
||||
@@ -300,7 +300,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
if (ObjectUtil.isNotEmpty(device)) {
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
String link_three_lamp = device.getExtraValue().get("link_three_lamp").toString();
|
||||
String link_three_lamp = (String) device.getExtraValue().get("link_three_lamp");
|
||||
if (StrUtil.isNotEmpty(link_three_lamp)) {
|
||||
Device code = deviceAppService.findDeviceByCode(link_three_lamp);
|
||||
if (code.getDeviceDriver() instanceof LampThreecolorDeviceDriver) {
|
||||
|
||||
@@ -21,10 +21,10 @@ public class SpxToAcsController {
|
||||
@Autowired
|
||||
private SpxToAcsService spxToAcsService;
|
||||
|
||||
@PostMapping("/task")
|
||||
@PostMapping("/order")
|
||||
@Log(value = "ACS接收SPX任务")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> createFromWms(@RequestBody String whereJson) {
|
||||
public ResponseEntity<Object> createFromSPX(@RequestBody String whereJson) {
|
||||
return new ResponseEntity<>(spxToAcsService.crateTask(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ public class SpxToAcsServiceImpl implements SpxToAcsService {
|
||||
// 记录异常日志
|
||||
log.error("创建工单时发生异常: ", e);
|
||||
JSONObject resultJson = new JSONObject();
|
||||
resultJson.put("status", HttpStatus.BAD_REQUEST.value());
|
||||
resultJson.put("message", "操作失败");
|
||||
resultJson.put("MSG_CODE", HttpStatus.BAD_REQUEST.value());
|
||||
resultJson.put("MSG", "操作失败");
|
||||
return resultJson;
|
||||
}
|
||||
}
|
||||
@@ -133,11 +133,11 @@ public class SpxToAcsServiceImpl implements SpxToAcsService {
|
||||
private JSONObject buildResultJson(JSONArray errArr) {
|
||||
JSONObject resultJson = new JSONObject();
|
||||
if (ObjectUtil.isEmpty(errArr)) {
|
||||
resultJson.put("status", HttpStatus.OK.value());
|
||||
resultJson.put("message", "操作成功");
|
||||
resultJson.put("MSG_CODE", HttpStatus.OK.value());
|
||||
resultJson.put("MSG", "操作成功");
|
||||
} else {
|
||||
resultJson.put("status", HttpStatus.BAD_REQUEST.value());
|
||||
resultJson.put("message", "操作失败");
|
||||
resultJson.put("MSG_CODE", HttpStatus.BAD_REQUEST.value());
|
||||
resultJson.put("MSG", "操作失败");
|
||||
if (ObjectUtil.isNotEmpty(errArr)) {
|
||||
resultJson.put("errArr", errArr);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
and create_time = #{query.begin_time}
|
||||
</if>
|
||||
and is_delete = '0'
|
||||
and status in ('0','1')
|
||||
</where>
|
||||
order by create_time DESC
|
||||
order by realstart_time ASC
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.sch.task.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.sch.task.service.WorkService;
|
||||
import org.nl.acs.sch.task.service.dao.SchBaseTask;
|
||||
@@ -83,4 +84,11 @@ public class WorkController {
|
||||
workService.confirm(id);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("暂停配料作业")
|
||||
@PostMapping(value = "/pause/{id}")
|
||||
public ResponseEntity<Object> pause(@RequestBody String id) {
|
||||
workService.pause(id);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,4 +49,6 @@ public interface WorkService extends IService<Work> {
|
||||
void confirm(String id);
|
||||
|
||||
Work findByCode(String work_code);
|
||||
|
||||
void pause(String id);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,6 @@
|
||||
</if>
|
||||
AND wo.status != '2'
|
||||
</where>
|
||||
ORDER BY work.seq_no asc
|
||||
ORDER BY work.mfg_order_name asc ,work.seq_no asc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.sch.task.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -162,6 +163,7 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements Wo
|
||||
taskDto.setNext_device_code(resource_name);
|
||||
taskDto.setTask_type(CommonFinalParam.TYPE_THREE);
|
||||
taskDto.setAgv_system_type(CommonFinalParam.TWO);
|
||||
taskDto.setWork_id(id);
|
||||
AcsPoint point = acsPointService.findByCode("T1");
|
||||
if (ObjectUtil.isEmpty(point)) {
|
||||
throw new BadRequestException("不存在T1点位");
|
||||
@@ -196,4 +198,18 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements Wo
|
||||
.eq(Work::getWork_code, work_code);
|
||||
return workMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause(String id) {
|
||||
Work work = workMapper.selectById(id);
|
||||
if (ObjectUtil.isEmpty(work)) {
|
||||
throw new BadRequestException("不存在该配料任务");
|
||||
}
|
||||
List<TaskDto> list = taskService.findByWorkId(id);
|
||||
if (CollUtil.isNotEmpty(list)){
|
||||
throw new BadRequestException("存在正在执行中的agv任务");
|
||||
}
|
||||
work.setStatus(TaskStatus.PAUSE.getCode());
|
||||
workMapper.updateById(work);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,9 @@ public enum TaskStatus {
|
||||
/**
|
||||
* 未完成
|
||||
*/
|
||||
UNFINISHED("7", "未完成", "未完成");
|
||||
UNFINISHED("7", "未完成", "未完成"),
|
||||
|
||||
PAUSE("4", "暂停", "暂停");
|
||||
|
||||
|
||||
TaskStatus(String code, String name, String desc) {
|
||||
|
||||
@@ -41,6 +41,11 @@ public class Task extends CommonModel<Task> implements Serializable {
|
||||
|
||||
private String ext_task_id;
|
||||
|
||||
/**
|
||||
* 配料作业任务标识
|
||||
*/
|
||||
private String work_id;
|
||||
|
||||
|
||||
@NotBlank
|
||||
private String task_code;
|
||||
|
||||
@@ -567,4 +567,6 @@ public interface TaskService extends CommonService<Task> {
|
||||
TaskDto findByTaskCode(String task_code);
|
||||
|
||||
List<TaskDto> queryAllHJReadyTask();
|
||||
|
||||
List<TaskDto> findByWorkId(String id);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,11 @@ public class TaskDto implements Serializable {
|
||||
*/
|
||||
private String ext_task_id;
|
||||
|
||||
/**
|
||||
* 配料作业任务标识
|
||||
*/
|
||||
private String work_id;
|
||||
|
||||
/**
|
||||
* 任务号
|
||||
*/
|
||||
|
||||
@@ -1604,6 +1604,17 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> findByWorkId(String id) {
|
||||
return Optional
|
||||
.ofNullable(this.tasks)
|
||||
.orElse(new CopyOnWriteArrayList<>())
|
||||
.stream()
|
||||
.filter(taskDto -> StrUtil.equals(taskDto.getWork_id(), id)
|
||||
&& StrUtil.equals(taskDto.getTask_status(), TaskStatusEnum.BUSY.getIndex()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 把多个字符串拼接的inst_nextDevice_code解析成集合
|
||||
|
||||
@@ -28,7 +28,7 @@ public class HandController {
|
||||
@Autowired
|
||||
private HandService handService;
|
||||
|
||||
@PostMapping
|
||||
@PostMapping("/queryWorks")
|
||||
@Log("配料作业查询")
|
||||
public ResponseEntity<Object> query() {
|
||||
return new ResponseEntity<>(handService.query(), HttpStatus.OK);
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
|
||||
@RequestMapping("/api/pda")
|
||||
@SaIgnore
|
||||
public class PdaController {
|
||||
@@ -35,13 +34,15 @@ public class PdaController {
|
||||
return new ResponseEntity<>(pdaService.queryOrders(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/queryWorks")
|
||||
@Log("配料作业查询")
|
||||
public ResponseEntity<Object> queryWorks() {
|
||||
return new ResponseEntity<>(pdaService.queryWorks(), HttpStatus.OK);
|
||||
public ResponseEntity<Object> queryWorks(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(pdaService.queryWorks(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/queryAllPoints")
|
||||
@PostMapping("/queryDevices")
|
||||
@Log("查询所有点位")
|
||||
@ApiOperation("查询所有点位")
|
||||
@SaIgnore
|
||||
@@ -82,6 +83,12 @@ public class PdaController {
|
||||
return new ResponseEntity<>(pdaService.finishWork(whereJson),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("暂停配料作业")
|
||||
@PostMapping(value = "/pause")
|
||||
public ResponseEntity<Object> pause(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(pdaService.pause(whereJson),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/callTask")
|
||||
@Log("生成退桶任务")
|
||||
@ApiOperation("生成退桶任务")
|
||||
|
||||
@@ -23,7 +23,9 @@ public interface PdaService {
|
||||
|
||||
PdaResponseVo forceFinish(JSONObject whereJson);
|
||||
|
||||
List<WorkVo> queryWorks();
|
||||
List<WorkVo> queryWorks(JSONObject whereJson);
|
||||
|
||||
List<WorkVo> getExcWorks();
|
||||
|
||||
PdaResponseVo sendWork(JSONObject whereJson);
|
||||
|
||||
@@ -34,4 +36,7 @@ public interface PdaService {
|
||||
JSONArray queryAllPoints();
|
||||
|
||||
Map<String, Object> callTask(PdaDto dto);
|
||||
|
||||
PdaResponseVo pause(JSONObject whereJson);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.hand.service.dao.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.hand.service.vo.OrderVo;
|
||||
import org.nl.hand.service.vo.WorkVo;
|
||||
|
||||
@@ -9,5 +10,7 @@ public interface PdaMapper {
|
||||
|
||||
List<OrderVo> getOrders();
|
||||
|
||||
List<WorkVo> getWorks();
|
||||
List<WorkVo> getWorks(@Param("mfg_order_name") String mfg_order_name);
|
||||
|
||||
List<WorkVo> getExcWorks();
|
||||
}
|
||||
|
||||
@@ -6,30 +6,61 @@
|
||||
product_name,
|
||||
description,
|
||||
resource_name,
|
||||
point_code,
|
||||
total_qty,
|
||||
Case status
|
||||
WHEN '0' THEN '就绪'
|
||||
WHEN '1' THEN '执行中'
|
||||
ELSE ''
|
||||
END AS status,
|
||||
create_name
|
||||
realstart_time,
|
||||
create_time
|
||||
FROM acs_workorder
|
||||
WHERE status != '2'
|
||||
order by realstart_time ASC
|
||||
</select>
|
||||
<select id="getWorks" resultType="org.nl.hand.service.vo.WorkVo">
|
||||
SELECT seq_no,
|
||||
work_code,
|
||||
mfg_order_name,
|
||||
material_code,
|
||||
material_name,
|
||||
qty,
|
||||
resource_name,
|
||||
require_num,
|
||||
remain_num,
|
||||
Case status
|
||||
WHEN '0' THEN '就绪'
|
||||
WHEN '1' THEN '执行中'
|
||||
WHEN '2' THEN '完成'
|
||||
ELSE ''
|
||||
END AS status
|
||||
FROM work
|
||||
WHERE status != '0' AND remain_num > 0
|
||||
<where>
|
||||
<if test="mfg_order_name != null and mfg_order_name != ''">
|
||||
work.mfg_order_name = #{mfg_order_name}
|
||||
</if>
|
||||
AND status != '2'
|
||||
</where>
|
||||
ORDER BY work.mfg_order_name asc ,work.seq_no asc
|
||||
</select>
|
||||
<select id="getExcWorks" resultType="org.nl.hand.service.vo.WorkVo">
|
||||
SELECT seq_no,
|
||||
mfg_order_name,
|
||||
work_code,
|
||||
material_code,
|
||||
material_name,
|
||||
qty,
|
||||
resource_name,
|
||||
require_num,
|
||||
remain_num,
|
||||
Case status
|
||||
WHEN '0' THEN '就绪'
|
||||
WHEN '1' THEN '执行中'
|
||||
WHEN '2' THEN '完成'
|
||||
ELSE ''
|
||||
END AS status
|
||||
FROM work
|
||||
where status != '2' ORDER BY work.mfg_order_name asc ,work.seq_no asc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -24,7 +24,7 @@ public class HandServiceImpl implements HandService {
|
||||
|
||||
@Override
|
||||
public List<WorkVo> query() {
|
||||
return pdaService.queryWorks();
|
||||
return pdaService.getExcWorks();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -82,8 +82,16 @@ public class PdaServiceImpl implements PdaService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkVo> queryWorks() {
|
||||
return pdaMapper.getWorks();
|
||||
public List<WorkVo> queryWorks(JSONObject whereJson) {
|
||||
if (StrUtil.isEmpty(whereJson.getString("mfg_order_name"))){
|
||||
throw new BadRequestException("工单号为空!");
|
||||
}
|
||||
return pdaMapper.getWorks(whereJson.getString("mfg_order_name"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkVo> getExcWorks() {
|
||||
return pdaMapper.getExcWorks();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,12 +108,19 @@ public class PdaServiceImpl implements PdaService {
|
||||
@Override
|
||||
public PdaResponseVo reSendWork(JSONObject whereJson) {
|
||||
String work_code = whereJson.getString("work_code");
|
||||
String require_num = whereJson.getString("require_num");
|
||||
if (StrUtil.isEmpty(require_num)){
|
||||
return PdaResponseVo.pdaResultOk("补发数量为空");
|
||||
}
|
||||
if (StrUtil.isEmpty(work_code)){
|
||||
return PdaResponseVo.pdaResultOk("补发作业号为空");
|
||||
}
|
||||
Work work = workService.findByCode(work_code);
|
||||
if (work == null) {
|
||||
return PdaResponseVo.pdaResultOk("配料作业不存在");
|
||||
}
|
||||
work.setRemain_num(work.getRemain_num() + whereJson.getIntValue("count"));
|
||||
work.setRequire_num(work.getRequire_num() + whereJson.getIntValue("count"));
|
||||
work.setRemain_num(work.getRemain_num() + whereJson.getIntValue("require_num"));
|
||||
work.setRequire_num(work.getRequire_num() + whereJson.getIntValue("require_num"));
|
||||
workService.updateById(work);
|
||||
return PdaResponseVo.pdaResultOk("补发成功");
|
||||
}
|
||||
@@ -147,7 +162,6 @@ public class PdaServiceImpl implements PdaService {
|
||||
JSONArray errArr = new JSONArray();
|
||||
String start_device_code = dto.getStart_device_code();
|
||||
String next_device_code = dto.getNext_device_code();
|
||||
String task_type = dto.getTask_type();
|
||||
|
||||
if (StrUtil.isEmpty(start_device_code)) {
|
||||
throw new BadRequestException("起点不能为空");
|
||||
@@ -155,22 +169,18 @@ public class PdaServiceImpl implements PdaService {
|
||||
if (StrUtil.isEmpty(next_device_code)) {
|
||||
throw new BadRequestException("终点不能为空");
|
||||
}
|
||||
if (StrUtil.isEmpty(task_type)) {
|
||||
throw new BadRequestException("任务类型不能为空");
|
||||
}
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("start_device_code", start_device_code);
|
||||
jo.put("next_device_code", next_device_code);
|
||||
jo.put("start_point_code", start_device_code);
|
||||
jo.put("next_point_code", next_device_code);
|
||||
jo.put("task_type", task_type);
|
||||
jo.put("task_type", "1");
|
||||
jo.put("priority", "1");
|
||||
|
||||
TaskDto task_dto = jo.toJavaObject(TaskDto.class);
|
||||
try {
|
||||
taskserver.create(task_dto);
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("message", e.getMessage());
|
||||
errArr.add(json);
|
||||
@@ -187,4 +197,15 @@ public class PdaServiceImpl implements PdaService {
|
||||
}
|
||||
return resultJson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PdaResponseVo pause(JSONObject whereJson) {
|
||||
String work_code = whereJson.getString("work_code");
|
||||
Work work = workService.findByCode(work_code);
|
||||
if (work == null) {
|
||||
return PdaResponseVo.pdaResultOk("配料作业不存在");
|
||||
}
|
||||
workService.pause(work.getWork_id());
|
||||
return PdaResponseVo.pdaResultOk("暂停成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,6 @@ public class OrderVo {
|
||||
private String resource_name;
|
||||
private float total_qty;
|
||||
private String status;
|
||||
private String create_name;
|
||||
private String create_time;
|
||||
private String realstart_time;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class WorkVo {
|
||||
private int seq_no;
|
||||
private String work_code;
|
||||
private String mfg_order_name;
|
||||
private String material_code;
|
||||
private String material_name;
|
||||
private float qty;
|
||||
private String resource_name;
|
||||
|
||||
@@ -10,7 +10,7 @@ spring:
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:niudixiya_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:niudixiya_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
|
||||
username: ${DB_USER:root}
|
||||
# password: ${DB_PWD:Root.123456}
|
||||
|
||||
Reference in New Issue
Block a user