|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesConfigService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEmergencyLocationLogService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEmergencyLocationService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderExtService;
|
|
|
|
@ -7,14 +8,17 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.StringUtilExt;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesEmergencyLocationModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.util.DateUtil;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.util.StringUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesConfig;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesEmergencyLocation;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesConfigRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesEmergencyLocationRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
@ -23,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
@ -47,12 +52,29 @@ public class MesEmergencyLocationServiceImpl implements IMesEmergencyLocationSer
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesWorkOrderExtService mesWorkOrderExtService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesConfigService mesConfigService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesConfigRepository mesConfigRepository;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<MesEmergencyLocation> findMesEmergencyLocationList(String organizeCode, String workCenterCode) {
|
|
|
|
|
if (StringUtil.isEmptyAndNull(organizeCode) || StringUtil.isEmptyAndNull(workCenterCode)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return findMesEmergencyLocationList(organizeCode, CommonEnumUtil.VALID, workCenterCode);
|
|
|
|
|
List<MesEmergencyLocation> emergencyLocationList = findMesEmergencyLocationList(organizeCode, CommonEnumUtil.VALID, workCenterCode);
|
|
|
|
|
if(CollectionUtils.isEmpty(emergencyLocationList)){
|
|
|
|
|
return emergencyLocationList;
|
|
|
|
|
}
|
|
|
|
|
int remindDay = Integer.parseInt(mesConfigService.getCfgValue(organizeCode, MesPcnExtConstWords.REMIND_DAY));
|
|
|
|
|
//超过提醒天数标记黄色
|
|
|
|
|
emergencyLocationList.forEach(location -> {
|
|
|
|
|
if (!StringUtil.isEmpty(location.getInDate()) && new Date().compareTo(DateUtil.addDays(location.getInDate(), remindDay)) > MesPcnExtConstWords.ZERO) {
|
|
|
|
|
location.setColor(MesExtEnumUtil.COLOR.YELLOW.getValue());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return emergencyLocationList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -70,6 +92,30 @@ public class MesEmergencyLocationServiceImpl implements IMesEmergencyLocationSer
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doShippingStockOutOnline(String organizeCode, String workOrderNo, String userName, boolean isShipping) {
|
|
|
|
|
if (StringUtil.isEmpty(organizeCode) || StringUtil.isEmpty(workOrderNo)) return;
|
|
|
|
|
//校验加工单信息
|
|
|
|
|
MesEmergencyLocation locationWorkOrder = getMesEmergencyLocation(organizeCode, workOrderNo, null, isShipping);
|
|
|
|
|
if (Objects.isNull(locationWorkOrder)) return;
|
|
|
|
|
|
|
|
|
|
locationWorkOrder.setOutDate(TimeTool.getNowTime(true));
|
|
|
|
|
locationWorkOrder.setStockType(MesExtEnumUtil.EMERGENCY_LOCATION_STOCK_TYPE.EMERGENCY_LOCATION_STOCK_TYPE_20.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(locationWorkOrder, userName);
|
|
|
|
|
//记录日志
|
|
|
|
|
mesEmergencyLocationLogService.insertMesEmergencyLocationLog(locationWorkOrder);
|
|
|
|
|
//数据解绑
|
|
|
|
|
locationWorkOrder.setWorkOrderNo(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setOfflineDate(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setCustPartNo(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setPartName(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setInDate(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setOutDate(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setVehicleNo(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setSystemSyncStatus(CommonEnumUtil.FALSE);
|
|
|
|
|
mesEmergencyLocationRepository.update(locationWorkOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<MesEmergencyLocation> findMesEmergencyLocationList(String organizeCode, Integer status, String workCenterCode) {
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(workCenterCode, MesPcnExtConstWords.WORK_CENTER_CODE, packBean);
|
|
|
|
@ -105,23 +151,7 @@ public class MesEmergencyLocationServiceImpl implements IMesEmergencyLocationSer
|
|
|
|
|
|
|
|
|
|
private void doStockOutOnline(MesEmergencyLocationModel model) {
|
|
|
|
|
ValidatorBean.checkNotNull(model.getWorkOrderNo(), "加工单号不能为空");
|
|
|
|
|
//校验加工单信息
|
|
|
|
|
MesEmergencyLocation locationWorkOrder = getMesEmergencyLocation(model);
|
|
|
|
|
locationWorkOrder.setOutDate(TimeTool.getNowTime(true));
|
|
|
|
|
locationWorkOrder.setStockType(MesExtEnumUtil.EMERGENCY_LOCATION_STOCK_TYPE.EMERGENCY_LOCATION_STOCK_TYPE_20.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(locationWorkOrder, model.getUserName());
|
|
|
|
|
//记录日志
|
|
|
|
|
mesEmergencyLocationLogService.insertMesEmergencyLocationLog(locationWorkOrder);
|
|
|
|
|
//数据解绑
|
|
|
|
|
locationWorkOrder.setWorkOrderNo(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setOfflineDate(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setCustPartNo(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setPartName(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setInDate(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setOutDate(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setVehicleNo(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
locationWorkOrder.setSystemSyncStatus(CommonEnumUtil.FALSE);
|
|
|
|
|
mesEmergencyLocationRepository.update(locationWorkOrder);
|
|
|
|
|
doShippingStockOutOnline(model.getOrganizeCode(), model.getWorkOrderNo(), model.getUserName(), false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void doGpInspectionOnline(MesEmergencyLocationModel model) {
|
|
|
|
@ -131,7 +161,7 @@ public class MesEmergencyLocationServiceImpl implements IMesEmergencyLocationSer
|
|
|
|
|
if (Objects.isNull(workOrder)) {
|
|
|
|
|
MesPcnException.throwMesBusiException("加工单【%s】信息不存在", model.getWorkOrderNo());
|
|
|
|
|
}
|
|
|
|
|
MesEmergencyLocation locationWorkOrder = getMesEmergencyLocation(model);
|
|
|
|
|
MesEmergencyLocation locationWorkOrder = getMesEmergencyLocation(model.getOrganizeCode(), model.getWorkOrderNo(), model.getWorkCenterCode(), false);
|
|
|
|
|
if (MesExtEnumUtil.EMERGENCY_LOCATION_STOCK_TYPE.EMERGENCY_LOCATION_STOCK_TYPE_30.getValue() == locationWorkOrder.getStockType()) {
|
|
|
|
|
locationWorkOrder.setStockType(MesExtEnumUtil.EMERGENCY_LOCATION_STOCK_TYPE.EMERGENCY_LOCATION_STOCK_TYPE_40.getValue());
|
|
|
|
|
} else {
|
|
|
|
@ -149,6 +179,9 @@ public class MesEmergencyLocationServiceImpl implements IMesEmergencyLocationSer
|
|
|
|
|
ValidatorBean.checkNotNull(model.getLocationNumber(), "库位数不能为空");
|
|
|
|
|
ValidatorBean.checkNotNull(model.getRemindDay(), "提醒天数不能为空");
|
|
|
|
|
List<MesEmergencyLocation> locationList = findMesEmergencyLocationList(model.getOrganizeCode(), null, model.getWorkCenterCode());
|
|
|
|
|
//更新系统参数
|
|
|
|
|
updateMesConfig(model);
|
|
|
|
|
|
|
|
|
|
int lastNumber = 0;
|
|
|
|
|
if (!CollectionUtils.isEmpty(locationList)) {
|
|
|
|
|
lastNumber = locationList.get(locationList.size() - MesPcnExtConstWords.ONE).getLocationNumber();
|
|
|
|
@ -183,13 +216,24 @@ public class MesEmergencyLocationServiceImpl implements IMesEmergencyLocationSer
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MesEmergencyLocation getMesEmergencyLocation(MesEmergencyLocationModel model) {
|
|
|
|
|
MesEmergencyLocation locationWorkOrder = getMesEmergencyLocation(model.getOrganizeCode(), null, null, model.getWorkOrderNo());
|
|
|
|
|
if (Objects.isNull(locationWorkOrder)) {
|
|
|
|
|
MesPcnException.throwMesBusiException("加工单【%s】应急件库位管理信息不存在", model.getWorkOrderNo());
|
|
|
|
|
private void updateMesConfig(MesEmergencyLocationModel model) {
|
|
|
|
|
MesConfig remindDayCfg = mesConfigService.getMesConfig(model.getOrganizeCode(), MesPcnExtConstWords.REMIND_DAY);
|
|
|
|
|
if(model.getRemindDay() != Integer.parseInt(remindDayCfg.getCfgValue())){
|
|
|
|
|
remindDayCfg.setCfgValue(model.getRemindDay().toString());
|
|
|
|
|
ConvertBean.serviceModelUpdate(remindDayCfg, model.getUserName());
|
|
|
|
|
mesConfigRepository.update(remindDayCfg);
|
|
|
|
|
}
|
|
|
|
|
if (!model.getWorkCenterCode().equals(locationWorkOrder.getWorkCenterCode())) {
|
|
|
|
|
MesPcnException.throwMesBusiException("加工单【%s】所在产线【%s】与当前产线【%s】不匹配", model.getWorkOrderNo(), locationWorkOrder.getWorkCenterCode(), model.getWorkCenterCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MesEmergencyLocation getMesEmergencyLocation(String organizeCode,String workOrderNo,String workCenterCode,boolean isShipping) {
|
|
|
|
|
MesEmergencyLocation locationWorkOrder = getMesEmergencyLocation(organizeCode, null, null, workOrderNo);
|
|
|
|
|
if (!isShipping){
|
|
|
|
|
if (Objects.isNull(locationWorkOrder)) {
|
|
|
|
|
MesPcnException.throwMesBusiException("加工单【%s】应急件库位管理信息不存在", workOrderNo);
|
|
|
|
|
}
|
|
|
|
|
if (!workCenterCode.equals(locationWorkOrder.getWorkCenterCode())) {
|
|
|
|
|
MesPcnException.throwMesBusiException("加工单【%s】所在产线【%s】与当前产线【%s】不匹配", workOrderNo, locationWorkOrder.getWorkCenterCode(), workCenterCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return locationWorkOrder;
|
|
|
|
|
}
|
|
|
|
|