diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/coderule/impl/SysCodeRuleServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/coderule/impl/SysCodeRuleServiceImpl.java index 2b54c03..f891a75 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/coderule/impl/SysCodeRuleServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/coderule/impl/SysCodeRuleServiceImpl.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.extern.slf4j.Slf4j; import org.nl.common.domain.query.PageQuery; import org.nl.common.exception.BadRequestException; import org.nl.common.utils.SecurityUtils; @@ -36,6 +37,7 @@ import java.util.Set; * @author generator * @since 2022-12-19 */ +@Slf4j @Service public class SysCodeRuleServiceImpl extends ServiceImpl implements ISysCodeRuleService { @Autowired @@ -126,6 +128,7 @@ public class SysCodeRuleServiceImpl extends ServiceImpl deviceCodes = workorderService.getTheDayUnProducedDevice(); - // 查找该设备未生产的工单去下发 - deviceCodes.forEach(s -> { - // 判断是否有工单 - List lists = workorderService.getTheDayProducedWorkOrderByDevice(s); - if (lists.size() > 0) return; - List acsWorkOrderVoList = workorderService.getAcsWorkOrderVos(s); - if (acsWorkOrderVoList.size() == 0) return; - AcsWorkOrderVo acsWorkOrderVo = acsWorkOrderVoList.get(0); - // 获取一个下发 - List 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; + RLock lock = redissonClient.getLock(this.getClass().getName()); + boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); + try { + if (tryLock) { + // 获取所有设备号 + List deviceCodes = workorderService.getTheDayUnProducedDevice(); + // 查找该设备未生产的工单去下发 + deviceCodes.forEach(s -> { + // 判断是否有工单 + List lists = workorderService.getTheDayProducedWorkOrderByDevice(s); + if (lists.size() > 0) return; + List acsWorkOrderVoList = workorderService.getAcsWorkOrderVos(s); + if (acsWorkOrderVoList.size() == 0) return; + AcsWorkOrderVo acsWorkOrderVo = acsWorkOrderVoList.get(0); + // 获取一个下发 + List 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); + }); } - if (resultForAcs.getCode() != HttpStatus.HTTP_OK) { - // 不成功 - noticeService.createNotice(resultForAcs.getMessage(), "工单下发失败: " + acsWorkOrderVo.getWorkorder_code(), - NoticeTypeEnum.EXCEPTION.getCode()); - return; + } finally { + if (tryLock) { + lock.unlock(); } - // 修改工单数据 - PdmBdWorkorder pdmBdWorkorder = workorderService.getByCode(acsWorkOrderVo.getWorkorder_code()); - pdmBdWorkorder.setWorkorder_status(WorkOrderStatusEnum.ISSUED.getCode()); - TaskUtils.setWorkOrderUpdateByAcs(pdmBdWorkorder); - workorderService.updateById(pdmBdWorkorder); - }); + } + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java index ec2de5c..46156c9 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java @@ -558,8 +558,12 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { bdWorkorder.setQualified_qty(qualified_qty); bdWorkorder.setUnqualified_qty(unqualified_qty); workorderService.updateById(bdWorkorder); - // todo: 统计当前设备的不合格位置的数量作为不合格数,并上报给mes - wmsToMesService.reportPressUnusedMaterial(bdWorkorder); + try { + // todo: 统计当前设备的不合格位置的数量作为不合格数,并上报给mes + wmsToMesService.reportPressUnusedMaterial(bdWorkorder); + } catch (Exception e) { + log.info("调用mes异常:{}", e.getMessage()); + } return BaseResponse.responseOk(requestNo); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/controller/PdmBdWorkorderController.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/controller/PdmBdWorkorderController.java index 27e4f33..48c744a 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/controller/PdmBdWorkorderController.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/controller/PdmBdWorkorderController.java @@ -112,4 +112,12 @@ public class PdmBdWorkorderController { wmsToMesService.synchronizeWorkOrderInfo(); return new ResponseEntity<>(HttpStatus.OK); } + + @PostMapping("/forceFinish") + @Log("强制完工") + @ApiOperation("强制完工") + public ResponseEntity forceFinish(@RequestBody PdmBdWorkorder entity){ + pdmBdWorkorderService.forceFinish(entity); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java index e9592a0..fd1b7a7 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java @@ -108,4 +108,10 @@ public interface IPdmBdWorkorderService extends IService { List getAcsWorkOrderVos(String s); List getTheDayProducedWorkOrderByDevice(String s); + + /** + * 强制报工完成 + * @param entity + */ + void forceFinish(PdmBdWorkorder entity); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java index f391823..4d9ec81 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java @@ -16,9 +16,11 @@ import org.nl.common.exception.BadRequestException; import org.nl.common.utils.CodeUtil; import org.nl.common.utils.SecurityUtils; import org.nl.system.service.notice.ISysNoticeService; +import org.nl.wms.database.brick.service.IMdBaseBrickInfoService; import org.nl.wms.database.material.service.IMdBaseMaterialService; import org.nl.wms.database.material.service.dao.MdBaseMaterial; 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.mes.service.WmsToMesService; import org.nl.wms.ext.mes.service.dto.MesOrderInfo; @@ -65,6 +67,8 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl queryAll(PdmBdWorkorderQuery query, PageQuery page) { @@ -275,4 +279,38 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl getTheDayProducedWorkOrderByDevice(String s) { return pdmBdWorkorderMapper.getTheDayProducedWorkOrderByDevice(s); } + + @Override + public void forceFinish(PdmBdWorkorder entity) { + String workorderCode = entity.getWorkorder_code(); + if (workorderCode == null) { + throw new BadRequestException("工单标识不能为空!"); + } + PdmBdWorkorder bdWorkorder = this.getByCode(workorderCode); + if (bdWorkorder == null) { + throw new BadRequestException("未找到工单号[" + workorderCode + "]的记录!"); + } + if (bdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.ISSUED.getCode()) + || bdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.UNPRODUCED.getCode())) { + throw new BadRequestException("工单号[" + workorderCode + "]未生产不能完成工!"); + } + if (bdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.COMPLETE.getCode())) { + throw new BadRequestException("工单号[" + workorderCode + "]已完工,不能重复完工!"); + } + bdWorkorder.setWorkorder_status(WorkOrderStatusEnum.COMPLETE.getCode()); + bdWorkorder.setRealproduceend_date(DateUtil.now()); + TaskUtils.setWorkOrderUpdateByAcs(bdWorkorder); + // 统计合不合格数量到工单字段中 + int qualified_qty = baseBrickInfoService.getCountQualifiedQty(bdWorkorder.getWorkorder_code()); + int unqualified_qty = baseBrickInfoService.getCountUnqualifiedQty(bdWorkorder.getWorkorder_code()); + bdWorkorder.setQualified_qty(qualified_qty); + bdWorkorder.setUnqualified_qty(unqualified_qty); + this.updateById(bdWorkorder); + try { + // todo: 统计当前设备的不合格位置的数量作为不合格数,并上报给mes +// wmsToMesService.reportPressUnusedMaterial(bdWorkorder); + } catch (Exception e) { + log.info("调用mes异常:{}", e.getMessage()); + } + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/resources/stopword.dic b/lms/nladmin-system/nlsso-server/src/main/resources/stopword.dic index 4bd7454..3a56472 100644 --- a/lms/nladmin-system/nlsso-server/src/main/resources/stopword.dic +++ b/lms/nladmin-system/nlsso-server/src/main/resources/stopword.dic @@ -1256,3 +1256,4 @@ $ 反馈压机产出插入mes数据库失败 插入压机检测失败 包装数据 +更新成功:更新数据 diff --git a/lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue b/lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue index 08081d5..107c697 100644 --- a/lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue +++ b/lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue @@ -82,6 +82,17 @@ > 同步 + + 强制完工 + { - this.crud.notify('下发成功', CRUD.NOTIFICATION_TYPE.SUCCESS) + this.crud.notify('报工完成', CRUD.NOTIFICATION_TYPE.SUCCESS) this.crud.toQuery() }).catch(() => { this.fullscreenLoading = false @@ -672,6 +683,17 @@ export default { }).finally(() => { this.fullscreenLoading = false }) + }, + forceFinish(row) { + this.fullscreenLoading = true + crudPdmBdWorkorder.forceFinish(row).then(res => { + this.crud.notify('下发成功', CRUD.NOTIFICATION_TYPE.SUCCESS) + this.crud.toQuery() + }).catch(() => { + this.fullscreenLoading = false + }).finally(() => { + this.fullscreenLoading = false + }) } } } diff --git a/lms/nladmin-ui/src/views/wms/pdm/workerorder/pdmBdWorkorder.js b/lms/nladmin-ui/src/views/wms/pdm/workerorder/pdmBdWorkorder.js index a4eb005..8cc674b 100644 --- a/lms/nladmin-ui/src/views/wms/pdm/workerorder/pdmBdWorkorder.js +++ b/lms/nladmin-ui/src/views/wms/pdm/workerorder/pdmBdWorkorder.js @@ -32,6 +32,13 @@ export function submits(param) { data: param }) } +export function forceFinish(param) { + return request({ + url: 'api/pdmBdWorkorder/forceFinish', + method: 'post', + data: param + }) +} export function orderSynchronize(data) { return request({ @@ -55,4 +62,4 @@ export function getCuster() { }) } -export default { add, edit, del, submits, orderSynchronize, queryMaterials, getCuster } +export default { add, edit, del, submits, forceFinish, orderSynchronize, queryMaterials, getCuster }