|
@@ -1,5 +1,6 @@
|
|
|
package com.persagy.calendar.handle;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -9,16 +10,21 @@ import java.util.Set;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.persagy.calendar.pojo.dto.WorkCalendar;
|
|
|
import com.persagy.calendar.pojo.dto.WorkCalendarDate;
|
|
|
+import com.persagy.calendar.pojo.dto.WorkCalendarDict;
|
|
|
import com.persagy.calendar.pojo.dto.WorkCalendarLabel;
|
|
|
import com.persagy.calendar.pojo.dto.WorkCalendarRule;
|
|
|
import com.persagy.calendar.service.IWorkCalendarDateService;
|
|
|
+import com.persagy.calendar.service.IWorkCalendarDictService;
|
|
|
import com.persagy.calendar.service.IWorkCalendarLabelService;
|
|
|
import com.persagy.calendar.service.IWorkCalendarRuleService;
|
|
|
+import com.persagy.calendar.service.RwdObjectService;
|
|
|
+import com.persagy.common.utils.IdGenerator;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
@@ -33,6 +39,9 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
public class CommonHandler {
|
|
|
|
|
|
@Autowired
|
|
|
+ private RwdObjectService rwdObjectService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private IWorkCalendarLabelService workCalendarLabelService;
|
|
|
|
|
|
@Autowired
|
|
@@ -41,6 +50,71 @@ public class CommonHandler {
|
|
|
@Autowired
|
|
|
private IWorkCalendarDateService workCalendarDateService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IWorkCalendarDictService workCalendarDictService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化项目ID的字典数据
|
|
|
+ *
|
|
|
+ * @param groupCode
|
|
|
+ * @param dictTypes
|
|
|
+ * @return 不为null,返回错误信息
|
|
|
+ */
|
|
|
+ public String initProjectDict(String groupCode, Set<String> dictTypes) {
|
|
|
+ try {
|
|
|
+ // 1.获取运维系统中的项目数据
|
|
|
+ Set<String> allProjects = this.rwdObjectService.queryAllProjects(groupCode);
|
|
|
+ if (CollectionUtil.isEmpty(allProjects)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ // 2.更新工作历这边的字典表信息
|
|
|
+ List<WorkCalendarDict> calendarDicts = new ArrayList<WorkCalendarDict>();
|
|
|
+ for (String projectId : allProjects) {
|
|
|
+ // 删除这个项目下的已有信息
|
|
|
+ LambdaQueryWrapper<WorkCalendarDict> queryWrapper = new WorkCalendarDict.BuilderQueryWrapper()
|
|
|
+ .projectIdEq(projectId, null).dictTypeIn(dictTypes).builder();
|
|
|
+ this.workCalendarDictService.remove(queryWrapper);
|
|
|
+
|
|
|
+ // 每个项目添加六条
|
|
|
+ calendarDicts.add(this.getWorkCalendarDict(groupCode, projectId, "ACSeason", "ACSeason-1", "供冷"));
|
|
|
+ calendarDicts.add(this.getWorkCalendarDict(groupCode, projectId, "ACSeason", "ACSeason-2", "供暖"));
|
|
|
+ calendarDicts.add(this.getWorkCalendarDict(groupCode, projectId, "ACSeason", "ACSeason-3", "过渡"));
|
|
|
+ calendarDicts.add(this.getWorkCalendarDict(groupCode, projectId, "shop", "2", "开店时间"));
|
|
|
+ calendarDicts.add(this.getWorkCalendarDict(groupCode, projectId, "shop", "3", "商业闭店时间"));
|
|
|
+ calendarDicts.add(this.getWorkCalendarDict(groupCode, projectId, "shop", "4", "娱乐闭店时间"));
|
|
|
+ }
|
|
|
+
|
|
|
+ this.workCalendarDictService.batchCreateCalendarDict(calendarDicts);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return e.getMessage();
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param groupCode
|
|
|
+ * @param projectId
|
|
|
+ * @param dictType
|
|
|
+ * @param dictCode
|
|
|
+ * @param dictDesc
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private WorkCalendarDict getWorkCalendarDict(String groupCode, String projectId, String dictType, String dictCode, String dictDesc) {
|
|
|
+ WorkCalendarDict calendarDict = new WorkCalendarDict();
|
|
|
+ calendarDict.setId(IdGenerator.getUUID());
|
|
|
+ calendarDict.setCalendarId("0");
|
|
|
+ calendarDict.setProjectId(projectId);
|
|
|
+ calendarDict.setGroupCode(groupCode);
|
|
|
+ calendarDict.setDictType(dictType);
|
|
|
+ calendarDict.setDictCode(dictCode);
|
|
|
+ calendarDict.setDictDesc(dictDesc);
|
|
|
+ return calendarDict;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 数据转换
|
|
|
*
|