优化生产单任务创建的逻辑
This commit is contained in:
parent
0b5c7886a6
commit
9c4e091956
@ -1,17 +1,24 @@
|
||||
package com.mt.wms.empty.controller;
|
||||
|
||||
import com.mt.wms.basic.service.KilnInfoService;
|
||||
import com.mt.wms.basic.vo.KilnInfoVo;
|
||||
import com.mt.wms.core.base.BaseController;
|
||||
import com.mt.wms.core.constants.CommonConstant;
|
||||
import com.mt.wms.core.dal.entity.CurrTask;
|
||||
import com.mt.wms.core.params.BasePageParam;
|
||||
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.ApmsCreateProcessSheet;
|
||||
import com.mt.wms.empty.params.CreateItem;
|
||||
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.OrderInfoService;
|
||||
import com.mt.wms.empty.vo.ApmsCreateProcessSheetVo;
|
||||
import com.mt.wms.empty.vo.ApmsStoveVo;
|
||||
import com.mt.wms.empty.vo.CurrTaskMainQueryVo;
|
||||
import com.mt.wms.empty.vo.CurrTaskQueryVo;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -24,6 +31,11 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xcc
|
||||
* @date 2021年11月8日
|
||||
@ -40,21 +52,80 @@ public class CurrTaskController extends BaseController {
|
||||
private CurrTaskDetService currTaskDetService;
|
||||
@Autowired
|
||||
private OrderInfoService orderInfoService;
|
||||
@Autowired
|
||||
private ApmsController apmsControl;
|
||||
@Autowired
|
||||
private KilnInfoService kilnInfoService;
|
||||
|
||||
@PostMapping(value = "createProcessTask")
|
||||
@ApiOperation(value = "订单加工-创建一个加工任务至任务队列")
|
||||
public R<String> createProcessTask(@Validated @RequestBody TaskCreateParam param) {
|
||||
//验证标识卡号正确无误。
|
||||
orderInfoService.verifyTaskInfoByIdenCardNum(param.getDetParams());
|
||||
R<IdVo> mainTask = currTaskService.createProcessTask(param);
|
||||
currTaskDetService.createProcessTaskDet(param.getDetParams(), mainTask.getData().getId());
|
||||
return successful("创建成功,任务添加至等待执行队列。");
|
||||
//验证炉子编码信息在apms正确无误
|
||||
R<KilnInfoVo> kilnInfoVoR = kilnInfoService.get(IdParam.builder().id(param.getKilnId()).build());
|
||||
String kilnCode = kilnInfoVoR.getData().getCode();
|
||||
R<ApmsStoveVo> bm = apmsControl.getStoveCodeByWorkShopCode("BM");
|
||||
ArrayList<Map<String, String>> stoveCodes = bm.getData().getStoveCodes();
|
||||
//验证apms存在这个炉子
|
||||
boolean verifyCodes = false;
|
||||
ArrayList<String> codeStr = new ArrayList<>();
|
||||
stoveCodes.forEach(kilnMap -> {
|
||||
codeStr.addAll(kilnMap.keySet());
|
||||
});
|
||||
for (String s : codeStr)
|
||||
{
|
||||
if (s.equals(kilnCode))
|
||||
{
|
||||
verifyCodes = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!verifyCodes)
|
||||
{
|
||||
return failed(kilnCode + " 验证APMS炉号失败!");
|
||||
}
|
||||
|
||||
//通知apms创建一个生产单
|
||||
ApmsCreateProcessSheet apmsCreateSheet = new ApmsCreateProcessSheet();
|
||||
apmsCreateSheet.setWorkShopCode("BM");
|
||||
apmsCreateSheet.setStartTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
apmsCreateSheet.setTechCode(param.getCraftCode());
|
||||
//fixme 暂时没有user信息
|
||||
apmsCreateSheet.setStartUser("");
|
||||
ArrayList<CreateItem> createItems = new ArrayList<>();
|
||||
param.getDetParams().forEach(e -> {
|
||||
CreateItem createItem = new CreateItem();
|
||||
createItem.setItemCode(e.getIdenCardNum());
|
||||
createItem.setQuantity(e.getQuantity().intValue());
|
||||
createItem.setWeight(e.getWeight().doubleValue());
|
||||
createItems.add(createItem);
|
||||
});
|
||||
apmsCreateSheet.setItems(createItems);
|
||||
R<ApmsCreateProcessSheetVo> processSheet = apmsControl.createProcessSheet(apmsCreateSheet);
|
||||
|
||||
if (processSheet.getData().getSuccess())
|
||||
{
|
||||
//apms创建成功后写入数据库
|
||||
R<IdVo> mainTask = currTaskService.createProcessTask(param);
|
||||
currTaskDetService.createProcessTaskDet(param.getDetParams(), mainTask.getData().getId());
|
||||
String sheetNo = processSheet.getData().getSheetNo();
|
||||
//将返回的生产单号写入到主任务中。
|
||||
CurrTask currTaskById = currTaskService.getCurrTaskById(mainTask.getData().getId());
|
||||
currTaskById.setSheetNo(sheetNo);
|
||||
currTaskService.updateCurrTaskById(currTaskById);
|
||||
return successful("创建成功,任务添加至等待执行队列。");
|
||||
}
|
||||
else
|
||||
{
|
||||
return failed("创建失败,APMS报错:" + processSheet.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "mainCurrentTaskNow")
|
||||
@ApiOperation(value = "首页-获取当前执行中的任务")
|
||||
public R<PageVo<CurrTaskMainQueryVo>> mainCurrentTaskNow(BasePageParam param) {
|
||||
public R<PageVo<CurrTaskMainQueryVo>> mainCurrentTaskNow(@Validated @RequestBody BasePageParam param) {
|
||||
return currTaskService.currentTaskMainPage(param);
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,10 @@ public class TaskCreateParam extends BaseParam {
|
||||
private String targetPosition;
|
||||
@ApiModelProperty(value = "加工类型:0 初始加工,1 复加工 ,2 追加加工", required = true)
|
||||
private Integer processType;
|
||||
@ApiModelProperty(value = "窑炉Id", required = true)
|
||||
@ApiModelProperty(value = "窑炉Id", example = "1", required = true)
|
||||
private Long kilnId;
|
||||
@ApiModelProperty(value = "工艺号", required = true)
|
||||
private String craftCode;
|
||||
@ApiModelProperty(value = "详细信息", required = true)
|
||||
private List<TaskCreateDetParam> detParams;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.mt.wms.empty.service;
|
||||
|
||||
import com.mt.wms.core.dal.entity.CurrTask;
|
||||
import com.mt.wms.core.params.BasePageParam;
|
||||
import com.mt.wms.core.params.IdParam;
|
||||
import com.mt.wms.core.vo.IdVo;
|
||||
@ -22,11 +23,26 @@ public interface CurrTaskService {
|
||||
|
||||
/**
|
||||
* 内部使用,获取详情任务的关联任务
|
||||
*
|
||||
* @param idParam 任务id
|
||||
* @return 任务实体
|
||||
*/
|
||||
CurrTaskVo getCurrTask(IdParam idParam);
|
||||
|
||||
/**
|
||||
* 内部使用,更新任务单号
|
||||
*
|
||||
* @param id 任务id
|
||||
*/
|
||||
void updateCurrTaskById(CurrTask id);
|
||||
|
||||
/**
|
||||
* 内部使用,获取任务实体
|
||||
*
|
||||
* @param id 任务id
|
||||
* @return 任务实体
|
||||
*/
|
||||
CurrTask getCurrTaskById(Long id);
|
||||
|
||||
/**
|
||||
* 创建加工任务的主任务信息
|
||||
|
@ -75,6 +75,7 @@ public class CurrTaskDetServiceImpl extends BaseService implements CurrTaskDetSe
|
||||
e -> {
|
||||
OrderInfo one = orderInfoService.getOne(new QueryWrapper<OrderInfo>().eq(OrderInfo.IDEN_CARD_NUM, e.getIdenCardNum()));
|
||||
e.setProductModel(one.getProductModel());
|
||||
e.setCustomer(one.getCustomerName());
|
||||
}
|
||||
);
|
||||
return successful(currTaskDetVo);
|
||||
|
@ -70,6 +70,16 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
|
||||
return build;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrTask getCurrTaskById(Long id) {
|
||||
return currTaskServiceBiz.getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCurrTaskById(CurrTask id) {
|
||||
currTaskServiceBiz.updateById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<IdVo> createProcessTask(TaskCreateParam param) {
|
||||
Assert.notNull("错误,加工类型不可为空!", param.getProcessType());
|
||||
|
@ -94,7 +94,7 @@ public class OrderInfoHisServiceImpl extends BaseService implements OrderInfoHis
|
||||
public R<PageVo<OrderInfoTaskDetVo>> getTaskInfo(OrderInfoTaskDetParam param) {
|
||||
//从历史任务详细中获取该标识卡和订单的所有订单
|
||||
PageVo<OrderInfoTaskDetVo> currOrderCurrTask = taskDetHisService.getHisOrderHisTask(param);
|
||||
Assert.gtZero(currOrderCurrTask.getRecords().size(), "该订单暂无详细记录。");
|
||||
Assert.notNull("该订单下无历史任务!", currOrderCurrTask.getRecords());
|
||||
//获取车辆信息
|
||||
R<List<VehicleVo>> vehicle = vehicleService.list(new VehicleQueryParam());
|
||||
Map<Long, List<VehicleVo>> collect = vehicle.getData().stream().collect(Collectors.groupingBy(VehicleVo::getId));
|
||||
|
@ -98,6 +98,7 @@ public class TaskDetHisServiceImpl extends BaseService implements TaskDetHisServ
|
||||
e -> {
|
||||
OrderInfo one = orderInfoService.getOne(new QueryWrapper<OrderInfo>().eq(OrderInfo.IDEN_CARD_NUM, e.getIdenCardNum()));
|
||||
e.setProductModel(one.getProductModel());
|
||||
e.setCustomer(one.getCustomerName());
|
||||
}
|
||||
);
|
||||
return successful(taskHisDetVoPageVo);
|
||||
|
Loading…
Reference in New Issue
Block a user