|
@@ -16,6 +16,10 @@ import com.rongwei.bscommon.sys.service.*;
|
|
import com.rongwei.bscommon.sys.utils.ApsUtils;
|
|
import com.rongwei.bscommon.sys.utils.ApsUtils;
|
|
import com.rongwei.bsentity.domain.*;
|
|
import com.rongwei.bsentity.domain.*;
|
|
import com.rongwei.bsentity.vo.*;
|
|
import com.rongwei.bsentity.vo.*;
|
|
|
|
+import com.rongwei.rwadmincommon.system.domain.SysOrganizationDo;
|
|
|
|
+import com.rongwei.rwadmincommon.system.service.SysOrganizationService;
|
|
|
|
+import com.rongwei.rwadmincommon.system.service.impl.SysOrganizationServiceImpl;
|
|
|
|
+import com.rongwei.rwadmincommon.system.vo.SysOrganizationVo;
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
import com.rongwei.rwcommon.base.R;
|
|
import com.rongwei.rwcommon.base.R;
|
|
@@ -39,6 +43,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
import java.text.Collator;
|
|
import java.text.Collator;
|
|
|
|
+import java.time.LocalTime;
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -121,6 +126,10 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
private ApsProcessOperationProcessEquDao apsProcessOperationProcessEquDao;
|
|
private ApsProcessOperationProcessEquDao apsProcessOperationProcessEquDao;
|
|
@Autowired
|
|
@Autowired
|
|
private ApsProductionProcessesService apsProductionProcessesService;
|
|
private ApsProductionProcessesService apsProductionProcessesService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysOrganizationService sysOrganizationService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ApsScheduleLogService apsScheduleLogService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -734,21 +743,21 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
@Override
|
|
@Override
|
|
public void blankOrderAps(List<ApsBlankOrderVo> apsBlankOrders) {
|
|
public void blankOrderAps(List<ApsBlankOrderVo> apsBlankOrders) {
|
|
apsService.apsSchedule(apsBlankOrders, new ApsTypeVo(), null, null, null);
|
|
apsService.apsSchedule(apsBlankOrders, new ApsTypeVo(), null, null, null);
|
|
-// //调度排程
|
|
|
|
-// //判断是否是 18:00:00-24:00:00/00:00:00-5:00:00
|
|
|
|
-// // 获取当前时间
|
|
|
|
-// LocalTime now = LocalTime.now();
|
|
|
|
-// // 定义时间段
|
|
|
|
-// LocalTime startTime1 = LocalTime.of(18, 0); // 18:00:00
|
|
|
|
-// LocalTime endTime1 = LocalTime.of(23, 59, 59); // 23:59:59 (24:00:00 - 1 second)
|
|
|
|
-// LocalTime startTime2 = LocalTime.MIDNIGHT; // 00:00:00
|
|
|
|
-// LocalTime endTime2 = LocalTime.of(5, 0); // 05:00:00
|
|
|
|
-// // 检查当前时间是否在两个时间段之一内
|
|
|
|
-// boolean isInFirstRange = (now.isAfter(startTime1) || now.equals(startTime1)) && (now.isBefore(endTime1) || now.equals(endTime1));
|
|
|
|
-// boolean isInSecondRange = (now.isAfter(startTime2) || now.equals(startTime2)) && (now.isBefore(endTime2) || now.equals(endTime2));
|
|
|
|
-// if (isInFirstRange || isInSecondRange) {
|
|
|
|
-// apsScheduleRestart(null);
|
|
|
|
-// }
|
|
|
|
|
|
+ //调度排程
|
|
|
|
+ //判断是否是 18:00:00-24:00:00/00:00:00-5:00:00
|
|
|
|
+ // 获取当前时间
|
|
|
|
+ LocalTime now = LocalTime.now();
|
|
|
|
+ // 定义时间段
|
|
|
|
+ LocalTime startTime1 = LocalTime.of(17, 0); // 17:00:00
|
|
|
|
+ LocalTime endTime1 = LocalTime.of(23, 59, 59); // 23:59:59 (24:00:00 - 1 second)
|
|
|
|
+ LocalTime startTime2 = LocalTime.MIDNIGHT; // 00:00:00
|
|
|
|
+ LocalTime endTime2 = LocalTime.of(5, 0); // 05:00:00
|
|
|
|
+ // 检查当前时间是否在两个时间段之一内
|
|
|
|
+ boolean isInFirstRange = (now.isAfter(startTime1) || now.equals(startTime1)) && (now.isBefore(endTime1) || now.equals(endTime1));
|
|
|
|
+ boolean isInSecondRange = (now.isAfter(startTime2) || now.equals(startTime2)) && (now.isBefore(endTime2) || now.equals(endTime2));
|
|
|
|
+ if (isInFirstRange || isInSecondRange) {
|
|
|
|
+ apsScheduleRestart(null, null, null, null);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -4173,8 +4182,11 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void apsScheduleRestart(Integer hour, String chongpaiStartDateStr, String chongpaiEndDateStr) {
|
|
|
|
- ApsUtils.checkScheduling(null);
|
|
|
|
|
|
+ public void apsScheduleRestart(Integer hour, String chongpaiStartDateStr, String chongpaiEndDateStr, SysUserVo currentUser) {
|
|
|
|
+ if (currentUser == null) {
|
|
|
|
+ currentUser = CXCommonUtils.getCurrentUser();
|
|
|
|
+ }
|
|
|
|
+ ApsUtils.checkScheduling(currentUser);
|
|
String needScheduleDate = "";
|
|
String needScheduleDate = "";
|
|
DateTime chongpaiStartDate = null;
|
|
DateTime chongpaiStartDate = null;
|
|
DateTime chongpaiEndDate = null;
|
|
DateTime chongpaiEndDate = null;
|
|
@@ -4206,7 +4218,7 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
if (ObjectUtil.isNotEmpty(needScheduleDate)) {
|
|
if (ObjectUtil.isNotEmpty(needScheduleDate)) {
|
|
|
|
|
|
//将实际完工时间大于明天的作业挪到实际完工时间
|
|
//将实际完工时间大于明天的作业挪到实际完工时间
|
|
- this.baseMapper.updateFinishDateAboutProcessEqu(needScheduleDate, CXCommonUtils.getCurrentUserFactoryId(null), chongpaiStartDate, chongpaiEndDate);
|
|
|
|
|
|
+ this.baseMapper.updateFinishDateAboutProcessEqu(needScheduleDate, CXCommonUtils.getCurrentUserFactoryId(currentUser), chongpaiStartDate, chongpaiEndDate);
|
|
//锁定所有 未锁定的 作业和作业明细
|
|
//锁定所有 未锁定的 作业和作业明细
|
|
apsProcessOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>()
|
|
apsProcessOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>()
|
|
.set(ApsProcessOperationProcessEquDo::getLockmarkdetail, "y")
|
|
.set(ApsProcessOperationProcessEquDo::getLockmarkdetail, "y")
|
|
@@ -4214,15 +4226,13 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
apsProcessOperationService.update(new LambdaUpdateWrapper<ApsProcessOperationDo>()
|
|
apsProcessOperationService.update(new LambdaUpdateWrapper<ApsProcessOperationDo>()
|
|
.set(ApsProcessOperationDo::getLockmark, "y")
|
|
.set(ApsProcessOperationDo::getLockmark, "y")
|
|
.eq(ApsProcessOperationDo::getLockmark, "n"));
|
|
.eq(ApsProcessOperationDo::getLockmark, "n"));
|
|
-// //查询在重排时间前一天之后的所有作业明细信息,不包括:铸轧、成退、中退、小卷成退
|
|
|
|
-// List<ApsProcessOperationProcessEquChongpaiVo> list = this.baseMapper.selectNeedRescheduleEqu(needScheduleDate, CXCommonUtils.getCurrentUserFactoryId(null));
|
|
|
|
//排程设置
|
|
//排程设置
|
|
ApsScheduleConfigDo apsScheduleConfigDo = apsScheduleConfigService.getById("1");
|
|
ApsScheduleConfigDo apsScheduleConfigDo = apsScheduleConfigService.getById("1");
|
|
try {
|
|
try {
|
|
//冷轧重排
|
|
//冷轧重排
|
|
- lenzhaChongpai(chongpaiStartDate, chongpaiEndDate, apsScheduleConfigDo);
|
|
|
|
|
|
+ lenzhaChongpai(chongpaiStartDate, chongpaiEndDate, apsScheduleConfigDo, currentUser);
|
|
//退火重排
|
|
//退火重排
|
|
- tuihuoChongpai(chongpaiStartDate, chongpaiEndDate, apsScheduleConfigDo);
|
|
|
|
|
|
+ tuihuoChongpai(chongpaiStartDate, chongpaiEndDate, apsScheduleConfigDo, currentUser);
|
|
} finally {
|
|
} finally {
|
|
//锁定所有 未锁定的 作业和作业明细
|
|
//锁定所有 未锁定的 作业和作业明细
|
|
apsProcessOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>()
|
|
apsProcessOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>()
|
|
@@ -4337,6 +4347,63 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void apsScheduleRestart2() {
|
|
|
|
+ String bancaiTenantId = "0001S31000000000J0TR";
|
|
|
|
+ String bocaiTenantId = "0001651000000015EFDD";
|
|
|
|
+
|
|
|
|
+ Thread thread = new Thread(() -> {
|
|
|
|
+ doRestartSchedule(bancaiTenantId);
|
|
|
|
+ });
|
|
|
|
+ thread.start();
|
|
|
|
+
|
|
|
|
+ Thread thread1 = new Thread(() -> {
|
|
|
|
+ doRestartSchedule(bocaiTenantId);
|
|
|
|
+ });
|
|
|
|
+ thread1.start();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void doRestartSchedule(String tenantId) {
|
|
|
|
+ //即将排程日期
|
|
|
|
+ DateTime nowDate = DateUtil.date();
|
|
|
|
+ String time1 = DateUtil.format(nowDate, "yyyy-MM-dd 00:00:00");
|
|
|
|
+ String time2 = DateUtil.format(nowDate, "yyyy-MM-dd 12:00:00");
|
|
|
|
+ String time3 = DateUtil.format(nowDate, "yyyy-MM-dd 23:59:59");
|
|
|
|
+ String now = DateUtil.format(nowDate, "yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ //如果当前时间在0-12点,重排明天的
|
|
|
|
+ //如果当前时间在12-24点,重排后天的
|
|
|
|
+ String needScheduleDate = "";
|
|
|
|
+ if (now.compareTo(time1) >= 0 && now.compareTo(time2) < 0) {
|
|
|
|
+ needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 1), "yyyy-MM-dd 12:00:00");
|
|
|
|
+ }
|
|
|
|
+ if (now.compareTo(time2) >= 0 && now.compareTo(time3) <= 0) {
|
|
|
|
+ needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 2), "yyyy-MM-dd 12:00:00");
|
|
|
|
+ }
|
|
|
|
+ //查询日志判断是否已调度排程成功
|
|
|
|
+ int count = apsScheduleLogService.count(new LambdaQueryWrapper<ApsScheduleLogDo>()
|
|
|
|
+ .eq(ApsScheduleLogDo::getTenantid, tenantId)
|
|
|
|
+ .eq(ApsScheduleLogDo::getScheduletype, "调度排程")
|
|
|
|
+ .eq(ApsScheduleLogDo::getSucess,"是")
|
|
|
|
+ .le(ApsScheduleLogDo::getSchedulestarttime, needScheduleDate)
|
|
|
|
+ .ge(ApsScheduleLogDo::getScheduleendtime, needScheduleDate));
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ log.info("{}已调度排程,无需排程", tenantId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SysUserVo currentUser = new SysUserVo();
|
|
|
|
+ currentUser.setId("8672bf72ab274bec83052868ae336b38");
|
|
|
|
+ currentUser.setName("管理员");
|
|
|
|
+ List<SysOrganizationVo> organizationVoList = new LinkedList<>();
|
|
|
|
+ SysOrganizationDo org = sysOrganizationService.getById(tenantId);
|
|
|
|
+ SysOrganizationVo sysOrganizationVo = BeanUtil.toBean(org, SysOrganizationVo.class);
|
|
|
|
+ organizationVoList.add(sysOrganizationVo);
|
|
|
|
+ currentUser.setOrganizationDoList(organizationVoList);
|
|
|
|
+ CXCommonUtils.getCurrentUserFactoryId(currentUser);
|
|
|
|
+
|
|
|
|
+ apsScheduleRestart(null, null, null, currentUser);
|
|
|
|
+ }
|
|
|
|
+
|
|
//去除后续的冲突
|
|
//去除后续的冲突
|
|
@Override
|
|
@Override
|
|
public void sortLenZha(DateTime chongpaiEndDate) {
|
|
public void sortLenZha(DateTime chongpaiEndDate) {
|
|
@@ -4393,10 +4460,10 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void tuihuoChongpai(DateTime chongpaiStartDate, DateTime chongpaiEndDate, ApsScheduleConfigDo apsScheduleConfigDo) {
|
|
|
|
|
|
+ private void tuihuoChongpai(DateTime chongpaiStartDate, DateTime chongpaiEndDate, ApsScheduleConfigDo apsScheduleConfigDo, SysUserVo currentUser) {
|
|
//退火重排
|
|
//退火重排
|
|
//查询在重排时间段的所有作业明细信息,只包括:成退、中退、小卷成退
|
|
//查询在重排时间段的所有作业明细信息,只包括:成退、中退、小卷成退
|
|
- List<ApsProcessOperationProcessEquDo> needScheduleList = this.baseMapper.selectNeedRescheduleEqu2(chongpaiStartDate, chongpaiEndDate, CXCommonUtils.getCurrentUserFactoryId(null), apsScheduleConfigDo.getWorkshopin(), apsScheduleConfigDo.getWorkshopcross());
|
|
|
|
|
|
+ List<ApsProcessOperationProcessEquDo> needScheduleList = this.baseMapper.selectNeedRescheduleEqu2(chongpaiStartDate, chongpaiEndDate, CXCommonUtils.getCurrentUserFactoryId(currentUser), apsScheduleConfigDo.getWorkshopin(), apsScheduleConfigDo.getWorkshopcross());
|
|
if (needScheduleList.isEmpty()) {
|
|
if (needScheduleList.isEmpty()) {
|
|
log.info("未查询到退火作业明细,结束排程");
|
|
log.info("未查询到退火作业明细,结束排程");
|
|
return;
|
|
return;
|
|
@@ -4479,9 +4546,6 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
.in(ApsProcessOperationDo::getId, needUnLockProcessIdList)
|
|
.in(ApsProcessOperationDo::getId, needUnLockProcessIdList)
|
|
);
|
|
);
|
|
|
|
|
|
-// //将调度时间范围内还未解锁的退火作业全部往后推一天
|
|
|
|
-// this.baseMapper.setTuiHuoNextDay(CXCommonUtils.getCurrentUserFactoryId(null),chongpaiStartDate,chongpaiEndDate);
|
|
|
|
-
|
|
|
|
//重新排程
|
|
//重新排程
|
|
String scheduletype = apsScheduleConfigDo.getScheduletype();
|
|
String scheduletype = apsScheduleConfigDo.getScheduletype();
|
|
ApsTypeVo apsTypeVo = BeanUtil.toBean(scheduletype, ApsTypeVo.class);
|
|
ApsTypeVo apsTypeVo = BeanUtil.toBean(scheduletype, ApsTypeVo.class);
|
|
@@ -4492,13 +4556,13 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
needUnLockProcessIdList.addAll(notNeedUnLockProcessIdList);
|
|
needUnLockProcessIdList.addAll(notNeedUnLockProcessIdList);
|
|
needUnLockProcessIdList = needUnLockProcessIdList.stream().distinct().collect(Collectors.toList());
|
|
needUnLockProcessIdList = needUnLockProcessIdList.stream().distinct().collect(Collectors.toList());
|
|
log.info("所有传入退火排程的作业ID:{}", needUnLockProcessIdList);
|
|
log.info("所有传入退火排程的作业ID:{}", needUnLockProcessIdList);
|
|
- apsService.apsSchedule(new ArrayList<>(), apsTypeVo, null, needUnLockProcessIdList, chongpaiStartDate);
|
|
|
|
|
|
+ apsService.apsSchedule(new ArrayList<>(), apsTypeVo, currentUser, needUnLockProcessIdList, chongpaiStartDate);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private void lenzhaChongpai(DateTime chongpaiStartDate, DateTime chongpaiEndDate, ApsScheduleConfigDo apsScheduleConfigDo) {
|
|
|
|
|
|
+ private void lenzhaChongpai(DateTime chongpaiStartDate, DateTime chongpaiEndDate, ApsScheduleConfigDo apsScheduleConfigDo, SysUserVo currentUser) {
|
|
//查询需要重排的所有明细信息
|
|
//查询需要重排的所有明细信息
|
|
- List<ApsProcessOperationProcessEquDo> needScheduleList = this.baseMapper.selectNeedRescheduleEqu3(chongpaiStartDate, chongpaiEndDate, CXCommonUtils.getCurrentUserFactoryId(null), apsScheduleConfigDo.getWorkshopin(), apsScheduleConfigDo.getWorkshopcross());
|
|
|
|
|
|
+ List<ApsProcessOperationProcessEquDo> needScheduleList = this.baseMapper.selectNeedRescheduleEqu3(chongpaiStartDate, chongpaiEndDate, CXCommonUtils.getCurrentUserFactoryId(currentUser), apsScheduleConfigDo.getWorkshopin(), apsScheduleConfigDo.getWorkshopcross());
|
|
if (needScheduleList.isEmpty()) {
|
|
if (needScheduleList.isEmpty()) {
|
|
log.info("未查询到冷轧作业明细,结束排程");
|
|
log.info("未查询到冷轧作业明细,结束排程");
|
|
return;
|
|
return;
|
|
@@ -4653,9 +4717,6 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
.in(ApsProcessOperationDo::getId, needUnLockProcessIdList)
|
|
.in(ApsProcessOperationDo::getId, needUnLockProcessIdList)
|
|
);
|
|
);
|
|
|
|
|
|
-// //将调度时间范围内还未解锁的冷轧作业全部往后推一天
|
|
|
|
-// this.baseMapper.setLenZhaNextDay(CXCommonUtils.getCurrentUserFactoryId(null),chongpaiStartDate,chongpaiEndDate);
|
|
|
|
-
|
|
|
|
String scheduletype = apsScheduleConfigDo.getScheduletype();
|
|
String scheduletype = apsScheduleConfigDo.getScheduletype();
|
|
ApsTypeVo apsTypeVo = BeanUtil.toBean(scheduletype, ApsTypeVo.class);
|
|
ApsTypeVo apsTypeVo = BeanUtil.toBean(scheduletype, ApsTypeVo.class);
|
|
apsTypeVo.setMixIf("default");
|
|
apsTypeVo.setMixIf("default");
|
|
@@ -4667,7 +4728,7 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
needUnLockProcessIdList.addAll(notNeedUnLockProcessIdList);
|
|
needUnLockProcessIdList.addAll(notNeedUnLockProcessIdList);
|
|
needUnLockProcessIdList = needUnLockProcessIdList.stream().distinct().collect(Collectors.toList());
|
|
needUnLockProcessIdList = needUnLockProcessIdList.stream().distinct().collect(Collectors.toList());
|
|
log.info("所有传入冷轧排程的作业ID:{}", needUnLockProcessIdList);
|
|
log.info("所有传入冷轧排程的作业ID:{}", needUnLockProcessIdList);
|
|
- apsService.apsSchedule(new ArrayList<>(), apsTypeVo, null, needUnLockProcessIdList, chongpaiStartDate);
|
|
|
|
|
|
+ apsService.apsSchedule(new ArrayList<>(), apsTypeVo, currentUser, needUnLockProcessIdList, chongpaiStartDate);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|