Browse Source

feat: 工单强制报工

master
李永德 1 year ago
parent
commit
43e9f732fc
  1. 3
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/coderule/impl/SysCodeRuleServiceImpl.java
  2. 82
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/autotask/AutoIssueWorkOrder.java
  3. 8
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java
  4. 8
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/controller/PdmBdWorkorderController.java
  5. 6
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java
  6. 38
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java
  7. 1
      lms/nladmin-system/nlsso-server/src/main/resources/stopword.dic
  8. 24
      lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue
  9. 9
      lms/nladmin-ui/src/views/wms/pdm/workerorder/pdmBdWorkorder.js

3
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<SysCodeRuleMapper, SysCodeRule> implements ISysCodeRuleService {
@Autowired
@ -126,6 +128,7 @@ public class SysCodeRuleServiceImpl extends ServiceImpl<SysCodeRuleMapper, SysCo
if (flag.equals("1")) {
codeRuleDetailMapper.updateById(detail);
}
log.info("更新成功:更新数据{}", detail);
}
return demo;
}

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

@ -12,12 +12,15 @@ import org.nl.wms.pdm.workorder.service.dao.vo.AcsWorkOrderVo;
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum;
import org.nl.wms.sch.task_manage.enums.WorkOrderStatusEnum;
import org.nl.wms.util.TaskUtils;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
/**
* @Author: lyd
@ -34,42 +37,55 @@ public class AutoIssueWorkOrder {
private WmsToAcsService wmsToAcsService;
@Autowired
private ISysNoticeService noticeService;
@Autowired
private RedissonClient redissonClient;
@SneakyThrows
public void run() {
// 获取所有设备号
List<String> deviceCodes = workorderService.getTheDayUnProducedDevice();
// 查找该设备未生产的工单去下发
deviceCodes.forEach(s -> {
// 判断是否有工单
List<PdmBdWorkorder> lists = workorderService.getTheDayProducedWorkOrderByDevice(s);
if (lists.size() > 0) return;
List<AcsWorkOrderVo> acsWorkOrderVoList = workorderService.getAcsWorkOrderVos(s);
if (acsWorkOrderVoList.size() == 0) return;
AcsWorkOrderVo acsWorkOrderVo = acsWorkOrderVoList.get(0);
// 获取一个下发
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;
RLock lock = redissonClient.getLock(this.getClass().getName());
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
try {
if (tryLock) {
// 获取所有设备号
List<String> deviceCodes = workorderService.getTheDayUnProducedDevice();
// 查找该设备未生产的工单去下发
deviceCodes.forEach(s -> {
// 判断是否有工单
List<PdmBdWorkorder> lists = workorderService.getTheDayProducedWorkOrderByDevice(s);
if (lists.size() > 0) return;
List<AcsWorkOrderVo> acsWorkOrderVoList = workorderService.getAcsWorkOrderVos(s);
if (acsWorkOrderVoList.size() == 0) return;
AcsWorkOrderVo acsWorkOrderVo = acsWorkOrderVoList.get(0);
// 获取一个下发
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);
});
}
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);
});
}
}
}

8
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);
}

8
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<Object> forceFinish(@RequestBody PdmBdWorkorder entity){
pdmBdWorkorderService.forceFinish(entity);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}

6
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<PdmBdWorkorder> {
List<AcsWorkOrderVo> getAcsWorkOrderVos(String s);
List<PdmBdWorkorder> getTheDayProducedWorkOrderByDevice(String s);
/**
* 强制报工完成
* @param entity
*/
void forceFinish(PdmBdWorkorder entity);
}

38
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<PdmBdWorkorderMapper,
private IMdBaseMaterialService materialService;
@Autowired
private ISchBaseVehiclematerialgroupService vehiclematerialgroupService;
@Autowired
private IMdBaseBrickInfoService baseBrickInfoService;
@Override
public IPage<PdmBdWorkorder> queryAll(PdmBdWorkorderQuery query, PageQuery page) {
@ -275,4 +279,38 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
public List<PdmBdWorkorder> 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());
}
}
}

1
lms/nladmin-system/nlsso-server/src/main/resources/stopword.dic

@ -1256,3 +1256,4 @@ $
反馈压机产出插入mes数据库失败
插入压机检测失败
包装数据
更新成功:更新数据

24
lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue

@ -82,6 +82,17 @@
>
同步
</el-button>
<el-button
slot="right"
class="filter-item"
type="danger"
icon="el-icon-position"
size="mini"
:disabled="!(crud.selections[0]) || crud.selections[1]"
@click="forceFinish(crud.selections[0])"
>
强制完工
</el-button>
</crudOperation>
<!--表单组件-->
<el-dialog
@ -654,7 +665,7 @@ export default {
submits(row) {
this.fullscreenLoading = true
crudPdmBdWorkorder.submits(row).then(res => {
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
})
}
}
}

9
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 }

Loading…
Cancel
Save