|
|
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
import com.xunmei.common.core.domain.worktime.domain.SysWorkTime;
|
|
|
+import com.xunmei.common.core.enums.CycleCommonEnum;
|
|
|
import com.xunmei.common.core.utils.DateHelper;
|
|
|
import com.xunmei.common.core.utils.IDHelper;
|
|
|
import com.xunmei.core.TaskCreatingServiceImplBase;
|
|
|
@@ -42,7 +43,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
-public class SafetyCheckJobBusiness extends TaskCreatingServiceImplBase<CoreSafetyTaskMapper,CoreSafetyTask> {
|
|
|
+public class SafetyCheckJobBusiness extends TaskCreatingServiceImplBase<CoreSafetyTaskMapper, CoreSafetyTask> {
|
|
|
@Resource
|
|
|
CoreSafecheckPlanMapper planMapper;
|
|
|
@Resource
|
|
|
@@ -94,6 +95,7 @@ public class SafetyCheckJobBusiness extends TaskCreatingServiceImplBase<CoreSafe
|
|
|
|
|
|
/**
|
|
|
* 检查指定机构有无作息
|
|
|
+ *
|
|
|
* @param workstartTime
|
|
|
* @param workendTime
|
|
|
* @param orgId
|
|
|
@@ -150,23 +152,24 @@ public class SafetyCheckJobBusiness extends TaskCreatingServiceImplBase<CoreSafe
|
|
|
|
|
|
/**
|
|
|
* 指定计划生成任务
|
|
|
+ *
|
|
|
* @param plans
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Async
|
|
|
public void createTaskByPlans(List<CoreSafecheckPlan> plans) throws Exception {
|
|
|
- if(plans!=null&&plans.size()>0){
|
|
|
+ if (plans != null && plans.size() > 0) {
|
|
|
int cycle = Math.toIntExact(plans.get(0).getPlanCycle());
|
|
|
DateTime datetime = new DateTime();
|
|
|
datetime.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
DateHelper dateHelper = new DateHelper(datetime);
|
|
|
- Map<String, Date> map=null;
|
|
|
+ Map<String, Date> map = null;
|
|
|
//如果无周期
|
|
|
- if(cycle==6){
|
|
|
+ if (cycle == 6) {
|
|
|
map = DateHelper.getStartAndEnd(dateHelper, null);
|
|
|
map.put("start", plans.get(0).getStartDate());
|
|
|
map.put("end", plans.get(0).getEndDate());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
map = DateHelper.getStartAndEnd(dateHelper, cycle);
|
|
|
}
|
|
|
List<PlanTaskBuildVo> tasks = new ArrayList<>();
|
|
|
@@ -631,7 +634,26 @@ public class SafetyCheckJobBusiness extends TaskCreatingServiceImplBase<CoreSafe
|
|
|
|
|
|
@Override
|
|
|
public void rebuildWeeklyTask(List<Long> orgIds, Date startDate, Date endDate) {
|
|
|
+ Map<Long, Boolean> workingMap = orgWorkTimeStatusMap(startDate, CycleCommonEnum.WEEKLY, orgIds);
|
|
|
+// List<Long> deleteTaskIds = new ArrayList<>();
|
|
|
+
|
|
|
+ List<SysOrg> orgs = remoteOrgService.selectByOrgIdList(orgIds, SecurityConstants.INNER);
|
|
|
+ for (SysOrg org : orgs) {
|
|
|
+ if (ObjectUtil.isNull(org.getType())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
+ Long orgId = org.getId();
|
|
|
+ if (!workingMap.containsKey(orgId) || !workingMap.get(orgId)) {
|
|
|
+ //当前作息周期已经歇业,删除未进行的任务
|
|
|
+ checkTaskService.deleteByOrgIdAndRange(orgId, startDate, endDate);
|
|
|
+ continue;
|
|
|
+ }else{
|
|
|
+ //开始营业,重新生成任务
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|