Commit ef4f0eca by 丁伟峰

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

2 parents 2ff72eac 4723bf4a
......@@ -44,6 +44,10 @@ public class Result<T> {
return new Result<>(ResultEnum.COMMON_FAILED.getCode(), message, null);
}
public static <T> Result<T> failure(String message) {
return new Result<>(ResultEnum.COMMON_FAILED.getCode(), message, null);
}
public static Result<?> failed(IResult errorResult) {
return new Result<>(errorResult.getCode(), errorResult.getMessage(), null);
}
......
......@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.pojo.OrganizationDTO;
/**
* 组织结构相关接口
......@@ -24,7 +25,7 @@ public interface IOrganization {
* @return
*/
@RequestMapping(value = "/pea-order/organization/list", method = RequestMethod.GET)
public Result<?> getAllOrganizations(@RequestParam("levelType") String levelType,
public Result<List<OrganizationDTO>> getAllOrganizations(@RequestParam("levelType") String levelType,
@RequestParam("organizationIds") List<String> organizationIds);
}
......@@ -11,6 +11,7 @@ import com.dituhui.pea.common.Result;
import com.dituhui.pea.enums.ThirdPartyEnum;
import com.dituhui.pea.pojo.ThirdUserInfo;
import com.dituhui.pea.pojo.UserInfo;
import com.dituhui.pea.pojo.UserLoginDTO;
import com.dituhui.pea.pojo.UserLoginParam;
import com.dituhui.pea.pojo.WebResult;
......@@ -22,10 +23,10 @@ import com.dituhui.pea.pojo.WebResult;
public interface IUser {
@RequestMapping(value = "/pea-user/login", method = RequestMethod.POST)
public Result<?> userLogin(@RequestBody UserLoginParam user);
public Result<UserLoginDTO> userLogin(@RequestBody UserLoginParam user);
@RequestMapping(value = "/pea-user/userInfo", method = RequestMethod.GET)
public Result<?> getUserInfo(@RequestHeader(name="userId", required = true) String userId);
public Result<UserLoginDTO> getUserInfo(@RequestHeader(name="userId", required = true) String userId);
/**
* 获取当前登陆用户信息
......
......@@ -47,14 +47,16 @@ public class OrderAssignCheck {
private int distanceAddition;
private LocalDateTime start;
private LocalDateTime end;
private int index;
public Result(boolean canAssign, String message, int minuteAddition, int distanceAddition, LocalDateTime start, LocalDateTime end){
public Result(boolean canAssign, String message, int minuteAddition, int distanceAddition, LocalDateTime start, LocalDateTime end, int index){
this.canAssign = canAssign;
this.message = message;
this.minuteAddition = minuteAddition;
this.distanceAddition = distanceAddition;
this.start = start;
this.end = end;
this.index = index;
}
}
......@@ -83,7 +85,7 @@ public class OrderAssignCheck {
int index = SegmentInsertion.insertSegment(takeTime, start, end, segments);
if (index == -1) {
log.info("没有可连续插入的空间");
return new Result(false, "没有连续可插入空间(没计算时间)", 0, 0, null, null);
return new Result(false, "没有连续可插入空间(没计算时间)", 0, 0, null, null, index);
}
log.info("插入位置为第{}单, 已分配单数(不包含本单):{}", index, orderSegments.size());
......@@ -105,7 +107,7 @@ public class OrderAssignCheck {
LocalDateTime startDateTime = this.point2LocalDateTime(startInsert, order.getDt());
LocalDateTime endDateTime = this.point2LocalDateTime(endInsert, order.getDt());
return new Result(true, "success", 0, 0, startDateTime, endDateTime);
return new Result(true, "success", 0, 0, startDateTime, endDateTime, index);
}
else if(index == 0 && !orderSegments.isEmpty()) {
// 第一订单为出发地, 且有其他订单
......@@ -115,7 +117,7 @@ public class OrderAssignCheck {
OrderSegment post = orderSegments.get(0);
OrderSegment pre = new OrderSegment(480, 480, preX, preY);
return this.getResult(curX, curY, pre, post, takeTime, order.getDt());
return this.getResult(curX, curY, pre, post, takeTime, order.getDt(), index);
}
else if(index == orderSegments.size()) {
// 最后一个订单出发
......@@ -128,12 +130,12 @@ public class OrderAssignCheck {
LocalDateTime startDateTime = this.point2LocalDateTime(startInsert, order.getDt());
LocalDateTime endDateTime = this.point2LocalDateTime(endInsert, order.getDt());
return new Result(true, "success", 0, 0, startDateTime, endDateTime);
return new Result(true, "success", 0, 0, startDateTime, endDateTime, index);
} else {
OrderSegment pre = orderSegments.get(index-1);
OrderSegment post = orderSegments.get(index);
return this.getResult(curX, curY, pre, post, takeTime, order.getDt());
return this.getResult(curX, curY, pre, post, takeTime, order.getDt(), index);
}
}
......@@ -181,7 +183,7 @@ public class OrderAssignCheck {
return segments;
}
private Result getResult(double curX, double curY, OrderSegment pre, OrderSegment post, int takeTime, LocalDate dt) {
private Result getResult(double curX, double curY, OrderSegment pre, OrderSegment post, int takeTime, LocalDate dt, int index) {
Pair preCurPair = this.getDistanceAndDuration(pre.getX(), pre.getY(), curX, curY);
Pair postCurPair = this.getDistanceAndDuration(post.getX(), post.getY(), curX, curY);
Pair prePostPair = this.getDistanceAndDuration(post.getX(), post.getY(), pre.getX(), pre.getY());
......@@ -190,7 +192,7 @@ public class OrderAssignCheck {
int distance = post.getStart() - postCurPair.getDuration() - (pre.getEnd() + preCurPair.getDuration());
if(distance < takeTime) {
// 不支持插入
return new Result(false, "增加时间路程后,不支持插入", 0, 0, null, null);
return new Result(false, "增加时间路程后,不支持插入", 0, 0, null, null, index);
}
// 插入点(时间点)
int startInsert = pre.getEnd() + preCurPair.getDuration();
......@@ -200,7 +202,7 @@ public class OrderAssignCheck {
int minuteAddition = preCurPair.getDuration() + postCurPair.getDuration() - prePostPair.getDuration();
int distanceAddition = preCurPair.getDistance() + postCurPair.getDistance() - prePostPair.getDistance();
return new Result(true, "success", minuteAddition, distanceAddition, startDateTime, endDateTime);
return new Result(true, "success", minuteAddition, distanceAddition, startDateTime, endDateTime, index);
}
private double[] getEngineerDepartureLocation(String engineerCode){
......
......@@ -24,20 +24,20 @@ public class PublicOrganizationController implements IOrganization {
private OrganizationService organizationService;
@Override
public Result<?> getAllOrganizations(String levelType, List<String> organizationIds) {
public Result<List<OrganizationDTO>> getAllOrganizations(String levelType, List<String> organizationIds) {
if (StringUtils.isEmpty(levelType)) {
return Result.failed("缺少参数levelType");
return Result.failure("缺少参数levelType");
}
if (CollectionUtils.isEmpty(organizationIds)) {
return Result.failed("缺少参数organizationIds");
return Result.failure("缺少参数organizationIds");
}
Result<?> res = null;
Result<List<OrganizationDTO>> res = null;
try {
List<OrganizationDTO> orgs = organizationService.getAllOrganizations(levelType, organizationIds);
res = Result.success(orgs);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
return Result.failure(e.getMessage());
}
return res;
}
......
......@@ -23,4 +23,8 @@ public interface EngineerInfoMPDao extends BaseMapper<EngineerInfo> {
@Select("select * from engineer_info where group_id = #{groupId}")
List<EngineerInfo> selectByGroupId(String groupId);
@Select("<script> select * from engineer_info where group_id in " +
"<foreach item='groupId' collection='groupIds' open='(' separator=',' close=')'>#{groupId}</foreach></script>")
List<EngineerInfo> selectByGroupIds(@Param("groupIds") List<String> groupIds);
}
\ No newline at end of file
......@@ -12,4 +12,7 @@ import java.util.List;
public interface EngineerSkillGroupMPDao extends BaseMapper<EngineerSkillGroup> {
@Select("select * from engineer_skill_group where engineer_code = #{engineerCode}")
List<EngineerSkillGroup> selectByEngineerCode(String engineerCode);
@Select("select * from engineer_skill_group where skill_group_code = #{skillGroupCode}")
List<EngineerSkillGroup> selectBySkillGroupCode(String skillGroupCode);
}
......@@ -13,6 +13,7 @@ import com.dituhui.pea.enums.ThirdPartyEnum;
import com.dituhui.pea.pojo.ThirdUserInfo;
import com.dituhui.pea.pojo.UserAuthInfo;
import com.dituhui.pea.pojo.UserInfo;
import com.dituhui.pea.pojo.UserLoginDTO;
import com.dituhui.pea.pojo.UserLoginParam;
import com.dituhui.pea.pojo.WebResult;
import com.dituhui.pea.user.IUser;
......@@ -32,12 +33,12 @@ public class UserController implements IUser {
private UserService userService;
@Override
public Result<?> userLogin(UserLoginParam user) {
public Result<UserLoginDTO> userLogin(UserLoginParam user) {
return userService.userLogin(user.getAccount(), user.getPassword());
}
@Override
public Result<?> getUserInfo(String userId) {
public Result<UserLoginDTO> getUserInfo(String userId) {
return userService.getUserInfo(userId);
}
......
......@@ -93,12 +93,11 @@ public class UserService {
@Autowired
IOrganization organizationService;
public Result<?> userLogin(String account, String password) {
public Result<UserLoginDTO> userLogin(String account, String password) {
UserEntity user = userDao.findByAccountAndPassword(account, SecureUtil.md5(password));
log.info("{}/{} login", account, password);
if (null != user) {
UserLoginDTO userDTO = convertToUserLoginDTO(user);
// 生成token
String token = IdUtil.simpleUUID();
userDTO.setToken(token);
......@@ -106,7 +105,7 @@ public class UserService {
redisService.set(RedisKeyGroup.authToken + ":" + token, gson.toJson(userDTO), timestamp / 1000);
return Result.success(userDTO);
} else {
return Result.failed("鉴权失败");
return Result.failure("鉴权失败");
}
}
......@@ -151,24 +150,16 @@ public class UserService {
List<OrganizationDTO> allOrgs = resources.stream().filter(r -> r.getType() == 3).map(r -> {
List<OrganizationDTO> orgs = Lists.newArrayList();
String[] temp = r.getExtra().split("\\|");
Result<?> result = organizationService.getAllOrganizations(temp[0],
Result<List<OrganizationDTO>> result = organizationService.getAllOrganizations(temp[0],
Arrays.asList(temp[1].split(",")));
if (StringUtils.equals(ResultEnum.SUCCESS.getCode(), result.getCode())) {
orgs = (List<OrganizationDTO>) result.getResult();
orgs = result.getResult();
}
return orgs;
}).flatMap(a -> a.stream()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(allOrgs)) {
log.info("allOrgs2: {}", allOrgs.size());
try {
allOrgs.stream().forEach(o -> o.setIsActive(true));
log.info("allOrgs3: {}", allOrgs.get(0));
log.info("allOrgs4: {}", allOrgs.get(0).getIsActive());
// 设置第一个为当前权限等级
allOrgs.get(0).setIsActive(true);
} catch (Throwable e) {
e.printStackTrace();
log.error("allOrgs4: {} {}", e.getMessage(), e);
}
}
userDTO.setAuths(allOrgs);
}
......@@ -184,7 +175,7 @@ public class UserService {
resourceInfo.setExtra(null);
}
public Result<?> getUserInfo(String userId) {
public Result<UserLoginDTO> getUserInfo(String userId) {
UserEntity user = userDao.getById(userId);
UserLoginDTO userDTO = convertToUserLoginDTO(user);
return Result.success(userDTO);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!