完成订单,作废订单,完成任务接口

This commit is contained in:
徐晨晨 2021-11-16 20:19:17 +08:00
parent 579b77daaa
commit 87f91696e4
9 changed files with 158 additions and 53 deletions

View File

@ -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<IdVo> 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<IdVo> mainTask = currTaskService.createProcessTask(param);
currTaskDetService.createProcessTaskDet(param.getDetParams(), mainTask.getData().getId());
return successful("创建成功。");
}
@PostMapping(value = "currentTaskNow")
@ApiOperation(value = "获取当前执行的任务")
public R<PageVo<CurrTaskQueryVo>> currentTask(@Validated @RequestBody CurrTaskQueryParam param){
public R<PageVo<CurrTaskQueryVo>> 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);
}
}

View File

@ -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<PageVo<OrderInfoVo>> 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);
}
}

View File

@ -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<TaskCreateDetParam> detParams;

View File

@ -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<OrderInfoTaskDetVo> getCurrOrderCurrTask(OrderInfoTaskDetParam param);
/**
* 创建正常加工的详细任务信息
*
* @param taskDet 详细任务信息
* @param taskId 主任务id
* @param taskId 主任务id
*/
void createFirstTaskDet(List<TaskCreateDetParam> taskDet, Long taskId);
void createProcessTaskDet(List<TaskCreateDetParam> taskDet, Long taskId);
/**
* 查询正常加工的详细任务信息
*
* @param currTaskId 详细任务信息
* @return 结果
*/
R<PageVo<CurrTaskDetVo>> getTaskDetailsPage(CurrTaskDetQueryParam currTaskId);
/**
* 查询某个主任务下的详细任务列表
*
* @param idParam 主任务id
* @return 结果
*/
List<CurrTaskDet> getTaskDetailsByMainId(IdParam idParam);
}

View File

@ -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<IdVo> createFirstTask(TaskCreateParam param);
R<IdVo> createProcessTask(TaskCreateParam param);
/**
* 查询分页信息
*
* @param param 查询参数
* @return 结果
*/
R<PageVo<CurrTaskQueryVo>> currentTaskPage(CurrTaskQueryParam param);
/**
* 完成执行任务
*
* @param param id
* @return 结果
*/
R completeTask(IdParam param);
}

View File

@ -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<PageVo<OrderInfoTaskDetVo>> getTaskInfo(OrderInfoTaskDetParam orderInfoTaskDetParam);
/**
* 创建加工订单时查询订单信息
*
* @param idenCardNum 标识卡号
* @return 结果
*/
R<OrderInfoVo> getTaskInfoByIdenCardNum(String idenCardNum);
/**
* 完成订单
*
* @param idParam id号
* @return 结果
*/
R completeOrder(IdParam idParam);
/**
* 作废订单
*
* @param idParam id号
* @return 结果
*/
R voidOrder(IdParam idParam);
}

View File

@ -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<TaskCreateDetParam> taskDet, Long taskId) {
public void createProcessTaskDet(List<TaskCreateDetParam> taskDet, Long taskId) {
List<CurrTaskDet> 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<PageVo<CurrTaskDetVo>> getTaskDetailsPage(CurrTaskDetQueryParam currTaskId) {
QueryWrapper<CurrTaskDet> 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<CurrTaskDet> page = currTaskDetServiceBiz.page(new Page<>(currTaskId.getCurrent(), currTaskId.getSize()), queryWrapper);
return successful(new PageVo<>(page, CurrTaskDetVo.class));
}
@Override
public List<CurrTaskDet> getTaskDetailsByMainId(IdParam idParam) {
QueryWrapper<CurrTaskDet> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(CurrTaskDet.CURR_TASK_ID, idParam.getId())
.eq(CurrTaskDet.VALID, 1);
return currTaskDetServiceBiz.list(queryWrapper);
}
}

View File

@ -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<IdVo> createFirstTask(TaskCreateParam param) {
public R<IdVo> 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<PageVo<CurrTaskQueryVo>> currentTaskPage(CurrTaskQueryParam param) {
QueryWrapper<CurrTask> currTaskQueryWrapper= new QueryWrapper<>();
currTaskQueryWrapper.eq(StringUtils.isNotBlank(param.getVehicleId()),CurrTask.VEHICLE_ID,param.getVehicleId());
currTaskQueryWrapper.eq(CurrTask.VALID,1);
QueryWrapper<CurrTask> currTaskQueryWrapper = new QueryWrapper<>();
currTaskQueryWrapper.eq(StringUtils.isNotBlank(param.getVehicleId()), CurrTask.VEHICLE_ID, param.getVehicleId());
currTaskQueryWrapper.eq(CurrTask.VALID, 1);
Page<CurrTask> 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<IdVo> save = taskHisService.save(taskHis);
currTaskServiceBiz.removeById(byId.getId());
List<CurrTaskDet> taskDetailsByMainId = currTaskDetService.getTaskDetailsByMainId(IdParam.builder().id(byId.getId()).build());
List<TaskDetHis> taskDetHis = com.mt.wms.core.utils.BeanUtils.copyList(taskDetailsByMainId, TaskDetHis.class);
taskDetHis.forEach(detHis -> {
detHis.setTaskId(save.getData().getId());
});
//将详细任务信息放入详细历史表
taskDetHisService.saveList(taskDetHis);
return successful("执行成功。");
}
}

View File

@ -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<OrderInfoVo> getTaskInfoByIdenCardNum(String idenCardNum) {
QueryWrapper<OrderInfo> wrapper=new QueryWrapper<>();
wrapper.eq(OrderInfo.IDEN_CARD_NUM,idenCardNum).eq(OrderInfo.VALID,1).eq(OrderInfo.STATUS,0);
QueryWrapper<OrderInfo> 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("操作成功。");
}
}