Commit a75f8659 by chamberone

Merge branch 'develop' of https://zhangguoping@gitlab.dituhui.com/bsh/project/pr…

…oject.git into develop
2 parents 0c7e3fcb dcedda19
Showing with 1905 additions and 60 deletions
......@@ -24,5 +24,5 @@ spring:
- Path=/dispatch/**
auth:
path: /pea-user/**,/pea-order/**,/test/**,/v1/**,/gis/** # 需要认证的路边列表,多个用逗号连接
path: /pea-user/**,/pea-role/**,/pea-order/**,/test/**,/v1/**,/gis/** # 需要认证的路边列表,多个用逗号连接
......@@ -129,6 +129,7 @@ services:
container_name: project-order
ports:
- ${ORDER_PORT}:${ORDER_PORT}
- "62001:62001"
depends_on:
- nacos
# - postgres
......@@ -146,6 +147,7 @@ services:
container_name: project-user
ports:
- ${USER_PORT}:${USER_PORT}
- "62000:5005"
depends_on:
- nacos
# - postgres
......
package com.dituhui.pea.common;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* 分页结果返回
*/
public class PageResult<E> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 当前页
*/
public int currPage = 0;
/**
* 总共页数
*/
public int totalPage = 0;
/**
* 总记录数
*/
public long recordCount = 0;
/**
* 数据明细
*/
public List<E> dataList = new ArrayList<E>();
public PageResult() {
}
public PageResult(int currPage, List<E> dataList, long recordCount, int totalPage) {
this.currPage = currPage;
this.dataList = dataList;
this.recordCount = recordCount;
this.totalPage = totalPage;
}
public int getCurrPage() {
return currPage;
}
public void setCurrPage(int currPage) {
this.currPage = currPage;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public long getRecordCount() {
return recordCount;
}
public void setRecordCount(long recordCount) {
this.recordCount = recordCount;
}
public List<E> getDataList() {
return dataList;
}
public void setDataList(List<E> dataList) {
this.dataList = dataList;
}
}
package com.dituhui.pea.pojo;
import lombok.Data;
@Data
public class PageRequest {
private Integer size = 10;
private Integer page = 1;
}
......@@ -29,6 +29,10 @@ public class ResourceInfo {
private String code;
private Integer order;
/**
* 名称
*/
private String parentId;
/**
* 描述
*/
private String description;
......
......@@ -2,8 +2,13 @@ package com.dituhui.pea.pojo;
import javax.validation.constraints.NotBlank;
import com.dituhui.pea.pojo.role.RoleResourceInfo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* 角色信息
*/
......@@ -14,19 +19,35 @@ public class RoleInfo {
* 主键
*/
private String id;
/**
* 名称
*/
@NotBlank(message = "角色名称不能为空!")
private String name;
/**
* 角色组id
*/
private String groupId;
/**
* 角色自定义条件
*/
@NotBlank(message = "角色条件不能为空!")
private String extra;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdTime;
/**
* 到修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updatedTime;
private List<RoleResourceInfo> resourceInfos;
}
......@@ -8,9 +8,11 @@ import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;
/**
* 用户信息
*
* @author zl
*/
@Data
......@@ -82,6 +84,18 @@ public class UserInfo {
*/
private String extra;
/**
* 组织ids
*/
private List<Integer> orgIds;
/**
* 组织级别 0:大区 1:分部 2:站点
*/
private Integer orgLevel;
/**
* 角色id
*/
private List<String> roleIds;
/**
* 创建人
*/
//private String createdBy;
......
package com.dituhui.pea.pojo;
import com.dituhui.pea.validated.Phone;
import lombok.Data;
import javax.validation.constraints.Email;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 用户信息
*
* @author zl
*/
@Data
public class UserInfoSearch extends PageRequest implements Serializable {
/**
* 主键
*/
private String id;
/**
* 账号
*/
private String account;
/**
* 昵称
*/
private String nickname;
/**
* 邮箱
*/
private String email;
/**
* 电话
*/
private String phone;
/**
* 生日
*/
private String birthday;
/**
* 地区
*/
private String region;
/**
* 性别
*/
private Integer sex;
/**
* 头像
*/
private String avatar;
private String wechat;
private String qq;
private String weibo;
/**
* 最后登录时间
*/
//private Date lastLoginTime;
/**
* 用户自定义条件
*/
private String extra;
/**
* 角色id
*/
private String roleId;
/**
* 角色id
*/
private String roleName;
/**
* 用户来源:0:bean 1:新建
*/
private Integer source;
/**
* 模糊查询字段
*/
private String queryString;
/**
* 工程师工号
*/
private String engineerCode;
/**
* 是否禁用 0: 否 1:是 默认0
*/
private Integer ban;
/**
* 组织id
*/
private String orgId;
/**
* 创建人
*/
//private String createdBy;
/**
* 创建时间
*/
// private Date createdTime;
/**
* 更新人
*/
//private String updatedBy;
/**
* 更新时间
*/
// private Date updatedTime;
}
package com.dituhui.pea.pojo.role;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 角色资源表(RoleResourceEntity)实体类
*
*/
@Data
public class RoleResourceInfo implements Serializable {
/**
* 主键
*/
private String id;
/**
* 角色id
*/
private String roleId;
/**
* 资源id
*/
private String resourceId;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}
package com.dituhui.pea.pojo.role;
import java.util.Date;
public class UserRoleInfo {
/**
* 主键
*/
private String id;
/**
* 用户id
*/
private String userId;
/**
* 角色id
*/
private String roleId;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}
package com.dituhui.pea.user;
import com.dituhui.pea.common.PageResult;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.pojo.PageRequest;
import com.dituhui.pea.pojo.ResourceInfo;
import com.dituhui.pea.pojo.RoleInfo;
import com.dituhui.pea.pojo.WebResult;
......@@ -9,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 角色相关接口
*/
......@@ -17,79 +22,125 @@ public interface IRole {
/**
* 添加角色
*
* @param roleInfo 角色信息
* @return
*/
@RequestMapping(value = "/v1/role/add", method = RequestMethod.POST)
@RequestMapping(value = "/pea-user/role/add", method = RequestMethod.POST)
WebResult<RoleInfo> addRole(@RequestBody RoleInfo roleInfo);
/**
* 修改角色
*
* @param roleInfo 角色信息
* @return
*/
@RequestMapping(value = "/pea-user/role/update", method = RequestMethod.POST)
WebResult<RoleInfo> updateRole(@RequestBody RoleInfo roleInfo);
/**
* 删除角色
*
* @param roleId 角色ID
* @return
*/
@RequestMapping(value = "/v1/role/delete", method = RequestMethod.POST)
@RequestMapping(value = "/pea-user/role/delete", method = RequestMethod.POST)
WebResult<Boolean> deleteRole(@RequestParam("id") String roleId);
/**
* 添加用户角色
*
* @param roleId 角色ID
* @param userId 用户ID
* @return
*/
@RequestMapping(value = "/v1/role/addUser", method = RequestMethod.POST)
@RequestMapping(value = "/pea-user/role/addUser", method = RequestMethod.POST)
WebResult<Boolean> addUserRole(@RequestParam("id") String roleId, @RequestParam("userId") String userId);
/**
* 删除用户角色
*
* @param userId 用户ID
* @param roleId 角色ID
* @return
*/
@RequestMapping(value = "/v1/role/deleteUser", method = RequestMethod.POST)
@RequestMapping(value = "/pea-user/role/deleteUser", method = RequestMethod.POST)
WebResult<Boolean> deleteUserRole(@RequestParam("id") String roleId, @RequestParam("userId") String userId);
/**
* 添加资源
*
* @param resourceInfo 资源信息
* @return
*/
@RequestMapping(value = "/v1/resource/add", method = RequestMethod.POST)
@RequestMapping(value = "/pea-user/resource/add", method = RequestMethod.POST)
WebResult<ResourceInfo> addResource(@RequestBody ResourceInfo resourceInfo);
/**
* 删除资源
*
* @param resourceId 资源ID
* @return
*/
@RequestMapping(value = "/v1/resource/delete", method = RequestMethod.POST)
@RequestMapping(value = "/pea-user/resource/delete", method = RequestMethod.POST)
WebResult<Boolean> deleteResource(@RequestParam("id") String resourceId);
/**
* 添加角色资源
* @param roleId 角色ID
*
* @param roleId 角色ID
* @param resourceId 资源ID
* @return
*/
@RequestMapping(value = "/v1/role/addResource", method = RequestMethod.POST)
@RequestMapping(value = "/pea-user/role/addResource", method = RequestMethod.POST)
WebResult<Boolean> addRoleResource(@RequestParam("id") String roleId, @RequestParam("resource_id") String resourceId);
/**
* 批量更新/替换角色权限/资源,会清空原来的权限/资源
* @param roleId 角色Id
*
* @param roleId 角色Id
* @param resourceIds 资源ID集合
* @return
*/
@RequestMapping(value = "/v1/role/replaceResources", method = RequestMethod.POST)
@RequestMapping(value = "/pea-user/role/replaceResources", method = RequestMethod.POST)
WebResult<Boolean> replaceRoleResource(@RequestParam("id") String roleId, @RequestParam("resource_ids") String resourceIds);
/**
* 删除角色资源
* @param roleId 角色ID
*
* @param roleId 角色ID
* @param resourceId 资源ID
* @return
*/
@RequestMapping(value = "/v1/role/deleteResource", method = RequestMethod.POST)
@RequestMapping(value = "/pea-user/role/deleteResource", method = RequestMethod.POST)
WebResult<Boolean> deleteRoleResource(@RequestParam("id") String roleId, @RequestParam("resource_id") String resourceId);
/**
* 获取角色列表
*
* @param pageRequest 分页参数
* @return
*/
@RequestMapping(value = "/pea-user/role/list", method = RequestMethod.GET)
Result<PageResult<RoleInfo>> listRole(PageRequest pageRequest);
/**
* 获取用户角色权限列表
*
* @param roleId 用户id
* @return
*/
@RequestMapping(value = "/pea-user/role/info", method = RequestMethod.GET)
Result<RoleInfo> info(@RequestParam("roleId") String roleId);
/**
* 获取用户角色权限列表
*
* @param userId 用户id
* @return
*/
@RequestMapping(value = "/pea-user/role/allResource", method = RequestMethod.GET)
Result<List<ResourceInfo>> allResource();
}
package com.dituhui.pea.user;
import com.dituhui.pea.common.PageResult;
import com.dituhui.pea.pojo.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
......@@ -9,11 +11,6 @@ import org.springframework.web.bind.annotation.RequestParam;
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;
/**
* 用户相关接口
......@@ -21,19 +18,19 @@ import com.dituhui.pea.pojo.WebResult;
*/
@FeignClient(value = "project-user", contextId = "user")
public interface IUser {
/**
* 登录接口
*
*
* @param user
* @return
*/
@RequestMapping(value = "/pea-user/login", method = RequestMethod.POST)
public Result<UserLoginDTO> userLogin(@RequestBody UserLoginParam user);
/**
* 获取用户信息
*
*
* @param userId
* @return
*/
......@@ -43,7 +40,7 @@ public interface IUser {
/**
* 刷新appkey接口<br>
* 初始化系统ak缓存,例如系统上线,新ak入库的时候
*
*
* @return
*/
@RequestMapping(value = "/pea-user/refreshAppkey", method = RequestMethod.POST)
......@@ -138,4 +135,22 @@ public interface IUser {
@RequestMapping(value = "/pea-user/thirdRegister", method = RequestMethod.POST)
WebResult<UserInfo> thirdRegister(@RequestBody ThirdUserInfo thirdUserInfo);
/**
* 用户列表
* @param search 查询条件
* @return
*/
@RequestMapping(value = "/pea-user/list", method = RequestMethod.GET)
Result<PageResult<UserInfoSearch>> list(UserInfoSearch search);
/**
* 禁用用户
* @param search 查询条件
* @return
*/
@RequestMapping(value = "/pea-user/ban", method = RequestMethod.GET)
Result<Boolean> ban(UserInfoSearch search);
}
......@@ -10,5 +10,6 @@ ADD ./project-order/target/project-order-*.jar /app.jar
RUN sh -c 'touch /app.jar'
EXPOSE 8013
EXPOSE 62001
ENTRYPOINT ["java", "-jar","/app.jar"]
ENTRYPOINT ["java", "-jar","-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=62001","/app.jar"]
......@@ -114,6 +114,12 @@
<artifactId>sentry-spring-boot-starter</artifactId>
<version>6.22.0</version>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-core-impl</artifactId>
<version>9.38.0.Final</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
......@@ -130,6 +136,19 @@
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>com.github.shalousun</groupId>
<artifactId>smart-doc-maven-plugin</artifactId>
<version>2.7.6</version>
<configuration>
<configFile>./src/main/resources/smart-doc.json</configFile>
<projectName>${project.description}</projectName>
<includes>
<!-- 使用了jpa的分页需要include所使用的源码包 -->
<include>org.springframework.data:spring-data-commons</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.dituhui.pea.order.config;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Configuration
public class OrderConfig {
......@@ -12,4 +23,20 @@ public class OrderConfig {
public static final Integer TEAMTYPE_BEAN = 1;
public static final Integer TEAMTYPE_PEA = 2;
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@Bean
public Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DATE_FORMATTER));
javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DATE_FORMATTER));
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DATE_TIME_FORMATTER));
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DATE_TIME_FORMATTER));
builder.modules(javaTimeModule);
return builder;
}
}
......@@ -9,6 +9,8 @@ import com.dituhui.pea.order.service.OrganizationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -42,8 +44,8 @@ public class OrganizationController {
return res;
}
@GetMapping("/organization/engineer/list")
public Result<?> getEngineersByTeams(OrganizationEngineersByTeamsDTO.Request reqDTO) {
@PostMapping("/organization/engineer/list")
public Result<?> getEngineersByTeams(@RequestBody OrganizationEngineersByTeamsDTO.Request reqDTO) {
Result<?> res = null;
try {
res = organizationService.getEngineersByTeams(reqDTO.getTeamIds());
......
package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.PageResult;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.pojo.PageRequest;
import com.dituhui.pea.pojo.RoleInfo;
import com.dituhui.pea.pojo.WebResult;
import com.dituhui.pea.user.IRole;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/pea-role")
public class RoleController {
@Autowired
IRole roleService;
@GetMapping("/list")
public Result<PageResult<RoleInfo>> listRole(PageRequest pageRequest) {
WebResult<PageResult<RoleInfo>> result = roleService.listRole(pageRequest);
return Result.success(result.getResult());
}
}
......@@ -2,6 +2,7 @@ package com.dituhui.pea.order.controller;
import javax.servlet.http.HttpServletRequest;
import com.dituhui.pea.pojo.UserInfoSearch;
import com.dituhui.pea.pojo.UserLoginParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -52,4 +53,10 @@ public class UserController {
return Result.success(result.getResult());
}
@GetMapping("/user/list")
public Result<?> list(UserInfoSearch search) {
return user.list(search);
}
}
package com.dituhui.pea.order.dto;
import com.dituhui.pea.order.dto.param.ValidGroup;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import java.util.List;
@lombok.Data
......@@ -10,7 +12,15 @@ public class OrganizationTreeDTO {
@Data
public static class Request {
/**
* 组织级别,包括:cluster大区; branch分部; group分站/网点
*/
@NotBlank(message = "组织级别不能为空", groups = {ValidGroup.PeaTree.class})
private String levelType;
/**
* 组织编码, 大区、分部、分站的编码;
*/
@NotBlank(message = "组织编码不能为空", groups = {ValidGroup.PeaTree.class})
private String levelValue;
}
......
package com.dituhui.pea.order.dto.param;
import lombok.Getter;
import lombok.Setter;
/**
* 两点间里程和耗时 结果返回参数
*/
@Setter
@Getter
public class BaseDistance {
/**
* 出发点 经度,纬度
*/
private String origin;
/**
* 目的地 经度,纬度
*/
private String destination;
/**
* 交通工具,1汽车;2电动车;3骑车;4步行
*/
private Integer vehicle;
/**
* 路程距离,单位: 米
*/
private Integer distance;
/**
* 耗时 单位: 秒
*/
private Long duration;
}
package com.dituhui.pea.order.dto.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
/**
* 创单可用容量
*/
@Validated
@Setter
@Getter
public class CapacityQueryDTO {
/**
* 查询参数
*/
@Setter
@Getter
public static class Request {
/**
* 服务技能
*/
@Valid
private List<Service> services;
/**
* 地址坐标信息
*/
@Valid
@NotNull
private Location location;
/**
* 查询起始日期
*/
@NotNull
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date beginDate;
/**
* 查询结束日期
*/
@NotNull
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endDate;
}
/**
* 返回值
*/
@Setter
@Getter
public static class Result {
/**
* 符合条件的履约组织网点)Id
*/
private String groupId;
/**
* 原始请求参数
*/
private Request params;
/**
* 需要的服务时长,单位: 分钟
*/
private int takeTime;
/**
* 查询容量返回结果
*/
private List<Data> datas;
}
/**
* 改派到人查询结果
*/
@Setter
@Getter
public static class PersonalResult {
/**
* 查询的工程师工号
*/
private String engineerCode;
/**
* 查询工程师姓名
*/
private String engineerName;
/**
* 查询容量返回结果
*/
private List<Data> datas;
}
/**
* 查询容量返回结果
*/
@Setter
@Getter
public static class Data {
/**
* 日期 yyyy-MM-dd
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date date;
/**
* 容量列表
*/
private List<Segment> segments;
}
/**
* 容量
*/
@Setter
@Getter
public static class Segment {
/**
* 最大可用时长, 单位: 分钟
*/
private int maxDuration;
/**
* 容量名称 全天/上午/下午/晚上等
*/
private String name;
/**
* 起始时间 yyyy-MM-dd HH:mm:ss
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime beginTime;
/**
* 截止时间 yyyy-MM-dd HH:mm:ss
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime;
/**
* 容量状态 0不可约;1可约;
*/
private int status;
/**
* 剩余容量
*/
private int remain;
}
/**
* 服务
*/
@Setter
@Getter
public static class Service {
/**
* 品牌
*/
@NotBlank
private String brand;
/**
* 产品类型
*/
@NotBlank
private String productType;
/**
* 需要的技能
*/
@NotBlank
private String serviceType;
}
}
package com.dituhui.pea.order.dto.param;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/**
* 工程师基础信息
*/
@Setter
@Getter
@EqualsAndHashCode(callSuper = false)
public class EngineerBaseInfo extends EngineerCode {
/**
* 工程师名称
*/
private String engineerName;
}
package com.dituhui.pea.order.dto.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 工程师日历
*/
@Setter
@Getter
@EqualsAndHashCode
public class EngineerCalendar {
/**
* 日期
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date date;
/**
* 事件类型
*/
private String type;
/**
* 开始时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date beginTime;
/**
* 结束时间
*/
private Date endTime;
/**
* 备注
*/
private String memo ;
}
package com.dituhui.pea.order.dto.param;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* 技术员日历返回参数
*/
@Setter
@Getter
@EqualsAndHashCode(callSuper = false)
public class EngineerCalendarResultDTO extends EngineerBaseInfo {
/**
* 日历内容
*/
private List<EngineerCalendar> calendar;
}
package com.dituhui.pea.order.dto.param;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
/**
* 工程师编号
*/
@Setter
@Getter
@EqualsAndHashCode
public class EngineerCode {
/**
* 工程师工号
*/
@NotBlank
protected String engineerCode;
}
package com.dituhui.pea.order.dto.param;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
/**
* 申请加单 参数
*/
@Setter
@Getter
public class EngineerOrderParam {
/**
* 工程师工号
*/
@NotBlank
private String engineerCode;
/**
* 地址坐标信息
*/
private Location location;
/**
* 空闲时长 至少空闲多久以上,单位:分钟
*/
private Integer idleDuration;
}
package com.dituhui.pea.order.dto.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
* 技术员信息
*/
@Setter
@Getter
@Validated
public class EngineerParamDTO {
/**
* Body 请求参数
*/
@Setter
@Getter
@Validated
public static class Request {
/**
* 网点/分站编码
*/
@NotBlank
private String groupId;
/**
* 同步工程师列表
*/
@NotNull
private List<Engineer> egineers;
}
/**
* 技术员信息
*/
@Setter
@Getter
public static class Engineer {
/**
* 工程师工号
*/
private String engineerCode;
/**
* 工程师姓名
*/
private String name;
/**
* 工程师联系电话
*/
private String phone;
private int kind;
/**
* 地址坐标信息
*/
private Location location;
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date birth;
private String gender;
private List<String> skills;
private String grade;
private List<String> credentials;
private int vehicle;
private String status;
private String address;
private String vehicleNo;
private String memo;
}
}
package com.dituhui.pea.order.dto.param;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Setter
@Getter
public class EstimateDTO {
/**
* 技术员上门里程预估请求参数
*/
@Setter
@Getter
public static class VisitRequest {
/**
* 品牌
*/
@NotBlank
private String brand;
/**
* 类型
*/
@NotBlank
private String productType;
/**
* 技能
*/
@NotBlank
private String serviceType;
/**
* 地址坐标信息
*/
@NotNull
private Location location;
}
/**
* 技术员上门里程预估返回结果参数结构
*/
@Setter
@Getter
public static class VisitResult {
/**
* 服务站点ID
*/
private String groupId;
/**
* 服务站点名称
*/
private String groupName;
/**
* 服务站点距离客户路程里程 ,单位: 米
*/
private Integer distance;
/**
* 地址坐标信息
*/
private Location groupLocation;
/**
* 地址坐标信息
*/
private Location destination;
}
}
package com.dituhui.pea.order.dto.param;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotNull;
/**
* 地址坐标信息
*/
@Setter
@Getter
public class Location {
/**
* 地点名称,例如:xx小区
*/
private String name;
/**
* 详细地址, xx路xx号等信息
*/
private String address;
/**
* 地址纬度
*/
@NotNull
private Double latitude;
/**
* 地址经度
*/
@NotNull
private Double longitude;
}
package com.dituhui.pea.order.dto.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 订单返回值
*/
@Setter
@Getter
public class Order {
/**
* 距离,当前位置路程距离,单位: 米
*/
private Integer distance;
/**
* 工单号
*/
private String orderId;
/**
* 客户姓名
*/
private String name;
/**
* 客户电话
*/
private String phone;
/**
* 品牌
*/
private String brand;
/**
* 分类
*/
private String product_type;
/**
* 需要的技能
*/
private String service_type;
/**
* 预计需要服务的时长
*/
private Integer takeTime;
/**
* 故障描述
*/
private String faultDescribe;
/**
* 客户期望上门最早时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date expectTimeBegin;
/**
* 客户期望上门最晚时间
*/
private Date expectTimeEnd;
/**
* 备注信息
*/
private String memo;
/**
* 地址坐标信息
*/
private Location location;
/**
* 其他参考信息
*/
private String applyNote;
}
package com.dituhui.pea.order.dto.param;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
/**
* 加单基础实体
*/
@Setter
@Getter
@EqualsAndHashCode(callSuper = false)
public class OrderConfirmBaseParam extends EngineerCode {
/**
* 工单号
*/
@NotBlank
protected String orderId;
}
package com.dituhui.pea.order.dto.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import java.util.Date;
/**
* 预约加单请求参数
*/
@Setter
@Getter
public class OrderConfirmParam extends OrderConfirmBaseParam{
/**
* 预约沟通结果, confirmed预约成功;other预约失败
*/
@NotBlank
private String appointmentResult;
/**
* 预约上门时间,预约成功时候填写
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date appointmentTime;
}
package com.dituhui.pea.order.dto.param;
import lombok.Getter;
import lombok.Setter;
/**
* 预约加单返回值
*/
@Setter
@Getter
public class OrderConfirmResult extends OrderConfirmBaseParam{
/**
* 预约状态
*/
private String appointmentStatus;
}
package com.dituhui.pea.order.dto.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
* 工单数据传输对象
*/
@Setter
@Getter
public class OrderDTO {
/**
* 工单创建请求参数
*/
@Setter
@Getter
@EqualsAndHashCode
public static class OrderCreateRequest {
/**
* 工单来源,填写:JD、400等
*/
@NotBlank
private String source;
/**
* BEAN工单号码
*/
@NotBlank
private String orderId;
/**
* BEAN系统子工单号码
*/
private String subId;
/**
* 客户姓名
*/
@NotBlank
private String name;
/**
* 客户联系电话
*/
@NotBlank
private String phone;
/**
* 地址坐标信息
*/
@NotNull
@Valid
private Location location;
/**
* 设备品牌(博世/西门子)
*/
@NotBlank
private String brand;
/**
* 产品类别
*/
@NotBlank
private String product_type;
/**
* 服务类型
*/
@NotBlank
private String service_type;
/**
* 故障描述
*/
@NotBlank
private String faultDescribe;
/**
* 预约时间段开始
*/
@NotNull
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date expectBegin;
/**
* 预约时间段结束
*/
@NotNull
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date expectEnd;
/**
* 预约描述时间(全天/上午/下午)
*/
@NotBlank
private String expectDesc;
/**
* 优先级
*/
@NotBlank
private String priority;
/**
* 服务单标签列表
*/
@NotNull
private List<String> orderTags;
/**
* 备注(周末安装/到小区打电话)
*/
@NotBlank
private String description;
/**
* 其他详细信息, 预留的其他详细信息,具体等BEAN提供
*/
private Object extraInfo;
}
/**
* 工单变更请求参数
*/
@Setter
@Getter
public static class StageChangeRequest {
/**
* 工单号码
*/
@NotBlank
private String orderId;
/**
* 工单状态,取消/改约/挂起等
*/
@NotBlank
private String orderStatus;
/**
* 发生时间,yyyy-MM-dd HH:mm:ss
*/
@NotNull
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date happen;
/**
* 过程节点 已联系/准备服务/开始服务/结束服务等
*/
@NotBlank
private String stage;
/**
* 新预约时间, 特殊状态的时候填写:orderStatus为改约的时候填写
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date newReservationTime;
/**
* 描述信息
*/
private String description;
/**
* 地址坐标信息
*/
private Location happenLocation;
}
/**
* 服务单进度
*/
@Setter
@Getter
public static class StageResult {
/**
* 工单号
*/
private String orderId;
/**
* 工程师工号
*/
private String engineerCode;
/**
* 工程师姓名
*/
private String engineerName;
/**
* 辅助工程师工号
*/
private String engineerCodeAssist;
/**
* 辅助工程师姓名
*/
private String engineerNameAssist;
/**
* 推荐上门时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date planVisitTime;
/**
* 工程师实时信息,服务当天返回;非当天不返回;
*/
private RealtimeInfo realtimeInfo;
}
@Setter
@Getter
public static class RealtimeInfo {
/**
* 地址坐标信息
*/
private Location engineerLocation;
/**
* 上门预估信息
*/
private Estimate estimate;
}
@Setter
@Getter
public static class Estimate {
/**
* 距离
*/
private Double distance;
/**
* 预计到达时间 格式: yyyy-MM-dd HH:mm:ss
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date arriveTime;
}
/**
* 工程师统计订单结果
*/
@Setter
@Getter
public static class AppointResult extends EngineerCode {
/**
* 查询日期
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date date;
/**
* 查询统计订单列表
*/
private List<AppointmentOrderResult> orders;
}
/**
* 预约单
*/
@Setter
@Getter
public static class AppointmentOrderResult {
/**
* 工单号
*/
private String orderId;
/**
* 服务状态
*/
private String orderStatus;
/**
* 计划服务开始时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date planBeginTime;
/**
* 计划在途里程
*/
private Integer planDistance;
/**
* 计划在途时间
*/
private Integer planDuration;
/**
* 实际在途时间 实际服务后返回,单位:秒
*/
private Integer actualDuration;
/**
* 实际服务开始时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date actualBeginTime;
/**
* 实际在途里程 实际服务后返回
*/
private Integer actualDistance;
}
}
package com.dituhui.pea.order.dto.param;
import javax.validation.GroupSequence;
/**
* 参数校验分组, 定义分组
*/
public class ValidGroup {
/**
* 新增使用(配合spring的@Validated功能分组使用)
*/
public interface Insert {
}
/**
* 更新使用(配合spring的@Validated功能分组使用)
*/
public interface Update {
}
/**
* 删除使用(配合spring的@Validated功能分组使用)
*/
public interface Delete {
}
/**
* 属性必须有这两个分组的才验证(配合spring的@Validated功能分组使用)
*/
@GroupSequence({Insert.class, Update.class, Delete.class})
public interface All {
}
/**
* pea Api 组织架构同步事件
*/
public interface PeaTree {
}
/**
* pea Api 组织人员同步事件
*/
public interface PeaOrganization {
}
}
......@@ -109,15 +109,18 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
List<EngineersGanttDTO.GanttChart> engineers = new ArrayList<>();
for (String engineerCode : engineerCodes) {
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(engineerCode);
EngineerBusinessEntity engineerBusinessEntity = engineerBusinessDao.getByEngineerCode(engineerCode);
EngineersGanttDTO.GanttChart engineer = new EngineersGanttDTO.GanttChart();
engineer.setEngineerCode(engineerCode)
.setStartTime(String.format("%s %s", reqDTO.getDate(), engineerBusinessEntity.getWorkOn()))
.setEndTime(String.format("%s %s", reqDTO.getDate(), engineerBusinessEntity.getWorkOff()))
.setHoliday(false) // todo
.setEngineerName(engineerInfo.getName())
.setGrade(engineerInfo.getGrade());
EngineerBusinessEntity engineerBusinessEntity = engineerBusinessDao.getByEngineerCode(engineerCode);
if (Objects.nonNull(engineerBusinessEntity)) {
engineer.setStartTime(String.format("%s %s", reqDTO.getDate(), engineerBusinessEntity.getWorkOn()))
.setEndTime(String.format("%s %s", reqDTO.getDate(), engineerBusinessEntity.getWorkOff()));
}
CapacityEngineerStatEntity capacityEngineerStat = capacityEngineerStatDao.getByWorkdayAndEngineerCode(reqDTO.getDate(), engineerCode);
if (capacityEngineerStat == null) {
log.warn("技术员当日的容量数据不存在,{}{}", engineerCode, reqDTO.getDate());
......
......@@ -176,8 +176,12 @@ public class EngineerServiceImpl implements EngineerService {
EngineerSkillGroupEntity e = new EngineerSkillGroupEntity();
e.setEngineerCode(engineerCode);
e.setSkillGroupCode(skillGroupId);
e.setBeanStatus(Boolean.TRUE);
e.setDescription("");
e.setStatus(true);
e.setMemo("");
e.setCreateTime(LocalDateTime.now());
e.setUpdateTime(LocalDateTime.now());
entityManager.persist(e);
}
return null;
......
......@@ -131,7 +131,7 @@ public class ScheduleServiceImpl implements ScheduleService {
team.setChildren(children);
team.setOrderDesc(String.format("人均:%d", orders.size() / teamEngineers.size()));
team.setOrderDesc(String.format("人均:%d", teamEngineers.size() > 0 ? (orders.size() / teamEngineers.size()) : 0));
team.setDistanceDesc("");
teams.add(team);
......
{
"serverUrl": "http://{{server}}",
"serverEnv": "http://{{server}}",
"pathPrefix": "",
"isStrict": false,
"allInOne": true,
"outPath": "../doc",
"randomMock": false,
"coverOld": true,
"createDebugPage": true,
"packageFilters": "",
"packageExcludeFilters": "",
"md5EncryptedHtmlName": false,
"style":"xt256",
"framework": "spring",
"skipTransientField": true,
"sortByTitle":false,
"showAuthor":false,
"requestFieldToUnderline":false,
"responseFieldToUnderline":false,
"inlineEnum":true,
"recursionLimit":3,
"allInOneDocFileName":"index.html",
"requestExample":"true",
"responseExample":"true",
"requestParamsTable": true,
"responseParamsTable": true,
"urlSuffix":"",
"displayActualType":false
}
\ No newline at end of file
......@@ -7,5 +7,6 @@ ADD ./project-user/target/project-user-*.jar /app.jar
RUN sh -c 'touch /app.jar'
EXPOSE 8000
EXPOSE 5005
ENTRYPOINT ["java", "-jar","/app.jar"]
\ No newline at end of file
ENTRYPOINT ["java", "-jar","-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005","/app.jar"]
\ No newline at end of file
package com.dituhui.pea.user.controller;
import com.dituhui.pea.common.PageResult;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.pojo.PageRequest;
import com.dituhui.pea.pojo.ResourceInfo;
import com.dituhui.pea.pojo.RoleInfo;
import com.dituhui.pea.pojo.WebResult;
import com.dituhui.pea.pojo.role.RoleResourceInfo;
import com.dituhui.pea.pojo.role.UserRoleInfo;
import com.dituhui.pea.user.IRole;
import com.dituhui.pea.user.entity.UserRoleEntity;
import com.dituhui.pea.user.service.RoleService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 角色控制层
*/
......@@ -29,9 +38,16 @@ public class RoleController implements IRole {
return WebResult.ok(roleInfo);
}
@Override
public WebResult<RoleInfo> updateRole(@Validated RoleInfo roleInfo) {
roleInfo = roleService.updateRole(roleInfo);
return WebResult.ok(roleInfo);
}
@Override
public WebResult<Boolean> deleteRole(String roleId) {
if (StringUtils.isBlank(roleId)){
if (StringUtils.isBlank(roleId)) {
return WebResult.failed(StatusCodeEnum.COMMON_PARAM_EMPTY);
}
roleService.deleteRole(roleId);
......@@ -52,7 +68,7 @@ public class RoleController implements IRole {
if (StringUtils.isBlank(roleId) || StringUtils.isBlank(userId)) {
return WebResult.failed(StatusCodeEnum.COMMON_PARAM_EMPTY);
}
roleService.deleteUserRole(roleId,userId);
roleService.deleteUserRole(roleId, userId);
return WebResult.ok();
}
......@@ -82,7 +98,7 @@ public class RoleController implements IRole {
@Override
public WebResult<Boolean> replaceRoleResource(String roleId, String resourceIds) {
if (StringUtils.isBlank(roleId) || StringUtils.isBlank(resourceIds)){
if (StringUtils.isBlank(roleId) || StringUtils.isBlank(resourceIds)) {
return WebResult.failed(StatusCodeEnum.COMMON_PARAM_EMPTY);
}
roleService.replaceRoleResource(roleId, resourceIds);
......@@ -94,9 +110,29 @@ public class RoleController implements IRole {
if (StringUtils.isBlank(roleId) || StringUtils.isBlank(resourceId)) {
return WebResult.failed(StatusCodeEnum.COMMON_PARAM_EMPTY);
}
roleService.deleteRoleResource(roleId,resourceId);
roleService.deleteRoleResource(roleId, resourceId);
return WebResult.ok();
}
@Override
public Result<PageResult<RoleInfo>> listRole(PageRequest pageRequest) {
PageResult<RoleInfo> result = roleService.listRole(pageRequest);
return Result.success(result);
}
@Override
public Result<RoleInfo> info(String roleId) {
RoleInfo result = roleService.info(roleId);
return Result.success(result);
}
@Override
public Result<List<ResourceInfo>> allResource() {
List<ResourceInfo> result = roleService.allResource();
return Result.success(result);
}
}
package com.dituhui.pea.user.controller;
import com.dituhui.pea.common.PageResult;
import com.dituhui.pea.pojo.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
......@@ -9,11 +11,6 @@ import org.springframework.web.bind.annotation.RestController;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.enums.StatusCodeEnum;
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;
import com.dituhui.pea.user.IUser;
import com.dituhui.pea.user.service.UserService;
......@@ -21,7 +18,6 @@ import cn.hutool.core.util.ObjectUtil;
/**
* 用户控制层
*
*/
@RestController
public class UserController implements IUser {
......@@ -30,19 +26,19 @@ public class UserController implements IUser {
private UserService userService;
@Override
public Result<UserLoginDTO> userLogin(UserLoginParam user) {
return userService.userLogin(user.getAccount(), user.getPassword());
}
public Result<UserLoginDTO> userLogin(UserLoginParam user) {
return userService.userLogin(user.getAccount(), user.getPassword());
}
@Override
public Result<UserLoginDTO> getUserInfo(String userId) {
return userService.getUserInfo(userId);
}
@Override
public Result<Boolean> refreshAppkey() {
return userService.refreshAppkey();
}
public Result<UserLoginDTO> getUserInfo(String userId) {
return userService.getUserInfo(userId);
}
@Override
public Result<Boolean> refreshAppkey() {
return userService.refreshAppkey();
}
@Override
public WebResult<UserInfo> getCurrentUserInfo(String userToken, Boolean needTeamInfo) {
......@@ -69,12 +65,12 @@ public class UserController implements IUser {
@Override
public WebResult<UserInfo> queryUserByPhone(String phone) {
System.out.println("queryUserByPhone ["+phone+"]");
System.out.println("queryUserByPhone [" + phone + "]");
if (StringUtils.isBlank(phone)) {
return WebResult.failed(StatusCodeEnum.COMMON_PARAM_EMPTY);
}
UserInfo userInfo = userService.queryUserByPhone(phone);
System.out.println("queryUserByPhone UserInfo ["+userInfo+"]");
System.out.println("queryUserByPhone UserInfo [" + userInfo + "]");
return WebResult.ok(userInfo);
}
......@@ -135,4 +131,30 @@ public class UserController implements IUser {
return WebResult.ok(userInfo);
}
/**
* 用户列表
*
* @param search 查询条件
* @return
*/
@Override
public Result<PageResult<UserInfoSearch>> list(UserInfoSearch search) {
PageResult<UserInfoSearch> result = userService.list(search);
return Result.success(result);
}
/**
* 禁用用户
*
* @param search 查询条件
* @return
*/
@Override
public Result<Boolean> ban(UserInfoSearch search) {
userService.ban(search);
return Result.success(true);
}
}
......@@ -33,6 +33,14 @@ public interface RoleResourceDao extends JpaRepository<RoleResourceEntity, Strin
List<RoleResourceEntity> findByRoleIdIn(List<String> roleIds);
/**
* 根据角色ID查询
*
* @param roleIds 角色ID
* @return
*/
List<RoleResourceEntity> findByRoleId(String roleId);
/**
* 根据角色ID删除对应的资源关系
*
* @param roleId 角色ID
......
package com.dituhui.pea.user.dao;
import com.dituhui.pea.user.entity.UserOrgEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
/**
* 用户组织关联表
*/
public interface UserOrgDao extends JpaRepository<UserOrgEntity, String>, JpaSpecificationExecutor<UserOrgEntity>,
CrudRepository<UserOrgEntity, String> {
/**
* 根据用户id查询
*
* @param id
* @return
*/
UserOrgEntity findByUserId(String id);
void deleteByUserId(String userId);
}
......@@ -19,13 +19,15 @@ public interface UserRoleDao extends JpaRepository<UserRoleEntity, String>,
/**
* 根据角色ID查询
*
* @param roleId 角色ID
* @return
*/
List<UserRoleEntity> findByRoleId(String roleId);
/**
* 根据用户ID查询
*
* @param roleId 角色ID
* @return
*/
......@@ -33,6 +35,7 @@ public interface UserRoleDao extends JpaRepository<UserRoleEntity, String>,
/**
* 根据角色ID和用户ID删除
*
* @param roleId 角色ID
* @param userId 用户ID
*/
......@@ -41,8 +44,16 @@ public interface UserRoleDao extends JpaRepository<UserRoleEntity, String>,
/**
* 根据角色ID删除
*
* @param roleId 角色ID
*/
void deleteByRoleId(String roleId);
/**
* 根据用户ID删除
*
* @param userId 角色ID
*/
void deleteByUserId(String userId);
}
......@@ -12,11 +12,10 @@ import java.util.Date;
/**
* 用户表(UserEntity)实体类
*
*/
@Data
@Entity
@Table(name ="sys_user")
@Table(name = "sys_user")
@EntityListeners(AuditingEntityListener.class)
public class UserEntity implements Serializable {
private static final long serialVersionUID = 595672857439664430L;
......@@ -114,4 +113,21 @@ public class UserEntity implements Serializable {
@LastModifiedDate
private Date updatedTime;
/**
* 是否禁用 0: 否 1:是 默认0
*/
@Column(name = "ban")
private Integer ban = 0;
/**
* 用户来源:0:bean 1:新建
*/
@Column(name = "source")
private Integer source;
/**
* 工程师工号
*/
@Column(name = "engineer_code")
private String engineerCode;
}
package com.dituhui.pea.user.entity;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.persistence.*;
import java.time.LocalDateTime;
@Entity
@Table(name = "sys_user_org")
@Data
@Accessors(chain = true)
public class UserOrgEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "user_id", nullable = false, unique = true)
private String userId;
@Column(name = "org_id", nullable = false)
private Integer orgId;
/**
* 组织级别 0:大区 1:分部 2:站点
*/
@Column(name = "org_level", nullable = false)
private Integer orgLevel;
@Column(name = "create_time", nullable = false, updatable = false, columnDefinition = "timestamp default current_timestamp")
private LocalDateTime createTime;
@Column(name = "update_time", nullable = false, columnDefinition = "timestamp default current_timestamp on update current_timestamp")
private LocalDateTime updateTime;
}
......@@ -3,22 +3,32 @@ package com.dituhui.pea.user.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.dituhui.pea.common.PageResult;
import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.exception.BusinessException;
import com.dituhui.pea.pojo.PageRequest;
import com.dituhui.pea.pojo.ResourceInfo;
import com.dituhui.pea.pojo.RoleInfo;
import com.dituhui.pea.pojo.role.RoleResourceInfo;
import com.dituhui.pea.user.dao.*;
import com.dituhui.pea.user.entity.*;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* 角色业务层
*
* @author zl
*/
@Service
......@@ -44,6 +54,31 @@ public class RoleService {
public RoleInfo addRole(RoleInfo roleInfo) {
RoleEntity roleEntity = BeanUtil.copyProperties(roleInfo, RoleEntity.class);
roleEntity = roleDao.save(roleEntity);
List<RoleResourceInfo> resourceInfos = roleInfo.getResourceInfos();
if (CollectionUtils.isNotEmpty(resourceInfos)) {
for (RoleResourceInfo resourceInfo : resourceInfos) {
RoleResourceEntity roleResourceEntity = assembleRoleResource(roleEntity.getId(), resourceInfo.getResourceId());
roleResourceDao.save(roleResourceEntity);
}
}
roleInfo = BeanUtil.copyProperties(roleEntity, RoleInfo.class);
return roleInfo;
}
@Transactional(rollbackFor = Exception.class)
public RoleInfo updateRole(RoleInfo roleInfo) {
RoleEntity roleEntity = BeanUtil.copyProperties(roleInfo, RoleEntity.class);
roleEntity = roleDao.save(roleEntity);
List<RoleResourceInfo> resourceInfos = roleInfo.getResourceInfos();
if (CollectionUtils.isNotEmpty(resourceInfos)) {
for (RoleResourceInfo resourceInfo : resourceInfos) {
// 先清除
roleResourceDao.deleteByRoleId(roleEntity.getId());
RoleResourceEntity roleResourceEntity = assembleRoleResource(roleEntity.getId(), resourceInfo.getResourceId());
roleResourceDao.save(roleResourceEntity);
}
}
roleInfo = BeanUtil.copyProperties(roleEntity, RoleInfo.class);
return roleInfo;
}
......@@ -59,10 +94,12 @@ public class RoleService {
roleDao.deleteById(roleId);
// 删除用户和角色的关系
userRoleDao.deleteByRoleId(roleId);
// 删除权限和角色的关系
roleResourceDao.deleteByRoleId(roleId);
}
@Transactional(rollbackFor = Exception.class)
public void addUserRole(String roleId, String userId){
public void addUserRole(String roleId, String userId) {
// 查询角色是否存在
RoleEntity roleEntity = roleDao.findById(roleId).orElse(null);
if (ObjectUtil.isNull(roleEntity)) {
......@@ -181,7 +218,7 @@ public class RoleService {
}
private RoleResourceEntity assembleRoleResource(String roleId, String resourceId){
private RoleResourceEntity assembleRoleResource(String roleId, String resourceId) {
RoleResourceEntity roleResourceEntity = new RoleResourceEntity();
roleResourceEntity.setRoleId(roleId);
roleResourceEntity.setResourceId(resourceId);
......@@ -189,6 +226,44 @@ public class RoleService {
}
public PageResult<RoleInfo> listRole(PageRequest pageRequest) {
Sort sort = Sort.by(Sort.Order.desc("createdTime"));
Pageable pageable = org.springframework.data.domain.PageRequest.of(pageRequest.getPage() - 1, pageRequest.getSize(), sort);
Page<RoleEntity> page = roleDao.findAll(pageable);
List<RoleInfo> roleInfos = new ArrayList<>();
for (RoleEntity role : page.getContent()) {
RoleInfo roleInfo = BeanUtil.copyProperties(role, RoleInfo.class);
roleInfos.add(roleInfo);
}
PageResult<RoleInfo> result = new PageResult<>();
result.setDataList(roleInfos);
result.setCurrPage(page.getNumber());
result.setRecordCount(page.getTotalElements());
result.setTotalPage(page.getTotalPages());
return result;
}
/**
* 获取用户下所有角色权限
*
* @param roleId
* @return
*/
public RoleInfo info(String roleId) {
// 判断角色是否存在
RoleEntity roleEntity = roleDao.findById(roleId).orElse(null);
if (ObjectUtil.isNull(roleEntity)) {
throw new BusinessException(StatusCodeEnum.ROLE_DOES_NOT_EXIST);
}
RoleInfo roleInfo = BeanUtil.copyProperties(roleEntity, RoleInfo.class);
List<RoleResourceEntity> resourceEntities = roleResourceDao.findByRoleId(roleId);
List<RoleResourceInfo> resourceInfos = resourceEntities.stream().map(entity -> BeanUtil.copyProperties(entity, RoleResourceInfo.class)).collect(Collectors.toList());
roleInfo.setResourceInfos(resourceInfos);
return roleInfo;
}
public List<ResourceInfo> allResource() {
List<ResourceEntity> all = resourceDao.findAll();
return all.stream().map(entity -> BeanUtil.copyProperties(entity, ResourceInfo.class)).collect(Collectors.toList());
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!