Commit a1fc747a by 丁伟峰

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

2 parents 2f694c08 45cabcf0
Showing with 649 additions and 32 deletions
...@@ -52,7 +52,7 @@ public class OrgGroup implements Serializable { ...@@ -52,7 +52,7 @@ public class OrgGroup implements Serializable {
private Integer category; private Integer category;
@Column(name = "warehouse_id") @Column(name = "warehouse_id")
private Integer warehouseId; private String warehouseId;
private String memo; private String memo;
......
package com.dituhui.pea.dispatch.pojo; package com.dituhui.pea.dispatch.pojo;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.optaplanner.core.api.domain.solution.PlanningEntityCollectionProperty; import org.optaplanner.core.api.domain.solution.PlanningEntityCollectionProperty;
...@@ -20,7 +21,6 @@ public class DispatchSolution { ...@@ -20,7 +21,6 @@ public class DispatchSolution {
private String batchNo; private String batchNo;
private String name; private String name;
@ProblemFactCollectionProperty @ProblemFactCollectionProperty
...@@ -40,6 +40,11 @@ public class DispatchSolution { ...@@ -40,6 +40,11 @@ public class DispatchSolution {
@PlanningScore @PlanningScore
private HardSoftLongScore score; private HardSoftLongScore score;
/**
* 未分配订单
*/
private List<Customer> unDispatchedCustomers = new ArrayList<>();
public DispatchSolution() { public DispatchSolution() {
} }
......
...@@ -139,16 +139,16 @@ public class BatchServiceImpl implements BatchService { ...@@ -139,16 +139,16 @@ public class BatchServiceImpl implements BatchService {
" and a.dt = ? " + " and a.dt = ? " +
" and o.pre_status in ('CONFIRM') \n" + " and o.pre_status in ('CONFIRM') \n" +
" order by a.expect_time_begin asc "; " order by a.expect_time_begin asc ";
int orderCountConfirm = jdbcTemplate.update(sqlOrderConfirm, batchNo, groupId, batchDay); // int orderCountConfirm = jdbcTemplate.update(sqlOrderConfirm, batchNo, groupId, batchDay);
log.info("准备批次数据 orderCount :{}", orderCount); log.info("准备批次数据 orderCount :{}", orderCount);
log.info("准备批次数据 orderCountPre :{}", orderCountPre); log.info("准备批次数据 orderCountPre :{}", orderCountPre);
log.info("准备批次数据 orderCountConfirm :{}", orderCountConfirm); // log.info("准备批次数据 orderCountConfirm :{}", orderCountConfirm);
if (orderCount + orderCountPre > 0) { if (orderCount + orderCountPre > 0) {
jdbcTemplate.update("update dispatch_batch set engineer_num=? , order_num=?, start_time=?, end_time=null, status='RUNNING' where group_id=? and batch_no=?", jdbcTemplate.update("update dispatch_batch set engineer_num=? , order_num=?, start_time=?, end_time=null, status='RUNNING' where group_id=? and batch_no=?",
engCount, orderCount + orderCountPre + orderCountConfirm, LocalDateTime.now(), groupId, batchNo); engCount, orderCount + orderCountPre , LocalDateTime.now(), groupId, batchNo);
} else { } else {
jdbcTemplate.update("update dispatch_batch set engineer_num=? , order_num=?, start_time=?, end_time=?, status='DONE' where group_id=? and batch_no=?", jdbcTemplate.update("update dispatch_batch set engineer_num=? , order_num=?, start_time=?, end_time=?, status='DONE' where group_id=? and batch_no=?",
engCount, 0, LocalDateTime.now(), LocalDateTime.now(), groupId, batchNo); engCount, 0, LocalDateTime.now(), LocalDateTime.now(), groupId, batchNo);
......
...@@ -148,14 +148,14 @@ public class ExtractServiceImpl implements ExtractService { ...@@ -148,14 +148,14 @@ public class ExtractServiceImpl implements ExtractService {
// 写order_log // 写order_log
OrderLog orderLog = new OrderLog().setOrderId(orderId).setSuborderId(subId).setSource("PEA-BACKEND").setOperator("DISPATCH") OrderLog orderLog = new OrderLog().setOrderId(orderId).setSuborderId(subId).setSource("PEA-DISPATCH").setOperator("DISPATCH")
.setContent(String.format("批量自动指派:<%s,%s>", engCode, engName)).setContentOld("") .setContent(String.format("批量自动指派:<%s,%s>", engCode, engName)).setContentOld("")
.setMemo("批量自动指派").setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now()); .setMemo("批量自动指派").setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderLogRepo.save(orderLog); orderLogRepo.save(orderLog);
if (isConfirm) { if (isConfirm) {
OrderEvent orderEvent = new OrderEvent().setOrderId(orderId).setSuborderId(subId).setHappen(LocalDateTime.now()) OrderEvent orderEvent = new OrderEvent().setOrderId(orderId).setSuborderId(subId).setHappen(LocalDateTime.now())
.setEvent("批量自动指派").setOperator("DISPATCH").setOperatorName("算法批量指派").setSource("PEA-BACKEND") .setEvent("批量自动指派").setOperator("DISPATCH").setOperatorName("算法批量指派").setSource("PEA-DISPATCH")
.setDescription(String.format("批量自动指派:<%s,%s>", engCode, engName)).setMemo("") .setDescription(String.format("批量自动指派:<%s,%s>", engCode, engName)).setMemo("")
.setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now()); .setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderEventRepo.save(orderEvent); orderEventRepo.save(orderEvent);
...@@ -183,14 +183,14 @@ public class ExtractServiceImpl implements ExtractService { ...@@ -183,14 +183,14 @@ public class ExtractServiceImpl implements ExtractService {
appointment.setSuborderId(appointment.getOrderId()); appointment.setSuborderId(appointment.getOrderId());
} }
OrderLog orderLog = new OrderLog().setOrderId(orderId).setSuborderId(appointment.getSuborderId()).setSource("PEA-BACKEND").setOperator("DISPATCH") OrderLog orderLog = new OrderLog().setOrderId(orderId).setSuborderId(appointment.getSuborderId()).setSource("PEA-DISPATCH").setOperator("DISPATCH")
.setContent(String.format("批量自动指派:<%s,%s>", engCode, engName)).setContentOld(lastContent) .setContent(String.format("批量自动指派:<%s,%s>", engCode, engName)).setContentOld(lastContent)
.setMemo("批量自动指派").setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now()); .setMemo("批量自动指派").setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderLogRepo.save(orderLog); orderLogRepo.save(orderLog);
if (isConfirm) { if (isConfirm) {
OrderEvent orderEvent = new OrderEvent().setOrderId(orderId).setSuborderId(appointment.getSuborderId()).setHappen(LocalDateTime.now()) OrderEvent orderEvent = new OrderEvent().setOrderId(orderId).setSuborderId(appointment.getSuborderId()).setHappen(LocalDateTime.now())
.setEvent("批量自动指派").setOperator("DISPATCH").setOperatorName("算法批量指派").setSource("PEA-BACKEND") .setEvent("批量自动指派").setOperator("DISPATCH").setOperatorName("算法批量指派").setSource("PEA-DISPATCH")
.setDescription(String.format("批量自动指派:<%s,%s>", engCode, engName)).setMemo("") .setDescription(String.format("批量自动指派:<%s,%s>", engCode, engName)).setMemo("")
.setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now()); .setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderEventRepo.save(orderEvent); orderEventRepo.save(orderEvent);
......
...@@ -152,6 +152,11 @@ public class DispatchSolutionUtils { ...@@ -152,6 +152,11 @@ public class DispatchSolutionUtils {
.map(c -> c.getPreferredlocation().getX() + "," + c.getPreferredlocation().getY()) .map(c -> c.getPreferredlocation().getX() + "," + c.getPreferredlocation().getY())
.reduce((a, b) -> a + ";" + b).get() + "\""; .reduce((a, b) -> a + ";" + b).get() + "\"";
// 技术员名称
String names = "\"" + solution.getTechnicianList().stream()
.map(c -> c.getPreferredlocation().getX() + "," + c.getPreferredlocation().getY()+ "," + c.getCode())
.reduce((a, b) -> a + ";" + b).get() + "\"";
List<String> dispatchMapLines = IOUtils.readLines(new FileInputStream("data/dispatchMap.html"), "GBK"); List<String> dispatchMapLines = IOUtils.readLines(new FileInputStream("data/dispatchMap.html"), "GBK");
dispatchMapLines = dispatchMapLines.stream().map(line -> { dispatchMapLines = dispatchMapLines.stream().map(line -> {
if (StringUtils.startsWith(line, " var depot = ")) { if (StringUtils.startsWith(line, " var depot = ")) {
...@@ -160,7 +165,9 @@ public class DispatchSolutionUtils { ...@@ -160,7 +165,9 @@ public class DispatchSolutionUtils {
return " var preferredlocation = " + preferredlocation; return " var preferredlocation = " + preferredlocation;
} else if (StringUtils.startsWith(line, " var lines = ")) { } else if (StringUtils.startsWith(line, " var lines = ")) {
return " var lines = " + lines; return " var lines = " + lines;
} else { } else if (StringUtils.startsWith(line, " var names = ")) {
return " var names = " + names;
} else{
return line; return line;
} }
}).collect(Collectors.toList()); }).collect(Collectors.toList());
...@@ -374,6 +381,8 @@ public class DispatchSolutionUtils { ...@@ -374,6 +381,8 @@ public class DispatchSolutionUtils {
// 移除技术员 // 移除技术员
customer.getTechnician().getCustomerList().remove(customer); customer.getTechnician().getCustomerList().remove(customer);
solution.getUnDispatchedCustomers().add(customer);
} }
} }
break; break;
......
...@@ -118,6 +118,11 @@ ...@@ -118,6 +118,11 @@
preferredlocation.split(';').forEach(function(xy,index){ preferredlocation.split(';').forEach(function(xy,index){
addCircle(xy,colors[index]); addCircle(xy,colors[index]);
}); });
// 技术员
var names = "120.753876,31.312792;120.60937,31.37701;120.59335,31.314192;120.6781,31.312456;120.694275,31.230944;120.68786,31.631952;120.62794,31.25647;120.630035,31.153814;120.53737,31.36919;120.597626,31.18977;120.62713,31.29919;120.69743,31.234127;120.634636,31.298191;120.72335,31.296595;120.39913,31.233416;120.72677,31.3044;120.66996,31.272655;120.6085,31.126905;120.385025,31.351074;120.736176,31.337831";
names.split(';').forEach(function(xy,index){
addText(xy,colors[index]);
});
} }
...@@ -142,6 +147,8 @@ ...@@ -142,6 +147,8 @@
showDir: true, //白色方向箭头 showDir: true, //白色方向箭头
}); });
mapObj.add(polygon); mapObj.add(polygon);
polygon.on('mouseover', showInfoOver);
polygon.on('mouseout', showInfoOut);
} }
// 实例化点标记 // 实例化点标记
...@@ -217,11 +224,59 @@ ...@@ -217,11 +224,59 @@
fillColor: "#"+color, //填充颜色 fillColor: "#"+color, //填充颜色
fillOpacity: 0.8 //填充透明度 fillOpacity: 0.8 //填充透明度
}); });
mapObj.add(circle); mapObj.add(circle);
return new AMap.LngLat(segs[0], segs[1]); return new AMap.LngLat(segs[0], segs[1]);
}); });
} }
function showInfoOver(e){
e.target.setOptions({
strokeWeight: 10
});
}
function showInfoOut(e){
e.target.setOptions({
strokeWeight: 5
});
}
// 实例化文字标记
function addText(bounds,color) {
if ('' == bounds) {
alert("请输入坐标串");
return;
}
bounds.split(';').map(xy => {
var segs = xy.split(',');
var name = segs[2];
// 创建纯文本标记
var text = new AMap.Text({
text:name,
anchor:'center',
draggable:false,
cursor:'pointer',
style:{
'padding': '.75rem 1.25rem',
'margin-bottom': '1rem',
'border-radius': '.25rem',
'background-color': 'rgba(0, 0, 0, 0)',
'width': '15rem',
'border-width': 0,
'text-align': 'center',
'font-size': '12px',
'color': 'black'
},
position: [segs[0], segs[1]]
});
mapObj.add(text);
return new AMap.LngLat(segs[0], segs[1]);
});
}
//设置地图显示要素 //设置地图显示要素
function setMapFeatures() { function setMapFeatures() {
var features = []; var features = [];
......
...@@ -9,9 +9,6 @@ import org.springframework.cloud.gateway.filter.GlobalFilter; ...@@ -9,9 +9,6 @@ import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebExchange;
...@@ -31,7 +28,8 @@ public class AuthFilter implements GlobalFilter, Ordered { ...@@ -31,7 +28,8 @@ public class AuthFilter implements GlobalFilter, Ordered {
/** /**
* 白名单 * 白名单
*/ */
private static final Set<String> authWhiteList = Sets.newHashSet("/pea-user/login", "/pea-user/login/"); private static final Set<String> authWhiteList = Sets.newHashSet("/pea-user/login", "/pea-user/login/",
"/pea-user/refreshAppkey", "/pea-user/refreshAppkey/");
private static final Gson gson = new Gson(); private static final Gson gson = new Gson();
@Autowired @Autowired
...@@ -60,29 +58,49 @@ public class AuthFilter implements GlobalFilter, Ordered { ...@@ -60,29 +58,49 @@ public class AuthFilter implements GlobalFilter, Ordered {
if (StringUtils.isEmpty(authToken)) { if (StringUtils.isEmpty(authToken)) {
authToken = exchange.getRequest().getQueryParams().getFirst("token"); authToken = exchange.getRequest().getQueryParams().getFirst("token");
} }
UserLoginDTO userDTO = null;
if (StringUtils.isNotEmpty(authToken)) {
if (log.isTraceEnabled()) { if (log.isTraceEnabled()) {
log.trace("token is {}", authToken); log.trace("token is {}", authToken);
} }
UserLoginDTO userDTO = null;
if (StringUtils.isNotEmpty(authToken)) {
// 查询token对应的用户 // 查询token对应的用户
String value = redisService.get(RedisKeyGroup.authToken + ":" + authToken); String value = redisService.get(RedisKeyGroup.authToken + ":" + authToken);
if (null != value) { if (null != value) {
userDTO = gson.fromJson(value, UserLoginDTO.class); userDTO = gson.fromJson(value, UserLoginDTO.class);
} }
} }
// ak登录处理
if (StringUtils.isEmpty(authToken)) {
String ak = exchange.getRequest().getQueryParams().getFirst("ak");
if (log.isTraceEnabled()) {
log.trace("ak is {}", ak);
}
if (StringUtils.isNotEmpty(ak)) {
// 验证ak,设置userDTO
String value = redisService.get(RedisKeyGroup.appKey + ":" + ak);
if (StringUtils.isNotEmpty(value)) {
// 验证成功,设置为管理员
// AppDTO appDTO = gson.fromJson(value, AppDTO.class);
// String secret = appDTO.getSecret();
userDTO = new UserLoginDTO();
userDTO.setId("1");
}
}
}
if (userDTO == null) { if (userDTO == null) {
log.info("未授权访问{} ip:{}", url, getRemoteIP(exchange)); log.info("未授权访问{} ip:{}", url, getRemoteIP(exchange));
} else { } else {
log.info("用户:{} id:{} 访问{}", userDTO.getAccount(), userDTO.getId(), url); log.info("用户:{} id:{} 访问{}", userDTO.getAccount(), userDTO.getId(), url);
// 获取当前的请求对象信息 // 获取当前的请求对象信息
// exchange.getRequest().getHeaders().add("userId", userDTO.getId());
ServerHttpRequest.Builder builder = exchange.getRequest().mutate(); ServerHttpRequest.Builder builder = exchange.getRequest().mutate();
// 向header中设置新的key,存储解析好的token对应基本信息 // 向header中设置新的key,存储解析好的token对应基本信息
builder.header("userId", userDTO.getId()); builder.header("userId", userDTO.getId());
// 向下游传递 // 向下游传递
Authentication authentication = new UsernamePasswordAuthenticationToken(userDTO.getAccount(), null, null); // Authentication authentication = new UsernamePasswordAuthenticationToken(userDTO.getAccount(), null, null);
SecurityContextHolder.getContext().setAuthentication(authentication); // SecurityContextHolder.getContext().setAuthentication(authentication);
return chain.filter(exchange.mutate().request(builder.build()).build()); return chain.filter(exchange.mutate().request(builder.build()).build());
} }
......
...@@ -11,7 +11,7 @@ public enum RedisKeyGroup { ...@@ -11,7 +11,7 @@ public enum RedisKeyGroup {
authToken, authToken,
/** /**
* 认证ak对应的团队信息 * 认证ak对应的认证信息
*/ */
appKey; appKey;
......
package com.dituhui.pea.pojo;
import lombok.Data;
@Data
public class AppDTO {
/**
* 主键
*/
private String id;
private String name;
private String key;
private String secret;
}
...@@ -22,13 +22,34 @@ import com.dituhui.pea.pojo.WebResult; ...@@ -22,13 +22,34 @@ import com.dituhui.pea.pojo.WebResult;
@FeignClient(value = "project-user", contextId = "user") @FeignClient(value = "project-user", contextId = "user")
public interface IUser { public interface IUser {
/**
* 登录接口
*
* @param user
* @return
*/
@RequestMapping(value = "/pea-user/login", method = RequestMethod.POST) @RequestMapping(value = "/pea-user/login", method = RequestMethod.POST)
public Result<UserLoginDTO> userLogin(@RequestBody UserLoginParam user); public Result<UserLoginDTO> userLogin(@RequestBody UserLoginParam user);
/**
* 获取用户信息
*
* @param userId
* @return
*/
@RequestMapping(value = "/pea-user/userInfo", method = RequestMethod.GET) @RequestMapping(value = "/pea-user/userInfo", method = RequestMethod.GET)
public Result<UserLoginDTO> getUserInfo(@RequestHeader(name="userId", required = true) String userId); public Result<UserLoginDTO> getUserInfo(@RequestHeader(name="userId", required = true) String userId);
/** /**
* 刷新appkey接口<br>
* 初始化系统ak缓存,例如系统上线,新ak入库的时候
*
* @return
*/
@RequestMapping(value = "/pea-user/refreshAppkey", method = RequestMethod.POST)
public Result<Boolean> refreshAppkey();
/**
* 获取当前登陆用户信息 * 获取当前登陆用户信息
* *
* @param token 登录token * @param token 登录token
......
package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.EngineerBusinessDTO;
import com.dituhui.pea.order.service.EngineerBusinessService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author zhangx
*/
@Slf4j
@RestController
@RequestMapping("/pea-order")
public class EngineerCenterPoiController {
@Autowired
private EngineerBusinessService engineerBusinessService;
@GetMapping("/engineer-center/list")
public Result<?> getEngineerCenterList(@Validated EngineerBusinessDTO.Request engineerReq) {
// 获取工程师中心点信息列表
if (!"group".equals(engineerReq.getLevelType())) {
return Result.failed("请切换到分站级别查看");
}
if (StringUtils.isEmpty(engineerReq.getLevelValue())) {
return Result.failed("分站参数不能为空");
}
Result<?> res = null;
try {
EngineerBusinessDTO.Result result = new EngineerBusinessDTO.Result();
result.setEngineers(engineerBusinessService.getEngineerCenterList(engineerReq));
result.setGroup(engineerBusinessService.getGroupInfo(engineerReq));
result.setWarehouse(engineerBusinessService.getWareHouse(result.getGroup().getWarehouseId()));
res = Result.success(result);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@PostMapping("/engineer-center/update")
public Result<?> engineerCenterUpdate(@RequestBody EngineerBusinessDTO.EngineerCenterUpdateReqDTO req) {
// 工程师中心点信息修改
if (StringUtils.isEmpty(req.getEngineerCode())) {
return Result.failed("工程师参数不能为空");
}
if (StringUtils.isEmpty(req.getAddress())) {
return Result.failed("工程师地址不能为空");
}
if (StringUtils.isEmpty(req.getLocation())) {
return Result.failed("工程师坐标不能为空");
}
try {
engineerBusinessService.updateEngineerCenter(req);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return Result.success(null);
}
}
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.EngineerBusinessEntity;
import com.dituhui.pea.order.entity.EngineerInfoEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @author zhangx
*/
public interface EngineerBusinessDao extends CrudRepository<EngineerBusinessEntity, Long> {
@Transactional
@Modifying
@Query("UPDATE EngineerBusinessEntity tt SET tt.address = :address, tt.X= :x, tt.Y=:y WHERE tt.engineerCode = :engineerCode")
void updateEngineerCenter(String address, String x, String y, String engineerCode);
}
...@@ -19,4 +19,8 @@ public interface WarehouseInfoDao extends JpaRepository<OrgWarehouseInfoEntity, ...@@ -19,4 +19,8 @@ public interface WarehouseInfoDao extends JpaRepository<OrgWarehouseInfoEntity,
// 返回工作队关联的配件仓 // 返回工作队关联的配件仓
@Query("select a from OrgWarehouseInfoEntity a join OrgTeamEntity o on a.warehouseId=o.warehouseId where o.teamId= :teamId") @Query("select a from OrgWarehouseInfoEntity a join OrgTeamEntity o on a.warehouseId=o.warehouseId where o.teamId= :teamId")
OrgWarehouseInfoEntity getByTeamAssigned(String teamId); OrgWarehouseInfoEntity getByTeamAssigned(String teamId);
OrgWarehouseInfoEntity getOrgWarehouseInfoEntityByWarehouseId(String wareHouseId);
} }
package com.dituhui.pea.order.dto;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.List;
public class EngineerBusinessDTO {
@lombok.Data
public static class Request {
@NotNull(message = "组织结构不能为空")
private String levelType;
@NotNull(message = "组织结构不能为空")
private String levelValue;
private String kind;
private String key;
}
@lombok.Data
@Accessors(chain = true)
public static class Result {
private List<Engineer> engineers;
private Group group;
private WareHouse warehouse;
// @JsonIgnore
// private List<Blocks> blocks;
}
@lombok.Data
public static class Engineer {
private String engineerCode;
private String engineerName;
private String address;
private String location;
}
@lombok.Data
public static class Group {
private String groupId;
private String groupName;
private String address;
private String location;
private String warehouseId;
}
@lombok.Data
public static class WareHouse {
private String wareHouseId;
private String wareHouseName;
private String address;
private String location;
}
@lombok.Data
public static class EngineerCenterUpdateReqDTO {
private String engineerCode;
private String address;
private String location;
}
}
...@@ -44,5 +44,6 @@ public class ScheduleOverviewResp { ...@@ -44,5 +44,6 @@ public class ScheduleOverviewResp {
private Integer fixNum; private Integer fixNum;
private Integer designNum; private Integer designNum;
private Integer cleanNum; private Integer cleanNum;
private Integer reformNum;
} }
} }
package com.dituhui.pea.order.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author zhangx
*/
@Data
@Entity
@Table(name = "engineer_business")
public class EngineerBusinessEntity implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
@Column(name = "engineer_code")
private String engineerCode;
@Column(name = "max_num")
private Integer maxNum;
@Column(name = "max_minute")
private Integer maxMinute;
@Column(name = "max_distance")
private Integer maxDistance;
private String address;
@Column(name = "x")
private String X;
@Column(name = "y")
private String Y;
private Integer priority;
private Integer departure;
private String memo;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time")
private LocalDateTime createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "update_time")
private LocalDateTime updateTime;
}
\ No newline at end of file
...@@ -17,7 +17,7 @@ public class OrgGroup { ...@@ -17,7 +17,7 @@ public class OrgGroup {
private String cityCode; private String cityCode;
private Integer kind; private Integer kind;
private Integer category; private Integer category;
private Integer warehouseId; private String warehouseId;
private String memo; private String memo;
private Timestamp createTime; private Timestamp createTime;
private Timestamp updateTime; private Timestamp updateTime;
......
...@@ -71,7 +71,7 @@ public class OrgGroupEntity { ...@@ -71,7 +71,7 @@ public class OrgGroupEntity {
/** /**
* 默认配件仓 * 默认配件仓
*/ */
private Integer warehouseId; private String warehouseId;
/** /**
* 备注 * 备注
......
...@@ -9,7 +9,7 @@ import java.time.LocalDateTime; ...@@ -9,7 +9,7 @@ import java.time.LocalDateTime;
@Data @Data
@Entity @Entity
@Table(name="org_warehouse_info") @Table(name = "org_warehouse_info")
public class OrgWarehouseInfoEntity { public class OrgWarehouseInfoEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
package com.dituhui.pea.order.service;
import com.dituhui.pea.order.dto.EngineerBusinessDTO;
import java.util.List;
public interface EngineerBusinessService {
List<EngineerBusinessDTO.Engineer> getEngineerCenterList(EngineerBusinessDTO.Request engineerReq);
EngineerBusinessDTO.Group getGroupInfo(EngineerBusinessDTO.Request engineerReq);
EngineerBusinessDTO.WareHouse getWareHouse(String wareHouseId);
void updateEngineerCenter(EngineerBusinessDTO.EngineerCenterUpdateReqDTO centerReq );
}
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.order.dao.EngineerBusinessDao;
import com.dituhui.pea.order.dao.EngineerInfoDao;
import com.dituhui.pea.order.dao.OrgGroupDao;
import com.dituhui.pea.order.dao.WarehouseInfoDao;
import com.dituhui.pea.order.dto.EngineerBusinessDTO;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.EngineerBusinessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Service
public class EngineerBusinessServiceImpl implements EngineerBusinessService {
@Autowired
private OrgGroupDao orgGroupDao;
@Autowired
private EngineerBusinessDao engineerBusinessDao;
@Autowired
private EngineerInfoDao engineerInfoDao;
@Autowired
private WarehouseInfoDao warehouseInfoDao;
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public List<EngineerBusinessDTO.Engineer> getEngineerCenterList(EngineerBusinessDTO.Request engineerReq) {
String sql = "select a.engineer_code , b.address, b.x, b.y from engineer_info a left join engineer_business b on a.engineer_code= b.engineer_code\n" +
" where a.group_id=?";
// 创建一个新的BeanPropertyRowMapper对象
RowMapper<EngineerBusinessEntity> rowMapper = new BeanPropertyRowMapper<>(EngineerBusinessEntity.class);
List<EngineerBusinessEntity> engineerEntiryList = this.jdbcTemplate.query(sql, rowMapper, engineerReq.getLevelValue());
Map<String, String> codeNameMap = engineerInfoDao.findByGroupId(engineerReq.getLevelValue()).stream().collect(Collectors.toMap(EngineerInfoEntity::getEngineerCode, EngineerInfoEntity::getName));
return engineerEntiryList.stream().map(item -> {
EngineerBusinessDTO.Engineer engineer = new EngineerBusinessDTO.Engineer();
engineer.setEngineerCode(item.getEngineerCode());
engineer.setEngineerName(codeNameMap.getOrDefault(item.getEngineerCode(), item.getEngineerCode()));
engineer.setAddress(item.getAddress() == null ? "" : item.getAddress());
if (item.getX() == null) {
engineer.setLocation("");
} else {
engineer.setLocation(item.getX() + "," + item.getY());
}
return engineer;
}).collect(Collectors.toList());
}
@Override
public EngineerBusinessDTO.Group getGroupInfo(EngineerBusinessDTO.Request engineerReq) {
OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(engineerReq.getLevelValue());
EngineerBusinessDTO.Group result = new EngineerBusinessDTO.Group();
if (groupEntity != null) {
result.setGroupId(groupEntity.getGroupId());
result.setGroupName(groupEntity.getGroupName());
result.setAddress(groupEntity.getAddress());
result.setLocation(groupEntity.getX() + "," + groupEntity.getY());
result.setWarehouseId(groupEntity.getWarehouseId());
}
return result;
}
@Override
public EngineerBusinessDTO.WareHouse getWareHouse(String wareHouseId) {
OrgWarehouseInfoEntity item = warehouseInfoDao.getOrgWarehouseInfoEntityByWarehouseId(wareHouseId);
EngineerBusinessDTO.WareHouse wareHouse = new EngineerBusinessDTO.WareHouse();
if (item != null) {
wareHouse.setWareHouseId(item.getWarehouseId());
wareHouse.setWareHouseName(item.getWarehouseName());
wareHouse.setAddress(item.getAddress());
wareHouse.setLocation(item.getX() + "," + item.getY());
}
return wareHouse;
}
@Override
public void updateEngineerCenter(EngineerBusinessDTO.EngineerCenterUpdateReqDTO centerReq) {
String location = centerReq.getLocation();
String[] xyArr = location.split(",");
engineerBusinessDao.updateEngineerCenter(centerReq.getAddress(), xyArr[0], xyArr[1], centerReq.getEngineerCode());
}
}
...@@ -342,17 +342,18 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -342,17 +342,18 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
private List<KV> packOrderDetail(OrderRequest order) { private List<KV> packOrderDetail(OrderRequest order) {
List<KV> items = new ArrayList<>(); List<KV> items = new ArrayList<>();
items.add(this.packOrderItem("客户姓名", order.getName())); items.add(this.packOrderItem("客户姓名", order.getName()));
items.add(this.packOrderItem("标签", order.getTags()));
items.add(this.packOrderItem("客户电话", order.getPhone())); items.add(this.packOrderItem("客户电话", order.getPhone()));
items.add(this.packOrderItem("客户地址", String.format("%s%s%s",order.getCity(), order.getCounty(), order.getAddress())));
items.add(this.packOrderItem("品牌", order.getBrand()));
items.add(this.packOrderItem("设备", order.getType())); items.add(this.packOrderItem("设备", order.getType()));
items.add(this.packOrderItem("服务", order.getSkill())); items.add(this.packOrderItem("服务", order.getSkill()));
items.add(this.packOrderItem("故障描述", order.getFaultDescribe())); items.add(this.packOrderItem("故障描述", order.getFaultDescribe()));
items.add(this.packOrderItem("备注", order.getApplyNote()));
log.info("======= 意向时间111 {}", order.getExpectTimeBegin());
items.add(this.packOrderItem("意向时间", TimeUtils.IsoTimestamp2DateTime(order.getExpectTimeBegin()))); items.add(this.packOrderItem("意向时间", TimeUtils.IsoTimestamp2DateTime(order.getExpectTimeBegin())));
log.info("======= 意向时间222 {}", TimeUtils.IsoTimestamp2DateTime(order.getExpectTimeBegin()));
items.add(this.packOrderItem("时间要求", order.getExpectTimeDesc())); items.add(this.packOrderItem("时间要求", order.getExpectTimeDesc()));
items.add(this.packOrderItem("预约方式", order.getSource())); items.add(this.packOrderItem("预约方式", order.getSource()));
items.add(this.packOrderItem("标签", order.getTags()));
items.add(this.packOrderItem("创建时间", TimeUtils.IsoTimestamp2DateTime(order.getCreateTime())));
items.add(this.packOrderItem("备注", order.getApplyNote()));
return items; return items;
} }
......
...@@ -291,8 +291,9 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -291,8 +291,9 @@ public class ScheduleServiceImpl implements ScheduleService {
s.setTotal(orders.size()); s.setTotal(orders.size());
s.setInstallNum(skillCounter.getOrDefault("安装", 0)); s.setInstallNum(skillCounter.getOrDefault("安装", 0));
s.setFixNum(skillCounter.getOrDefault("维修", 0)); s.setFixNum(skillCounter.getOrDefault("维修", 0));
s.setDesignNum(skillCounter.getOrDefault("整改", 0)); s.setDesignNum(0); // 前端接口已废弃
s.setCleanNum(skillCounter.getOrDefault("清洁保养", 0)); s.setCleanNum(skillCounter.getOrDefault("清洁保养", 0));
s.setReformNum(skillCounter.getOrDefault("整改", 0));
return s; return s;
} }
......
...@@ -7,17 +7,14 @@ import org.springframework.validation.annotation.Validated; ...@@ -7,17 +7,14 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
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;
import com.dituhui.pea.pojo.ThirdUserInfo; import com.dituhui.pea.pojo.ThirdUserInfo;
import com.dituhui.pea.pojo.UserAuthInfo;
import com.dituhui.pea.pojo.UserInfo; import com.dituhui.pea.pojo.UserInfo;
import com.dituhui.pea.pojo.UserLoginDTO; import com.dituhui.pea.pojo.UserLoginDTO;
import com.dituhui.pea.pojo.UserLoginParam; import com.dituhui.pea.pojo.UserLoginParam;
import com.dituhui.pea.pojo.WebResult; import com.dituhui.pea.pojo.WebResult;
import com.dituhui.pea.user.IUser; import com.dituhui.pea.user.IUser;
import com.dituhui.pea.user.commom.RedisService;
import com.dituhui.pea.user.service.UserService; import com.dituhui.pea.user.service.UserService;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
...@@ -43,6 +40,11 @@ public class UserController implements IUser { ...@@ -43,6 +40,11 @@ public class UserController implements IUser {
} }
@Override @Override
public Result<Boolean> refreshAppkey() {
return userService.refreshAppkey();
}
@Override
public WebResult<UserInfo> getCurrentUserInfo(String userToken, Boolean needTeamInfo) { public WebResult<UserInfo> getCurrentUserInfo(String userToken, Boolean needTeamInfo) {
return null; return null;
} }
......
package com.dituhui.pea.user.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import com.dituhui.pea.user.entity.AppEntity;
import com.dituhui.pea.user.entity.ResourceEntity;
/**
* app表 管理ak表的数据库访问层
*
*/
public interface AppDao extends JpaRepository<AppEntity, String>,
JpaSpecificationExecutor<AppEntity>, CrudRepository<AppEntity, String> {
/**
* 查询key信息
*
* @param key
* @return
*/
ResourceEntity findByKey(String key);
}
package com.dituhui.pea.user.entity;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
/**
* 应用ak表 管理不同关联方使用的不同ak
*
*/
@Data
@Entity
@Table(name = "sys_app")
@EntityListeners(AuditingEntityListener.class)
public class AppEntity implements Serializable {
private static final long serialVersionUID = 157258775707540233L;
/**
* 主键
*/
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid")
@Column(name = "ID", unique = true, nullable = false, length = 32)
private String id;
/**
* 名称
*/
@Column(name = "name")
@NotBlank(message = "名称不能为空!")
private String name;
/**
* key
*/
@Column(name = "key")
private String key;
/**
* secret
*/
@Column(name = "secret")
private String secret;
/**
* 创建人
*/
@Column(name = "CREATED_BY")
private String createdBy;
/**
* 创建时间
*/
@Column(name = "CREATED_TIME")
@CreatedDate
private Date createdTime;
/**
* 更新人
*/
@Column(name = "UPDATED_BY")
private String updatedBy;
/**
* 更新时间
*/
@Column(name = "UPDATED_TIME")
@LastModifiedDate
private Date updatedTime;
}
...@@ -23,6 +23,7 @@ import com.dituhui.pea.enums.StatusCodeEnum; ...@@ -23,6 +23,7 @@ import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.enums.ThirdPartyEnum; import com.dituhui.pea.enums.ThirdPartyEnum;
import com.dituhui.pea.exception.BusinessException; import com.dituhui.pea.exception.BusinessException;
import com.dituhui.pea.order.IOrganization; import com.dituhui.pea.order.IOrganization;
import com.dituhui.pea.pojo.AppDTO;
import com.dituhui.pea.pojo.OrganizationDTO; import com.dituhui.pea.pojo.OrganizationDTO;
import com.dituhui.pea.pojo.ResourceInfo; import com.dituhui.pea.pojo.ResourceInfo;
import com.dituhui.pea.pojo.RoleInfo; import com.dituhui.pea.pojo.RoleInfo;
...@@ -31,11 +32,13 @@ import com.dituhui.pea.pojo.UserInfo; ...@@ -31,11 +32,13 @@ import com.dituhui.pea.pojo.UserInfo;
import com.dituhui.pea.pojo.UserLoginDTO; import com.dituhui.pea.pojo.UserLoginDTO;
import com.dituhui.pea.user.commom.RedisService; import com.dituhui.pea.user.commom.RedisService;
import com.dituhui.pea.user.constant.TextConstant; import com.dituhui.pea.user.constant.TextConstant;
import com.dituhui.pea.user.dao.AppDao;
import com.dituhui.pea.user.dao.ResourceDao; import com.dituhui.pea.user.dao.ResourceDao;
import com.dituhui.pea.user.dao.RoleDao; import com.dituhui.pea.user.dao.RoleDao;
import com.dituhui.pea.user.dao.RoleResourceDao; import com.dituhui.pea.user.dao.RoleResourceDao;
import com.dituhui.pea.user.dao.UserDao; import com.dituhui.pea.user.dao.UserDao;
import com.dituhui.pea.user.dao.UserRoleDao; import com.dituhui.pea.user.dao.UserRoleDao;
import com.dituhui.pea.user.entity.AppEntity;
import com.dituhui.pea.user.entity.ResourceEntity; import com.dituhui.pea.user.entity.ResourceEntity;
import com.dituhui.pea.user.entity.RoleEntity; import com.dituhui.pea.user.entity.RoleEntity;
import com.dituhui.pea.user.entity.RoleResourceEntity; import com.dituhui.pea.user.entity.RoleResourceEntity;
...@@ -68,6 +71,10 @@ public class UserService { ...@@ -68,6 +71,10 @@ 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;
...@@ -93,6 +100,9 @@ public class UserService { ...@@ -93,6 +100,9 @@ public class UserService {
@Autowired @Autowired
IOrganization organizationService; IOrganization organizationService;
@Autowired
AppDao appDao;
public Result<UserLoginDTO> userLogin(String account, String password) { public Result<UserLoginDTO> userLogin(String account, String password) {
UserEntity user = userDao.findByAccountAndPassword(account, SecureUtil.md5(password)); UserEntity user = userDao.findByAccountAndPassword(account, SecureUtil.md5(password));
log.info("{}/{} login", account, password); log.info("{}/{} login", account, password);
...@@ -121,13 +131,22 @@ public class UserService { ...@@ -121,13 +131,22 @@ public class UserService {
.collect(Collectors.toList())); .collect(Collectors.toList()));
// 获取资源 // 获取资源
List<ResourceEntity> resources = null;
if (ids.contains(SUPER_ADMIN_ID)) {
// 超管处理,不用配置资源自动拥有所有权限
resources = resourceDao.findAll();
} else {
// 普通用户
List<RoleResourceEntity> roleResources = roleResourceDao.findByRoleIdIn(ids); List<RoleResourceEntity> roleResources = roleResourceDao.findByRoleIdIn(ids);
log.info("role : {} roleResources:{}", ids, CollectionUtils.isNotEmpty(roleResources)); log.info("role : {} roleResources:{}", ids, CollectionUtils.isNotEmpty(roleResources));
if (CollectionUtils.isNotEmpty(roleResources)) { if (CollectionUtils.isNotEmpty(roleResources)) {
List<String> resourceIds = roleResources.stream().map(r -> r.getResourceId()) List<String> resourceIds = roleResources.stream().map(r -> r.getResourceId())
.collect(Collectors.toList()); .collect(Collectors.toList());
List<ResourceEntity> resources = resourceDao.findAllById(resourceIds); resources = resourceDao.findAllById(resourceIds);
}
}
if (CollectionUtils.isNotEmpty(resources)) {
// 菜单嵌套处理+菜单排序 // 菜单嵌套处理+菜单排序
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)
...@@ -570,4 +589,33 @@ public class UserService { ...@@ -570,4 +589,33 @@ public class UserService {
} }
toUserEntity.setSex(formUserInfo.getSex()); toUserEntity.setSex(formUserInfo.getSex());
} }
public Result<Boolean> refreshAppkey() {
// 超级管理员才能执行此命令
// RoleEntity role = null;
// List<UserRoleEntity> userRoles = userRoleDao.findByUserId(userId);
// if (CollectionUtils.isNotEmpty(userRoles)) {
// List<String> ids = userRoles.stream().map(r -> r.getRoleId()).collect(Collectors.toList());
// List<RoleEntity> roles = roleDao.findAllById(ids);
// if (CollectionUtils.isNotEmpty(roles)) {
// role = roles.stream().filter(r -> StringUtils.equals(r.getId(), SUPER_ADMIN_ID)).findFirst()
// .orElse(null);
// }
// }
// if (null == role) {
// return Result.failure("超级管理员才能执行此命令");
// }
// 缓存所有key
List<AppEntity> keyList = appDao.findAll();
if (CollectionUtils.isNotEmpty(keyList)) {
for (AppEntity appkey : keyList) {
redisService.set(RedisKeyGroup.appKey + ":" + appkey.getKey(),
gson.toJson(BeanUtil.copyProperties(appkey, AppDTO.class)));
}
}
return Result.success(true);
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!