Commit 925d1fb3 by 丁伟峰

Merge remote-tracking branch 'origin/develop' into develop

2 parents 0770a1aa 18e85cdb
...@@ -108,7 +108,7 @@ public class BatchServiceImpl implements BatchService { ...@@ -108,7 +108,7 @@ public class BatchServiceImpl implements BatchService {
" from order_request a left join skill_info b on (a.brand=b.brand and a.type=b.type and a.skill=b.skill )\n" + " from order_request a left join skill_info b on (a.brand=b.brand and a.type=b.type and a.skill=b.skill )\n" +
" where a.org_group_id=? and a.status='OPEN' " + " where a.org_group_id=? and a.status='OPEN' " +
" and a.dt = ? " + " and a.dt = ? " +
" and a.appointment_status ='NOT_ASSIGNED' and appointment_method like 'AUTO%' \n" + " and a.appointment_status ='NOT_ASSIGNED' and a.appointment_method like 'AUTO%' \n" +
" order by a.expect_time_begin asc "; " order by a.expect_time_begin asc ";
int orderCount = jdbcTemplate.update(sqlOrder, batchNo, groupId, batchDay); int orderCount = jdbcTemplate.update(sqlOrder, batchNo, groupId, batchDay);
...@@ -121,7 +121,7 @@ public class BatchServiceImpl implements BatchService { ...@@ -121,7 +121,7 @@ public class BatchServiceImpl implements BatchService {
" left join order_appointment o on (a.order_id =o.order_id)\n" + " left join order_appointment o on (a.order_id =o.order_id)\n" +
" where a.org_group_id=? and a.status='OPEN' \n" + " where a.org_group_id=? and a.status='OPEN' \n" +
" and a.dt = ? " + " and a.dt = ? " +
" and a.appointment_status = 'ASSIGNED' and appointment_method like 'AUTO%' \n" + " and a.appointment_status = 'ASSIGNED' and o.appointment_method like 'AUTO%' \n" +
" and o.pre_status in ('PRE') \n" + " and o.pre_status in ('PRE') \n" +
" order by a.expect_time_begin asc "; " order by a.expect_time_begin asc ";
int orderCountPre = jdbcTemplate.update(sqlOrderPre, batchNo, groupId, batchDay); int orderCountPre = jdbcTemplate.update(sqlOrderPre, batchNo, groupId, batchDay);
......
...@@ -42,7 +42,7 @@ class SolveServiceTest { ...@@ -42,7 +42,7 @@ class SolveServiceTest {
ExtractService extractService; ExtractService extractService;
String groupId = "gsuzhou"; String groupId = "gsuzhou";
String day = "2023-03-20"; String day = "2023-07-25";
private SolverManager<DispatchSolution, UUID> solverManager; private SolverManager<DispatchSolution, UUID> solverManager;
private SolverFactory<DispatchSolution> solverFactory; private SolverFactory<DispatchSolution> solverFactory;
...@@ -53,7 +53,7 @@ class SolveServiceTest { ...@@ -53,7 +53,7 @@ class SolveServiceTest {
SolverConfig solverConfig = new SolverConfig().withSolutionClass(DispatchSolution.class); SolverConfig solverConfig = new SolverConfig().withSolutionClass(DispatchSolution.class);
solverConfig.withEntityClassList(Arrays.asList(Technician.class, Customer.class));// 这里不能漏掉,否则约束不生效 solverConfig.withEntityClassList(Arrays.asList(Technician.class, Customer.class));// 这里不能漏掉,否则约束不生效
solverConfig.withConstraintProviderClass(DispatchConstraintProvider.class); solverConfig.withConstraintProviderClass(DispatchConstraintProvider.class);
solverConfig.withTerminationSpentLimit(Duration.ofSeconds(10)); solverConfig.withTerminationSpentLimit(Duration.ofSeconds(20));
solverFactory = SolverFactory.create(solverConfig); solverFactory = SolverFactory.create(solverConfig);
solver = solverFactory.buildSolver(); solver = solverFactory.buildSolver();
......
...@@ -12,6 +12,7 @@ import org.springframework.http.server.reactive.ServerHttpRequest; ...@@ -12,6 +12,7 @@ import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebExchange;
import com.dituhui.pea.constants.Globals;
import com.dituhui.pea.enums.RedisKeyGroup; import com.dituhui.pea.enums.RedisKeyGroup;
import com.dituhui.pea.gateway.commom.RedisService; import com.dituhui.pea.gateway.commom.RedisService;
import com.dituhui.pea.pojo.UserLoginDTO; import com.dituhui.pea.pojo.UserLoginDTO;
...@@ -85,7 +86,7 @@ public class AuthFilter implements GlobalFilter, Ordered { ...@@ -85,7 +86,7 @@ public class AuthFilter implements GlobalFilter, Ordered {
// AppDTO appDTO = gson.fromJson(value, AppDTO.class); // AppDTO appDTO = gson.fromJson(value, AppDTO.class);
// String secret = appDTO.getSecret(); // String secret = appDTO.getSecret();
userDTO = new UserLoginDTO(); userDTO = new UserLoginDTO();
userDTO.setId("1"); userDTO.setId(Globals.SUPER_ADMIN_ID);
} }
} }
} }
......
package com.dituhui.pea.constants; package com.dituhui.pea.constants;
/** /**
* 团队相关常量 * 全局常量
* @author zl
*/ */
public interface TeamConstant { public interface Globals {
/** /**
* 团队名称默认后缀 * 超管用户id
*/ */
String TEAM_NAME_SUFFIX = "的团队"; public static final String SUPER_ADMIN_ID = "1";
} }
...@@ -3,13 +3,14 @@ package com.dituhui.pea.order.common; ...@@ -3,13 +3,14 @@ package com.dituhui.pea.order.common;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
public class TimeUtils { public class TimeUtils {
public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
public static final String DATE_NO_GAP_FORMAT = "yyyyMMdd"; public static final String DATE_NO_GAP_FORMAT = "yyyyMMdd";
public static final String DATE_GAP_FORMAT = "yyyy-MM-dd"; public static final String DATE_GAP_FORMAT = "yyyy-MM-dd";
public static final String TIME_HH_MM_FORMAT = "HHmm"; public static final String TIME_HH_MM_FORMAT = "HH:mm";
public static final String IsoTimestamp2DateTime(Timestamp timestamp) { public static final String IsoTimestamp2DateTime(Timestamp timestamp) {
// Timestamp转换为日期时间字符串 // Timestamp转换为日期时间字符串
...@@ -51,6 +52,10 @@ public class TimeUtils { ...@@ -51,6 +52,10 @@ public class TimeUtils {
return localDate.format(DateTimeFormatter.ofPattern(DATE_GAP_FORMAT)); return localDate.format(DateTimeFormatter.ofPattern(DATE_GAP_FORMAT));
} }
public static final LocalTime time2LocalTime(String s) {
return LocalTime.parse(s, DateTimeFormatter.ofPattern(TIME_HH_MM_FORMAT));
}
public static final LocalDate addDays(LocalDate date, long days) { public static final LocalDate addDays(LocalDate date, long days) {
return date.plusDays(days); return date.plusDays(days);
} }
......
...@@ -132,8 +132,8 @@ public class EngineerController { ...@@ -132,8 +132,8 @@ public class EngineerController {
Result<?> res = null; Result<?> res = null;
try { try {
res = engineerService.engineerBusinessUpdate( res = engineerService.engineerBusinessUpdate(
req.getEngineerCode(), req.getMaxNum(), req.getMaxMinute(), req.getEngineerCode(), req.getMaxNum(), req.getDeparture(), req.getPriority(),
req.getDeparture(), req.getPriority()); req.getWorkOn(), req.getWorkOff(), req.getTransportMode());
} catch (BusinessException e) { } catch (BusinessException e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
......
...@@ -17,12 +17,15 @@ public class EngineerBusinessListResp { ...@@ -17,12 +17,15 @@ public class EngineerBusinessListResp {
private String engineerCode; private String engineerCode;
private String engineerName; private String engineerName;
private String groupName; private String groupName;
private String workOn;
private String workOff;
private String kind; private String kind;
private Integer maxNum; private Integer maxNum;
private Integer maxMinute; private Integer maxMinute;
private Integer priority; private Integer priority;
private String address; private String address;
private String location; private String location;
private String transportMode;
private Integer departure; private Integer departure;
} }
} }
...@@ -9,4 +9,7 @@ public class EngineerBusinessUpdateReqDTO { ...@@ -9,4 +9,7 @@ public class EngineerBusinessUpdateReqDTO {
private Integer maxMinute; private Integer maxMinute;
private Integer departure; private Integer departure;
private Integer priority; private Integer priority;
private String workOn;
private String workOff;
private String transportMode;
} }
...@@ -8,12 +8,16 @@ import java.sql.Timestamp; ...@@ -8,12 +8,16 @@ import java.sql.Timestamp;
public class EngineerBusiness { public class EngineerBusiness {
private Integer id; private Integer id;
private String engineerCode; private String engineerCode;
private String workOn;
private String workOff;
private Integer maxNum; private Integer maxNum;
private Integer maxMinute; private Integer maxMinute;
private Integer maxDistance; private Integer maxDistance;
private String address; private String address;
private String x; private String x;
private String y; private String y;
private String vehicle;
private String vehicleNo;
private Integer priority; private Integer priority;
private Integer departure; private Integer departure;
private String memo; private String memo;
......
...@@ -20,5 +20,7 @@ public interface EngineerService { ...@@ -20,5 +20,7 @@ public interface EngineerService {
Result<?> getEngineerBusinessDetail(String engineerCode); Result<?> getEngineerBusinessDetail(String engineerCode);
// 技术员业务属性配置修改 // 技术员业务属性配置修改
Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMinute, Integer departure, Integer priority); Result<?> engineerBusinessUpdate(
String engineerCode, Integer maxNum, Integer departure, Integer priority,
String workOn, String workOff, String transportMode);
} }
...@@ -18,6 +18,9 @@ import org.springframework.stereotype.Service; ...@@ -18,6 +18,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -202,15 +205,22 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -202,15 +205,22 @@ public class EngineerServiceImpl implements EngineerService {
@Transactional @Transactional
@Override @Override
public Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMinute, Integer departure, Integer priority) { public Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer departure, Integer priority,
// 技术员业务属性配置修改 String workOn, String workOff, String transportMode) {
// 计算时间差
int minute = this.getMinuteDiff(TimeUtils.time2LocalTime(workOn), TimeUtils.time2LocalTime(workOff));
// 技术员业务属性配置修改
LambdaUpdateWrapper<EngineerBusiness> wrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<EngineerBusiness> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(EngineerBusiness::getEngineerCode, engineerCode); wrapper.eq(EngineerBusiness::getEngineerCode, engineerCode);
wrapper.set(maxNum >= 0, EngineerBusiness::getMaxNum, maxNum); wrapper.set(EngineerBusiness::getMaxNum, maxNum);
wrapper.set(maxMinute >= 0, EngineerBusiness::getMaxMinute, maxMinute);
wrapper.set(EngineerBusiness::getDeparture, departure); wrapper.set(EngineerBusiness::getDeparture, departure);
wrapper.set(EngineerBusiness::getPriority, priority); wrapper.set(EngineerBusiness::getPriority, priority);
wrapper.set(EngineerBusiness::getWorkOn, workOn);
wrapper.set(EngineerBusiness::getWorkOff, workOff);
wrapper.set(EngineerBusiness::getMaxMinute, minute);
wrapper.set(EngineerBusiness::getVehicle, transportMode);
// 更新字段 // 更新字段
engineerBusinessDao.update(null, wrapper); engineerBusinessDao.update(null, wrapper);
...@@ -398,28 +408,25 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -398,28 +408,25 @@ public class EngineerServiceImpl implements EngineerService {
List<EngineerBusinessListResp.EngineerBusiness> items = new ArrayList<>(); List<EngineerBusinessListResp.EngineerBusiness> items = new ArrayList<>();
for (EngineerInfo e : engineers) { for (EngineerInfo e : engineers) {
EngineerBusinessListResp.EngineerBusiness item = new EngineerBusinessListResp.EngineerBusiness(); EngineerBusinessListResp.EngineerBusiness item = new EngineerBusinessListResp.EngineerBusiness();
EngineerBusiness b = buss.getOrDefault(e.getEngineerCode(), null);
if(b == null){
// 若没有配置,则不返回, 由同步程序初始化
continue;
}
item.setEngineerCode(e.getEngineerCode()); item.setEngineerCode(e.getEngineerCode());
item.setGroupName(groupNames.getOrDefault(e.getGroupId(), "")); item.setGroupName(groupNames.getOrDefault(e.getGroupId(), ""));
item.setEngineerName(e.getName()); item.setEngineerName(e.getName());
item.setKind((e.getKind() == 1) ? "fullJob" : "partJob"); item.setKind((e.getKind() == 1) ? "fullJob" : "partJob");
EngineerBusiness b = buss.getOrDefault(e.getEngineerCode(), null);
if (b == null) {
item.setAddress("");
item.setLocation("");
item.setDeparture(1);
item.setMaxMinute(0);
item.setMaxNum(0);
item.setPriority(1);
} else {
item.setAddress(b.getAddress()); item.setAddress(b.getAddress());
item.setLocation(String.format("%s,%s", b.getX(), b.getY())); item.setLocation(String.format("%s,%s", b.getX(), b.getY()));
item.setWorkOn(b.getWorkOn());
item.setWorkOff(b.getWorkOff());
item.setTransportMode(b.getVehicle());
item.setDeparture(b.getDeparture()); item.setDeparture(b.getDeparture());
item.setMaxMinute(b.getMaxMinute()); item.setMaxMinute(b.getMaxMinute());
item.setMaxNum(b.getMaxNum()); item.setMaxNum(b.getMaxNum());
item.setPriority(b.getPriority()); item.setPriority(b.getPriority());
}
items.add(item); items.add(item);
} }
return items; return items;
...@@ -456,4 +463,20 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -456,4 +463,20 @@ public class EngineerServiceImpl implements EngineerService {
return (age <= 0) ? "" : Integer.toString(age); return (age <= 0) ? "" : Integer.toString(age);
} }
private int getMinuteDiff(LocalTime tBegin, LocalTime tEnd) {
int r = tBegin.compareTo(tEnd);
if (r == 0) {
return 0;
}
LocalDateTime dtBegin = LocalDateTime.of(LocalDateTime.now().toLocalDate(), tBegin);
LocalDateTime dtEnd;
if(r < 0) {
dtEnd = LocalDateTime.of(LocalDateTime.now().toLocalDate(), tEnd);
} else {
dtEnd = LocalDateTime.of(LocalDateTime.now().plusDays(1).toLocalDate(), tEnd);
}
Duration duration = Duration.between(dtBegin, dtEnd);
return (int) duration.toMinutes();
}
} }
...@@ -4,6 +4,7 @@ import java.util.Arrays; ...@@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.persistence.criteria.Path; import javax.persistence.criteria.Path;
...@@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.common.ResultEnum; import com.dituhui.pea.common.ResultEnum;
import com.dituhui.pea.constants.Globals;
import com.dituhui.pea.enums.RedisKeyGroup; import com.dituhui.pea.enums.RedisKeyGroup;
import com.dituhui.pea.enums.StatusCodeEnum; import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.enums.ThirdPartyEnum; import com.dituhui.pea.enums.ThirdPartyEnum;
...@@ -71,10 +73,6 @@ public class UserService { ...@@ -71,10 +73,6 @@ public class UserService {
*/ */
private static final int LIVE_TIME_MILLIS = 7200000; private static final int LIVE_TIME_MILLIS = 7200000;
private static final Gson gson = new Gson(); private static final Gson gson = new Gson();
/**
* 超管id
*/
private static final String SUPER_ADMIN_ID = "1";
@Autowired @Autowired
UserDao userDao; UserDao userDao;
...@@ -132,7 +130,7 @@ public class UserService { ...@@ -132,7 +130,7 @@ public class UserService {
// 获取资源 // 获取资源
List<ResourceEntity> resources = null; List<ResourceEntity> resources = null;
if (ids.contains(SUPER_ADMIN_ID)) { if (ids.contains(Globals.SUPER_ADMIN_ID)) {
// 超管处理,不用配置资源自动拥有所有权限 // 超管处理,不用配置资源自动拥有所有权限
resources = resourceDao.findAll(); resources = resourceDao.findAll();
} else { } else {
...@@ -148,13 +146,16 @@ public class UserService { ...@@ -148,13 +146,16 @@ public class UserService {
if (CollectionUtils.isNotEmpty(resources)) { if (CollectionUtils.isNotEmpty(resources)) {
// 菜单嵌套处理+菜单排序 // 菜单嵌套处理+菜单排序
final Set<String> resourceIds = resources.stream().map(r -> r.getId()).collect(Collectors.toSet());
List<ResourceInfo> levelOne = resources.stream() List<ResourceInfo> levelOne = resources.stream()
.filter(r -> StringUtils.isEmpty(r.getParentId()) && r.getType() == 1) .filter(r -> StringUtils.isEmpty(r.getParentId()) && r.getType() == 1)
.map(r -> BeanUtil.copyProperties(r, ResourceInfo.class)).collect(Collectors.toList()); .map(r -> BeanUtil.copyProperties(r, ResourceInfo.class)).collect(Collectors.toList());
for (ResourceInfo resourceInfo : levelOne) { for (ResourceInfo resourceInfo : levelOne) {
splitMenuExtra(resourceInfo); splitMenuExtra(resourceInfo);
List<ResourceEntity> levelTow = resourceDao.findByParentId(resourceInfo.getId()); List<ResourceEntity> levelTow = resourceDao.findByParentId(resourceInfo.getId());
List<ResourceInfo> levelTowResourceInfo = levelTow.stream().map(r -> { List<ResourceInfo> levelTowResourceInfo = levelTow.stream()
// 过滤未配置二级菜单
.filter(r -> resourceIds.contains(r.getId())).map(r -> {
ResourceInfo res = BeanUtil.copyProperties(r, ResourceInfo.class); ResourceInfo res = BeanUtil.copyProperties(r, ResourceInfo.class);
splitMenuExtra(res); splitMenuExtra(res);
return res; return res;
...@@ -178,7 +179,13 @@ public class UserService { ...@@ -178,7 +179,13 @@ public class UserService {
}).flatMap(a -> a.stream()).collect(Collectors.toList()); }).flatMap(a -> a.stream()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(allOrgs)) { if (CollectionUtils.isNotEmpty(allOrgs)) {
// 设置第一个为当前权限等级 // 设置第一个为当前权限等级
allOrgs.get(0).setIsActive(true); for (int i = 0; i < allOrgs.size(); i++) {
if (i == 0) {
allOrgs.get(i).setIsActive(true);
} else {
allOrgs.get(i).setIsActive(false);
}
}
} }
userDTO.setAuths(allOrgs); userDTO.setAuths(allOrgs);
} }
...@@ -598,7 +605,7 @@ public class UserService { ...@@ -598,7 +605,7 @@ public class UserService {
// List<String> ids = userRoles.stream().map(r -> r.getRoleId()).collect(Collectors.toList()); // List<String> ids = userRoles.stream().map(r -> r.getRoleId()).collect(Collectors.toList());
// List<RoleEntity> roles = roleDao.findAllById(ids); // List<RoleEntity> roles = roleDao.findAllById(ids);
// if (CollectionUtils.isNotEmpty(roles)) { // if (CollectionUtils.isNotEmpty(roles)) {
// role = roles.stream().filter(r -> StringUtils.equals(r.getId(), SUPER_ADMIN_ID)).findFirst() // role = roles.stream().filter(r -> StringUtils.equals(r.getId(), Globals.SUPER_ADMIN_ID)).findFirst()
// .orElse(null); // .orElse(null);
// } // }
// } // }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!