Commit 3420618f authored by xixinzhao's avatar xixinzhao

计划生成任务

parent b7bedffb
...@@ -243,10 +243,16 @@ public class Plan extends BasicEntity { ...@@ -243,10 +243,16 @@ public class Plan extends BasicEntity {
//单位code //单位code
@Column(name = "biz_org_code") @Column(name = "biz_org_code")
private String bizOrgCode; private String bizOrgCode;
//单位名称 //单位名称
@Column(name = "biz_org_name") @Column(name = "biz_org_name")
private String bizOrgName; private String bizOrgName;
/**
* 用户组id
*/
@Column(name = "user_group_id")
private String userGroupId;
public String getBizOrgCode() { public String getBizOrgCode() {
return bizOrgCode; return bizOrgCode;
...@@ -614,4 +620,12 @@ public class Plan extends BasicEntity { ...@@ -614,4 +620,12 @@ public class Plan extends BasicEntity {
public void setIsSingleExecution(boolean isSingleExecution) { public void setIsSingleExecution(boolean isSingleExecution) {
this.isSingleExecution = 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; ...@@ -12,13 +12,13 @@ import java.util.List;
@Repository("iRoutePointDao") @Repository("iRoutePointDao")
public interface IRoutePointDao extends BaseDao<RoutePoint, Long> { 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); 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); 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); int maxRoutePointOrderNo(Long routeId);
@Modifying @Modifying
...@@ -32,7 +32,7 @@ public interface IRoutePointDao extends BaseDao<RoutePoint, Long> { ...@@ -32,7 +32,7 @@ public interface IRoutePointDao extends BaseDao<RoutePoint, Long> {
@Query(value = "delete from p_route_point WHERE point_id = ?1", nativeQuery = true) @Query(value = "delete from p_route_point WHERE point_id = ?1", nativeQuery = true)
void delRoutePointByPointId(Long pointId); 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); List<Long> queryRoutePointIds(Long routeId);
@Modifying @Modifying
...@@ -59,7 +59,7 @@ public interface IRoutePointDao extends BaseDao<RoutePoint, Long> { ...@@ -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) @Query(value = "SELECT id FROM p_route_point WHERE point_id IN (?1)", nativeQuery = true)
List<BigInteger> queryRoutePointByPointId(List<Long> pointIds); 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); List<String> getRoutePointIds(String routeId);
int deleteByRouteIdAndPointIdInAndIdNotIn(Long targetRouteId, List<Long> targetPointIds, List<Long> ids); 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; package com.yeejoin.amos.patrol.business.util;
import com.yeejoin.amos.patrol.business.constants.XJConstant; 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.business.vo.CalDateVo;
import com.yeejoin.amos.patrol.core.util.DateUtil; import com.yeejoin.amos.patrol.core.util.DateUtil;
import com.yeejoin.amos.patrol.core.util.StringUtil; import com.yeejoin.amos.patrol.core.util.StringUtil;
import com.yeejoin.amos.patrol.dao.entity.Plan; import com.yeejoin.amos.patrol.dao.entity.Plan;
import com.yeejoin.amos.patrol.dao.entity.Route;
import com.yeejoin.amos.patrol.exception.YeeException; import com.yeejoin.amos.patrol.exception.YeeException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
public class PlanTaskUtil { public class PlanTaskUtil {
private static final Logger log = LoggerFactory.getLogger(PlanTaskUtil.class); private static final Logger log = LoggerFactory.getLogger(PlanTaskUtil.class);
...@@ -503,63 +507,60 @@ private static List<HashMap<String, Object>> genTimeByRate(Plan plan,List<HashMa ...@@ -503,63 +507,60 @@ private static List<HashMap<String, Object>> genTimeByRate(Plan plan,List<HashMa
* @param plan * @param plan
* @return * @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 ){ if(timeList == null || timeList.size()<=0 ){
return null; return null;
} }
String users = plan.getUserId(); List<HashMap<String, Object>> wholeList = new ArrayList<>();
String userAndDepts = plan.getUserDept(); // String deviceType = route.getDeviceType();
List<HashMap<String, Object>> wholeList = new ArrayList<HashMap<String, Object>>(); // String unitType = route.getUnitType();
if(StringUtil.isNotEmpty(users)){ String deviceType = "3000";
String[] userArr = users.split(","); String unitType = "1232";
String[] userAndDeptArr = userAndDepts.split(",");
//IUserService userService = (IUserService) IotContext.getInstance().getBean("userService"); if (!CollectionUtils.isEmpty(userDetailsDtoList)) {
for(int i =0;i<timeList.size();i++){ Map<String, List<UserDetailsDto>> userDetailsDtoMap = userDetailsDtoList.stream().
HashMap<String, Object> tempMap = new HashMap<String, Object>(); filter(obj -> obj.getEquipCategoryCode().contains(deviceType) && obj.getUnitTypeCode().contains(unitType))
Object strBeginTime = timeList.get(i).get("BEGIN_TIME"); .collect(Collectors.groupingBy(UserDetailsDto::getUnitCode));
Object strEndTime = timeList.get(i).get("END_TIME"); for (HashMap<String, Object> stringObjectHashMap : timeList) {
Object nextGenDate = timeList.get(i).get("NEXT_GEN_DATE"); 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("BEGIN_TIME", strBeginTime);
tempMap.put("END_TIME", strEndTime); tempMap.put("END_TIME", strEndTime);
tempMap.put("NEXT_GEN_DATE", nextGenDate); 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(); } else {
temp.put("USER_ID", users);
temp.put("USER_DEPT", userAndDepts);
wholeList.add(temp);
}
}
}else{
wholeList = timeList; wholeList = timeList;
} }
return wholeList; 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