|
|
@ -6,11 +6,13 @@ import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import org.nl.common.exception.BadRequestException; |
|
|
|
import org.nl.system.service.notice.ISysNoticeService; |
|
|
|
import org.nl.wms.database.material.service.IMdBaseMaterialService; |
|
|
|
import org.nl.wms.database.material.service.dao.MdBaseMaterial; |
|
|
|
import org.nl.wms.pdm.record.service.IPdmBdRequestMaterialRecordService; |
|
|
|
import org.nl.wms.pdm.record.service.dao.PdmBdRequestMaterialRecord; |
|
|
|
import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService; |
|
|
|
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; |
|
|
|
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; |
|
|
@ -43,6 +45,7 @@ import java.util.stream.Collectors; |
|
|
|
* @version 1.0 |
|
|
|
* @date 2023年05月16日 16:44 |
|
|
|
* @desc 混碾满料任务: 混碾机 -> 困料输送线 |
|
|
|
* 混碾没有工单,也可能获取不到压机工单(统一用获取不到压机工单,全部由要料记录表) |
|
|
|
*/ |
|
|
|
@Component |
|
|
|
@TaskType("HLMLTask") |
|
|
@ -118,7 +121,8 @@ public class HNMLTask extends AbstractTask { |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 叫料完成
|
|
|
|
// requestMaterialRecordService.callMaterialFinish(point.getRecord_id());
|
|
|
|
requestMaterialRecordService.callMaterialFinish(point.getRecord_id()); |
|
|
|
jsonObject.put("record_id", point.getPoint_code()); // 要料记录
|
|
|
|
// 设置终点并修改创建成功状态
|
|
|
|
task.setPoint_code2(point.getPoint_code()); |
|
|
|
task.setTask_status(TaskStatus.CREATED.getCode()); |
|
|
@ -127,54 +131,16 @@ public class HNMLTask extends AbstractTask { |
|
|
|
// 告知acs去左边右边
|
|
|
|
int number = getNumber(point); |
|
|
|
task.setResponse_param(new JSONObject().fluentPut("direction", number).toJSONString()); |
|
|
|
task.setRequest_param(jsonObject.toString()); |
|
|
|
taskService.updateById(task); |
|
|
|
|
|
|
|
point.setIng_task_code(task.getTask_code()); |
|
|
|
PointUtils.setUpdateByAcs(point); |
|
|
|
pointService.updateById(point); |
|
|
|
|
|
|
|
//下发
|
|
|
|
// this.renotifyAcs(task);
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
protected void createCompletion(SchBaseTask task) { |
|
|
|
// 配置信息
|
|
|
|
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>() |
|
|
|
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); |
|
|
|
TaskUtils.setUpdateByAcs(task); // 修改修改者
|
|
|
|
List<String> nextRegionStr = Arrays.stream(taskConfig.getNext_region_str().split(",")) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
String requestParam = task.getRequest_param();// 任务的其他数据
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(requestParam); |
|
|
|
// 找终点
|
|
|
|
SchBasePoint point = findNextPoint(nextRegionStr, jsonObject); |
|
|
|
if (ObjectUtil.isEmpty(point)) { |
|
|
|
// 消息通知
|
|
|
|
noticeService.createNotice("未存在生产该料的压机!", TASK_CONFIG_CODE + task.getPoint_code1(), |
|
|
|
NoticeTypeEnum.WARN.getCode()); |
|
|
|
throw new BadRequestException("未存在生产该料的压机!"); |
|
|
|
} |
|
|
|
// 叫料完成
|
|
|
|
// requestMaterialRecordService.callMaterialFinish(point.getRecord_id());
|
|
|
|
// 设置终点并修改创建成功状态
|
|
|
|
task.setPoint_code2(point.getPoint_code()); |
|
|
|
task.setTask_status(TaskStatus.CREATED.getCode()); |
|
|
|
task.setRemark(""); |
|
|
|
task.setVehicle_type(GeneralDefinition.MATERIAL_CUP); |
|
|
|
// 告知acs去左边右边
|
|
|
|
int number = getNumber(point); |
|
|
|
task.setResponse_param(new JSONObject().fluentPut("direction", number).toJSONString()); |
|
|
|
taskService.save(task); |
|
|
|
|
|
|
|
point.setIng_task_code(task.getTask_code()); |
|
|
|
PointUtils.setUpdateByAcs(point); |
|
|
|
pointService.updateById(point); |
|
|
|
} |
|
|
|
|
|
|
|
private static int getNumber(SchBasePoint point) { |
|
|
|
String deviceCode = point.getDevice_code(); // 获取设备编码
|
|
|
|
int number = Integer.parseInt(deviceCode.replaceAll("[^0-9]", "")); |
|
|
@ -191,13 +157,33 @@ public class HNMLTask extends AbstractTask { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private SchBasePoint findNextPoint(List<String> nextRegionStr, JSONObject requestParam) { |
|
|
|
// *: 混碾无工单
|
|
|
|
String materialCode = requestParam.getString("material_code"); // 混碾编码
|
|
|
|
Assert.notNull(materialCode, "物料编码不能为空!"); |
|
|
|
materialCode = materialCode.substring(0, 12); |
|
|
|
// 根据工单物料标识寻找点位
|
|
|
|
List<SchBasePoint> points = hnMapper.findPointForHNMLAndWorkOrder(nextRegionStr, materialCode); |
|
|
|
return ObjectUtil.isNotEmpty(points) ? points.get(0) : null; |
|
|
|
// 获取要料表中的数据,获取对应物料(要料表存的是泥料)
|
|
|
|
List<PdmBdRequestMaterialRecord> list = requestMaterialRecordService.list( |
|
|
|
new LambdaQueryWrapper<PdmBdRequestMaterialRecord>() |
|
|
|
.eq(PdmBdRequestMaterialRecord::getMaterial_id, materialCode) |
|
|
|
.eq(PdmBdRequestMaterialRecord::getIs_delete, false) |
|
|
|
.eq(PdmBdRequestMaterialRecord::getIs_finish, false) |
|
|
|
.orderByAsc(PdmBdRequestMaterialRecord::getCreate_time)); |
|
|
|
if (list.size() == 0) { |
|
|
|
throw new BadRequestException("泥料记录出现异常"); |
|
|
|
} |
|
|
|
PdmBdRequestMaterialRecord requestMaterialRecord = list.get(0); // 要料数据
|
|
|
|
// 根据设备号查找对应的工单点位
|
|
|
|
LambdaQueryWrapper<SchBasePoint> lam = new QueryWrapper<SchBasePoint>().lambda(); |
|
|
|
lam.eq(SchBasePoint::getRegion_code, "LZKLX") |
|
|
|
.eq(SchBasePoint::getPoint_type, "5") |
|
|
|
.like(SchBasePoint::getParent_point_code, requestMaterialRecord.getDevice_code()); |
|
|
|
List<SchBasePoint> points = pointService.list(lam); |
|
|
|
if (points.size() == 0) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
SchBasePoint point = points.get(0); |
|
|
|
point.setDevice_code(requestMaterialRecord.getDevice_code()); |
|
|
|
point.setRecord_id(requestMaterialRecord.getRecord_id()); |
|
|
|
return point; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -216,7 +202,6 @@ public class HNMLTask extends AbstractTask { |
|
|
|
throw new BadRequestException("该任务不存在"); |
|
|
|
} |
|
|
|
this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); |
|
|
|
// todo: 通知acs取消任务
|
|
|
|
} |
|
|
|
|
|
|
|
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|
|
@ -225,6 +210,7 @@ public class HNMLTask extends AbstractTask { |
|
|
|
SchBasePoint endPointObj = pointService.getById(endPoint); |
|
|
|
String responseParam = taskObj.getResponse_param(); |
|
|
|
JSONObject responseObj = JSONObject.parseObject(responseParam); |
|
|
|
String recordId = responseObj.getString("record_id"); |
|
|
|
// 要把数据存到组盘表。压制工单放进去,
|
|
|
|
SchBaseVehiclematerialgroup groupEntity = vehiclematerialgroupService.getOne( |
|
|
|
new LambdaQueryWrapper<SchBaseVehiclematerialgroup>() |
|
|
@ -252,10 +238,9 @@ public class HNMLTask extends AbstractTask { |
|
|
|
PointUtils.setUpdateByType(yjDevice, taskFinishedType); |
|
|
|
yjDevice.setPoint_status(PointStatusEnum.FULL_POINT.getCode()); |
|
|
|
pointService.updateById(yjDevice); |
|
|
|
// 找压机工单
|
|
|
|
PdmBdWorkorder one = workorderService.getOne(new LambdaQueryWrapper<PdmBdWorkorder>() |
|
|
|
.eq(yjDevice != null, PdmBdWorkorder::getPoint_code, yjDevice.getPoint_code()) |
|
|
|
.eq(PdmBdWorkorder::getWorkorder_status, WorkOrderStatusEnum.PRODUCING.getCode())); |
|
|
|
PdmBdRequestMaterialRecord materialRecord = requestMaterialRecordService.getById(recordId); |
|
|
|
// 找压机工单, 可能没有开工的工单
|
|
|
|
PdmBdWorkorder one = workorderService.getByCode(materialRecord.getWorkorder_id()); |
|
|
|
if (ObjectUtil.isNotEmpty(one)) { |
|
|
|
// 给组盘数据设置批次:压制工单+混砂机号+碾次
|
|
|
|
groupEntity.setWorkorder_code(one.getWorkorder_code()); |
|
|
@ -354,7 +339,7 @@ public class HNMLTask extends AbstractTask { |
|
|
|
groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
|
|
|
|
groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
|
|
|
|
groupEntity.setIs_delete(false); |
|
|
|
groupEntity.setExt_data(packNo);// todo: 对于混碾的组盘 暂时存吨袋号
|
|
|
|
groupEntity.setExt_data(packNo);// 对于混碾的组盘 暂时存吨袋号
|
|
|
|
vehiclematerialgroupService.saveOrUpdate(groupEntity); |
|
|
|
return groupEntity.getGroup_id(); |
|
|
|
} |
|
|
|