|
|
@@ -3,6 +3,7 @@ package com.xunmei.core.resumption.task;
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
@@ -19,6 +20,7 @@ import com.xunmei.common.core.utils.ResumptionStatus;
|
|
|
import com.xunmei.common.core.utils.ResumptionType;
|
|
|
import com.xunmei.core.resumption.vo.AppRulePointTaskVo;
|
|
|
import com.xunmei.core.resumption.vo.WorkChangeResumptionVo;
|
|
|
+import com.xunmei.system.api.Eto.OrgListByTypesConditionEto;
|
|
|
import com.xunmei.system.api.RemoteConfigService;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.RemoteWorkTimeService;
|
|
|
@@ -56,7 +58,6 @@ public class ResumptionTaskBusiness {
|
|
|
private RemoteConfigService systemParameService;
|
|
|
|
|
|
|
|
|
-
|
|
|
// @Resource
|
|
|
// DelayTaskService delayTaskService;
|
|
|
/**
|
|
|
@@ -110,8 +111,8 @@ public class ResumptionTaskBusiness {
|
|
|
List<NFCBindPageVo> nfcList = nfcBindService.all(jobDto,NFCBindPageVo::to);*/
|
|
|
//获取有 作息的机构id
|
|
|
R<List<Long>> listR = workTimeService.findOrgIdsByYmd(dateTime.toString().substring(0, 10), SecurityConstants.INNER);
|
|
|
- List<Long> orgIdsNew=new ArrayList<>();
|
|
|
- if (listR.getCode()==200) {
|
|
|
+ List<Long> orgIdsNew = new ArrayList<>();
|
|
|
+ if (listR.getCode() == 200) {
|
|
|
orgIdsNew = listR.getData();
|
|
|
}
|
|
|
List<Long> finalOrgIdsNew = orgIdsNew;
|
|
|
@@ -123,10 +124,10 @@ public class ResumptionTaskBusiness {
|
|
|
jobDto.setNfcBindIdList(new ArrayList(nfcBindIdList));
|
|
|
jobDto.setOrgId(orgId);
|
|
|
List<NFCBindPageVo> nfcList = nfcBindService.all(jobDto,NFCBindPageVo::to);*/
|
|
|
- Ymd ymd=toYmd(dateTime,"DAY");
|
|
|
+ Ymd ymd = toYmd(dateTime, "DAY");
|
|
|
ymd.setOrgId(orgId);
|
|
|
ymd.setEnable(true);
|
|
|
- SysWorkTime workTime =workTimeService.findWorkTimeByYmd(ymd).getData();
|
|
|
+ SysWorkTime workTime = workTimeService.findWorkTimeByYmd(ymd).getData();
|
|
|
if (workTime != null) {
|
|
|
List<String[]> workTimes = new ArrayList<>();
|
|
|
if (appPlan.getNotResumptionOnRest() != null && appPlan.getNotResumptionOnRest() == 1 &&
|
|
|
@@ -203,7 +204,8 @@ public class ResumptionTaskBusiness {
|
|
|
//获取履职计划
|
|
|
List<AppPlan> AppPlanList = appPlanService.list((new QueryWrapper<AppPlan>()).lambda()
|
|
|
.eq(AppPlan::getPlanStatus, 1)
|
|
|
- .eq(AppPlan::getPlanCycle, plancycle));
|
|
|
+ .eq(AppPlan::getPlanCycle, plancycle)
|
|
|
+ .in(AppPlan::getPlanOfOrgId, getHangsheOrgIds()));
|
|
|
// .eq(AppPlan::getPlanType, 1)
|
|
|
// .notIn(AppPlan::getPlanExec, canteenPlanExec));
|
|
|
for (AppPlan appPlan : AppPlanList) {
|
|
|
@@ -277,10 +279,10 @@ public class ResumptionTaskBusiness {
|
|
|
// workTime.setOpenTime("00:00");
|
|
|
// workTime.setCloseTime("23:59");
|
|
|
// } else {
|
|
|
- Ymd ymd=toYmd(dateTime,"DAY");
|
|
|
- ymd.setOrgId(orgId);
|
|
|
- ymd.setEnable(true);
|
|
|
- workTime = this.workTimeService.findWorkTimeByYmd(ymd).getData();
|
|
|
+ Ymd ymd = toYmd(dateTime, "DAY");
|
|
|
+ ymd.setOrgId(orgId);
|
|
|
+ ymd.setEnable(true);
|
|
|
+ workTime = this.workTimeService.findWorkTimeByYmd(ymd).getData();
|
|
|
// }
|
|
|
|
|
|
DateTime planstartTime = null;
|
|
|
@@ -347,7 +349,8 @@ public class ResumptionTaskBusiness {
|
|
|
public void syncWeek(DateTime dateTime, int plancycle) {//plancycle==1
|
|
|
List<AppPlan> AppPlanList = appPlanService.list((new QueryWrapper<AppPlan>()).lambda()
|
|
|
.eq(AppPlan::getPlanStatus, 1)
|
|
|
- .eq(AppPlan::getPlanCycle, plancycle));
|
|
|
+ .eq(AppPlan::getPlanCycle, plancycle)
|
|
|
+ .in(AppPlan::getPlanOfOrgId, getHangsheOrgIds()));
|
|
|
// .eq(AppPlan::getPlanType, 0)
|
|
|
// .notIn(AppPlan::getPlanExec, canteenPlanExec));
|
|
|
KeyValue<Integer, Integer> yearWeek = new KeyValue<>(DateUtil.year(dateTime), DateUtil.weekOfYear(dateTime));
|
|
|
@@ -394,7 +397,7 @@ public class ResumptionTaskBusiness {
|
|
|
jobDto.setOrgId(orgId);
|
|
|
List<NFCBindPageVo> nfcList = nfcBindService.all(jobDto,NFCBindPageVo::to);*/
|
|
|
// 判断这周是否有作息
|
|
|
- boolean isExist = workTimeService.existByYmd( Ymd.builder().year(yearWeek.getKey()).week(yearWeek.getValue()).orgId(orgId).isEnable(true).build()).getData();
|
|
|
+ boolean isExist = workTimeService.existByYmd(Ymd.builder().year(yearWeek.getKey()).week(yearWeek.getValue()).orgId(orgId).isEnable(true).build()).getData();
|
|
|
// final boolean isExist = false;
|
|
|
// 应该用周的第一天, 不然页面查是查询不到的
|
|
|
//dateTime即为本周第一天
|
|
|
@@ -419,7 +422,8 @@ public class ResumptionTaskBusiness {
|
|
|
public void syncMonth(DateTime dateTime, int plancycle) {//plancycle==2
|
|
|
List<AppPlan> AppPlanList = appPlanService.list((new QueryWrapper<AppPlan>()).lambda()
|
|
|
.eq(AppPlan::getPlanStatus, 1)
|
|
|
- .eq(AppPlan::getPlanCycle, plancycle));
|
|
|
+ .eq(AppPlan::getPlanCycle, plancycle)
|
|
|
+ .in(AppPlan::getPlanOfOrgId, getHangsheOrgIds()));
|
|
|
// .eq(AppPlan::getPlanType, 0)
|
|
|
// .notIn(AppPlan::getPlanExec, canteenPlanExec));
|
|
|
KeyValue<Integer, Integer> yearMonth = new KeyValue<>(DateUtil.year(dateTime), DateUtil.month(dateTime) + 1);
|
|
|
@@ -468,7 +472,7 @@ public class ResumptionTaskBusiness {
|
|
|
List<NFCBindPageVo> nfcList = nfcBindService.all(jobDto,NFCBindPageVo::to);*/
|
|
|
// 判断这月是否有作息
|
|
|
// final boolean isExist = this.workTimeService.existByYmd(orgId, Ymd.builder().year(yearMonth.getKey()).month(yearMonth.getValue()).build(), true);
|
|
|
- final boolean isExist = workTimeService.existByYmd( Ymd.builder().year(yearMonth.getKey()).week(yearMonth.getValue()).orgId(orgId).isEnable(true).build()).getData();
|
|
|
+ final boolean isExist = workTimeService.existByYmd(Ymd.builder().year(yearMonth.getKey()).week(yearMonth.getValue()).orgId(orgId).isEnable(true).build()).getData();
|
|
|
|
|
|
// 应该用月的第一天, 不然页面查是查询不到的
|
|
|
//dateTime即为本月第一天
|
|
|
@@ -491,7 +495,8 @@ public class ResumptionTaskBusiness {
|
|
|
public void syncQuarter(DateTime dateTime, int plancycle) {//plancycle==3
|
|
|
List<AppPlan> AppPlanList = appPlanService.list((new QueryWrapper<AppPlan>()).lambda()
|
|
|
.eq(AppPlan::getPlanStatus, 1)
|
|
|
- .eq(AppPlan::getPlanCycle, plancycle));
|
|
|
+ .eq(AppPlan::getPlanCycle, plancycle)
|
|
|
+ .in(AppPlan::getPlanOfOrgId, getHangsheOrgIds()));
|
|
|
// .eq(AppPlan::getPlanType, 0)
|
|
|
// .notIn(AppPlan::getPlanExec, canteenPlanExec));
|
|
|
KeyValue<Integer, Integer> yearQuarter = new KeyValue<>(DateUtil.year(dateTime), DateUtil.quarter(dateTime));
|
|
|
@@ -560,7 +565,8 @@ public class ResumptionTaskBusiness {
|
|
|
public void syncHalfYear(DateTime dateTime, int plancycle) {//plancycle==4
|
|
|
List<AppPlan> AppPlanList = appPlanService.list((new QueryWrapper<AppPlan>()).lambda()
|
|
|
.eq(AppPlan::getPlanStatus, 1)
|
|
|
- .eq(AppPlan::getPlanCycle, plancycle));
|
|
|
+ .eq(AppPlan::getPlanCycle, plancycle)
|
|
|
+ .in(AppPlan::getPlanOfOrgId, getHangsheOrgIds()));
|
|
|
// .eq(AppPlan::getPlanType, 0)
|
|
|
// .notIn(AppPlan::getPlanExec, canteenPlanExec));
|
|
|
DateHelper dateHelper = new DateHelper(dateTime);
|
|
|
@@ -624,7 +630,8 @@ public class ResumptionTaskBusiness {
|
|
|
public void syncYear(DateTime dateTime, int plancycle) {//plancycle==5
|
|
|
List<AppPlan> AppPlanList = appPlanService.list((new QueryWrapper<AppPlan>()).lambda()
|
|
|
.eq(AppPlan::getPlanStatus, 1)
|
|
|
- .eq(AppPlan::getPlanCycle, plancycle));
|
|
|
+ .eq(AppPlan::getPlanCycle, plancycle)
|
|
|
+ .in(AppPlan::getPlanOfOrgId, getHangsheOrgIds()));
|
|
|
// .eq(AppPlan::getPlanType, 0)
|
|
|
// .notIn(AppPlan::getPlanExec, canteenPlanExec));
|
|
|
DateTime time1 = new DateTime(dateTime);
|
|
|
@@ -734,13 +741,21 @@ public class ResumptionTaskBusiness {
|
|
|
*/
|
|
|
private List<Long> getPlanOrgIds(AppPlan appPlan) {
|
|
|
List<Long> orgIds = null;
|
|
|
- if (appPlan.getExecType()!=null&&appPlan.getExecType() == 0) {//0机构类型需要安类型去机构里查询所以的机构
|
|
|
- orgIds = orgService.findListByOrgType(appPlan.getExecOrgType(),SecurityConstants.INNER).getData();
|
|
|
- } else {
|
|
|
- List<SysOrg> sysOrgs = orgService.selectByOrgType(appPlan.getExecOrgType(), SecurityConstants.INNER);
|
|
|
- orgIds = sysOrgs.stream().map(SysOrg::getId).collect(Collectors.toList());
|
|
|
-// orgIds = appPlanService.findExecOrgByPlan(appPlan.getId());
|
|
|
+// if (appPlan.getExecType()!=null&&appPlan.getExecType() == 0) {//0机构类型需要安类型去机构里查询所以的机构
|
|
|
+ OrgListByTypesConditionEto cond = new OrgListByTypesConditionEto();
|
|
|
+ cond.setOrgId(appPlan.getPlanOfOrgId());
|
|
|
+ cond.setOrgTypes(Arrays.asList(appPlan.getExecOrgType().toString()));
|
|
|
+ R<List<SysOrg>> r = orgService.listByTypes(cond);
|
|
|
+ if (ObjectUtil.isNull(r) || ObjectUtil.isEmpty(r.getData())) {
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
+ orgIds = r.getData().stream().map(i -> i.getId()).collect(Collectors.toList());
|
|
|
+// }
|
|
|
+// else {
|
|
|
+// List<SysOrg> sysOrgs = orgService.selectByOrgType(appPlan.getExecOrgType(), SecurityConstants.INNER);
|
|
|
+// orgIds = sysOrgs.stream().map(SysOrg::getId).collect(Collectors.toList());
|
|
|
+//// orgIds = appPlanService.findExecOrgByPlan(appPlan.getId());
|
|
|
+// }
|
|
|
|
|
|
return orgIds;
|
|
|
}
|
|
|
@@ -748,15 +763,22 @@ public class ResumptionTaskBusiness {
|
|
|
private List<SysOrg> getPlanOrgs(AppPlan appPlan) {
|
|
|
List<Long> orgIds = null;
|
|
|
if (appPlan.getExecType() == 0) {//0机构类型需要安类型去机构里查询所以的机构
|
|
|
- orgIds = orgService.findListByOrgType(appPlan.getExecOrgType(),SecurityConstants.INNER).getData();
|
|
|
+ orgIds = orgService.findListByOrgType(appPlan.getExecOrgType(), SecurityConstants.INNER).getData();
|
|
|
} else {
|
|
|
orgIds = appPlanService.findExecOrgByPlan(appPlan.getId());
|
|
|
}
|
|
|
|
|
|
- return orgService.listByIds(orgIds,SecurityConstants.INNER).getData();
|
|
|
+ return orgService.listByIds(orgIds, SecurityConstants.INNER).getData();
|
|
|
}
|
|
|
|
|
|
+ private List<Long> getHangsheOrgIds() {
|
|
|
+ R<List<Long>> allHangshe = orgService.findListByOrgType(3, SecurityConstants.INNER);
|
|
|
+ if (ObjectUtil.isNull(allHangshe) || ObjectUtil.isEmpty(allHangshe.getData())) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
|
|
|
+ return allHangshe.getData();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 根据作息变更生成新的每日每小时履职任务
|
|
|
@@ -1270,7 +1292,7 @@ public class ResumptionTaskBusiness {
|
|
|
//更加计划id获取启用状态的计划
|
|
|
List<AppPlan> appPlans = getAppPlanByPlanIds(planIds);
|
|
|
//获取有作息的机构id
|
|
|
- List<Long> workOrgIds = this.workTimeService.findOrgIdsByYmd(datetime.toString().substring(0, 10),SecurityConstants.INNER).getData();
|
|
|
+ List<Long> workOrgIds = this.workTimeService.findOrgIdsByYmd(datetime.toString().substring(0, 10), SecurityConstants.INNER).getData();
|
|
|
for (AppPlan plan : appPlans) {
|
|
|
//获取每个计划要生成任务的机构
|
|
|
List<Long> orgIdsByPlanListNew = getOrgIdsByPlanIds(plan, orgIds, workOrgIds);
|
|
|
@@ -1315,7 +1337,7 @@ public class ResumptionTaskBusiness {
|
|
|
|
|
|
private void saveResumptionByDay(List<Long> orgIdsByPlanListNew, AppPlan appPlan, List<Long> roleIds, DateTime dateTime) {
|
|
|
for (Long orgId : orgIdsByPlanListNew) {
|
|
|
- Ymd ymd=toYmd(dateTime,"DAY");
|
|
|
+ Ymd ymd = toYmd(dateTime, "DAY");
|
|
|
ymd.setOrgId(orgId);
|
|
|
ymd.setEnable(true);
|
|
|
final SysWorkTime workTime = this.workTimeService.findWorkTimeByYmd(ymd).getData();
|
|
|
@@ -1436,7 +1458,7 @@ public class ResumptionTaskBusiness {
|
|
|
|
|
|
private void saveResumptionByHour(List<Long> orgIdsByPlanListNew, AppPlan appPlan, List<Long> roleIds, DateTime dateTime) {
|
|
|
for (final Long orgId : orgIdsByPlanListNew) {
|
|
|
- Ymd ymd=toYmd(dateTime,"DAY");
|
|
|
+ Ymd ymd = toYmd(dateTime, "DAY");
|
|
|
ymd.setOrgId(orgId);
|
|
|
ymd.setEnable(true);
|
|
|
final SysWorkTime workTime = this.workTimeService.findWorkTimeByYmd(ymd).getData();
|