Commit 9dcf0504 authored by 李秀明's avatar 李秀明

fix(巡检): 任务下发增加superviseOrgCode、superviseOrgName字段

parent f9939d7d
......@@ -168,7 +168,7 @@ public class PlanController extends AbstractBaseController {
List<UserDetailsDto> resultList = response.getResult();
for (UserDetailsDto udd : resultList) {
userIdSB.append(",").append(udd.getUserId());
userDeptSB.append(",").append(udd.getUserId()).append("@").append(udd.getUnitCode());
userDeptSB.append(",").append(udd.getUserId()).append("@").append(udd.getSuperviseOrgCode()).append("@").append(udd.getSuperviseOrgName());
userNameSB.append(",").append(udd.getUserName());
}
}
......
......@@ -25,10 +25,18 @@ public class UserDetailsDto {
*/
private String unitName;
/**
* 企业名称
* 企业Code
*/
private String unitCode;
/**
* 组织名称
*/
private String superviseOrgName;
/**
* 组织Code
*/
private String superviseOrgCode;
/**
* 用户id
*/
private String userId;
......
......@@ -29,9 +29,9 @@ public class PlanTaskUtil {
*/
public static CalDateVo reGenPlanTaskData(Plan plan,String strBginDate,String strEndDate){
CalDateVo vo = CalDateData(strBginDate,strEndDate,plan);
return vo;
return vo;
}
/**
* 重做数据生成
* @param strBginDate 前端上送重做开始日期
......@@ -61,7 +61,7 @@ public class PlanTaskUtil {
log.error(e.getMessage(),e);
throw new YeeException("日期转换失败");
}
//日期区间判断
if(endDate.before(planBegin)){//计划未开始
return null;
......@@ -94,7 +94,7 @@ public class PlanTaskUtil {
}
vo.setIsGenData(flag);
return vo;
}
/**
* 根据计划分类及计划类型校验合法性
......@@ -144,7 +144,7 @@ public static Boolean checkMustFile(Plan plan) {
flag = false;
}
}else if(XJConstant.PLAN_TYPE_YEAR.equals(planType)){
if(exeInt <= 0 || exeRate <=0){
flag = false;
}
......@@ -156,33 +156,33 @@ public static Boolean checkMustFile(Plan plan) {
}
/**
* 根据频率计算出开始日期及结束日期
* @param strPlanDegin
* @param exeInt
* @param strPlanDegin
* @param exeInt
* @return
*/
public static List<HashMap<String, String>> changeRateToDate(String strPlanDegin, int exeRate) {
List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
String strYear = strPlanDegin.substring(0, 4);
int period = 12/exeRate;//频率的间隔
for(int i=1;i<=exeRate;i++){
for(int i=1;i<=exeRate;i++){
HashMap<String, String> dateMap = new HashMap<String, String>();
int beginMonth = 1+(i-1)*period;//开始月
int endMonth = beginMonth + period-1;
String tempBegin = "0" + beginMonth;
String tempEnd = "0" + endMonth;
String strBeginMonth = tempBegin.substring(tempBegin.length()-2,tempBegin.length());
String strEndMonth= tempEnd.substring(tempEnd.length()-2,tempEnd.length());
String strBeginMonth = tempBegin.substring(tempBegin.length()-2,tempBegin.length());
String strEndMonth= tempEnd.substring(tempEnd.length()-2,tempEnd.length());
dateMap.put("begin_date", DateUtil.getStartMonthDate(strYear + strBeginMonth,"yyyy-MM-dd"));
dateMap.put("end_date", DateUtil.getEndMonthDate(strYear + strEndMonth,"yyyy-MM-dd"));
list.add(dateMap);
list.add(dateMap);
}
return list;
}
/**
* 计算时间间隔循环次数(以开始时间做间隔开始点)
* @param dayBegin 开始日期
* @param dayEnd 结束日期
* @param dayBegin 开始日期
* @param dayEnd 结束日期
* @param duration 时长(单位分钟)
* @param inter 间隔
* @param error 误差(单位分钟)
......@@ -221,7 +221,7 @@ public static List<HashMap<String, Date>> getLast6Time(Date dayBegin, Date dayEn
* @return
*/
public static Date getAddStarDate(Date dayBegin, int duration, int inter, String unit, int i, int error) {
Calendar calendar = Calendar.getInstance();
Calendar calendar = Calendar.getInstance();
calendar.setTime(dayBegin);
for (int j = 0; j < i; j++) {
if (XJConstant.INTERVAL_UNIT_HOUR.equals(unit)) {
......@@ -243,11 +243,11 @@ public static Date getAddStarDate(Date dayBegin, int duration, int inter, String
* @return
*/
public static Date getAddEndDateStr(Date dayDegin, int duration, int error) {
Calendar calendar = Calendar.getInstance();
Calendar calendar = Calendar.getInstance();
calendar.setTime(dayDegin);
calendar.add(Calendar.MINUTE,duration);
calendar.add(Calendar.MINUTE, 2*error);
return calendar.getTime();
return calendar.getTime();
}
/**
* 生成执行主表数据(开始日期,结束日期)
......@@ -292,7 +292,7 @@ public static List<HashMap<String, Date>> genExeDate(Plan plan, CalDateVo vo,Str
String[] strArr = (!StringUtil.isNotEmpty(whatDay))?null: whatDay.split(",");//哪一天执行
while(calDate.getTime()<= exeBeginDate.getTime() || calDate.getTime() <= exeEndDate.getTime() ){
HashMap<String, Date> dateMap = new HashMap<String, Date>();
if(XJConstant.PLAN_TYPE_DAY.equals(planType)){//日计划
if(XJConstant.PLAN_TYPE_DAY.equals(planType)){//日计划
if(calDate.getTime() >= exeBeginDate.getTime() && calDate.getTime() <= exeEndDate.getTime()){
dateMap.put("begin_date", calDate);
dateMap.put("end_date", calDate);
......@@ -304,7 +304,7 @@ public static List<HashMap<String, Date>> genExeDate(Plan plan, CalDateVo vo,Str
}else if(XJConstant.PLAN_TYPE_WEEK.equals(planType)){//周计划
for(String str :strArr){
HashMap<String, Date> tempMap = new HashMap<String, Date>();
int inter = Integer.parseInt(str);
int inter = Integer.parseInt(str);
calDate = DateUtil.getIntervalDate(weekDate,inter);
if(calDate.getTime() >= exeDate.getTime() && (calDate.getTime()>=exeBeginDate.getTime() && calDate.getTime() <= exeEndDate.getTime())){
tempMap.put("begin_date", calDate);
......@@ -312,7 +312,7 @@ public static List<HashMap<String, Date>> genExeDate(Plan plan, CalDateVo vo,Str
tempMap.put("next_gen_date", calDate);
dateList.add(tempMap);
}
}
}
init = init + exeInt;
weekDate = DateUtil.getIntervalWeekDate(exeDate,init);
}else if(XJConstant.PLAN_TYPE_MONTH.equals(planType)){//月计划
......@@ -327,14 +327,14 @@ public static List<HashMap<String, Date>> genExeDate(Plan plan, CalDateVo vo,Str
init = init + exeInt;
mounthEndDate = DateUtil.getEndMonthDate(exeDate, init);
}else if(XJConstant.MONTH_TYPE_AT.equals(monthType)){//在第几周第几天
calDate = DateUtil.getIntMonthWeekDate(mounthFirstDate,whatWeek,weekDay) ;
calDate = DateUtil.getIntMonthWeekDate(mounthFirstDate,whatWeek,weekDay) ;
if(calDate.getTime() >= exeDate.getTime() && (calDate.getTime()>=exeBeginDate.getTime() && calDate.getTime() <= exeEndDate.getTime())){
dateMap.put("begin_date", calDate);
dateMap.put("end_date", calDate);
dateMap.put("next_gen_date", calDate);
dateList.add(dateMap);
}
init = init + exeInt;
init = init + exeInt;
mounthFirstDate = DateUtil.getIntervalDate(DateUtil.getEndMonthDate(exeDate, init), 1);
}
} else {
......@@ -345,7 +345,7 @@ public static List<HashMap<String, Date>> genExeDate(Plan plan, CalDateVo vo,Str
List<HashMap<String, String>> yearList = new ArrayList<HashMap<String, String>>();
while(calDate.getTime()<= exeBeginDate.getTime() || calDate.getTime() <= exeEndDate.getTime() ){
HashMap<String, Date> dateMap = new HashMap<String, Date>();
if(XJConstant.PLAN_TYPE_DAY.equals(planType)){//日计划
if(XJConstant.PLAN_TYPE_DAY.equals(planType)){//日计划
if(calDate.getTime() >= exeBeginDate.getTime() && calDate.getTime() <= exeEndDate.getTime()){
dateMap.put("begin_date", calDate);
dateMap.put("end_date",calDate);
......@@ -362,23 +362,23 @@ public static List<HashMap<String, Date>> genExeDate(Plan plan, CalDateVo vo,Str
dateMap.put("end_date", DateUtil.getIntervalDate(weekDate, endNum));
dateMap.put("next_gen_date", DateUtil.getIntervalDate(calDate, exeInt * 7 - 1));
dateList.add(dateMap);
}
}
init = init + exeInt;
weekDate = DateUtil.getIntervalWeekDate(exeDate,init);
}else if(XJConstant.PLAN_TYPE_MONTH.equals(planType)){//月计划
weekDate = DateUtil.getIntervalWeekDate(exeDate,init);
}else if(XJConstant.PLAN_TYPE_MONTH.equals(planType)){//月计划
calDate = DateUtil.getIntervalDate(mounthEndDate,1);
if((calDate.getTime() <= exeBeginDate.getTime() && exeBeginDate.getTime() <= DateUtil.getEndMonthDate(calDate,1).getTime())
|| (calDate.getTime() >= exeBeginDate.getTime() && calDate.getTime() <= exeEndDate.getTime())){
if((calDate.getTime() <= exeBeginDate.getTime() && exeBeginDate.getTime() <= DateUtil.getEndMonthDate(calDate,1).getTime())
|| (calDate.getTime() >= exeBeginDate.getTime() && calDate.getTime() <= exeEndDate.getTime())){
dateMap.put("begin_date", calDate);
dateMap.put("end_date",DateUtil.getEndMonthDate(calDate,1));
dateMap.put("next_gen_date",DateUtil.getEndMonthDate(calDate,1));
dateList.add(dateMap);
}
}
init = init + 1;
mounthEndDate = DateUtil.getEndMonthDate(exeDate,init);
mounthEndDate = DateUtil.getEndMonthDate(exeDate,init);
}else if(XJConstant.PLAN_TYPE_YEAR.equals(planType)){//年计划
yearList.clear();
yearList = PlanTaskUtil.changeRateToDate(strPlanDegin,exeRate);
yearList = PlanTaskUtil.changeRateToDate(strPlanDegin,exeRate);
for(int i=0;i<yearList.size();i++){
HashMap<String, Date> tempMap = new HashMap<String, Date>();
String beginDate = yearList.get(i).get("begin_date");
......@@ -392,7 +392,7 @@ public static List<HashMap<String, Date>> genExeDate(Plan plan, CalDateVo vo,Str
} catch (ParseException e) {
throw new YeeException("日期格式化失败");
}
if((calDate.getTime() <= exeBeginDate.getTime() && exeBeginDate.getTime() <= dateYear.getTime())
if((calDate.getTime() <= exeBeginDate.getTime() && exeBeginDate.getTime() <= dateYear.getTime())
|| (calDate.getTime() >= exeBeginDate.getTime() && calDate.getTime() <= exeEndDate.getTime())){
tempMap.put("begin_date", calDate);
tempMap.put("end_date",dateYear);
......@@ -400,8 +400,8 @@ public static List<HashMap<String, Date>> genExeDate(Plan plan, CalDateVo vo,Str
dateList.add(tempMap);
}else if(calDate.getTime() > exeEndDate.getTime()){
break;
}
}
}
}
init = init + exeInt;
strPlanDegin = DateUtil.getIntervalYearDate(exeDate,init);
} else {
......@@ -428,7 +428,7 @@ public static List<HashMap<String, Object>> genWholeExeDate(List<HashMap<String,
String planType = plan.getPlanType();//计划类型:日,周,月,年
Date dayBegin = plan.getDayBegin();//开始时间
Date dayEnd = plan.getDayEnd();//结束时间
List<HashMap<String, Object>> timeList = new ArrayList<HashMap<String, Object>>();
List<HashMap<String, Object>> timeList = new ArrayList<HashMap<String, Object>>();
if(XJConstant.FIX_DATE_YES.equals(isFixDate)){
timeList = genTimeByRate(plan,list);
}else if (XJConstant.FIX_DATE_NO.equals(isFixDate))
......@@ -448,7 +448,7 @@ public static List<HashMap<String, Object>> genWholeExeDate(List<HashMap<String,
timeList.add(tempMap);
}
}
return timeList;
}
/**
......@@ -466,24 +466,24 @@ private static List<HashMap<String, Object>> genTimeByRate(Plan plan,List<HashMa
Date dayBegin = plan.getDayBegin();//开始时间(每天执行频率为多次时使用)
Date dayEnd = plan.getDayEnd();//结束时间(每天执行频率为多次时使用)
int error = plan.getError();//允许误差
List<HashMap<String, Object>> timeList = new ArrayList<HashMap<String, Object>>();
List<HashMap<String, Object>> timeList = new ArrayList<HashMap<String, Object>>();
if(dayRate == XJConstant.DAY_RATE_ONE){
for(int i= 0;i<list.size();i++){
HashMap<String, Object> tempMap = new HashMap<String, Object>();
Date beginDate = list.get(i).get("begin_date");
Date next_gen_date = list.get(i).get("next_gen_date");
String strBeginTime = DateUtil.formatDatrToStr(beginDate,"yyyy-MM-dd") +" "+ dayTime;
String strEndTime = DateUtil.getIntMinStrDate(strBeginTime,duration,"yyyy-MM-dd HH:mm:ss");
String strEndTime = DateUtil.getIntMinStrDate(strBeginTime,duration,"yyyy-MM-dd HH:mm:ss");
tempMap.put("BEGIN_TIME", strBeginTime);
tempMap.put("END_TIME", strEndTime);
tempMap.put("NEXT_GEN_DATE", DateUtil.formatDatrToStr(next_gen_date,"yyyy-MM-dd"));
timeList.add(tempMap);
}
}else if(dayRate == XJConstant.DAY_RATE_MANY){
}else if(dayRate == XJConstant.DAY_RATE_MANY){
List<HashMap<String, Date>> last6Timelist = PlanTaskUtil.getLast6Time(dayBegin,dayEnd,duration,inter,error,unit);//循环次数
if(last6Timelist != null && last6Timelist.size() > 0){
for(int i= 0;i<list.size();i++){
for(int i= 0;i<list.size();i++){
Date beginDate = list.get(i).get("begin_date");
Date next_gen_date = list.get(i).get("next_gen_date");
for(HashMap<String, Date> map :last6Timelist){
......@@ -496,7 +496,7 @@ private static List<HashMap<String, Object>> genTimeByRate(Plan plan,List<HashMa
timeList.add(tempMap);
}
}
}
}
return timeList;
......@@ -520,7 +520,7 @@ public static List<HashMap<String, Object>> genWholeExeData(List<HashMap<String,
if (!CollectionUtils.isEmpty(userDetailsDtoList)) {
Map<String, List<UserDetailsDto>> userDetailsDtoMap = userDetailsDtoList.stream().
filter(obj -> obj.getEquipCategoryCode().contains(deviceType) && obj.getUnitTypeCode().contains(unitType))
.collect(Collectors.groupingBy(UserDetailsDto::getUnitCode));
.collect(Collectors.groupingBy(UserDetailsDto::getSuperviseOrgCode));
for (HashMap<String, Object> stringObjectHashMap : timeList) {
HashMap<String, Object> tempMap = new HashMap<>();
Object strBeginTime = stringObjectHashMap.get("BEGIN_TIME");
......@@ -531,19 +531,18 @@ public static List<HashMap<String, Object>> genWholeExeData(List<HashMap<String,
tempMap.put("NEXT_GEN_DATE", nextGenDate);
List<HashMap<String, Object>> finalWholeList = wholeList;
userDetailsDtoMap.forEach((unitCode, userDetailsDto) -> {
userDetailsDtoMap.forEach((superviseOrgCode, userDetailsDto) -> {
if (!plan.getIsSingleExecution()) {
HashMap<String, Object> temp;
temp = (HashMap<String, Object>) tempMap.clone();
String userIds = userDetailsDto.stream().map(UserDetailsDto::getUserId).filter(Objects::nonNull).collect(Collectors.joining(","));
String userNames = userDetailsDto.stream().map(UserDetailsDto::getUserName).filter(Objects::nonNull).collect(Collectors.joining(","));
String userDept = userDetailsDto.stream().map(a->{
return a.getUserId() + "@" + unitCode;
}).collect(Collectors.joining(","));
String userDept = userDetailsDto.stream().map(dto-> dto.getUserId() + "@" + superviseOrgCode + "@" + dto.getSuperviseOrgName()).collect(Collectors.joining(","));
String orgCodes = userDetailsDto.stream().map(UserDetailsDto::getSuperviseOrgCode).filter(Objects::nonNull).collect(Collectors.joining(","));
temp.put("USER_ID", userIds);
temp.put("USER_NAME", userNames);
temp.put("ORG_CODE", unitCode);
temp.put("ORG_CODE", orgCodes);
temp.put("USER_DEPT", userDept);
finalWholeList.add(temp);
} else {
......@@ -552,7 +551,7 @@ public static List<HashMap<String, Object>> genWholeExeData(List<HashMap<String,
temp = (HashMap<String, Object>) tempMap.clone();
temp.put("USER_ID", dto.getUserId());
temp.put("USER_NAME", dto.getUserName());
temp.put("ORG_CODE", dto.getUserId() + "@" + unitCode);
temp.put("ORG_CODE", dto.getUserId() + "@" + superviseOrgCode + "@" + dto.getSuperviseOrgName());
finalWholeList.add(temp);
});
}
......@@ -572,7 +571,7 @@ public static List<HashMap<String, Object>> genWholeExeData(List<HashMap<String,
* @return
*/
public static Date getYearCalDate(String strPlanDegin, int exeRate,SimpleDateFormat df) {
List<HashMap<String, String>> yearList = PlanTaskUtil.changeRateToDate(strPlanDegin,exeRate);
List<HashMap<String, String>> yearList = PlanTaskUtil.changeRateToDate(strPlanDegin,exeRate);
Date calDate = null ;
for(int i=0;i<yearList.size();i++){
String beginDateStr = yearList.get(i).get("begin_date");
......@@ -586,7 +585,7 @@ public static Date getYearCalDate(String strPlanDegin, int exeRate,SimpleDateFor
planBegin = df.parse(beginDateStr);
} catch (ParseException e) {
throw new YeeException("日期格式化失败");
}
}
if(planBegin.getTime() >= beginDate.getTime() && planBegin.getTime() <= endDate.getTime()){
calDate = planBegin;
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment