diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java index d0984bb..f69eabc 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java @@ -2,6 +2,7 @@ package com.mt.wms.empty.controller; import com.mt.wms.core.base.BaseController; import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.params.IdParam; import com.mt.wms.core.vo.IdVo; import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; @@ -35,20 +36,24 @@ public class CurrTaskController extends BaseController { @Autowired private CurrTaskDetService currTaskDetService; - @PostMapping(value = "createTask") - @ApiOperation(value = "进入工业炉加工(首次加工)") - public R createFirstTask(@Validated @RequestBody TaskCreateParam param){ - R mainTask = currTaskService.createFirstTask(param); - currTaskDetService.createFirstTaskDet(param.getDetParams(),mainTask.getData().getId()); - //任务发起后,判断去窑炉,或者去缓存位,不由此处判断。 - //todo 调用后续的处理接口 + @PostMapping(value = "createProcessTask") + @ApiOperation(value = "创建一个加工任务至任务队列") + public R createProcessTask(@Validated @RequestBody TaskCreateParam param) { + R mainTask = currTaskService.createProcessTask(param); + currTaskDetService.createProcessTaskDet(param.getDetParams(), mainTask.getData().getId()); return successful("创建成功。"); } @PostMapping(value = "currentTaskNow") @ApiOperation(value = "获取当前执行的任务") - public R> currentTask(@Validated @RequestBody CurrTaskQueryParam param){ + public R> currentTask(@Validated @RequestBody CurrTaskQueryParam param) { return currTaskService.currentTaskPage(param); } + + @PostMapping(value = "completeTask") + @ApiOperation(value = "完成执行任务") + public R completeTask(@Validated @RequestBody IdParam param) { + return currTaskService.completeTask(param); + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/OrderInfoController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/OrderInfoController.java index e598a46..9bf5d8a 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/OrderInfoController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/OrderInfoController.java @@ -6,7 +6,6 @@ import com.mt.wms.core.params.IdParam; import com.mt.wms.core.validator.groups.PageGroup; import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; -import com.mt.wms.empty.params.OrderParamForApms; import com.mt.wms.empty.params.OrderInfoBasePageParam; import com.mt.wms.empty.params.OrderInfoPersonCreateParam; import com.mt.wms.empty.params.OrderInfoTaskDetParam; @@ -35,12 +34,6 @@ public class OrderInfoController extends BaseController { @Autowired private OrderInfoService orderInfoService; - @PostMapping(value = "apmsPostOrder") - @ApiOperation(value = "接收apms推送订单信息") - private R apmsPostOrder(@Validated @RequestBody OrderParamForApms apmsPostOrderParam) { - return orderInfoService.apmsPostOrder(apmsPostOrderParam); - } - @PostMapping(value = "page") @ApiOperation(value = "获取分页订单基础信息") private R> page(@Validated({PageGroup.class, Default.class}) @RequestBody OrderInfoBasePageParam orderBaseParam) { @@ -70,4 +63,16 @@ public class OrderInfoController extends BaseController { return orderInfoService.getTaskInfoByIdenCardNum(idenCardNum); } + + @PostMapping(value = "completeOrder") + @ApiOperation(value = "完成订单") + private R completeOrder(@Validated @RequestBody IdParam idParam) { + return orderInfoService.completeOrder(idParam); + } + + @PostMapping(value = "voidOrder") + @ApiOperation(value = "作废订单") + private R voidOrder(@Validated @RequestBody IdParam idParam) { + return orderInfoService.voidOrder(idParam); + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskCreateParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskCreateParam.java index d08ed64..b529af1 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskCreateParam.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskCreateParam.java @@ -1,7 +1,6 @@ package com.mt.wms.empty.params; import com.mt.wms.core.base.BaseParam; -import com.mt.wms.core.params.BasePageParam; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -18,20 +17,22 @@ import java.util.List; @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) -@ApiModel(value = "新建一个订单信息", description = "新建一个订单信息") +@ApiModel(value = "新建一个任务信息", description = "新建一个任务信息") public class TaskCreateParam extends BaseParam { private static final long serialVersionUID = 1L; - @ApiModelProperty(value = "托盘号") + @ApiModelProperty(value = "托盘号") private String palletCode; - @ApiModelProperty(value = "起点",required = true) + @ApiModelProperty(value = "起点", required = true) private String startPosition; - @ApiModelProperty(value = "终点位置",required = true) + @ApiModelProperty(value = "终点位置", required = true) private String targetPosition; - @ApiModelProperty(value = "窑炉Id",required = true) + @ApiModelProperty(value = "加工任务类型", required = true) + private Integer processType; + @ApiModelProperty(value = "窑炉Id", required = true) private Long kilnId; - @ApiModelProperty(value = "详细信息",required = true) + @ApiModelProperty(value = "详细信息", required = true) private List detParams; diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskDetService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskDetService.java index e92e310..dc95a63 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskDetService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskDetService.java @@ -1,5 +1,7 @@ package com.mt.wms.empty.service; +import com.mt.wms.core.dal.entity.CurrTaskDet; +import com.mt.wms.core.params.IdParam; import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; import com.mt.wms.empty.params.CurrTaskDetQueryParam; @@ -24,17 +26,28 @@ public interface CurrTaskDetService { * @return 结果 */ PageVo getCurrOrderCurrTask(OrderInfoTaskDetParam param); + /** * 创建正常加工的详细任务信息 + * * @param taskDet 详细任务信息 - * @param taskId 主任务id + * @param taskId 主任务id */ - void createFirstTaskDet(List taskDet, Long taskId); + void createProcessTaskDet(List taskDet, Long taskId); + /** * 查询正常加工的详细任务信息 + * * @param currTaskId 详细任务信息 * @return 结果 */ R> getTaskDetailsPage(CurrTaskDetQueryParam currTaskId); + /** + * 查询某个主任务下的详细任务列表 + * + * @param idParam 主任务id + * @return 结果 + */ + List getTaskDetailsByMainId(IdParam idParam); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java index f8178c3..bbb5387 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java @@ -1,18 +1,14 @@ package com.mt.wms.empty.service; -import com.mt.wms.core.dal.entity.CurrTaskDet; import com.mt.wms.core.params.IdParam; import com.mt.wms.core.vo.IdVo; import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; import com.mt.wms.empty.params.CurrTaskQueryParam; -import com.mt.wms.empty.params.TaskCreateDetParam; import com.mt.wms.empty.params.TaskCreateParam; import com.mt.wms.empty.vo.CurrTaskQueryVo; import com.mt.wms.empty.vo.CurrTaskVo; -import java.util.List; - /** * 拆分任务相关服务 * @@ -31,15 +27,26 @@ public interface CurrTaskService { /** - * 创建正常加工的主任务信息 + * 创建加工任务的主任务信息 + * * @param param 主任务信息 * @return 结果 */ - R createFirstTask(TaskCreateParam param); + R createProcessTask(TaskCreateParam param); + /** * 查询分页信息 + * * @param param 查询参数 * @return 结果 */ R> currentTaskPage(CurrTaskQueryParam param); + + /** + * 完成执行任务 + * + * @param param id + * @return 结果 + */ + R completeTask(IdParam param); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/OrderInfoService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/OrderInfoService.java index 1171af7..76915e5 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/OrderInfoService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/OrderInfoService.java @@ -3,10 +3,10 @@ package com.mt.wms.empty.service; import com.mt.wms.core.params.IdParam; import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; -import com.mt.wms.empty.params.OrderParamForApms; import com.mt.wms.empty.params.OrderInfoBasePageParam; import com.mt.wms.empty.params.OrderInfoPersonCreateParam; import com.mt.wms.empty.params.OrderInfoTaskDetParam; +import com.mt.wms.empty.params.OrderParamForApms; import com.mt.wms.empty.vo.OrderInfoTaskDetVo; import com.mt.wms.empty.vo.OrderInfoVo; @@ -53,10 +53,28 @@ public interface OrderInfoService { * @return 结果 */ R> getTaskInfo(OrderInfoTaskDetParam orderInfoTaskDetParam); + /** * 创建加工订单时查询订单信息 + * * @param idenCardNum 标识卡号 * @return 结果 */ R getTaskInfoByIdenCardNum(String idenCardNum); + + /** + * 完成订单 + * + * @param idParam id号 + * @return 结果 + */ + R completeOrder(IdParam idParam); + + /** + * 作废订单 + * + * @param idParam id号 + * @return 结果 + */ + R voidOrder(IdParam idParam); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskDetServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskDetServiceImpl.java index 36af814..4d4e152 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskDetServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskDetServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mt.wms.core.base.BaseService; import com.mt.wms.core.dal.entity.CurrTaskDet; import com.mt.wms.core.dal.service.CurrTaskDetServiceBiz; +import com.mt.wms.core.params.IdParam; import com.mt.wms.core.utils.BeanUtils; import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; @@ -18,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; import java.util.List; /** @@ -46,9 +46,9 @@ public class CurrTaskDetServiceImpl extends BaseService implements CurrTaskDetSe } @Override - public void createFirstTaskDet(List taskDet, Long taskId) { + public void createProcessTaskDet(List taskDet, Long taskId) { List params = BeanUtils.copyList(taskDet, CurrTaskDet.class); - params.forEach(param->{ + params.forEach(param -> { param.setCurrTaskId(taskId); setCommonField(param); }); @@ -58,9 +58,17 @@ public class CurrTaskDetServiceImpl extends BaseService implements CurrTaskDetSe @Override public R> getTaskDetailsPage(CurrTaskDetQueryParam currTaskId) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq(CurrTaskDet.CURR_TASK_ID,currTaskId.getCurrTaskId()) - .eq(CurrTaskDet.VALID,1); + queryWrapper.eq(CurrTaskDet.CURR_TASK_ID, currTaskId.getCurrTaskId()) + .eq(CurrTaskDet.VALID, 1); Page page = currTaskDetServiceBiz.page(new Page<>(currTaskId.getCurrent(), currTaskId.getSize()), queryWrapper); return successful(new PageVo<>(page, CurrTaskDetVo.class)); } + + @Override + public List getTaskDetailsByMainId(IdParam idParam) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(CurrTaskDet.CURR_TASK_ID, idParam.getId()) + .eq(CurrTaskDet.VALID, 1); + return currTaskDetServiceBiz.list(queryWrapper); + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java index a98cf19..2faa09f 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java @@ -2,9 +2,11 @@ package com.mt.wms.empty.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.mt.wms.core.api.Assert; import com.mt.wms.core.base.BaseService; import com.mt.wms.core.dal.entity.CurrTask; +import com.mt.wms.core.dal.entity.CurrTaskDet; +import com.mt.wms.core.dal.entity.TaskDetHis; +import com.mt.wms.core.dal.entity.TaskHis; import com.mt.wms.core.dal.service.CurrTaskServiceBiz; import com.mt.wms.core.params.IdParam; import com.mt.wms.core.vo.IdVo; @@ -15,15 +17,18 @@ import com.mt.wms.empty.params.CurrTaskQueryParam; import com.mt.wms.empty.params.TaskCreateParam; import com.mt.wms.empty.service.CurrTaskDetService; import com.mt.wms.empty.service.CurrTaskService; +import com.mt.wms.empty.service.TaskDetHisService; +import com.mt.wms.empty.service.TaskHisService; import com.mt.wms.empty.vo.CurrTaskQueryVo; import com.mt.wms.empty.vo.CurrTaskVo; -import org.apache.commons.codec.net.QCodec; import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; + /** * xx服务实现类 * @@ -41,22 +46,25 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService @Autowired CurrTaskDetService currTaskDetService; + @Autowired + TaskHisService taskHisService; + + @Autowired + TaskDetHisService taskDetHisService; + @Override public CurrTaskVo getCurrTask(IdParam idParam) { CurrTask byId = currTaskServiceBiz.getById(idParam.getId()); CurrTaskVo build = CurrTaskVo.builder().build(); - BeanUtils.copyProperties(byId,build); + BeanUtils.copyProperties(byId, build); return build; } @Override - public R createFirstTask(TaskCreateParam param) { + public R createProcessTask(TaskCreateParam param) { CurrTask currTask = new CurrTask(); - currTask.setStartPosition(param.getStartPosition()); - currTask.setTargetPosition(param.getTargetPosition()); - currTask.setKilnId(param.getKilnId()); + BeanUtils.copyProperties(param, currTask); currTask.setTaskType(TaskTypeEnum.WTK.getValue()); - currTask.setPalletCode(param.getPalletCode()); currTask.setTaskSource(0); setCommonField(currTask); currTaskServiceBiz.save(currTask); @@ -65,10 +73,30 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService @Override public R> currentTaskPage(CurrTaskQueryParam param) { - QueryWrapper currTaskQueryWrapper= new QueryWrapper<>(); - currTaskQueryWrapper.eq(StringUtils.isNotBlank(param.getVehicleId()),CurrTask.VEHICLE_ID,param.getVehicleId()); - currTaskQueryWrapper.eq(CurrTask.VALID,1); + QueryWrapper currTaskQueryWrapper = new QueryWrapper<>(); + currTaskQueryWrapper.eq(StringUtils.isNotBlank(param.getVehicleId()), CurrTask.VEHICLE_ID, param.getVehicleId()); + currTaskQueryWrapper.eq(CurrTask.VALID, 1); Page page = currTaskServiceBiz.page(new Page<>(param.getCurrent(), param.getSize()), currTaskQueryWrapper); - return successful(new PageVo<>(page,CurrTaskQueryVo.class)); + return successful(new PageVo<>(page, CurrTaskQueryVo.class)); + } + + @Override + public R completeTask(IdParam param) { + CurrTask byId = currTaskServiceBiz.getById(param.getId()); + TaskHis taskHis = new TaskHis(); + BeanUtils.copyProperties(byId, taskHis); + taskHis.setStatus(2); + taskHis.setId(null); + //将主任务放入到历史表,清空id,防止重复 + R save = taskHisService.save(taskHis); + currTaskServiceBiz.removeById(byId.getId()); + List taskDetailsByMainId = currTaskDetService.getTaskDetailsByMainId(IdParam.builder().id(byId.getId()).build()); + List taskDetHis = com.mt.wms.core.utils.BeanUtils.copyList(taskDetailsByMainId, TaskDetHis.class); + taskDetHis.forEach(detHis -> { + detHis.setTaskId(save.getData().getId()); + }); + //将详细任务信息放入详细历史表 + taskDetHisService.saveList(taskDetHis); + return successful("执行成功。"); } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java index 79bbc9d..52147c1 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java @@ -3,13 +3,11 @@ package com.mt.wms.empty.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mt.wms.basic.params.KilnInfoQueryParam; -import com.mt.wms.basic.params.LocationInfoQueryParam; import com.mt.wms.basic.params.VehicleQueryParam; import com.mt.wms.basic.service.KilnInfoService; import com.mt.wms.basic.service.LocationInfoService; import com.mt.wms.basic.service.VehicleService; import com.mt.wms.basic.vo.KilnInfoVo; -import com.mt.wms.basic.vo.LocationInfoVo; import com.mt.wms.basic.vo.VehicleVo; import com.mt.wms.core.api.Assert; import com.mt.wms.core.base.BaseService; @@ -19,12 +17,13 @@ import com.mt.wms.core.params.IdParam; import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; import com.mt.wms.empty.enums.OrderSourceEnum; -import com.mt.wms.empty.params.OrderParamForApms; import com.mt.wms.empty.params.OrderInfoBasePageParam; import com.mt.wms.empty.params.OrderInfoPersonCreateParam; import com.mt.wms.empty.params.OrderInfoTaskDetParam; +import com.mt.wms.empty.params.OrderParamForApms; import com.mt.wms.empty.service.CurrTaskDetService; import com.mt.wms.empty.service.CurrTaskService; +import com.mt.wms.empty.service.OrderInfoHisService; import com.mt.wms.empty.service.OrderInfoService; import com.mt.wms.empty.vo.CurrTaskVo; import com.mt.wms.empty.vo.OrderInfoTaskDetVo; @@ -53,6 +52,8 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic @Autowired OrderInfoServiceBiz orderInfoService; + @Autowired + OrderInfoHisService orderInfoHisService; @Autowired CurrTaskDetService currTaskDetService; @Autowired @@ -100,6 +101,7 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic orderInfo.setOrderSource(OrderSourceEnum.PERSON.getValue()); orderInfo.setInterCode("PERSONAL"+System.currentTimeMillis()); orderInfoService.save(orderInfo); + //todo 通知apms创建了一个订单 return successful("人工创建订单成功。"); } @@ -154,11 +156,29 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic @Override public R getTaskInfoByIdenCardNum(String idenCardNum) { - QueryWrapper wrapper=new QueryWrapper<>(); - wrapper.eq(OrderInfo.IDEN_CARD_NUM,idenCardNum).eq(OrderInfo.VALID,1).eq(OrderInfo.STATUS,0); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(OrderInfo.IDEN_CARD_NUM, idenCardNum).eq(OrderInfo.VALID, 1).eq(OrderInfo.STATUS, 0); OrderInfo one = orderInfoService.getOne(wrapper); OrderInfoVo build = OrderInfoVo.builder().build(); BeanUtils.copyProperties(one, build); return successful(build); } + + @Override + public R completeOrder(IdParam idParam) { + OrderInfo byId = orderInfoService.getById(idParam.getId()); + orderInfoHisService.save(byId); + byId.setValid(0); + byId.setStatus(2); + orderInfoService.updateById(byId); + return successful("操作成功。"); + } + + @Override + public R voidOrder(IdParam idParam) { + OrderInfo byId = orderInfoService.getById(idParam.getId()); + byId.setValid(0); + orderInfoService.updateById(byId); + return successful("操作成功。"); + } }