23 changed files with 443 additions and 84 deletions
@ -0,0 +1,48 @@ |
|||||
|
package org.nl.wms.ext.handheld.controller; |
||||
|
|
||||
|
import cn.dev33.satoken.annotation.SaIgnore; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.common.logging.annotation.Log; |
||||
|
import org.nl.wms.ext.handheld.service.HandheldService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
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; |
||||
|
|
||||
|
/** |
||||
|
* @author LENOVO |
||||
|
*/ |
||||
|
@RestController |
||||
|
@Api(tags = "手持") |
||||
|
@RequestMapping("/api/") |
||||
|
@Slf4j |
||||
|
@SaIgnore |
||||
|
public class HandheldController { |
||||
|
|
||||
|
@Autowired |
||||
|
private HandheldService handheldService; |
||||
|
|
||||
|
@PostMapping("/task") |
||||
|
@Log("手持创建去地面点位任务") |
||||
|
@ApiOperation("手持创建去地面点位任务") |
||||
|
@SaIgnore |
||||
|
public ResponseEntity<Object> applyGroundTask(@RequestBody JSONObject param) { |
||||
|
return new ResponseEntity<>(handheldService.applyTask(param), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@PostMapping("/emptyVehicle") |
||||
|
@Log("呼叫地面空载具点位") |
||||
|
@ApiOperation("呼叫地面空载具点位") |
||||
|
@SaIgnore |
||||
|
public ResponseEntity<Object> applyEmptyVehicle(@RequestBody JSONObject param) { |
||||
|
return new ResponseEntity<>(handheldService.applyEmptyVehicle(param), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package org.nl.wms.ext.handheld.service; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
|
||||
|
/** |
||||
|
* @author LENOVO |
||||
|
*/ |
||||
|
public interface HandheldService { |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 手持申请去地面点位任务 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
Object applyTask(JSONObject param); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 手持呼叫空载具地面点位 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
Object applyEmptyVehicle(JSONObject param); |
||||
|
} |
@ -0,0 +1,72 @@ |
|||||
|
package org.nl.wms.ext.handheld.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.bean.BeanUtil; |
||||
|
import cn.hutool.core.collection.CollUtil; |
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import nl.basjes.shaded.org.springframework.util.Assert; |
||||
|
import org.nl.common.exception.BadRequestException; |
||||
|
import org.nl.wms.ext.handheld.service.HandheldService; |
||||
|
import org.nl.wms.sch.point.service.ISchBasePointService; |
||||
|
import org.nl.wms.sch.point.service.dao.SchBasePoint; |
||||
|
import org.nl.wms.sch.task_manage.AbstractTask; |
||||
|
import org.nl.wms.sch.task_manage.GeneralDefinition; |
||||
|
import org.nl.wms.sch.task_manage.task.TaskFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author LENOVO |
||||
|
*/ |
||||
|
@Service |
||||
|
public class HandheldServiceImpl implements HandheldService { |
||||
|
|
||||
|
@Autowired |
||||
|
private ISchBasePointService iSchBasePointService; |
||||
|
|
||||
|
@Autowired |
||||
|
private TaskFactory taskFactory; |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public Object applyTask(JSONObject param) { |
||||
|
Assert.noNullElements(new Object[]{param.getString("device_code"), param.getString("vehicle_list") |
||||
|
, param.getString("vehicle_type")}, "参数不能为空!"); |
||||
|
String vehicle_list = param.getString("vehicle_list"); |
||||
|
String region_code = param.getString("region_code"); |
||||
|
|
||||
|
String device_code = param.getString("device_code"); |
||||
|
String vehicle_type = param.getString("vehicle_type"); |
||||
|
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code); |
||||
|
boolean equals = StrUtil.equals(schBasePoint.getPoint_type(), vehicle_type); |
||||
|
if (ObjectUtil.isEmpty(schBasePoint) || !equals) throw new BadRequestException("设备点位不存在!"); |
||||
|
AbstractTask connectorTask = taskFactory.getTask("HHTask"); |
||||
|
// 准备参数:设备编码
|
||||
|
JSONObject jo = new JSONObject(); |
||||
|
jo.put("device_code", device_code); |
||||
|
jo.put("config_code", "HHTask"); |
||||
|
jo.put("create_mode", GeneralDefinition.AUTO_CREATION); |
||||
|
jo.put("vehicle_qty", BeanUtil.toBean(vehicle_list, List.class).size()); |
||||
|
jo.put("vehicles", BeanUtil.toBean(vehicle_list, List.class)); |
||||
|
jo.put("vehicle_type", vehicle_type); |
||||
|
jo.put("ext_data", param); |
||||
|
connectorTask.apply(jo); |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Object applyEmptyVehicle(JSONObject param) { |
||||
|
Assert.noNullElements(new Object[]{param.getString("device_code"), param.getString("vehicle_type")}, "参数不能为空!"); |
||||
|
String device_code = param.getString("device_code"); |
||||
|
String vehicle_type = param.getString("vehicle_type"); |
||||
|
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code); |
||||
|
boolean equals = StrUtil.equals(schBasePoint.getPoint_type(), vehicle_type); |
||||
|
if (ObjectUtil.isEmpty(schBasePoint) || !equals) throw new BadRequestException("设备点位不存在!"); |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,104 @@ |
|||||
|
package org.nl.wms.sch.task_manage.task.tasks.handheld; |
||||
|
|
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import org.nl.common.enums.GoodsEnum; |
||||
|
import org.nl.common.enums.region.RegionEnum; |
||||
|
import org.nl.common.exception.BadRequestException; |
||||
|
import org.nl.system.service.notice.ISysNoticeService; |
||||
|
import org.nl.wms.ext.acs.service.dto.to.BaseResponse; |
||||
|
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; |
||||
|
import org.nl.wms.sch.point.service.ISchBasePointService; |
||||
|
import org.nl.wms.sch.point.service.dao.SchBasePoint; |
||||
|
import org.nl.wms.sch.task.service.ISchBaseTaskService; |
||||
|
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; |
||||
|
import org.nl.wms.sch.task.service.dao.SchBaseTask; |
||||
|
import org.nl.wms.sch.task_manage.AbstractTask; |
||||
|
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum; |
||||
|
import org.nl.wms.sch.task_manage.task.core.TaskStatus; |
||||
|
import org.nl.wms.sch.task_manage.task.core.TaskType; |
||||
|
import org.nl.wms.util.PointUtils; |
||||
|
import org.nl.wms.util.TaskUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author LENOVO |
||||
|
*/ |
||||
|
@Component("HHTask") |
||||
|
public class HHTask extends AbstractTask { |
||||
|
|
||||
|
|
||||
|
private static final String TASK_CONFIG_CODE = "HHTask"; |
||||
|
@Autowired |
||||
|
private ISchBasePointService pointService; |
||||
|
@Autowired |
||||
|
private ISchBaseTaskService taskService; |
||||
|
@Autowired |
||||
|
private ISchBaseTaskconfigService taskConfigService; |
||||
|
@Autowired |
||||
|
private ISysNoticeService noticeService; |
||||
|
@Autowired |
||||
|
private ISchBasePointService schBasePointService; |
||||
|
@Autowired |
||||
|
private ISchBaseVehiclematerialgroupService schBaseVehiclematerialgroupService; |
||||
|
|
||||
|
@Override |
||||
|
protected void create() throws BadRequestException { |
||||
|
// 获取任务
|
||||
|
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); |
||||
|
// 配置信息
|
||||
|
for (SchBaseTask task : tasks) { |
||||
|
TaskUtils.setUpdateByAcs(task); |
||||
|
// 查询终点
|
||||
|
SchBasePoint schBasePoint = schBasePointService.selectByVehicleQty(RegionEnum.TRUBEND_SHELVES_3_1_1.getRegion_code(),task.getVehicle_type()); |
||||
|
if (TaskType.CARRY_TASK.getValue().equals(task.getTask_type())) { |
||||
|
schBasePoint = schBasePointService.selectByRegionCode(RegionEnum.TRUBEND_SHELVES_3_1_1.getRegion_code(), task.getVehicle_code()); |
||||
|
} else if (TaskType.REASSIGN_TASK.getValue().equals(task.getTask_type())) { |
||||
|
schBasePoint = schBasePointService.selectByReassign(RegionEnum.TRUBEND_SHELVES_3_1_1.getRegion_code(), task.getVehicle_code()); |
||||
|
} |
||||
|
if (ObjectUtil.isEmpty(schBasePoint)) { |
||||
|
task.setRemark("未找到所需点位!"); |
||||
|
taskService.updateById(task); |
||||
|
// 消息通知
|
||||
|
noticeService.createNotice("未找到所需点位!", TASK_CONFIG_CODE + task.getTask_code(), |
||||
|
NoticeTypeEnum.WARN.getCode()); |
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
// 设置终点并修改创建成功状态
|
||||
|
task.setPoint_code2(schBasePoint.getPoint_code()); |
||||
|
task.setVehicle_type(schBasePoint.getCan_vehicle_type()); |
||||
|
task.setRemark(""); |
||||
|
task.setTask_status(TaskStatus.CREATED.getCode()); |
||||
|
taskService.updateById(task); |
||||
|
|
||||
|
schBasePoint.setIng_task_code(task.getTask_code()); |
||||
|
schBasePoint.setPoint_status(GoodsEnum.IN_STOCK.getValue()); |
||||
|
PointUtils.setUpdateByAcs(schBasePoint); |
||||
|
pointService.updateById(schBasePoint); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
protected void updateStatus(String task_code, TaskStatus status) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void forceFinish(String task_code) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void cancel(String task_code) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) { |
||||
|
|
||||
|
} |
||||
|
} |
Loading…
Reference in new issue