Browse Source

1.马钢分拣钢托物料多次出库问题优化开发

2.马钢混碾自动化初步开发与测试
master
李永德 1 year ago
parent
commit
6845411297
  1. 21
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/common/exception/handler/GlobalExceptionHandler.java
  2. 71
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/autotask/AutoCallMaterials.java
  3. 49
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/autotask/AutoIssueWorkOrder.java
  4. 23
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java
  5. 20
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/autotask/AutoSynWorkOrderInfo.java
  6. 10
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java
  7. 7
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/record/service/IPdmBdRequestMaterialRecordService.java
  8. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/record/service/dao/PdmBdRequestMaterialRecord.java
  9. 16
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/record/service/impl/PdmBdRequestMaterialRecordServiceImpl.java
  10. 13
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java
  11. 8
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/dao/PdmBdWorkorder.java
  12. 6
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/dao/mapper/PdmBdWorkorderMapper.java
  13. 13
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/dao/mapper/PdmBdWorkorderMapper.xml
  14. 24
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java
  15. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJMKTask.java
  16. 18
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQLTask.java
  17. 85
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/hn/HNMLTask.java

21
lms/nladmin-system/nlsso-server/src/main/java/org/nl/common/exception/handler/GlobalExceptionHandler.java

@ -40,10 +40,23 @@ import static org.springframework.http.HttpStatus.NOT_FOUND;
public class GlobalExceptionHandler { public class GlobalExceptionHandler {
@ExceptionHandler(NullPointerException.class) @ExceptionHandler(NullPointerException.class)
public ResponseEntity<String> handleNullPointerException(NullPointerException ex) { public ResponseEntity<ApiError> handleNullPointerException(NullPointerException ex) {
// 在这里处理空指针异常 // 获取堆栈跟踪元素
log.error(ThrowableUtil.getStackTrace(ex)); StackTraceElement[] stackTraceElements = ex.getStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("空指针异常发生了"); String bodyRes;
if (stackTraceElements.length > 0) {
StackTraceElement topStackTraceElement = stackTraceElements[0];
String className = topStackTraceElement.getClassName();
int lineNumber = topStackTraceElement.getLineNumber();
// 在这里处理空指针异常,同时获取类名和行号
bodyRes = "空指针异常发生在类:" + className + " 的第 " + lineNumber + " 行";
log.error(bodyRes);
} else {
bodyRes = "空指针异常发生,但无法获取详细信息";
log.error(bodyRes);
}
return buildResponseEntity(ApiError.error(cn.hutool.http.HttpStatus.HTTP_BAD_REQUEST, bodyRes));
} }
/** /**

71
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/autotask/AutoCallMaterials.java

@ -0,0 +1,71 @@
package org.nl.wms.ext.acs.autotask;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.wms.ext.mms.service.WmsToMmsService;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.List;
import java.util.function.Consumer;
/**
* @Author: lyd
* @Description: 自动请求叫料
* @Date: 2023/11/8
*/
@Slf4j
@Component
@Order(value = 1)
public class AutoCallMaterials {
@Autowired
private IPdmBdWorkorderService workorderService;
@Autowired
private IPdmBdRequestMaterialRecordService requestMaterialRecordService;
@Autowired
private WmsToMmsService wmsToMmsService;
@SneakyThrows
public void run() {
// 获取叫料工单
List<PdmBdWorkorder> workorderList = workorderService.getNeedCallMaterial();
// 判断是否可以叫料,可以就下发给混碾系统
workorderList.forEach(workorder -> {
if (workorder.getReal_weight().compareTo(workorder.getPlan_weight()) >= 0) {
return; // 不需要请求,等待工单完工
}
// 校验记录表是否达到两条
List<PdmBdRequestMaterialRecord> list = requestMaterialRecordService.list(
new LambdaQueryWrapper<PdmBdRequestMaterialRecord>()
.eq(PdmBdRequestMaterialRecord::getDevice_code, workorder.getPoint_code())
.eq(PdmBdRequestMaterialRecord::getIs_delete, false));
if (list.size() >= 2) {
return;
}
try {
// 记录数据
requestMaterialRecordService.recordData(workorder);
} catch (Exception e) {
log.error("插入LMS数据库失败,{}", e.getMessage());
log.error("插入LMS数据库失败数据:{}", workorder);
return;
}
// todo: 如何保证上下的一致性?
try {
// 下发混碾
wmsToMmsService.addRequestMaterial(workorder);
} catch (Exception e) {
log.error("下发混碾失败,{}", e.getMessage());
log.error("下发混碾失败数据:{}", workorder);
}
});
}
}

49
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/autotask/AutoIssueWorkOrder.java

@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -41,6 +42,54 @@ public class AutoIssueWorkOrder {
private RedissonClient redissonClient; private RedissonClient redissonClient;
@SneakyThrows @SneakyThrows
public void run() { public void run() {
RLock lock = redissonClient.getLock(this.getClass().getName());
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
try {
if (tryLock) {
// 获取每台设备的第一条工单
List<PdmBdWorkorder> workorderList = workorderService.getNeedCallMaterial();
// 查找该设备未生产的工单去下发
workorderList.forEach(s -> {
// 判断是否有工单
List<PdmBdWorkorder> lists = workorderService.getTheDayProducedWorkOrderByDevice(s.getPoint_code());
if (lists.size() > 0) return;
AcsWorkOrderVo acsWorkOrderVo = workorderService.toAcsWorkOrderById(s.getWorkorder_id());
// 获取一个下发
List<AcsWorkOrderVo> list = new CopyOnWriteArrayList<>();
list.add(acsWorkOrderVo);
AcsResponse resultForAcs;
try {
resultForAcs = wmsToAcsService.order(list);
} catch (Exception e) {
log.error("工单下发异常:" + e.getMessage());
// 通知
noticeService.createNotice("工单下发失败: " + e.getMessage(), "工单下发失败: "
+ acsWorkOrderVo.getWorkorder_code(), NoticeTypeEnum.EXCEPTION.getCode());
return;
}
if (resultForAcs.getCode() != HttpStatus.HTTP_OK) {
// 不成功
noticeService.createNotice(resultForAcs.getMessage(), "工单下发失败: " + acsWorkOrderVo.getWorkorder_code(),
NoticeTypeEnum.EXCEPTION.getCode());
return;
}
// 修改工单数据
PdmBdWorkorder pdmBdWorkorder = workorderService.getByCode(acsWorkOrderVo.getWorkorder_code());
pdmBdWorkorder.setWorkorder_status(WorkOrderStatusEnum.ISSUED.getCode());
TaskUtils.setWorkOrderUpdateByAcs(pdmBdWorkorder);
workorderService.updateById(pdmBdWorkorder);
});
}
} finally {
if (tryLock) {
lock.unlock();
}
}
}
@SneakyThrows
public void run_backup() {
RLock lock = redissonClient.getLock(this.getClass().getName()); RLock lock = redissonClient.getLock(this.getClass().getName());
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
try { try {

23
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java

@ -24,7 +24,6 @@ import org.nl.wms.ext.acs.service.dto.to.acs.GetPalletizeResponse;
import org.nl.wms.ext.acs.service.dto.to.wms.*; import org.nl.wms.ext.acs.service.dto.to.wms.*;
import org.nl.wms.ext.mes.service.WmsToMesService; import org.nl.wms.ext.mes.service.WmsToMesService;
import org.nl.wms.ext.mes.service.dto.CusterDo; import org.nl.wms.ext.mes.service.dto.CusterDo;
import org.nl.wms.ext.mes.service.dto.CusterVo;
import org.nl.wms.ext.mes.service.dto.MesMudConsumptionDto; import org.nl.wms.ext.mes.service.dto.MesMudConsumptionDto;
import org.nl.wms.ext.mms.service.WmsToMmsService; import org.nl.wms.ext.mms.service.WmsToMmsService;
import org.nl.wms.ext.record.service.ISysInteractRecordService; import org.nl.wms.ext.record.service.ISysInteractRecordService;
@ -66,6 +65,7 @@ import javax.annotation.PostConstruct;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -640,9 +640,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
throw new BadRequestException("压机" + yjDeviceCode + "工单不存在!"); throw new BadRequestException("压机" + yjDeviceCode + "工单不存在!");
} }
// 泥料 // 泥料
// todo: 暂时写死
String rawMaterialCode = productionTask.getRaw_material_code(); String rawMaterialCode = productionTask.getRaw_material_code();
// String rawMaterialCode = one.getRedundance_material_code();
if (!rawMaterialCode.equals(one.getRedundance_material_code())) { if (!rawMaterialCode.equals(one.getRedundance_material_code())) {
throw new BadRequestException("物料不一样!"); throw new BadRequestException("物料不一样!");
} }
@ -677,13 +675,24 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
// mudConsumption.setWorkorder_code(productionTask.getWorkorder_code()); // mudConsumption.setWorkorder_code(productionTask.getWorkorder_code());
// mudConsumption.setRaw_material_code(rawMaterialCode); // mudConsumption.setRaw_material_code(rawMaterialCode);
// String id = mudConsumptionService.create(mudConsumption); // String id = mudConsumptionService.create(mudConsumption);
// 回传给mes系统
wmsToMesService.reportMudConsumption(mesMudConsumptionDto);
// 反馈数据给acs // 反馈数据给acs
taskResponse.setMix_number(one.getMix_times()); taskResponse.setMix_number(one.getMix_times());
taskResponse.setIs_standing_finish(GeneralDefinition.YES); taskResponse.setIs_standing_finish(GeneralDefinition.YES);
taskResponse.setMessage("静置完成"); taskResponse.setMessage("静置完成");
taskResponse.setWeight(one.getMaterial_weight().toString()); taskResponse.setWeight(one.getMaterial_weight().toString());
// 泥料数据删除
List<PdmBdRequestMaterialRecord> list = requestMaterialRecordService.list(new LambdaQueryWrapper<PdmBdRequestMaterialRecord>()
.eq(PdmBdRequestMaterialRecord::getDevice_code, productionTask.getPoint_code())
.eq(PdmBdRequestMaterialRecord::getWorkorder_id, productionTask.getWorkorder_code()) // 工单编码
.eq(PdmBdRequestMaterialRecord::getIs_delete, false)
.orderByAsc(PdmBdRequestMaterialRecord::getCreate_time));
if (list.size() > 0) {
PdmBdRequestMaterialRecord record = list.get(0);
record.setIs_delete(true);
requestMaterialRecordService.updateById(record);
}
// 回传给mes系统
wmsToMesService.reportMudConsumption(mesMudConsumptionDto);
} else { } else {
taskResponse.setIs_standing_finish(GeneralDefinition.NO); taskResponse.setIs_standing_finish(GeneralDefinition.NO);
taskResponse.setMessage(CommonUtils.remainStandingFinishTime(one.getInstorage_time(), taskResponse.setMessage(CommonUtils.remainStandingFinishTime(one.getInstorage_time(),
@ -762,7 +771,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
} }
// todo: 2、通知混碾机生产泥料 - 直接存入混碾系统的数据库中 // todo: 2、通知混碾机生产泥料 - 直接存入混碾系统的数据库中
try { try {
// wmsToMmsService.addRequestMaterial(deviceProductionTask); wmsToMmsService.addRequestMaterial(deviceProductionTask);
} catch (Exception e) { } catch (Exception e) {
log.error("发送混碾失败"); log.error("发送混碾失败");
throw new BadRequestException("发送混碾失败"); throw new BadRequestException("发送混碾失败");
@ -864,7 +873,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
public GetPalletizeResponse getVehicleInfo(JSONObject param) { public GetPalletizeResponse getVehicleInfo(JSONObject param) {
// 校验组盘信息 // 校验组盘信息
GetPalletizeRequest palletizeRequest = param.toJavaObject(GetPalletizeRequest.class); GetPalletizeRequest palletizeRequest = param.toJavaObject(GetPalletizeRequest.class);
String vehicleCode = palletizeRequest.getVehicle_code(); String vehicleCode = TaskUtils.defaultVehicleCode(palletizeRequest.getVehicle_code());
String vehicleType = GeneralDefinition.STEEL_TRAY; String vehicleType = GeneralDefinition.STEEL_TRAY;
if (ObjectUtil.isEmpty(vehicleCode)) { if (ObjectUtil.isEmpty(vehicleCode)) {
throw new BadRequestException("载具编码为空!"); throw new BadRequestException("载具编码为空!");

20
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/autotask/AutoSynWorkOrderInfo.java

@ -3,10 +3,14 @@ package org.nl.wms.ext.mes.autotask;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.wms.ext.mes.service.WmsToMesService; import org.nl.wms.ext.mes.service.WmsToMesService;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/** /**
* @Author: lyd * @Author: lyd
* @Description: 自动同步工单 * @Description: 自动同步工单
@ -18,8 +22,22 @@ import org.springframework.stereotype.Component;
public class AutoSynWorkOrderInfo { public class AutoSynWorkOrderInfo {
@Autowired @Autowired
private WmsToMesService wmsToMesService; private WmsToMesService wmsToMesService;
@Autowired
private RedissonClient redissonClient;
@SneakyThrows @SneakyThrows
public void run() { public void run() {
wmsToMesService.synchronizeWorkOrderInfo(); RLock lock = redissonClient.getLock(this.getClass().getName());
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
try {
if (tryLock) {
wmsToMesService.synchronizeWorkOrderInfo();
}
} finally {
if (tryLock) {
lock.unlock();
}
}
} }
} }

10
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java

@ -26,6 +26,7 @@ import org.nl.wms.sch.task_manage.GeneralDefinition;
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum; import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum;
import org.nl.wms.sch.task_manage.enums.WorkOrderStatusEnum; import org.nl.wms.sch.task_manage.enums.WorkOrderStatusEnum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -55,6 +56,7 @@ public class WmsToMesServiceImpl implements WmsToMesService {
private ISysNoticeService noticeService; private ISysNoticeService noticeService;
@Override @Override
@Async
public void reportMudConsumption(MesMudConsumptionDto mudObject) { public void reportMudConsumption(MesMudConsumptionDto mudObject) {
// 请求mes插入mes数据库 // 请求mes插入mes数据库
try { try {
@ -113,7 +115,7 @@ public class WmsToMesServiceImpl implements WmsToMesService {
} }
@Override @Override
// @DSTransactional @Async
public void reportProductData(String groupId) { public void reportProductData(String groupId) {
// 获取组盘信息 // 获取组盘信息
SchBaseVehiclematerialgroup vehiclematerialgroup = vehiclematerialgroupService.getById(groupId); SchBaseVehiclematerialgroup vehiclematerialgroup = vehiclematerialgroupService.getById(groupId);
@ -158,6 +160,7 @@ public class WmsToMesServiceImpl implements WmsToMesService {
} }
@Override @Override
@Async
public void reportSemiProductionInfoIn(String groupId) { public void reportSemiProductionInfoIn(String groupId) {
log.info("半成品入库"); log.info("半成品入库");
// 获取组盘信息 // 获取组盘信息
@ -202,6 +205,7 @@ public class WmsToMesServiceImpl implements WmsToMesService {
} }
@Override @Override
@Async
public void reportSemiProductionInfoOut(String groupId) { public void reportSemiProductionInfoOut(String groupId) {
// 获取组盘信息 // 获取组盘信息
SchBaseVehiclematerialgroup vehiclematerialgroup = vehiclematerialgroupService.getById(groupId); SchBaseVehiclematerialgroup vehiclematerialgroup = vehiclematerialgroupService.getById(groupId);
@ -245,6 +249,7 @@ public class WmsToMesServiceImpl implements WmsToMesService {
} }
@Override @Override
@Async
public void reportGdyMaterialInfoIn(String groupId) { public void reportGdyMaterialInfoIn(String groupId) {
// 获取组盘信息 // 获取组盘信息
SchBaseVehiclematerialgroup vehiclematerialgroup = vehiclematerialgroupService.getById(groupId); SchBaseVehiclematerialgroup vehiclematerialgroup = vehiclematerialgroupService.getById(groupId);
@ -286,6 +291,7 @@ public class WmsToMesServiceImpl implements WmsToMesService {
} }
@Override @Override
@Async
public void reportGdyMaterialInfoOut(String groupId) { public void reportGdyMaterialInfoOut(String groupId) {
// 获取组盘信息 // 获取组盘信息
SchBaseVehiclematerialgroup vehiclematerialgroup = vehiclematerialgroupService.getById(groupId); SchBaseVehiclematerialgroup vehiclematerialgroup = vehiclematerialgroupService.getById(groupId);
@ -342,6 +348,7 @@ public class WmsToMesServiceImpl implements WmsToMesService {
} }
@Override @Override
@Async
public void reportPressUnusedMaterial(PdmBdWorkorder orderObj) { public void reportPressUnusedMaterial(PdmBdWorkorder orderObj) {
// 获取统计数量 // 获取统计数量
int number = mesRequestMapper.countFPNumber(orderObj.getWorkorder_code(), orderObj.getPoint_code()); int number = mesRequestMapper.countFPNumber(orderObj.getWorkorder_code(), orderObj.getPoint_code());
@ -385,6 +392,7 @@ public class WmsToMesServiceImpl implements WmsToMesService {
} }
@Override @Override
@Async
public void reportBrickInfo(MdBaseBrickInfo brickInfo) { public void reportBrickInfo(MdBaseBrickInfo brickInfo) {
// 转换成mes字段 // 转换成mes字段
MesQSPressMonitorData mesQSPressMonitorData = toPressMonitorMapper(brickInfo); MesQSPressMonitorData mesQSPressMonitorData = toPressMonitorMapper(brickInfo);

7
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/record/service/IPdmBdRequestMaterialRecordService.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import org.nl.common.domain.query.PageQuery; import org.nl.common.domain.query.PageQuery;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.wms.pdm.record.service.dao.PdmBdRequestMaterialRecord; import org.nl.wms.pdm.record.service.dao.PdmBdRequestMaterialRecord;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -46,4 +47,10 @@ public interface IPdmBdRequestMaterialRecordService extends IService<PdmBdReques
* @param recordId * @param recordId
*/ */
void callMaterialFinish(String recordId); void callMaterialFinish(String recordId);
/**
* 记录要料信息
* @param workorder
*/
PdmBdRequestMaterialRecord recordData(PdmBdWorkorder workorder);
} }

2
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/record/service/dao/PdmBdRequestMaterialRecord.java

@ -38,6 +38,8 @@ public class PdmBdRequestMaterialRecord implements Serializable {
private String create_time; private String create_time;
@ApiModelProperty(value = "是否上料成功") @ApiModelProperty(value = "是否上料成功")
private Boolean is_finish; private Boolean is_finish;
@ApiModelProperty(value = "是否删除")
private Boolean is_delete;
@ApiModelProperty(value = "上料时间") @ApiModelProperty(value = "上料时间")
private String update_time; private String update_time;

16
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/record/service/impl/PdmBdRequestMaterialRecordServiceImpl.java

@ -1,5 +1,6 @@
package org.nl.wms.pdm.record.service.impl; package org.nl.wms.pdm.record.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -14,6 +15,7 @@ import org.nl.common.utils.SecurityUtils;
import org.nl.wms.pdm.record.service.IPdmBdRequestMaterialRecordService; import org.nl.wms.pdm.record.service.IPdmBdRequestMaterialRecordService;
import org.nl.wms.pdm.record.service.dao.mapper.PdmBdRequestMaterialRecordMapper; import org.nl.wms.pdm.record.service.dao.mapper.PdmBdRequestMaterialRecordMapper;
import org.nl.wms.pdm.record.service.dao.PdmBdRequestMaterialRecord; import org.nl.wms.pdm.record.service.dao.PdmBdRequestMaterialRecord;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -70,4 +72,18 @@ public class PdmBdRequestMaterialRecordServiceImpl extends ServiceImpl<PdmBdRequ
pdmBdRequestMaterialRecordMapper.updateById(requestMaterialRecord); pdmBdRequestMaterialRecordMapper.updateById(requestMaterialRecord);
} }
@Override
public PdmBdRequestMaterialRecord recordData(PdmBdWorkorder workorder) {
PdmBdRequestMaterialRecord entity = new PdmBdRequestMaterialRecord();
entity.setRecord_id(IdUtil.getSnowflake(1, 1).nextIdStr());
entity.setCreate_time(DateUtil.format(new DateTime(), "yyyy-MM-dd HH:mm:ss.SSS"));
entity.setMaterial_id(workorder.getRaw_material_code());
entity.setDevice_code(workorder.getPoint_code());
entity.setIs_delete(false);
entity.setIs_finish(false);
entity.setWorkorder_id(workorder.getWorkorder_code());
pdmBdRequestMaterialRecordMapper.insert(entity);
return entity;
}
} }

13
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java

@ -114,4 +114,17 @@ public interface IPdmBdWorkorderService extends IService<PdmBdWorkorder> {
* @param entity * @param entity
*/ */
void forceFinish(PdmBdWorkorder entity); void forceFinish(PdmBdWorkorder entity);
/**
* 获取叫料工单没有则获取第一条
* @return
*/
List<PdmBdWorkorder> getNeedCallMaterial();
/**
* 根据id获取给acs的工单
* @param workorderId
* @return
*/
AcsWorkOrderVo toAcsWorkOrderById(String workorderId);
} }

8
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/dao/PdmBdWorkorder.java

@ -36,6 +36,12 @@ public class PdmBdWorkorder implements Serializable {
@ApiModelProperty(value = "实际数量") @ApiModelProperty(value = "实际数量")
private BigDecimal real_qty; private BigDecimal real_qty;
@ApiModelProperty(value = "计划重量")
private BigDecimal plan_weight;
@ApiModelProperty(value = "实际重量")
private BigDecimal real_weight;
@ApiModelProperty(value = "物料标识") @ApiModelProperty(value = "物料标识")
private String material_id; private String material_id;
@ -156,5 +162,7 @@ public class PdmBdWorkorder implements Serializable {
private int guadansum; private int guadansum;
@TableField(exist = false) @TableField(exist = false)
private String pack_method; private String pack_method;
@TableField(exist = false)
private String row_num;
} }

6
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/dao/mapper/PdmBdWorkorderMapper.java

@ -49,4 +49,10 @@ public interface PdmBdWorkorderMapper extends BaseMapper<PdmBdWorkorder> {
List<AcsWorkOrderVo> getAcsWorkOrderVos(String device); List<AcsWorkOrderVo> getAcsWorkOrderVos(String device);
List<PdmBdWorkorder> getTheDayProducedWorkOrderByDevice(String s); List<PdmBdWorkorder> getTheDayProducedWorkOrderByDevice(String s);
/**
* 获取叫料工单
* @return
*/
List<PdmBdWorkorder> getNeedCallMaterial();
} }

13
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/dao/mapper/PdmBdWorkorderMapper.xml

@ -126,4 +126,17 @@
WHERE w.point_code = #{s} WHERE w.point_code = #{s}
AND w.workorder_status != '5' AND w.workorder_status != '1' AND w.workorder_status != '5' AND w.workorder_status != '1'
</select> </select>
<select id="getNeedCallMaterial" resultType="org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder">
SELECT ranked.*
FROM (
SELECT
w.*,
ROW_NUMBER() OVER (PARTITION BY w.point_code ORDER BY w.workorder_status DESC, w.planproducestart_date) AS row_num
FROM
`pdm_bd_workorder` w
WHERE w.produce_date = CURDATE() AND w.region_code = 'YZ'
AND w.workorder_status IN ('1','2','3')
) AS ranked
WHERE row_num = 1
</select>
</mapper> </mapper>

24
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java

@ -3,7 +3,6 @@ package org.nl.wms.pdm.workorder.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpStatus; import cn.hutool.http.HttpStatus;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -22,7 +21,6 @@ import org.nl.wms.database.brick.service.IMdBaseBrickInfoService;
import org.nl.wms.database.material.service.IMdBaseMaterialService; import org.nl.wms.database.material.service.IMdBaseMaterialService;
import org.nl.wms.database.material.service.dao.MdBaseMaterial; import org.nl.wms.database.material.service.dao.MdBaseMaterial;
import org.nl.wms.ext.acs.service.WmsToAcsService; import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.ext.acs.service.dto.to.BaseResponse;
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse; import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
import org.nl.wms.ext.mes.service.WmsToMesService; import org.nl.wms.ext.mes.service.WmsToMesService;
import org.nl.wms.ext.mes.service.dto.MesOrderInfo; import org.nl.wms.ext.mes.service.dto.MesOrderInfo;
@ -87,9 +85,12 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
String nickName = SecurityUtils.getCurrentNickName(); String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now(); String now = DateUtil.now();
String today = DateUtil.format(DateUtil.date(), "yyyyMMdd"); String today = DateUtil.format(DateUtil.date(), "yyyyMMdd");
Integer integer = pdmBdWorkorderMapper.selectCount(new LambdaQueryWrapper<PdmBdWorkorder>()
.eq(PdmBdWorkorder::getProduce_date, today));
// 点位编码和点位名称为父点位 // 点位编码和点位名称为父点位
entity.setWorkorder_id(IdUtil.getSnowflake(1, 1).nextIdStr()); entity.setWorkorder_id(IdUtil.getSnowflake(1, 1).nextIdStr());
entity.setWorkorder_code(CodeUtil.getNewCode("PDM_SHIFTORDER")); // entity.setWorkorder_code(CodeUtil.getNewCode("PDM_SHIFTORDER"));
entity.setWorkorder_code(today + String.format("%03d", integer));
entity.setCreate_id(currentUserId); entity.setCreate_id(currentUserId);
entity.setCreate_name(nickName); entity.setCreate_name(nickName);
entity.setCreate_time(now); entity.setCreate_time(now);
@ -132,6 +133,7 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
res.put("custer_no", entity.getCuster_no()); res.put("custer_no", entity.getCuster_no());
entity.setPlan_qty(ceil > inventoryCeil ? BigDecimal.valueOf(inventoryCeil) : BigDecimal.valueOf(ceil)); entity.setPlan_qty(ceil > inventoryCeil ? BigDecimal.valueOf(inventoryCeil) : BigDecimal.valueOf(ceil));
entity.setExt_data(res.toJSONString()); entity.setExt_data(res.toJSONString());
entity.setPlan_weight(ceil > inventoryCeil ? BigDecimal.valueOf(inventoryQty) : BigDecimal.valueOf(residueNum)); // 对于分拣就是计划钢托盘上的砖数量
entity.setProduce_order(entity.getOrder_no()); entity.setProduce_order(entity.getOrder_no());
} }
@ -289,6 +291,7 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
@Override @Override
public void forceFinish(PdmBdWorkorder entity) { public void forceFinish(PdmBdWorkorder entity) {
String workorderCode = entity.getWorkorder_code(); String workorderCode = entity.getWorkorder_code();
String today = DateUtil.format(DateUtil.date(), "yyyyMMdd");
if (workorderCode == null) { if (workorderCode == null) {
throw new BadRequestException("工单标识不能为空!"); throw new BadRequestException("工单标识不能为空!");
} }
@ -296,8 +299,9 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
if (bdWorkorder == null) { if (bdWorkorder == null) {
throw new BadRequestException("未找到工单号[" + workorderCode + "]的记录!"); throw new BadRequestException("未找到工单号[" + workorderCode + "]的记录!");
} }
if (bdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.ISSUED.getCode()) if ((bdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.ISSUED.getCode())
|| bdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.UNPRODUCED.getCode())) { || bdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.UNPRODUCED.getCode()))
&& (ObjectUtil.isNotEmpty(entity.getProduce_date()) && entity.getProduce_date().equals(today))) {
throw new BadRequestException("工单号[" + workorderCode + "]未生产不能完成工!"); throw new BadRequestException("工单号[" + workorderCode + "]未生产不能完成工!");
} }
if (bdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.COMPLETE.getCode())) { if (bdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.COMPLETE.getCode())) {
@ -319,4 +323,14 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
log.info("调用mes异常:{}", e.getMessage()); log.info("调用mes异常:{}", e.getMessage());
} }
} }
@Override
public List<PdmBdWorkorder> getNeedCallMaterial() {
return pdmBdWorkorderMapper.getNeedCallMaterial();
}
@Override
public AcsWorkOrderVo toAcsWorkOrderById(String workorderId) {
return pdmBdWorkorderMapper.toAcsWorkOrderById(workorderId);
}
} }

2
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJMKTask.java

@ -377,7 +377,7 @@ public class FJMKTask extends AbstractTask {
} }
SchBaseVehiclematerialgroup vehicleMaterialGroupObj = SchBaseVehiclematerialgroup vehicleMaterialGroupObj =
vehiclematerialgroupService.getById(taskObj.getGroup_id()); vehiclematerialgroupService.getById(taskObj.getGroup_id());
// vehicleMaterialGroupObj.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue()); vehicleMaterialGroupObj.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue());
vehicleMaterialGroupObj.setTask_code(taskObj.getTask_code()); vehicleMaterialGroupObj.setTask_code(taskObj.getTask_code());
vehicleMaterialGroupObj.setPoint_code(bzxPointObj.getPoint_code()); // 当前位置 vehicleMaterialGroupObj.setPoint_code(bzxPointObj.getPoint_code()); // 当前位置
vehicleMaterialGroupObj.setPoint_name(bzxPointObj.getPoint_name()); vehicleMaterialGroupObj.setPoint_name(bzxPointObj.getPoint_name());

18
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQLTask.java

@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -120,6 +121,15 @@ public class FJQLTask extends AbstractTask {
// 找起点 // 找起点
String requestParam = task.getRequest_param(); String requestParam = task.getRequest_param();
JSONObject extGroupData = JSONObject.parseObject(requestParam); JSONObject extGroupData = JSONObject.parseObject(requestParam);
// 判断是否满足工单要求
PdmBdWorkorder workorderCode = workorderService.getByCode(extGroupData.getString("workorder_code"));
// 对于分拣,用于分拣钢托盘砖块数
if (workorderCode.getReal_weight().compareTo(workorderCode.getPlan_weight()) >= 0) {
// 消息通知
noticeService.createNotice("钢托盘砖块数已达到所需数量!", TASK_CONFIG_CODE + task.getPoint_code2(),
NoticeTypeEnum.WARN.getCode());
throw new BadRequestException("钢托盘砖块数已达到所需数量!");
}
extGroupData.put("vehicle_type", task.getVehicle_type()); extGroupData.put("vehicle_type", task.getVehicle_type());
SchBasePoint point = findStartPoint(startRegionStr, extGroupData); SchBasePoint point = findStartPoint(startRegionStr, extGroupData);
if (ObjectUtil.isEmpty(point)) { if (ObjectUtil.isEmpty(point)) {
@ -209,6 +219,8 @@ public class FJQLTask extends AbstractTask {
String endPoint = taskObj.getPoint_code2(); // 获取起点 String endPoint = taskObj.getPoint_code2(); // 获取起点
SchBasePoint startPointObj = pointService.getById(startPoint); SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint); SchBasePoint endPointObj = pointService.getById(endPoint);
String requestParam = taskObj.getRequest_param();
JSONObject extGroupData = JSONObject.parseObject(requestParam);
// 除了解锁需要将组盘表中的物料绑定载具设置为已解绑 // 除了解锁需要将组盘表中的物料绑定载具设置为已解绑
// 起点设置空位 // 起点设置空位
if (ObjectUtil.isNotEmpty(startPointObj)) { if (ObjectUtil.isNotEmpty(startPointObj)) {
@ -237,6 +249,12 @@ public class FJQLTask extends AbstractTask {
endPointObj.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode()); endPointObj.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode());
PointUtils.setUpdateByType(endPointObj, taskFinishedType); PointUtils.setUpdateByType(endPointObj, taskFinishedType);
pointService.updateById(endPointObj); pointService.updateById(endPointObj);
// 修改工单实际搬运钢托盘上的码垛数量
PdmBdWorkorder workorderCode = workorderService.getByCode(extGroupData.getString("workorder_code"));
workorderCode.setReal_weight(workorderCode.getReal_weight().add(BigDecimal.valueOf(
vehicleMaterialGroupObj.getMaterial_qty())));
TaskUtils.setWorkOrderUpdateByType(workorderCode, taskFinishedType);
workorderService.updateById(workorderCode);
} }
// 任务完成 // 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode()); taskObj.setTask_status(TaskStatus.FINISHED.getCode());

85
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/hn/HNMLTask.java

@ -6,11 +6,13 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.common.exception.BadRequestException;
import org.nl.system.service.notice.ISysNoticeService; import org.nl.system.service.notice.ISysNoticeService;
import org.nl.wms.database.material.service.IMdBaseMaterialService; import org.nl.wms.database.material.service.IMdBaseMaterialService;
import org.nl.wms.database.material.service.dao.MdBaseMaterial; import org.nl.wms.database.material.service.dao.MdBaseMaterial;
import org.nl.wms.pdm.record.service.IPdmBdRequestMaterialRecordService; 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.IPdmBdWorkorderService;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
@ -43,6 +45,7 @@ import java.util.stream.Collectors;
* @version 1.0 * @version 1.0
* @date 2023年05月16日 16:44 * @date 2023年05月16日 16:44
* @desc 混碾满料任务 混碾机 -> 困料输送线 * @desc 混碾满料任务 混碾机 -> 困料输送线
* 混碾没有工单也可能获取不到压机工单统一用获取不到压机工单全部由要料记录表)
*/ */
@Component @Component
@TaskType("HLMLTask") @TaskType("HLMLTask")
@ -118,7 +121,8 @@ public class HNMLTask extends AbstractTask {
continue; 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.setPoint_code2(point.getPoint_code());
task.setTask_status(TaskStatus.CREATED.getCode()); task.setTask_status(TaskStatus.CREATED.getCode());
@ -127,54 +131,16 @@ public class HNMLTask extends AbstractTask {
// 告知acs去左边右边 // 告知acs去左边右边
int number = getNumber(point); int number = getNumber(point);
task.setResponse_param(new JSONObject().fluentPut("direction", number).toJSONString()); task.setResponse_param(new JSONObject().fluentPut("direction", number).toJSONString());
task.setRequest_param(jsonObject.toString());
taskService.updateById(task); taskService.updateById(task);
point.setIng_task_code(task.getTask_code()); point.setIng_task_code(task.getTask_code());
PointUtils.setUpdateByAcs(point); PointUtils.setUpdateByAcs(point);
pointService.updateById(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) { private static int getNumber(SchBasePoint point) {
String deviceCode = point.getDevice_code(); // 获取设备编码 String deviceCode = point.getDevice_code(); // 获取设备编码
int number = Integer.parseInt(deviceCode.replaceAll("[^0-9]", "")); int number = Integer.parseInt(deviceCode.replaceAll("[^0-9]", ""));
@ -191,13 +157,33 @@ public class HNMLTask extends AbstractTask {
* @return * @return
*/ */
private SchBasePoint findNextPoint(List<String> nextRegionStr, JSONObject requestParam) { private SchBasePoint findNextPoint(List<String> nextRegionStr, JSONObject requestParam) {
// *: 混碾无工单
String materialCode = requestParam.getString("material_code"); // 混碾编码 String materialCode = requestParam.getString("material_code"); // 混碾编码
Assert.notNull(materialCode, "物料编码不能为空!"); Assert.notNull(materialCode, "物料编码不能为空!");
materialCode = materialCode.substring(0, 12); materialCode = materialCode.substring(0, 12);
// 根据工单物料标识寻找点位 // 获取要料表中的数据,获取对应物料(要料表存的是泥料)
List<SchBasePoint> points = hnMapper.findPointForHNMLAndWorkOrder(nextRegionStr, materialCode); List<PdmBdRequestMaterialRecord> list = requestMaterialRecordService.list(
return ObjectUtil.isNotEmpty(points) ? points.get(0) : null; 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 @Override
@ -216,7 +202,6 @@ public class HNMLTask extends AbstractTask {
throw new BadRequestException("该任务不存在"); throw new BadRequestException("该任务不存在");
} }
this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC);
// todo: 通知acs取消任务
} }
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
@ -225,6 +210,7 @@ public class HNMLTask extends AbstractTask {
SchBasePoint endPointObj = pointService.getById(endPoint); SchBasePoint endPointObj = pointService.getById(endPoint);
String responseParam = taskObj.getResponse_param(); String responseParam = taskObj.getResponse_param();
JSONObject responseObj = JSONObject.parseObject(responseParam); JSONObject responseObj = JSONObject.parseObject(responseParam);
String recordId = responseObj.getString("record_id");
// 要把数据存到组盘表。压制工单放进去, // 要把数据存到组盘表。压制工单放进去,
SchBaseVehiclematerialgroup groupEntity = vehiclematerialgroupService.getOne( SchBaseVehiclematerialgroup groupEntity = vehiclematerialgroupService.getOne(
new LambdaQueryWrapper<SchBaseVehiclematerialgroup>() new LambdaQueryWrapper<SchBaseVehiclematerialgroup>()
@ -252,10 +238,9 @@ public class HNMLTask extends AbstractTask {
PointUtils.setUpdateByType(yjDevice, taskFinishedType); PointUtils.setUpdateByType(yjDevice, taskFinishedType);
yjDevice.setPoint_status(PointStatusEnum.FULL_POINT.getCode()); yjDevice.setPoint_status(PointStatusEnum.FULL_POINT.getCode());
pointService.updateById(yjDevice); pointService.updateById(yjDevice);
// 找压机工单 PdmBdRequestMaterialRecord materialRecord = requestMaterialRecordService.getById(recordId);
PdmBdWorkorder one = workorderService.getOne(new LambdaQueryWrapper<PdmBdWorkorder>() // 找压机工单, 可能没有开工的工单
.eq(yjDevice != null, PdmBdWorkorder::getPoint_code, yjDevice.getPoint_code()) PdmBdWorkorder one = workorderService.getByCode(materialRecord.getWorkorder_id());
.eq(PdmBdWorkorder::getWorkorder_status, WorkOrderStatusEnum.PRODUCING.getCode()));
if (ObjectUtil.isNotEmpty(one)) { if (ObjectUtil.isNotEmpty(one)) {
// 给组盘数据设置批次:压制工单+混砂机号+碾次 // 给组盘数据设置批次:压制工单+混砂机号+碾次
groupEntity.setWorkorder_code(one.getWorkorder_code()); 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_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。 groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
groupEntity.setIs_delete(false); groupEntity.setIs_delete(false);
groupEntity.setExt_data(packNo);// todo: 对于混碾的组盘 暂时存吨袋号 groupEntity.setExt_data(packNo);// 对于混碾的组盘 暂时存吨袋号
vehiclematerialgroupService.saveOrUpdate(groupEntity); vehiclematerialgroupService.saveOrUpdate(groupEntity);
return groupEntity.getGroup_id(); return groupEntity.getGroup_id();
} }

Loading…
Cancel
Save