Commit 3420618f authored by xixinzhao's avatar xixinzhao

计划生成任务

parent b7bedffb
......@@ -243,10 +243,16 @@ public class Plan extends BasicEntity {
//单位code
@Column(name = "biz_org_code")
private String bizOrgCode;
//单位名称
@Column(name = "biz_org_name")
private String bizOrgName;
/**
* 用户组id
*/
@Column(name = "user_group_id")
private String userGroupId;
public String getBizOrgCode() {
return bizOrgCode;
......@@ -614,4 +620,12 @@ public class Plan extends BasicEntity {
public void setIsSingleExecution(boolean isSingleExecution) {
this.isSingleExecution = isSingleExecution;
}
public String getUserGroupId() {
return userGroupId;
}
public void setUserGroupId(String userGroupId) {
this.userGroupId = userGroupId;
}
}
\ No newline at end of file
......@@ -12,13 +12,13 @@ import java.util.List;
@Repository("iRoutePointDao")
public interface IRoutePointDao extends BaseDao<RoutePoint, Long> {
@Query(value = "SELECT COUNT( point_id ) FROM `p_route_point` where route_id = ?1", nativeQuery = true)
@Query(value = "SELECT COUNT( point_id ) FROM p_route_point where route_id = ?1", nativeQuery = true)
int countRoutePoint(Long routeId);
@Query(value = "SELECT * FROM `p_route_point` where point_id = ?1", nativeQuery = true)
@Query(value = "SELECT * FROM p_route_point where point_id = ?1", nativeQuery = true)
List<RoutePoint> queryByPointId(Long pointId);
@Query(value = "SELECT IfNULL(max(order_no),0) FROM `p_route_point` where route_id = ?1", nativeQuery = true)
@Query(value = "SELECT IfNULL(max(order_no),0) FROM p_route_point where route_id = ?1", nativeQuery = true)
int maxRoutePointOrderNo(Long routeId);
@Modifying
......@@ -32,7 +32,7 @@ public interface IRoutePointDao extends BaseDao<RoutePoint, Long> {
@Query(value = "delete from p_route_point WHERE point_id = ?1", nativeQuery = true)
void delRoutePointByPointId(Long pointId);
@Query(value = "SELECT DISTINCT point_id FROM `p_route_point` where route_id = ?1", nativeQuery = true)
@Query(value = "SELECT DISTINCT point_id FROM p_route_point where route_id = ?1", nativeQuery = true)
List<Long> queryRoutePointIds(Long routeId);
@Modifying
......@@ -59,7 +59,7 @@ public interface IRoutePointDao extends BaseDao<RoutePoint, Long> {
@Query(value = "SELECT id FROM p_route_point WHERE point_id IN (?1)", nativeQuery = true)
List<BigInteger> queryRoutePointByPointId(List<Long> pointIds);
@Query(value = "SELECT DISTINCT point_id FROM `p_route_point` where route_id = ?1", nativeQuery = true)
@Query(value = "SELECT DISTINCT point_id FROM p_route_point where route_id = ?1", nativeQuery = true)
List<String> getRoutePointIds(String routeId);
int deleteByRouteIdAndPointIdInAndIdNotIn(Long targetRouteId, List<Long> targetPointIds, List<Long> ids);
......
package com.yeejoin.amos.patrol.business.dto;
import lombok.Data;
/**
* @author DELL
*/
@Data
public class UserDetailsDto {
/**
* 企业id
*/
private String unitId;
/**
* 企业类型
*/
private String unitType;
/**
* 企业类型Code
*/
private String unitTypeCode;
/**
* 企业名称
*/
private String unitName;
/**
* 企业名称
*/
private String unitCode;
/**
* 用户id
*/
private String userId;
/**
* 用户名称
*/
private String userName;
/**
* 设备类型
*/
private String equipCategory;
/**
* 设备类型code
*/
private String equipCategoryCode;
/**
* 执行对象id
*/
private String groupId;
/**
* 执行对象
*/
private String groupName;
}
package com.yeejoin.amos.patrol.business.feign;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.patrol.business.dto.UserDetailsDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
/**
* @author DELL
*/
@FeignClient(name = "${tzs.feign.name}", path = "tcm", configuration = {FeignConfiguration.class})
public interface TzsFeign {
/**
* 根据用户组id获取用户
* @param groupId 用户组id
* @return
*/
@RequestMapping(value = "/userInfo/getGroupAndPersonInfo", method = RequestMethod.GET ,consumes="application/json")
ResponseModel<List<UserDetailsDto>> getGroupAndPersonInfo(@RequestParam(value = "groupId", required = false) Long groupId);
}
package com.yeejoin.amos.patrol.business.util;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dto.UserDetailsDto;
import com.yeejoin.amos.patrol.business.vo.CalDateVo;
import com.yeejoin.amos.patrol.core.util.DateUtil;
import com.yeejoin.amos.patrol.core.util.StringUtil;
import com.yeejoin.amos.patrol.dao.entity.Plan;
import com.yeejoin.amos.patrol.dao.entity.Route;
import com.yeejoin.amos.patrol.exception.YeeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
public class PlanTaskUtil {
private static final Logger log = LoggerFactory.getLogger(PlanTaskUtil.class);
......@@ -503,63 +507,60 @@ private static List<HashMap<String, Object>> genTimeByRate(Plan plan,List<HashMa
* @param plan
* @return
*/
public static List<HashMap<String, Object>> genWholeExeData(List<HashMap<String, Object>> timeList, Plan plan) {
public static List<HashMap<String, Object>> genWholeExeData(List<HashMap<String, Object>> timeList, Plan plan, List<UserDetailsDto> userDetailsDtoList, Route route) {
if(timeList == null || timeList.size()<=0 ){
return null;
}
String users = plan.getUserId();
String userAndDepts = plan.getUserDept();
List<HashMap<String, Object>> wholeList = new ArrayList<HashMap<String, Object>>();
if(StringUtil.isNotEmpty(users)){
String[] userArr = users.split(",");
String[] userAndDeptArr = userAndDepts.split(",");
//IUserService userService = (IUserService) IotContext.getInstance().getBean("userService");
for(int i =0;i<timeList.size();i++){
HashMap<String, Object> tempMap = new HashMap<String, Object>();
Object strBeginTime = timeList.get(i).get("BEGIN_TIME");
Object strEndTime = timeList.get(i).get("END_TIME");
Object nextGenDate = timeList.get(i).get("NEXT_GEN_DATE");
List<HashMap<String, Object>> wholeList = new ArrayList<>();
// String deviceType = route.getDeviceType();
// String unitType = route.getUnitType();
String deviceType = "3000";
String unitType = "1232";
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));
for (HashMap<String, Object> stringObjectHashMap : timeList) {
HashMap<String, Object> tempMap = new HashMap<>();
Object strBeginTime = stringObjectHashMap.get("BEGIN_TIME");
Object strEndTime = stringObjectHashMap.get("END_TIME");
Object nextGenDate = stringObjectHashMap.get("NEXT_GEN_DATE");
tempMap.put("BEGIN_TIME", strBeginTime);
tempMap.put("END_TIME", strEndTime);
tempMap.put("NEXT_GEN_DATE", nextGenDate);
if(plan.getIsSingleExecution()){
// for(String userId : userArr){
// if (!ObjectUtils.isEmpty(userId) /*&& userService.existUser(userId)*/) {
// HashMap<String, Object> temp = null;
// temp = (HashMap<String, Object>) tempMap.clone();
// temp.put("USER_ID", userId);
// wholeList.add(temp);
// }
// }
for(String userAndDept : userAndDeptArr){
if (!ObjectUtils.isEmpty(userAndDept)) {
HashMap<String, Object> temp = null;
temp = (HashMap<String, Object>) tempMap.clone();
String userAndDeptTemp[] = userAndDept.split("@");
if(userAndDeptTemp.length >= 1){
temp.put("USER_ID", userAndDeptTemp[0]);
temp.put("USER_DEPT", userAndDept);
}else{
temp.put("USER_ID", "");
temp.put("DEPT_ID", "");
}
wholeList.add(temp);
}
List<HashMap<String, Object>> finalWholeList = wholeList;
userDetailsDtoMap.forEach((unitCode, 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(","));
temp.put("USER_ID", userIds);
temp.put("USER_NAME", userNames);
temp.put("ORG_CODE", unitCode);
temp.put("USER_DEPT", userDept);
finalWholeList.add(temp);
} else {
userDetailsDto.forEach(dto -> {
HashMap<String, Object> temp;
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);
finalWholeList.add(temp);
});
}
}else{
HashMap<String, Object> temp = null;
temp = (HashMap<String, Object>) tempMap.clone();
temp.put("USER_ID", users);
temp.put("USER_DEPT", userAndDepts);
wholeList.add(temp);
}
}
}else{
});
}
} else {
wholeList = timeList;
}
return wholeList;
}
......
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