Commit c838ec90 by chamberone

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

…oject.git into develop
2 parents c140a1dc 950a2985
Showing with 414 additions and 263 deletions
......@@ -19,7 +19,8 @@ import java.util.List;
@Slf4j
public class SaasUtils {
@Value("${SaaS.ak}")
// todo
@Value("284c57cbabad4755a9c657885a8df3e2")
String ak;
@Value("${SaaS.url}")
......@@ -56,9 +57,9 @@ public class SaasUtils {
assert rs != null;
for (SaasXyFendanDTO.AreaInfo r : rs.getResult()) {
// 分单接口暂时无图层返回
if (r.getField2() != null && r.getField1() != null) {
if (r.getField3() != null && r.getField1() != null) {
blocks.add(new BlockInfo()
.setBlockId(r.getField2())
.setBlockId(r.getField3())
.setBlockName(r.getField1()));
}
}
......
package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.EngineerCalendarDTO;
import com.dituhui.pea.order.service.EngineerCalendarService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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-order")
public class EngineerCalendarController {
@Autowired
EngineerCalendarService engineerCalendarService;
@GetMapping("/engineer/calendar")
public Result<?> getEngineerCalendar(@Validated EngineerCalendarDTO.Request reqDTO) {
Result<?> res = null;
try {
res = engineerCalendarService.getEngineersCalendar(reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@GetMapping("/engineer/calendar/type/list")
public Result<?> getCalendarTypeList() {
Result<?> res = null;
try {
res = engineerCalendarService.getCalendarTypeList();
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
}
......@@ -41,6 +41,7 @@ public class EngineerCenterPoiController {
result.setGroup(engineerBusinessService.getGroupInfo(engineerReq));
result.setWarehouse(engineerBusinessService.getWareHouse(result.getGroup().getWarehouseId()));
result.setBlocks(engineerBusinessService.getBlocks(engineerReq));
res = Result.success(result);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
......
......@@ -151,15 +151,4 @@ public class EngineerController {
}
return res;
}
@GetMapping("/engineer/calendar")
public Result<?> getEngineerCalendar(@Validated EngineerCalendarDTO.Request reqDTO) {
Result<?> res = null;
try {
res = engineerCalendarService.getEngineersCalendar(reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
}
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.EngineerSkillGroupEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
public interface EngineerSkillGroupDao extends JpaRepository<EngineerSkillGroupEntity, Integer> {
List<EngineerSkillGroupEntity> findByEngineerCode(String engineerCode);
List<EngineerSkillGroupEntity> findByEngineerCodeAndStatus(String engineerCode, boolean status);
List<EngineerSkillGroupEntity> findByEngineerCodeInAndStatus(List<String> engineerCodes, boolean status);
List<EngineerSkillGroupEntity> findBySkillGroupCode(String skillGroupCode);
List<EngineerSkillGroupEntity> findBySkillGroupCodeAndStatus(String skillGroupCode, boolean status);
}
......@@ -14,6 +14,8 @@ public interface MapBlockInfoDao extends JpaRepository<MapBlockInfoEntity, Integ
MapBlockInfoEntity findByBlockId(String blockId);
List<MapBlockInfoEntity> findByGroupId(String groupId);
List<MapBlockInfoEntity> findByLayerId(String layerId);
}
......@@ -8,10 +8,13 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
@Repository
public interface OrderEventDao extends JpaRepository<OrderEventEntity, Integer> {
List<OrderEventEntity> findByOrderId(String orderId);
@Query("select a from OrderEventEntity a join OrderInfoEntity b on a.orderId=b.orderId where b.orgClusterId = :clusterId and DATE(a.createTime) = :date")
Page<OrderEventEntity> findAllByClusterId(String clusterId, Date date, Pageable pageable);
......
......@@ -9,6 +9,9 @@ import java.util.List;
public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long> {
OrderInfoEntity getByOrderId(String orderId);
OrderInfoEntity getByOrderIdAndDt(String orderId, LocalDate dt);
List<OrderInfoEntity> findByOrderId(String orderId);
List<OrderInfoEntity> findByDtAndEngineerCodeIn(LocalDate date, List<String> engineerCodes);
......
package com.dituhui.pea.order.dto;
import java.util.List;
public class CalendarBatAddDTO {
@lombok.Data
public static class Request {
/**
* 结束时间;如果是全天只需要填写日期;否则填写日期+时间
*/
private String end;
/**
* 技术员code列表
*/
private List<String> engineerCodes;
/**
* 是否全天
*/
private long isAllday;
/**
* 备注
*/
private String remark;
/**
* 重复截止日期
*/
private String repeatEndDate;
/**
* 重复类型
*/
private String repeatType;
/**
* 开始时间;如果是全天只需要填写日期;否则填写日期+时间
*/
private String start;
/**
* 日程类型
*/
private String type;
}
}
package com.dituhui.pea.order.dto;
import java.util.List;
public class CalendarBatDelDTO {
@lombok.Data
public static class Request {
/**
* 结束时间
*/
private String endDate;
/**
* 技术员code列表
*/
private List<String> engineerCodes;
/**
* 开始时间
*/
private String startDate;
/**
* 日程类型
*/
private String type;
}
}
package com.dituhui.pea.order.dto;
public class CalendarDeleteDTO {
@lombok.Data
public static class Request {
private String engineerCode;
private String planId;
}
}
package com.dituhui.pea.order.dto;
import java.time.LocalDateTime;
public class CalendarDetailDTO {
@lombok.Data
public static class Request {
private String engineerCode;
private String planId;
}
@lombok.Data
public static class Result {
private String endTime;
private String engineerCode;
private String engineerName;
private String operator;
private String phone;
private String remark;
private LocalDateTime startTime;
private String type;
private String typeName;
private LocalDateTime updateTime;
}
}
package com.dituhui.pea.order.dto;
public class CalendarQueryNumDTO {
@lombok.Data
public static class Request {
private String code;
private String message;
private Result result;
}
@lombok.Data
public static class Result {
private long planNum;
}
}
package com.dituhui.pea.order.dto;
import lombok.Data;
import java.util.List;
public class CalendarTypeDTO {
@lombok.Data
public static class Result {
private List<Type> types;
}
@lombok.Data
public static class Type {
private BarStyle barStyle;
private TagStyle tagStyle;
private String type;
private String typeName;
}
@lombok.Data
public static class BarStyle {
private String backgroundColor;
private String color;
}
@lombok.Data
public static class TagStyle {
private String backgroundColor;
}
}
package com.dituhui.pea.order.dto;
public class CalendarUpdateDTO {
@lombok.Data
public static class Request {
private String endTime;
/**
* 技术员code
*/
private String engineerCode;
/**
* 事件id
*/
private String planId;
private String remark;
private String startTime;
}
}
......@@ -28,7 +28,7 @@ public class EngineerBusinessDTO {
private Group group;
private WareHouse warehouse;
// @JsonIgnore
// private List<Blocks> blocks;
private List<Blocks> blocks;
}
......@@ -59,6 +59,14 @@ public class EngineerBusinessDTO {
private String location;
}
@lombok.Data
public static class Blocks {
private String blockId;
private String blockName;
private String blockData;
private String teamId;
}
@lombok.Data
public static class EngineerCenterUpdateReqDTO {
......
......@@ -34,10 +34,10 @@ public class CapacityEngineerCalendarEntity {
private String memo;
@Column(name = "create_time", nullable = false, updatable = false, columnDefinition = "timestamp default current_timestamp")
private Timestamp createTime;
private LocalDateTime createTime = LocalDateTime.now();
@Column(name = "update_time", nullable = false, columnDefinition = "timestamp default current_timestamp on update current_timestamp")
private Timestamp updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
// 其他字段和关联关系的定义
// ...
......
......@@ -63,10 +63,10 @@ public class CapacityEngineerStatEntity {
/**
* 创建时间
*/
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
/**
* 更新时间
*/
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
}
......@@ -68,11 +68,11 @@ public class CapacityOrgStatEntity {
/**
* 创建时间
*/
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
/**
* 更新时间
*/
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
}
......@@ -58,9 +58,9 @@ public class CapacityTeamStatEntity implements Serializable {
private String memo;
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
}
......@@ -69,11 +69,11 @@ public class EngineerBusinessEntity implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time", nullable = false, updatable = false, columnDefinition = "timestamp default current_timestamp")
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "update_time", nullable = false, columnDefinition = "timestamp default current_timestamp on update current_timestamp")
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
}
......@@ -100,12 +100,12 @@ public class EngineerInfoEntity {
/**
* 创建时间
*/
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
/**
* 更新时间
*/
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
public EngineerInfoEntity() {}
}
......@@ -24,7 +24,7 @@ public class OrderEventEntity {
private String suborderId;
@Column(name = "happen", nullable = false, columnDefinition = "timestamp default current_timestamp on update current_timestamp")
private LocalDateTime happen;
private LocalDateTime happen = LocalDateTime.now();
@Column(name = "event", nullable = false, length = 50, columnDefinition = "varchar(50) default ''")
private String event;
......@@ -45,10 +45,10 @@ public class OrderEventEntity {
private String memo;
@Column(name = "create_time", nullable = false, columnDefinition = "datetime default current_timestamp")
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
@Column(name = "update_time", nullable = false, columnDefinition = "datetime default current_timestamp")
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
// Getters and setters (省略)
}
......
......@@ -170,10 +170,10 @@ public class OrderInfoEntity {
private String extraInfo;
@Column(name = "create_time", nullable = true, columnDefinition = "timestamp default current_timestamp")
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
@Column(name = "update_time", nullable = true, columnDefinition = "timestamp default current_timestamp on update current_timestamp")
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
// Getters and setters (omitted for brevity)
}
package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Data
@Entity
@Table(name = "order_request")
public class OrderRequestEntity {
@Id
private String id;
@Column(name = "order_id", nullable = false)
private String orderId;
@Column(nullable = false)
private LocalDate dt;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String phone;
@Column(nullable = false)
private String address;
@Column(nullable = false)
private String x;
@Column(nullable = false)
private String y;
@Column
private String province;
@Column
private String city;
@Column
private String county;
@Column(nullable = false)
private String brand;
@Column(nullable = false)
private String type;
@Column(nullable = false)
private String skill;
@Column(name = "apply_note")
private String applyNote;
@Column(name = "fault_describe")
private String faultDescribe;
@Column(name = "expect_time_begin", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime expectTimeBegin;
@Column(name = "expect_time_end")
private LocalDateTime expectTimeEnd;
@Column(name = "expect_time_desc")
private String expectTimeDesc;
@Column
private String source;
@Column(name = "area_id")
private String areaId;
@Column(name = "order_priority")
private String orderPriority;
@Column(name = "order_tags")
private String orderTags;
@Column
private Integer priority;
@Column
private String tags;
@Column(nullable = false)
private String status;
@Column(name = "appointment_status", nullable = false)
private String appointmentStatus;
@Column(name = "appointment_method", nullable = false)
private String appointmentMethod;
@Column(name = "org_cluster_id")
private String orgClusterId;
@Column(name = "org_cluster_name")
private String orgClusterName;
@Column(name = "org_branch_id")
private String orgBranchId;
@Column(name = "org_branch_name")
private String orgBranchName;
@Column(name = "org_group_id")
private String orgGroupId;
@Column(name = "org_group_name")
private String orgGroupName;
@Column(name = "org_team_id")
private String orgTeamId;
@Column(name = "org_team_name")
private String orgTeamName;
@Column
private String description;
@Column(name = "create_time", nullable = 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;
// Getters and Setters
// ...
}
......@@ -19,6 +19,6 @@ public class OrderTagStrategyEntity {
private Integer priority;
private Integer disabled;
private String memo;
private LocalDateTime createTime;
private LocalDateTime updateTime;
private LocalDateTime createTime = LocalDateTime.now();
private LocalDateTime updateTime = LocalDateTime.now();
}
......@@ -45,10 +45,10 @@ public class OrgBranchEntity {
private String memo;
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
public OrgBranchEntity() {}
}
......@@ -37,10 +37,10 @@ public class OrgClusterEntity {
private String updateUser;
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
public OrgClusterEntity() {
}
......
......@@ -81,12 +81,12 @@ public class OrgGroupEntity {
/**
* 创建时间
*/
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
/**
* 更新时间
*/
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
public OrgGroupEntity() {}
}
......@@ -45,12 +45,12 @@ public class OrgTeamEngineerEntity {
/**
* 创建时间
*/
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
/**
* 更新时间
*/
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
public OrgTeamEngineerEntity() {
}
......
......@@ -90,11 +90,11 @@ public class OrgWarehouseInfoEntity {
/**
* 创建时间
*/
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
/**
* 更新时间
*/
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
}
......@@ -50,10 +50,10 @@ public class PubParamsEntity {
/**
* 创建时间
*/
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
/**
* 更新时间
*/
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
}
......@@ -30,10 +30,10 @@ public class SkillGroupEntity {
private String memo;
@Column(name = "create_time", nullable = false, columnDefinition = "datetime DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
@Column(name = "update_time", nullable = false, columnDefinition = "datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
// Getters and Setters
// ...
......
......@@ -58,10 +58,10 @@ public class SkillInfoEntity {
private String memo;
@Column(name = "create_time", nullable = false, columnDefinition = "datetime DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
@Column(name = "update_time", nullable = false, columnDefinition = "datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
// Getters and Setters
// ...
......
......@@ -12,4 +12,6 @@ public interface EngineerBusinessService {
EngineerBusinessDTO.WareHouse getWareHouse(String wareHouseId);
void updateEngineerCenter(EngineerBusinessDTO.EngineerCenterUpdateReqDTO centerReq );
List<EngineerBusinessDTO.Blocks> getBlocks(EngineerBusinessDTO.Request engineerReq);
}
......@@ -6,4 +6,6 @@ import com.dituhui.pea.order.dto.EngineerCalendarDTO;
public interface EngineerCalendarService {
Result<?> getEngineersCalendar(EngineerCalendarDTO.Request engineerCalendarReq);
Result<?> getCalendarTypeList();
}
......@@ -181,9 +181,11 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
}
String blockId = saasResult.getResult();
String blockName = String.format("%s_%s", layerName, team.getTeamName()); //区块名称
MapBlockInfo block = new MapBlockInfo();
block.setBlockId(blockId);
block.setBlockName(team.getTeamName()); //默认使用team name;
block.setBlockName(blockName);
block.setBranchId(team.getBranchId());
block.setGroupId(team.getGroupId());
block.setTeamId(teamId);
......
......@@ -51,8 +51,8 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
public Result<?> queryMatchCapacityData(CapacityOrderQueryDTO.Request reqDTO) {
// 单条容量查询
log.info("===> queryMatchCapacityData()");
List<String> layerIds = capacityUtils.getLayers(reqDTO.getBrand(), reqDTO.getType(), reqDTO.getSkill());
String peaBrand = fixBrand(reqDTO.getBrand());
List<String> layerIds = capacityUtils.getLayers(peaBrand, reqDTO.getType(), reqDTO.getSkill());
// 同步到saas,返回blockId
List<String> blockIds = null;
......@@ -61,12 +61,12 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
} else {
blockIds = saasUtils.queryBlocksByAddress(reqDTO.getAddress()).stream().map(SaasUtils.BlockInfo::getBlockId).collect(Collectors.toList());
}
if (blockIds.size() == 0) {
if (blockIds.isEmpty()) {
log.error("分单接口没有查到对应的结果");
Result.failed(String.format("分单接口(address:%s)(location:%s) 没有查到配置区块", reqDTO.getAddress(), reqDTO.getLocation()));
}
List<String> teamIds = capacityUtils.getTeamIdsByBlockIdsAndLayerIds(blockIds, layerIds);
if (teamIds == null || teamIds.size() == 0) {
if (teamIds == null || teamIds.isEmpty()) {
return Result.failed("没有找到匹配的工作队");
}
......@@ -77,13 +77,13 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
.map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList());
log.info("======= enginerCode: {}", engineerCodes);
List<String> matchEngineerCodes = engineerSkillDao.findAllByBrandAndTypeAndSkillAndEngineerCodeIn(reqDTO.getBrand(), reqDTO.getType(), reqDTO.getSkill(), engineerCodes).stream()
List<String> matchEngineerCodes = engineerSkillDao.findAllByBrandAndTypeAndSkillAndEngineerCodeIn(peaBrand, reqDTO.getType(), reqDTO.getSkill(), engineerCodes).stream()
.map(EngineerSkillEntity::getEngineerCode).collect(Collectors.toList());
log.info("======= matchEngineerCodes: {}", matchEngineerCodes);
log.info("符合技能要求的工作队[{}]符合技能要求的技术员[{}]", teamId, matchEngineerCodes);
SkillInfoEntity skillInfoEntity = skillInfoDao.getByBrandAndTypeAndSkill(reqDTO.getBrand(), reqDTO.getType(), reqDTO.getSkill());
SkillInfoEntity skillInfoEntity = skillInfoDao.getByBrandAndTypeAndSkill(peaBrand, reqDTO.getType(), reqDTO.getSkill());
List<CapacityOrderQueryDTO.CalendarDTO> calendars = getSummaryOfEngineersCapacity(teamId, matchEngineerCodes, reqDTO.getStartDate(), reqDTO.getEndDate(), skillInfoEntity.getTakeTime());
CapacityOrderQueryDTO.Result rs = new CapacityOrderQueryDTO.Result();
......@@ -179,4 +179,12 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
calendar.setTimes(List.of(timeDTO));
return calendar;
}
private String fixBrand(String brand){
if (!brand.equals("嘉格纳")){
return "博世/西门子以及其他品牌";
} else {
return brand;
}
}
}
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.dao.*;
import com.dituhui.pea.order.dto.EngineerBusinessDTO;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.EngineerBusinessService;
......@@ -37,6 +34,8 @@ public class EngineerBusinessServiceImpl implements EngineerBusinessService {
@Autowired
private WarehouseInfoDao warehouseInfoDao;
@Autowired
private MapBlockInfoDao mapBlockInfoDao;
@Autowired
private JdbcTemplate jdbcTemplate;
......@@ -115,4 +114,18 @@ public class EngineerBusinessServiceImpl implements EngineerBusinessService {
String[] xyArr = location.split(",");
engineerBusinessDao.updateEngineerCenter(centerReq.getAddress(), xyArr[0], xyArr[1], centerReq.getEngineerCode());
}
@Override
public List<EngineerBusinessDTO.Blocks> getBlocks(EngineerBusinessDTO.Request engineerReq) {
List<MapBlockInfoEntity> blockInfoList = mapBlockInfoDao.findByGroupId(engineerReq.getLevelValue());
return blockInfoList.stream().map(item -> {
EngineerBusinessDTO.Blocks block = new EngineerBusinessDTO.Blocks();
block.setBlockId(item.getBlockId());
block.setBlockName(item.getBlockName());
block.setBlockData(item.getAreaData());
block.setTeamId(item.getTeamId());
return block;
}).collect(Collectors.toList());
}
}
......@@ -7,11 +7,16 @@ import com.dituhui.pea.order.common.EngineerUtils;
import com.dituhui.pea.order.dao.CapacityEngineerCalendarDao;
import com.dituhui.pea.order.dao.OrgTeamDao;
import com.dituhui.pea.order.dao.OrgTeamEngineerDao;
import com.dituhui.pea.order.dao.PubParamsDao;
import com.dituhui.pea.order.dto.CalendarTypeDTO;
import com.dituhui.pea.order.dto.EngineerCalendarDTO;
import com.dituhui.pea.order.entity.CapacityEngineerCalendarEntity;
import com.dituhui.pea.order.entity.EngineerInfoEntity;
import com.dituhui.pea.order.entity.OrgTeamEntity;
import com.dituhui.pea.order.entity.PubParamsEntity;
import com.dituhui.pea.order.service.EngineerCalendarService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
......@@ -44,6 +49,8 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
@Autowired
private OrgTeamDao orgTeamDao;
@Autowired
private PubParamsDao pubParamsDao;
@Override
public Result<?> getEngineersCalendar(EngineerCalendarDTO.Request req) {
......@@ -72,13 +79,32 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
return Result.success(rs);
}
@Override
public Result<?> getCalendarTypeList() {
List<PubParamsEntity> entities = pubParamsDao.findByCatalogAndBiztype("CalendarType", "CalendarType");
try {
List<CalendarTypeDTO.Type> types = entities.stream().map(e -> {
try {
return new ObjectMapper().readValue(e.getPvalue(), CalendarTypeDTO.Type.class);
} catch (JsonProcessingException ex) {
throw new RuntimeException(ex);
}
}).collect(Collectors.toList());
CalendarTypeDTO.Result rs = new CalendarTypeDTO.Result();
rs.setTypes(types);
return Result.success(rs);
} catch (Exception e) {
return Result.failed(e.getMessage());
}
}
private List<EngineerCalendarDTO.Calendar> getOneEngineerCalendars(String engineerCode, String bdate, String edate) {
// 返回某一个技术员,日期范围内的日历列表
List<EngineerCalendarDTO.Calendar> calendars = new ArrayList<>();
List<String> teamIds = orgTeamEngineerDao.getTeamIdsByEngineerCode(engineerCode);
if (teamIds == null || teamIds.size() == 0) {
if (teamIds == null || teamIds.isEmpty()) {
return new ArrayList<>();
}
LocalDate startDate = LocalDate.parse(bdate);
......
......@@ -120,7 +120,8 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity.setName(req.getName());
entity.setPhone(req.getPhone());
entity.setBeanBrand(req.getBrand());
entity.setBrand(fixBrand(req.getBrand()));
String peaBrand = fixBrand(req.getBrand());
entity.setBrand(peaBrand);
entity.setType(req.getType());
entity.setSkill(req.getSkill());
entity.setFaultDescribe(req.getFaultDescribe());
......@@ -151,7 +152,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity.setAppointmentMethod("AUTO_NOW");
entity.setWorkshop(false);
SkillInfoEntity skillInfoEntity = skillInfoDao.getByBrandAndTypeAndSkill(req.getBrand(), req.getType(), req.getSkill());
SkillInfoEntity skillInfoEntity = skillInfoDao.getByBrandAndTypeAndSkill(peaBrand, req.getType(), req.getSkill());
assert skillInfoEntity != null;
entity.setTakeTime(skillInfoEntity.getTakeTime());
// 基础保存
......@@ -159,19 +160,19 @@ public class OrderCreateServiceImpl implements OrderCreateService {
// 分单处理
List<String> blockIds = null;
List<String> layerIds = capacityUtils.getLayers(req.getBrand(), req.getType(), req.getSkill());
List<String> layerIds = capacityUtils.getLayers(peaBrand, req.getType(), req.getSkill());
if (req.getLocation() != null) {
String loc = String.format("%f,%f", req.getLocation().getLng(), req.getLocation().getLat());
blockIds = saasUtils.queryBlocksByLocation(loc).stream().map(SaasUtils.BlockInfo::getBlockId).collect(Collectors.toList());
} else {
blockIds = saasUtils.queryBlocksByAddress(req.getAddress()).stream().map(SaasUtils.BlockInfo::getBlockId).collect(Collectors.toList());
}
if (blockIds.size() == 0) {
if (blockIds.isEmpty()) {
log.error("分单接口没有查到对应的结果");
return Result.failed(String.format("分单接口(address:%s)(location:%s) 没有查到配置区块", req.getAddress(), req.getLocation()));
}
List<String> teamIds = capacityUtils.getTeamIdsByBlockIdsAndLayerIds(blockIds, layerIds);
if (teamIds == null || teamIds.size() == 0) {
if (teamIds == null || teamIds.isEmpty()) {
return Result.failed("没有找到匹配的工作队");
}
// 选择一个工作队(理论上,只有1个合适的工作队),然后遍历下面的各个技术员,从符合技能的技术员中,汇总相关的容量
......
......@@ -23,32 +23,31 @@ import java.util.stream.Collectors;
public class OrderServiceDetailImpl implements OrderServiceDetail {
@Autowired
private OrderInfoMPDao orderInfoMPDao;
private OrderInfoDao orderInfoDao;
@Autowired
private EngineerInfoMPDao engineerInfoMPDao;
private EngineerInfoDao engineerInfoDao;
@Autowired
private OrderTimelineMPDao orderTimelineMPDao;
@Autowired
private OrderEventMPDao orderEventMPDao;
private OrderEventDao orderEventDao;
@Autowired
private OrgGroupMPDao orgGroupMPDao;
private OrgGroupDao orgGroupDao;
@Autowired
private EngineerSkillGroupMPDao engineerSkillGroupMPDao;
private EngineerSkillGroupDao engineerSkillGroupDao;
@Autowired
private SkillInfoMPDao skillInfoMPDao;
private SkillInfoDao skillInfoDao;
@Transactional
@Override
public Result<?> getOrderServiceDetail(String orderId) {
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
OrderInfoEntity order = orderInfoDao.getByOrderId(orderId);
List<KV> items = this.packOrderDetail(order);
......@@ -82,7 +81,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
public Result<?> getOrderServiceDynamics(String orderId) {
// 获取服务单动态
List<OrderEvent> events = this.queryOrderEvents(orderId);
List<OrderEventEntity> events = orderEventDao.findByOrderId(orderId);
// pack 动态items
List<OrderServiceDynamicsResp.Dynamics> dynamics = this.packOrderDynamics(events);
......@@ -101,7 +100,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
OrderAppointmentListResp res = new OrderAppointmentListResp();
// 查询预约单列表
List<OrderInfo> orders = orderInfoMPDao.selectByOrderId(orderId);
List<OrderInfoEntity> orders = orderInfoDao.findByOrderId(orderId);
if (orders.isEmpty()) {
// 没有指派单列表,返回
res.setOrderId(orderId);
......@@ -111,15 +110,15 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
// 获取工程师基础信息列表
Set<String> set = new HashSet<>();
orders.stream().map(OrderInfo::getEngineerCode).forEach(set::add);
orders.stream().map(OrderInfo::getEngineerCodeSub).forEach(set::add);
orders.stream().map(OrderInfoEntity::getEngineerCode).forEach(set::add);
orders.stream().map(OrderInfoEntity::getEngineerCodeSub).forEach(set::add);
List<String> engineerCodes = new ArrayList<>(set);
HashMap<String, EngineerInfo> egInfo = this.getEngineerInfos(engineerCodes);
HashMap<String, EngineerInfoEntity> egInfo = this.getEngineerInfos(engineerCodes);
// 获取groupIds 和 group信息
List<String> groupIds = egInfo.values().stream().map(EngineerInfo::getGroupId).collect(Collectors.toList());
HashMap<String, OrgGroup> groups = this.queryOrgGroups(groupIds);
List<String> groupIds = egInfo.values().stream().map(EngineerInfoEntity::getGroupId).collect(Collectors.toList());
HashMap<String, OrgGroupEntity> groups = this.queryOrgGroups(groupIds);
// 获取工程师技能列表<engineerCode, skills>
Map<String, String> egSkill = this.getEngineerSkills(engineerCodes);
......@@ -127,13 +126,13 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
// 获取subOrder订单timeline
Map<String, List<OrderTimeline>> timelines = this.getOrderTimelines(orderId);
Comparator<OrderInfo> dtDesc = Comparator.comparing(OrderInfo::getDt).reversed();
List<OrderInfo> results = orders.stream().sorted(dtDesc).collect(Collectors.toList());
Comparator<OrderInfoEntity> dtDesc = Comparator.comparing(OrderInfoEntity::getDt).reversed();
List<OrderInfoEntity> results = orders.stream().sorted(dtDesc).collect(Collectors.toList());
LocalDate lastDt = results.get(0).getDt(); //最新预约
List<OrderAppointmentListResp.OrderAppointment> items = new ArrayList<>();
for (OrderInfo o : results) {
EngineerInfo eg = egInfo.getOrDefault(o.getEngineerCode(), null);
for (OrderInfoEntity o : results) {
EngineerInfoEntity eg = egInfo.getOrDefault(o.getEngineerCode(), null);
if(eg == null) {
log.warn("未获得工程师{}基础信息, 订单:{}", o.getEngineerCode(), o.getOrderId());
continue;
......@@ -155,7 +154,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
OrderAppointmentListResp.OrderAppointment item = new OrderAppointmentListResp.OrderAppointment();
item.setTitle(title);
item.setEngineerCode(o.getEngineerCode());
item.setExpectTime(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeBegin()));
item.setExpectTime(TimeUtils.IsoLocalDateTime2String(o.getExpectTimeBegin()));
item.setTimelines(this.packOrderTimeline(timelines.getOrDefault(o.getSubId(), null)));
item.setItems(this.packEngineerItems(eg, skill, groups.get(eg.getGroupId())));
......@@ -173,7 +172,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
List<String> block = new ArrayList<>();
// 获取订单详情
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
OrderInfoEntity order = orderInfoDao.getByOrderId(orderId);
OrderTeamBlockResp res = new OrderTeamBlockResp();
res.setOrderId(orderId);
......@@ -183,37 +182,29 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return Result.success(res);
}
private List<OrderEvent> queryOrderEvents(String orderId) {
LambdaQueryWrapper<OrderEvent> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderEvent::getOrderId, orderId);
return orderEventMPDao.selectList(lqw);
}
private HashMap<String, OrgGroup> queryOrgGroups(List<String> groupIds) {
HashMap<String, OrgGroup> map = new HashMap<>();
private HashMap<String, OrgGroupEntity> queryOrgGroups(List<String> groupIds) {
HashMap<String, OrgGroupEntity> map = new HashMap<>();
if (groupIds.isEmpty()) {
return map;
}
LambdaQueryWrapper<OrgGroup> lqw = new LambdaQueryWrapper<>();
lqw.in(OrgGroup::getGroupId, groupIds);
List<OrgGroup> records = orgGroupMPDao.selectList(lqw);
for (OrgGroup r : records) {
List<OrgGroupEntity> records = orgGroupDao.findByGroupIdIn(groupIds);
for (OrgGroupEntity r : records) {
map.put(r.getGroupId(), r);
}
return map;
}
private HashMap<String, EngineerInfo> getEngineerInfos(List<String> egCodes) {
private HashMap<String, EngineerInfoEntity> getEngineerInfos(List<String> egCodes) {
// 获取工程师信息列表
HashMap<String, EngineerInfo> map = new HashMap<>();
HashMap<String, EngineerInfoEntity> map = new HashMap<>();
if (egCodes.isEmpty()) {
return map;
}
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
lqw.in(EngineerInfo::getEngineerCode, egCodes);
List<EngineerInfo> rows = engineerInfoMPDao.selectList(lqw);
List<EngineerInfoEntity> rows = engineerInfoDao.findByEngineerCodeIn(egCodes);;
for (EngineerInfo row : rows) {
for (EngineerInfoEntity row : rows) {
map.put(row.getEngineerCode(), row);
}
return map;
......@@ -226,25 +217,22 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
if (egCodes.isEmpty()) {
return map;
}
LambdaQueryWrapper<EngineerSkillGroup> lqw = new LambdaQueryWrapper<>();
lqw.select(EngineerSkillGroup::getEngineerCode, EngineerSkillGroup::getSkillGroupCode);
lqw.in(EngineerSkillGroup::getEngineerCode, egCodes);
lqw.eq(EngineerSkillGroup::getStatus, 1);
List<EngineerSkillGroup> rows = engineerSkillGroupMPDao.selectList(lqw);
List<EngineerSkillGroupEntity> rows = engineerSkillGroupDao.findByEngineerCodeInAndStatus(egCodes, true);
// 根据engineerCode排序
Comparator<EngineerSkillGroup> cmp = Comparator.comparing(EngineerSkillGroup::getEngineerCode);
List<EngineerSkillGroup> sortedResults = rows.stream().sorted(cmp).collect(Collectors.toList());
Comparator<EngineerSkillGroupEntity> cmp = Comparator.comparing(EngineerSkillGroupEntity::getEngineerCode);
List<EngineerSkillGroupEntity> sortedResults = rows.stream().sorted(cmp).collect(Collectors.toList());
// 根据engineerCode分组
Map<String, List<EngineerSkillGroup>> results = sortedResults.stream().collect(Collectors.groupingBy(EngineerSkillGroup::getEngineerCode));
Map<String, List<EngineerSkillGroupEntity>> results = sortedResults.stream().collect(
Collectors.groupingBy(EngineerSkillGroupEntity::getEngineerCode));
// 获取所有技能
HashMap<String, String> skills = this.queryAllSkills();
for (Map.Entry<String, List<EngineerSkillGroup>> entry : results.entrySet()) {
for (Map.Entry<String, List<EngineerSkillGroupEntity>> entry : results.entrySet()) {
String engineerCode = entry.getKey();
List<String> engineerSkills = new ArrayList<>();
for (EngineerSkillGroup r : entry.getValue()) {
for (EngineerSkillGroupEntity r : entry.getValue()) {
String skill = skills.getOrDefault(r.getSkillGroupCode(), "");
if (skill.isEmpty()) {
continue;
......@@ -275,15 +263,15 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
private HashMap<String, String> queryAllSkills() {
HashMap<String, String> map = new HashMap<>();
List<SkillInfo> records = skillInfoMPDao.selectList(null);
List<SkillInfoEntity> records = skillInfoDao.findAll();
Comparator<SkillInfo> cmp = Comparator.comparing(SkillInfo::getSkillGroupCode);
List<SkillInfo> sortedResults = records.stream().sorted(cmp).collect(Collectors.toList());
Map<String, List<SkillInfo>> results = sortedResults.stream().collect(Collectors.groupingBy(SkillInfo::getSkillGroupCode));
for (Map.Entry<String, List<SkillInfo>> entry : results.entrySet()) {
Comparator<SkillInfoEntity> cmp = Comparator.comparing(SkillInfoEntity::getSkillGroupCode);
List<SkillInfoEntity> sortedResults = records.stream().sorted(cmp).collect(Collectors.toList());
Map<String, List<SkillInfoEntity>> results = sortedResults.stream().collect(Collectors.groupingBy(SkillInfoEntity::getSkillGroupCode));
for (Map.Entry<String, List<SkillInfoEntity>> entry : results.entrySet()) {
String skillGroupCode = entry.getKey();
HashSet<String> categories = new HashSet<>();
for (SkillInfo s : entry.getValue()) {
for (SkillInfoEntity s : entry.getValue()) {
categories.add(String.format("%s%s", s.getTypeCategory(), s.getSkillCategory()));
}
List<String> skills = new ArrayList<>(categories);
......@@ -292,7 +280,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return map;
}
private List<KV> packEngineerItems(EngineerInfo eg, String skill, OrgGroup group) {
private List<KV> packEngineerItems(EngineerInfoEntity eg, String skill, OrgGroupEntity group) {
// 获取工程师信息
List<KV> items = new ArrayList<>();
......@@ -338,7 +326,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return items;
}
private List<KV> packOrderDetail(OrderInfo order) {
private List<KV> packOrderDetail(OrderInfoEntity order) {
List<KV> items = new ArrayList<>();
items.add(this.packOrderItem("客户姓名", order.getName()));
items.add(this.packOrderItem("客户电话", order.getPhone()));
......@@ -347,26 +335,26 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
items.add(this.packOrderItem("设备", order.getType()));
items.add(this.packOrderItem("服务", order.getSkill()));
items.add(this.packOrderItem("故障描述", order.getFaultDescribe()));
items.add(this.packOrderItem("意向时间", TimeUtils.IsoTimestamp2DateTime(order.getExpectTimeBegin())));
items.add(this.packOrderItem("意向时间", TimeUtils.IsoLocalDateTime2String(order.getExpectTimeBegin())));
items.add(this.packOrderItem("时间要求", order.getExpectTimeDesc()));
items.add(this.packOrderItem("预约方式", order.getSource()));
items.add(this.packOrderItem("标签", order.getTags()));
items.add(this.packOrderItem("创建时间", TimeUtils.IsoTimestamp2DateTime(order.getCreateTime())));
items.add(this.packOrderItem("创建时间", TimeUtils.IsoLocalDateTime2String(order.getCreateTime())));
items.add(this.packOrderItem("备注", order.getApplyNote()));
return items;
}
private List<OrderServiceDynamicsResp.Dynamics> packOrderDynamics(List<OrderEvent> events) {
private List<OrderServiceDynamicsResp.Dynamics> packOrderDynamics(List<OrderEventEntity> events) {
List<OrderServiceDynamicsResp.Dynamics> dynamics = new ArrayList<>();
// 根据happen排序
Comparator<OrderEvent> happen = Comparator.comparing(OrderEvent::getHappen);
List<OrderEvent> results = events.stream().sorted(happen).collect(Collectors.toList());
for (OrderEvent o : results) {
Comparator<OrderEventEntity> happen = Comparator.comparing(OrderEventEntity::getHappen);
List<OrderEventEntity> results = events.stream().sorted(happen).collect(Collectors.toList());
for (OrderEventEntity o : results) {
OrderServiceDynamicsResp.Dynamics d = new OrderServiceDynamicsResp.Dynamics();
d.setTitle(o.getEvent());
d.setSubTitle(String.format("操作人: %s", o.getOperatorName()));
d.setTime(TimeUtils.IsoTimestamp2DateTime(o.getHappen()));
d.setTime(TimeUtils.IsoLocalDateTime2String(o.getHappen()));
d.setMemo(o.getMemo());
dynamics.add(d);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!