Commit 225517f3 by 丁伟峰

Merge branch 'feat-warehouse'

2 parents 8fd41728 0e1263d8
Showing with 1113 additions and 468 deletions
......@@ -76,7 +76,7 @@ public class UserInfo {
/**
* 最后登录时间
*/
private Date lastLoginTime;
//private Date lastLoginTime;
/**
* 用户自定义条件
*/
......@@ -84,18 +84,18 @@ public class UserInfo {
/**
* 创建人
*/
private String createdBy;
//private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
// private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
//private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
// private Date updatedTime;
}
......@@ -19,12 +19,13 @@ package com.dituhui.pea.order;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
/**
* @author TrevorLink
*/
@SpringBootApplication
@EnableFeignClients
@EnableFeignClients(basePackages = {"com.dituhui.pea.user", "com.dituhui.pea.order"})
public class OrderServiceApplication {
public static void main(String[] args) {
......
......@@ -25,23 +25,47 @@ public class DateUtils {
return DayOfWeek.of(dayOfWeek).getDisplayName(TextStyle.SHORT, Locale.CHINESE);
}
public static String formatDateTime(LocalDateTime d, String format){
public static String formatDateTime(LocalDateTime d, String format) {
return d.format(DateTimeFormatter.ofPattern(format));
}
public static String formatDateTime(LocalDateTime d){
public static String formatDateTime(LocalDateTime d) {
return formatDateTime(d, PATTERN_DATETIME);
}
public static String formatDate(LocalDate d, String format){
public static String formatDate(LocalDate d, String format) {
return d.format(DateTimeFormatter.ofPattern(format));
}
public static String formatDate(LocalDate d){
public static String formatDate(LocalDate d) {
return formatDate(d, PATTERN_DATE);
}
public static long getAge(String birth){
public static long getAge(String birth) {
return ChronoUnit.YEARS.between(LocalDate.parse(birth), LocalDate.now());
}
public static LocalDate localDateFromStr(String dateStr) {
return localDateFromStr(dateStr, "yyyy-MM-dd");
}
public static LocalDate localDateFromStr(String str, String pattern) {
if (str.length() > pattern.length()) {
str = str.substring(0, pattern.length());
}
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
return LocalDate.parse(str, formatter);
}
public static LocalDateTime localDateTimeFromStr(String str) {
return localDateTimeFromStr(str, "yyyy-MM-dd HH:mm:ss");
}
public static LocalDateTime localDateTimeFromStr(String str, String pattern) {
if (str.length() > pattern.length()) {
str = str.substring(0, pattern.length());
}
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
return LocalDateTime.parse(str, formatter);
}
}
......@@ -74,6 +74,7 @@ public class BlockController {
}
region.setParts(parts);
}
request.setRegion(region);
res = blockService.synchronizeBlock(request.getBlockId(), request.getArea(), request.getRegion());
} catch (BusinessException e) {
......
......@@ -31,7 +31,7 @@ public class BusinessController {
}
@GetMapping("/business/team/warehouse/list")
public Result<?> getWarehouses(@Validated BusinessWarehousesDTO.Request reqDTO) {
public Result<?> getTeamWarehouses(@Validated BusinessTeamWarehousesDTO.Request reqDTO) {
Result<?> res = null;
try {
res = businessTeamService.getWarehouses(reqDTO);
......@@ -41,6 +41,17 @@ public class BusinessController {
return res;
}
@GetMapping("/business/warehouse/list")
public Result<?> getOrgWarehouses(@Validated BusinessOrgWarehousesDTO.Request reqDTO) {
Result<?> res = null;
try {
res = businessBaseService.getOrgWarehouses(reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@PostMapping("/business/team/add")
public Result<?> addTeam(@Validated @RequestBody BusinessTeamAddDTO.Request reqDTO) {
Result<?> res = null;
......
package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.*;
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.*;
import javax.servlet.http.HttpServletRequest;
import com.dituhui.pea.user.IUser;
@Slf4j
@RestController
@RequestMapping("/pea-order")
public class EngineerCalendarController {
@Autowired
EngineerCalendarService engineerCalendarService;
@Autowired
private HttpServletRequest request;
@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;
}
@GetMapping("/engineer/calendar/plan/detail")
public Result<?> getCalendarPlanDetail(@Validated CalendarDetailDTO.Request reqDTO) {
Result<?> res = null;
try {
res = engineerCalendarService.getPlanDetail(reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@PostMapping("/engineer/calendar/plan/update")
public Result<?> updateCalendarPlan(@Validated @RequestBody CalendarUpdateDTO.Request reqDTO) {
Result<?> res = null;
try {
String userId = request.getHeader("userId");
res = engineerCalendarService.updatePlan(userId, reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@PostMapping("/engineer/calendar/plan/delete")
public Result<?> deleteCalendarPlan(@Validated @RequestBody CalendarDeleteDTO.Request reqDTO) {
Result<?> res = null;
try {
String userId = request.getHeader("userId");
res = engineerCalendarService.deletePlan(userId, reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@PostMapping("/engineer/calendar/batch/add")
public Result<?> BatchAddPlan(@Validated @RequestBody CalendarBatAddDTO.Request reqDTO) {
Result<?> res = null;
try {
String userId = request.getHeader("userId");
res = engineerCalendarService.batchAddPlan(userId, reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@PostMapping("/engineer/calendar/batch/delete")
public Result<?> BatchDeletePlan(@Validated @RequestBody CalendarBatDelDTO.Request reqDTO) {
Result<?> res = null;
try {
String userId = request.getHeader("userId");
res = engineerCalendarService.batchDeletePlan(userId, reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@GetMapping("/engineer/calendar/plan/num")
public Result<?> getEngineerPlanNum(@Validated CalendarQueryNumDTO.Request reqDTO) {
Result<?> res = null;
try {
res = engineerCalendarService.queryEngineerPlanNum(reqDTO);
} 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.controller;
import javax.servlet.http.HttpServletRequest;
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.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.UserLoginDTO;
import com.dituhui.pea.order.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.dituhui.pea.pojo.UserInfo;
import com.dituhui.pea.pojo.WebResult;
import com.dituhui.pea.user.IUser;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@RestController
@RequestMapping("/pea-order")
public class UserController {
......@@ -13,13 +27,28 @@ public class UserController {
@Autowired
private UserService userService;
@Autowired
private IUser user;
@Autowired
private HttpServletRequest request;
@PostMapping("/user/login")
public Result<?> userLogin(@RequestBody UserLoginDTO user) {
return userService.userLogin(user.getAccount(), user.getAccount());
}
@GetMapping("/user/userInfo")
public Result<?> getUserInfo(@RequestHeader(name="Authorization", required = true) String authorization) {
public Result<?> getUserInfo(@RequestHeader(name = "Authorization", required = true) String authorization) {
return userService.getUserInfo(authorization, true);
}
@GetMapping("/user/test")
public Result<?> getUserRole(@RequestHeader(name = "userId", required = true) String userId) {
log.info("{} {} {}", "HttpServletRequest", request.getHeader("userId"), request.getHeader("Authorization"));
WebResult<UserInfo> result = user.queryUserById(userId);
return Result.success(result.getResult());
}
}
......@@ -2,12 +2,24 @@ package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.CapacityEngineerCalendarEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
public interface CapacityEngineerCalendarDao extends JpaRepository<CapacityEngineerCalendarEntity, Long> {
public interface CapacityEngineerCalendarDao extends JpaRepository<CapacityEngineerCalendarEntity, Integer> {
@Query("select a from CapacityEngineerCalendarEntity a where a.engineerCode=:engineerCode and a.workday between :beginDate and :endDate")
List<CapacityEngineerCalendarEntity> findCalendarByEngineerCodeAndDateBetween(String engineerCode, String beginDate, String endDate);
CapacityEngineerCalendarEntity getByPlanId(String planId);
@Query("select count(*) from CapacityEngineerCalendarEntity a where a.type = :type and a.startTime >= :startDate and a.endTime <= :endDate and a.engineerCode in :engineers")
Integer queryEngineerPlanNum(List<String> engineers, LocalDateTime startDate, LocalDateTime endDate, String type);
@Modifying
@Query("delete from CapacityEngineerCalendarEntity a where a.engineerCode in :engineerCodes and a.type = :type and a.workday between :startDate and :endDate")
void deleteByTypeAndEngineerCodesAndBetweenDates(List<String> engineerCodes, String type, String startDate, String endDate);
}
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);
}
......@@ -13,5 +13,10 @@ public interface MapBlockInfoDao extends JpaRepository<MapBlockInfoEntity, Integ
List<MapBlockInfoEntity> findByBlockIdInAndLayerIdIn(List<String> blockIds, List<String> layerIds);
MapBlockInfoEntity findByBlockId(String blockId);
List<MapBlockInfoEntity> findByGroupId(String groupId);
List<MapBlockInfoEntity> findByLayerId(String layerId);
MapBlockInfoEntity findByTeamIdAndLayerId(String teamId, String layerId);
}
......@@ -10,4 +10,8 @@ public interface MapBlockInfoMPDao extends BaseMapper<MapBlockInfo> {
@Select("select * from map_block_info where block_id=#{blockId}")
MapBlockInfo getByBlockId(String blockId);
@Select("select * from map_block_info where team_id=#{teamId} and layer_id=#{layerId}")
MapBlockInfo getByTeamIdAndLayerId(String teamId,String layerId);
}
......@@ -3,5 +3,14 @@ package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.MapLayerCustomizeEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface MapLayerCustomizeDao extends JpaRepository<MapLayerCustomizeEntity, Long> {
public MapLayerCustomizeEntity findByBranchIdAndLayerIdAndStatus(String branchId, String layerId, int status);
MapLayerCustomizeEntity getByLayerId(String layerId);
List<MapLayerCustomizeEntity> findByBranchIdInAndStatus(List<String> branchIds, int status);
}
......@@ -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,11 +9,13 @@ 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);
List<OrderInfoEntity> findByDtAndEngineerCode(LocalDate date, String engineerCode);
@Query("SELECT o.orderId, s.skillCategory as skillCaption FROM OrderInfoEntity o JOIN SkillInfoEntity s on o.brand=s.brand and o.type=s.type and o.skill=s.skill WHERE o.orderId = :orderId")
OrderSkillProjection getOrderSkillCaptionByOrderId(String orderId);
List<OrderInfoEntity> findAllByOrderIdIn(List<String> orderIds);
List<OrderInfoEntity> findAllByDtAndOrderIdIn(LocalDate dt, List<String> orderIds);
List<OrderInfoEntity> findByEngineerCodeAndDtAndAppointmentStatusIn(String engineerCode, LocalDate dt, List<String> appointmentStatus);
}
......@@ -15,6 +15,8 @@ public interface OrgGroupDao extends JpaRepository<OrgGroupEntity, Integer> {
List<OrgGroupEntity> findAllByClusterId(String clusterId);
List<OrgGroupEntity> findAllByGroupId(String groupId);
OrgGroupEntity getByGroupId(String groupId);
public List<OrgGroupEntity> findByGroupIdIn(List<String> ids);
......
......@@ -22,6 +22,9 @@ public interface OrgTeamDao extends JpaRepository<OrgTeamEntity, Integer> {
@Query("select t from OrgTeamEntity t where t.groupId = :groupId and t.status=1")
List<OrgTeamEntity> findAllByGroupId(String groupId);
@Query("select t from OrgTeamEntity t where t.teamId = :teamId and t.status=1")
List<OrgTeamEntity> findAllByTeamId(String teamId);
@Query("select t from OrgTeamEntity t where t.groupId = :groupId and t.status=1")
Page<OrgTeamEntity> findAllByGroupId(String groupId, Pageable pageable);
......
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.OrgWarehouseInfoEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface WarehouseInfoDao extends JpaRepository<OrgWarehouseInfoEntity, Long> {
public interface OrgWarehouseInfoDao extends JpaRepository<OrgWarehouseInfoEntity, Long> {
// 返回工作队所在的分部所有的配件仓
@Query("select a from OrgWarehouseInfoEntity a join OrgTeamEntity o on a.branchId=o.branchId where o.teamId= :teamId")
......@@ -23,4 +25,13 @@ public interface WarehouseInfoDao extends JpaRepository<OrgWarehouseInfoEntity,
OrgWarehouseInfoEntity getOrgWarehouseInfoEntityByWarehouseId(String wareHouseId);
List<OrgWarehouseInfoEntity> findByBranchId(String branchId);
@Query("select a from OrgWarehouseInfoEntity a join OrgBranchEntity o on a.branchId=o.branchId where o.clusterId=:clusterId")
Page<OrgWarehouseInfoEntity> findByClusterId(String clusterId, Pageable pageable);
Page<OrgWarehouseInfoEntity> findByBranchId(String branchId, Pageable pageable);
Page<OrgWarehouseInfoEntity> findByGroupId(String groupId, Pageable pageable);
}
......@@ -10,4 +10,6 @@ public interface PubParamsDao extends JpaRepository<PubParamsEntity, Integer> {
List<PubParamsEntity> findByBiztype(String biztype);
List<PubParamsEntity> findByCatalogAndBiztype(String cagtalog, String biztype);
PubParamsEntity getByCatalogAndBiztypeAndPkey(String catalog, String biztype, String pkey);
}
package com.dituhui.pea.order.dto;
import lombok.experimental.Accessors;
import java.util.List;
import static com.dituhui.pea.order.config.OrderConfig.DEFAULT_PAGE_SIZE;
public class BusinessOrgWarehousesDTO {
@lombok.Data
public static class Request {
private String levelType;
private String levelValue;
private Integer size = DEFAULT_PAGE_SIZE;
private Integer page = 1;
}
@lombok.Data
@Accessors(chain = true)
public static class Result {
private long pageCurrent;
private long pages;
private long pageSize;
private long total;
private List<Content> content;
}
@lombok.Data
@Accessors(chain = true)
public static class Content {
private String warehouseName;
private String warehouseId;
private String groupName;
private String address;
private String location;
private String managerName;
private String managerPhone;
private String updateTime;
private String type;
}
}
package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.List;
import static com.dituhui.pea.order.config.OrderConfig.DEFAULT_PAGE_SIZE;
......@@ -44,10 +39,8 @@ public class BusinessSkillListDTO {
public static class Content {
private String brand;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
private String createTime;
private Boolean gasCert;
private String layerId;
private String layerName;
......@@ -64,9 +57,7 @@ public class BusinessSkillListDTO {
private String type;
private String typeCategory;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private String updateTime;
}
}
......@@ -4,7 +4,7 @@ import lombok.experimental.Accessors;
import java.util.List;
public class BusinessWarehousesDTO {
public class BusinessTeamWarehousesDTO {
@lombok.Data
public static class Request {
......
package com.dituhui.pea.order.dto;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
public class CalendarBatAddDTO {
@lombok.Data
public static class Request {
/**
* 结束时间;如果是全天只需要填写日期;否则填写日期+时间
*/
@NotBlank
private String end;
/**
* 技术员code列表
*/
@NotEmpty
private List<String> engineerCodes;
/**
* 是否全天
*/
@NotNull
private Boolean isAllday;
/**
* 备注
*/
private String remark;
/**
* 重复截止日期
*/
@NotBlank
private String repeatEndDate;
/**
* 重复类型
*/
@NotBlank
private String repeatType;
/**
* 开始时间;如果是全天只需要填写日期;否则填写日期+时间
*/
@NotBlank
private String start;
/**
* 日程类型
*/
@NotBlank
private String type;
}
}
package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
public class CalendarBatDelDTO {
@lombok.Data
public static class Request {
/**
* 结束时间
*/
@NotBlank
@JsonFormat(pattern = "yyyy-MM-dd")
private String endDate;
/**
* 技术员code列表
*/
@NotEmpty
private List<String> engineerCodes;
/**
* 开始时间
*/
@NotBlank
@JsonFormat(pattern = "yyyy-MM-dd")
private String startDate;
/**
* 日程类型
*/
@NotBlank
private String type;
}
}
package com.dituhui.pea.order.dto;
import javax.validation.constraints.NotBlank;
public class CalendarDeleteDTO {
@lombok.Data
public static class Request {
@NotBlank
private String engineerCode;
@NotBlank
private String planId;
}
}
package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
public class CalendarDetailDTO {
@lombok.Data
public static class Request {
@NotBlank
private String engineerCode;
@NotBlank
private String planId;
}
@lombok.Data
@Accessors(chain = true)
public static class Result {
private String engineerCode;
private String engineerName;
private String operator;
private String phone;
private String planId;
private String remark;
private String type;
private String typeName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String endTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String updateTime;
}
}
package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
public class CalendarQueryNumDTO {
@lombok.Data
public static class Request {
@NotEmpty
private List<String> engineerCodes;
@NotBlank
private String type;
@NotBlank
@JsonFormat(pattern = "yyyy-MM-dd")
private String startDate;
@NotBlank
@JsonFormat(pattern = "yyyy-MM-dd")
private String endDate;
}
@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;
import javax.validation.constraints.NotBlank;
public class CalendarUpdateDTO {
@lombok.Data
public static class Request {
@NotBlank
private String startTime;
@NotBlank
private String endTime;
@NotBlank
private String engineerCode;
@NotBlank
private String planId;
private String remark;
}
}
package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
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 lombok.Data;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
public class CapacityAdjustDTO {
......@@ -20,15 +13,11 @@ public class CapacityAdjustDTO {
@NotNull(message = "teamId不能为空")
private String teamId;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate startDate;
private String startDate;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate endDate;
private String endDate;
private Integer capAdjust;
}
......
package com.dituhui.pea.order.dto;
import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.config.OrderConfig;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
......@@ -54,10 +51,8 @@ public class CapacityStatQueryDTO {
private long capUsed;
private long capLeft;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private String updateTime;
private String date;
private long engineerNum;
......@@ -67,7 +62,7 @@ public class CapacityStatQueryDTO {
private String showName;
public Content(){
updateTime = LocalDateTime.now();
updateTime = DateUtils.formatDateTime(LocalDateTime.now());
}
}
}
......@@ -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 {
......
......@@ -49,6 +49,7 @@ public class EngineerCalendarDTO {
private String title;
private String type;
private String value;
private String planId;
}
}
......@@ -4,13 +4,8 @@ package com.dituhui.pea.order.dto;
import com.dituhui.pea.order.config.OrderConfig;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import lombok.experimental.Accessors;
import java.time.LocalDate;
import java.util.List;
......@@ -25,10 +20,8 @@ public class EngineersGanttDTO {
private Integer page = OrderConfig.DEFAULT_PAGE_INDEX;
private Integer size = OrderConfig.DEFAULT_PAGE_SIZE;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate date;
private String date;
private List<String> engineerCodes;
private List<String> branchIds;
private List<String> groupIds;
......
......@@ -3,14 +3,9 @@ package com.dituhui.pea.order.dto;
import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.config.OrderConfig;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.experimental.Accessors;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import static com.dituhui.pea.order.config.OrderConfig.PATTERN_DATE;
......@@ -30,7 +25,7 @@ public class OrderChangeListDTO {
private String levelValue;
private int page = OrderConfig.DEFAULT_PAGE_INDEX;
private int size = OrderConfig.DEFAULT_PAGE_SIZE;
private String date = DateUtils.formatDate(LocalDate.now(), PATTERN_DATE);
private String date = DateUtils.formatDate(LocalDate.now());
/**
* 排序
*/
......@@ -73,9 +68,7 @@ public class OrderChangeListDTO {
/**
* 更新时间
*/
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private String updateTime;
}
}
......@@ -27,17 +27,30 @@ public class CapacityEngineerCalendarEntity {
@Column(name = "end_time", nullable = false)
private LocalDateTime endTime;
@Column(name = "plan_id")
private String planId;
@Column(nullable = false)
private String type;
@Column(name = "reason")
private String reason;
@Column(nullable = false)
private String memo;
private String memo = "";
@Column(name = "operator_id")
private String operatorId;
@Column(name = "operator_name")
private String operatorName;
@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() {}
}
......@@ -9,6 +9,7 @@ public class MapLayerCustomize {
private Integer id;
private String branchId;
private String layerId;
private String saasLayerId;
private String layer;
private String layerDescribe;
private Integer status;
......
......@@ -19,6 +19,9 @@ public class MapLayerCustomizeEntity {
@Column(name = "layer_id", length = 32)
private String layerId;
@Column(name = "saas_layer_id", length = 32)
private String saasLayerId;
@Column(name = "layer", nullable = false, length = 50)
private String layer;
......
......@@ -16,6 +16,9 @@ public class MapLayerEntity {
@Column(name = "layer_id", nullable = false, length = 32)
private String layerId;
@Column(name = "saas_layer_id", nullable = false, length = 32)
private String saasLayerId;
@Column(name = "layer", nullable = false, length = 50)
private String layer;
......
......@@ -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() {
}
......
......@@ -80,7 +80,7 @@ public class OrgWarehouseInfoEntity {
/**
* 管理员手机号码
*/
private String namagerPhone;
private String managerPhone;
/**
* 备注
......@@ -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
// ...
......
package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.BusinessOrgWarehousesDTO;
import com.dituhui.pea.order.dto.BusinessSkillListDTO;
import com.dituhui.pea.order.dto.BusinessTeamWarehousesDTO;
public interface BusinessBaseService {
Result<?> getSkillList(BusinessSkillListDTO.Request req);
Result<?> getOrgWarehouses(BusinessOrgWarehousesDTO.Request reqDTO);
}
......@@ -7,7 +7,7 @@ import com.dituhui.pea.order.dto.*;
public interface BusinessTeamService {
Result<?> getTeams(BusinessTeamsDTO.Request req);
Result<?> getWarehouses(BusinessWarehousesDTO.Request req);
Result<?> getWarehouses(BusinessTeamWarehousesDTO.Request req);
Result<?> addTeam(BusinessTeamAddDTO.Request req);
......
......@@ -12,4 +12,6 @@ public interface EngineerBusinessService {
EngineerBusinessDTO.WareHouse getWareHouse(String wareHouseId);
void updateEngineerCenter(EngineerBusinessDTO.EngineerCenterUpdateReqDTO centerReq );
List<EngineerBusinessDTO.Blocks> getBlocks(EngineerBusinessDTO.Request engineerReq);
}
package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.EngineerCalendarDTO;
import com.dituhui.pea.order.dto.*;
public interface EngineerCalendarService {
Result<?> getEngineersCalendar(EngineerCalendarDTO.Request engineerCalendarReq);
Result<?> getCalendarTypeList();
Result<?> getPlanDetail(CalendarDetailDTO.Request reqDTO);
Result<?> updatePlan(String userId, CalendarUpdateDTO.Request reqDTO);
Result<?> deletePlan(String userId, CalendarDeleteDTO.Request reqDTO);
Result<?> batchAddPlan(String userId, CalendarBatAddDTO.Request reqDTO);
Result<?> queryEngineerPlanNum(CalendarQueryNumDTO.Request reqDTO);
Result<?> batchDeletePlan(String userId, CalendarBatDelDTO.Request reqDTO);
}
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.MapLayerCustomizeDao;
import com.dituhui.pea.order.dao.MapLayerDao;
import com.dituhui.pea.order.dao.SkillGroupDao;
import com.dituhui.pea.order.dao.SkillInfoDao;
import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.BusinessOrgWarehousesDTO;
import com.dituhui.pea.order.dto.BusinessSkillListDTO;
import com.dituhui.pea.order.entity.MapLayerCustomizeEntity;
import com.dituhui.pea.order.entity.MapLayerEntity;
import com.dituhui.pea.order.entity.SkillGroupEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.BusinessBaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
......@@ -27,6 +23,8 @@ import java.util.stream.Collectors;
@Service
@Slf4j
public class BusinessBaseServiceImpl implements BusinessBaseService {
@Autowired
private OrgGroupDao orgGroupDao;
@Autowired
private SkillInfoDao skillInfoDao;
......@@ -43,6 +41,8 @@ public class BusinessBaseServiceImpl implements BusinessBaseService {
private Map<String, String> mapLayer = null;
private Map<String, String> mapSkillGroup = null;
@Autowired
private OrgWarehouseInfoDao orgWarehouseInfoDao;
@Override
public Result<?> getSkillList(BusinessSkillListDTO.Request req) {
......@@ -65,6 +65,56 @@ public class BusinessBaseServiceImpl implements BusinessBaseService {
return Result.success(rs);
}
@Override
public Result<?> getOrgWarehouses(BusinessOrgWarehousesDTO.Request req) {
Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize());
Page<OrgWarehouseInfoEntity> page = null;
if (req.getLevelType().equals("cluster")) {
page = orgWarehouseInfoDao.findByClusterId(req.getLevelValue(), pageable);
} else if (req.getLevelType().equals("branch")) {
page = orgWarehouseInfoDao.findByBranchId(req.getLevelValue(), pageable);
} else {
page = orgWarehouseInfoDao.findByGroupId(req.getLevelValue(), pageable);
}
List<BusinessOrgWarehousesDTO.Content> contents = page.getContent().stream().map(e -> {
BusinessOrgWarehousesDTO.Content content = new BusinessOrgWarehousesDTO.Content();
content.setWarehouseId(e.getWarehouseId());
content.setWarehouseName(e.getWarehouseName());
content.setAddress(e.getAddress());
content.setLocation(String.format("%s,%s", e.getX(), e.getY()));
content.setGroupName(getGroupName(e.getGroupId()));
content.setManagerName(e.getManagerName());
content.setManagerPhone(e.getManagerPhone());
if (e.getKind() == 1) {
content.setType("分部仓-可分发");
} else {
content.setType("小组仓-快递柜");
}
content.setUpdateTime(DateUtils.formatDateTime(e.getUpdateTime()));
return content;
}).collect(Collectors.toList());
BusinessOrgWarehousesDTO.Result rs = new BusinessOrgWarehousesDTO.Result();
rs.setTotal(page.getTotalElements())
.setPages(page.getTotalPages())
.setPageSize(page.getSize())
.setPageCurrent(page.getNumber());
rs.setContent(contents);
return Result.success(rs);
}
private String getGroupName(String groupId) {
if ("0".equals(groupId)) {
return "直属分部";
}
OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(groupId);
if (groupEntity != null) {
return groupEntity.getGroupName();
}
log.error("未找到匹配的 直属分站信息");
return null;
}
private void initMaps() {
// 图层
mapLayer = new HashMap<>();
......
......@@ -12,6 +12,7 @@ import com.dituhui.pea.order.dto.BusinessServerBlocksRespDTO;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.feign.ISaaSRemoteService;
import com.dituhui.pea.order.service.BusinessBlockService;
import com.dituhui.pea.order.utils.RegionUtils;
import com.dituhui.pea.order.utils.TypeUtils;
import lombok.extern.slf4j.Slf4j;
......@@ -45,6 +46,15 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
@Autowired
private ISaaSRemoteService saasRemoteService;
@Autowired
private OrgGroupDao orgGroupDao;
@Autowired
private MapLayerDao mapLayerDao;
@Autowired
private MapLayerCustomizeDao mapLayerCustomizeDao;
@Value("${SaaS.ak}")
String ak;
......@@ -146,25 +156,40 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
if (team == null) {
throw new BusinessException("关联小队不存在");
}
// 重复检查layerId+teamId
MapBlockInfo existBlock = mapBlockInfoMPDao.getByTeamIdAndLayerId(teamId, layerId);
if (null != existBlock) {
return Result.failure("区块已存在");
}
// 同步到saas,返回blockId
// 获取小队出发点,初始化区块 TODO
String region = "{points:[{\"x\":1.3720127240270969E7,\"y\":3692634.103416302},{\"x\":1.37245800199027E7,\"y\":3692634.103416302},{\"x\":1.3720127240270969E7,\"y\":3744947.448648849},{\"x\":1.3720127240270969E7,\"y\":3692634.103416302}]}";
String result = saasRemoteService.addArea(ak, team.getTeamName(), layerId, region, "gcj02mc");
log.info("params:{} {} {} result:{}", team.getTeamName(), layerId, region, result);
// 获取小队出发点,初始化区块
OrgGroupEntity group = orgGroupDao.getByGroupId(team.getGroupId());
String region = RegionUtils.constructRegion(group.getX(), group.getY());
// 获取saas图层id
String saasLayerId = getSaaSLayerId(team.getBranchId(), layerId);
if (StringUtils.isEmpty(saasLayerId)) {
return Result.failure("图层未配置");
}
String result = saasRemoteService.addArea(ak, team.getTeamName(), saasLayerId, region, "gcj02mc");
log.info("params:{} {} {} {} result:{}", team.getTeamName(), saasLayerId, region, result);
Result<String> saasResult = TypeUtils.<String>convertResult(result);
if (!ResultEnum.SUCCESS.getCode().equals(saasResult.getCode())) {
return Result.failure("区块已存在或者裁剪为空");
}
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);
block.setLayer(layerId);
block.setLayerId(layerId);
block.setLayer(layerName);
block.setStatus(1);
mapBlockInfoMPDao.insert(block);
......@@ -172,6 +197,30 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
return Result.success(null);
}
/**
* 获取saas图层id
*
* @param branchId
* @param layerId
* @return
*/
private String getSaaSLayerId(String branchId, String layerId) {
MapLayerEntity layer = mapLayerDao.getByLayerId(layerId);
String saasLayerId = null;
if (null == layer) {
MapLayerCustomizeEntity layerCustom = mapLayerCustomizeDao.findByBranchIdAndLayerIdAndStatus(branchId,
layerId, 1);
if (null != layerCustom) {
saasLayerId = layerCustom.getSaasLayerId();
} else {
log.error("图层不存在 {} {}", branchId, layerId);
}
} else {
saasLayerId = layer.getSaasLayerId();
}
return saasLayerId;
}
@Override
public Result<?> businessServiceBlockRemove(String blockId) throws BusinessException {
MapBlockInfo block = mapBlockInfoMPDao.getByBlockId(blockId);
......@@ -204,9 +253,11 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
String password = "qjOHxpQPXLnJP+Jq1CZGBQ==";
// 跳转SaaS url
// 获取saas图层id
String saasLayerId = getSaaSLayerId(block.getBranchId(), block.getLayerId());
HashMap<String, String> res = new HashMap<>();
res.put("url", url + "/mlAutoLogin?userAccount=" + userAccount + "&password=" + password
+ "&jump=basedata&navHidden=true&layerId=" + block.getLayerId() + "&areaId=" + block.getBlockId());
+ "&jump=basedata&navHidden=true&layerId=" + saasLayerId + "&areaId=" + block.getBlockId());
return Result.success(res);
}
......
package com.dituhui.pea.order.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -12,8 +13,11 @@ import com.dituhui.pea.order.dto.BusinessCustomLayerRespDTO;
import com.dituhui.pea.order.dto.BusinessCustomLayersRespDTO;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.feign.ISaaSRemoteService;
import com.dituhui.pea.order.feign.dto.LayerDTO;
import com.dituhui.pea.order.service.BusinessLayerService;
import com.dituhui.pea.order.utils.TypeUtils;
import com.google.gson.internal.LinkedTreeMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -42,6 +46,8 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
private SkillInfoMPDao skillInfoMPDao;
@Autowired
private ISaaSRemoteService saasRemoteService;
@Autowired
private MapBlockInfoDao mapBlockInfoDao;
@Override
public Result<?> businessLayerUniversal() {
......@@ -145,24 +151,21 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
throw new BusinessException("分部参数错误,请联系管理员/研发");
}
/* TODO
// 同步创建saas图层,返回layerId
String result = saasRemoteService.addLayer(ak, layerName, 1, 1);
log.info("addLayer params:{} result:{}", layerName, result);
Result<LayerDTO> saasResult = TypeUtils.convertResult(result);
Result<LinkedTreeMap<String, Object>> saasResult = TypeUtils.convertResult(result);
if (!ResultEnum.SUCCESS.getCode().equals(saasResult.getCode())) {
return Result.failure(saasResult.getMessage());
}
*/
String saasLayerId = (String) saasResult.getResult().get("id");// 存入pea
// TODO 临时生成,正式使用^
//String layerId = saasResult.getResult().getId();// 存入pea
String layerId = UUID.randomUUID().toString().replace("-", "");
// 入库保存
MapLayerCustomize m = new MapLayerCustomize();
m.setLayerId(layerId);
m.setSaasLayerId(saasLayerId);
m.setLayer(layerName);
m.setLayerDescribe(layerDesc);
m.setBranchId(branchId);
......@@ -202,21 +205,24 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
if (layer == null) {
throw new BusinessException("图层不存在");
}
// 更新状态为删除状态
layer.setStatus(0);
mapLayerCustomizeMPDao.updateById(layer);
/* TODO
// 同步创建saas图层,返回layerId
String result = saasRemoteService.deleteLayer(ak, layerId);
// 检查下面是否还有区块
List<MapBlockInfoEntity> blocks = mapBlockInfoDao.findByLayerId(layerId);
if (CollectionUtils.isNotEmpty(blocks)) {
return Result.failure("该图层下面还有区块");
}
// 同步删除saas图层
String result = saasRemoteService.deleteLayer(ak, layer.getSaasLayerId());
log.info("deleteLayer params:{} result:{}", layerId, result);
Result<Boolean> saasResult = TypeUtils.convertResult(result);
if (!ResultEnum.SUCCESS.getCode().equals(saasResult.getCode())) {
return Result.failure(saasResult.getMessage());
}
*/
// 更新状态为删除状态
layer.setStatus(0);
mapLayerCustomizeMPDao.updateById(layer);
return Result.success(null);
}
......
......@@ -35,7 +35,7 @@ public class BusinessTeamServiceImpl implements BusinessTeamService {
private OrgTeamDao orgTeamDao;
@Autowired
private WarehouseInfoDao warehouseInfoDao;
private OrgWarehouseInfoDao orgWarehouseInfoDao;
@Autowired
private OrgTeamEngineerDao orgTeamEngineerDao;
......@@ -68,7 +68,7 @@ public class BusinessTeamServiceImpl implements BusinessTeamService {
content.setTeamId(e.getTeamId()).setTeamName(e.getTeamName());
content.setWorkdays(String.join("、", getWorkdaysChinese(e.getWorkdays())));
content.setEngineers(String.join(";", engineers));
OrgWarehouseInfoEntity warehouse = warehouseInfoDao.getByTeamAssigned(e.getTeamId());
OrgWarehouseInfoEntity warehouse = orgWarehouseInfoDao.getByTeamAssigned(e.getTeamId());
if (warehouse != null) {
content.setWarehouseName(warehouse.getWarehouseName());
}
......@@ -94,17 +94,17 @@ public class BusinessTeamServiceImpl implements BusinessTeamService {
}
@Override
public Result<?> getWarehouses(BusinessWarehousesDTO.Request req) {
List<OrgWarehouseInfoEntity> warehouseInfoEntityList = warehouseInfoDao.getAllByGroupId(req.getGroupId());
List<BusinessWarehousesDTO.Content> contents = warehouseInfoEntityList.stream().map(entity -> {
BusinessWarehousesDTO.Content dto = new BusinessWarehousesDTO.Content();
public Result<?> getWarehouses(BusinessTeamWarehousesDTO.Request req) {
List<OrgWarehouseInfoEntity> warehouseInfoEntityList = orgWarehouseInfoDao.getAllByGroupId(req.getGroupId());
List<BusinessTeamWarehousesDTO.Content> contents = warehouseInfoEntityList.stream().map(entity -> {
BusinessTeamWarehousesDTO.Content dto = new BusinessTeamWarehousesDTO.Content();
dto.setWarehouseId(entity.getWarehouseId());
dto.setWarehouseName(entity.getWarehouseName());
// 手工赋值其他字段
return dto;
}).collect(Collectors.toList());
return Result.success(new BusinessWarehousesDTO.Result().setContent(contents));
return Result.success(new BusinessTeamWarehousesDTO.Result().setContent(contents));
}
@Override
......@@ -177,7 +177,7 @@ public class BusinessTeamServiceImpl implements BusinessTeamService {
orgTeamDao.save(entity);
// 技术员列表
if (req.getEngineerCodes() != null && req.getEngineerCodes().size() > 0) {
if (req.getEngineerCodes() != null && !req.getEngineerCodes().isEmpty()) {
updateTeamEngineers(req.getTeamId(), req.getEngineerCodes());
}
return Result.success(null);
......
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;
......@@ -35,8 +32,10 @@ public class EngineerBusinessServiceImpl implements EngineerBusinessService {
private EngineerInfoDao engineerInfoDao;
@Autowired
private WarehouseInfoDao warehouseInfoDao;
private OrgWarehouseInfoDao orgWarehouseInfoDao;
@Autowired
private MapBlockInfoDao mapBlockInfoDao;
@Autowired
private JdbcTemplate jdbcTemplate;
......@@ -97,7 +96,7 @@ public class EngineerBusinessServiceImpl implements EngineerBusinessService {
@Override
public EngineerBusinessDTO.WareHouse getWareHouse(String wareHouseId) {
OrgWarehouseInfoEntity item = warehouseInfoDao.getOrgWarehouseInfoEntityByWarehouseId(wareHouseId);
OrgWarehouseInfoEntity item = orgWarehouseInfoDao.getOrgWarehouseInfoEntityByWarehouseId(wareHouseId);
EngineerBusinessDTO.WareHouse wareHouse = new EngineerBusinessDTO.WareHouse();
if (item != null) {
wareHouse.setWareHouseId(item.getWarehouseId());
......@@ -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());
}
}
......@@ -13,6 +13,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
......@@ -46,13 +47,13 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
// 按日期返回技术员们当天的服务甘特图,不需要翻页
log.info("getEngineersGanttList: {}", reqDTO);
List<String> engineerCodes = reqDTO.getEngineerCodes();
if (engineerCodes == null || engineerCodes.size() == 0) {
if (engineerCodes == null || engineerCodes.isEmpty()) {
// 需要根据levelType/levelValue/brandIds/branchIds/groupIds/teamIds/key,后端查询匹配
engineerCodes = findEngineers(reqDTO.getLevelType(), reqDTO.getLevelValue(), reqDTO.getBranchIds(), reqDTO.getGroupIds(), reqDTO.getTeamIds(), reqDTO.getKey());
log.info("根据多条件,查询返回符合条件的技术员列表:{}", engineerCodes);
}
List<OrderInfoEntity> orders = orderInfoDao.findByDtAndEngineerCodeIn(reqDTO.getDate(), engineerCodes);
List<OrderInfoEntity> orders = orderInfoDao.findByDtAndEngineerCodeIn(LocalDate.parse(reqDTO.getDate()), engineerCodes);
HashMap<String, List<EngineersGanttDTO.Slot>> mapEngineers = new HashMap<>();
for (OrderInfoEntity order : orders) {
// 服务工单本体
......@@ -117,7 +118,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
.setEngineerName(engineerInfo.getName())
.setGrade(engineerInfo.getGrade());
CapacityEngineerStatEntity capacityEngineerStat = capacityEngineerStatDao.getByWorkdayAndEngineerCode(DateUtils.formatDate(reqDTO.getDate()), engineerCode);
CapacityEngineerStatEntity capacityEngineerStat = capacityEngineerStatDao.getByWorkdayAndEngineerCode(reqDTO.getDate(), engineerCode);
if (capacityEngineerStat == null) {
log.warn("技术员当日的容量数据不存在,{}{}", engineerCode, reqDTO.getDate());
} else {
......@@ -133,7 +134,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
engineers.sort(Comparator.comparing(EngineersGanttDTO.GanttChart::getEngineerName));
EngineersGanttDTO.Result res = new EngineersGanttDTO.Result();
res.setDate(DateUtils.formatDate(reqDTO.getDate())).setEngineers(engineers);
res.setDate(reqDTO.getDate()).setEngineers(engineers);
return Result.success(res);
}
......
......@@ -6,34 +6,38 @@ import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.EngineerTimelineResp;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.EngineerTimelineService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
public class EngineerTimelineServiceImpl implements EngineerTimelineService {
@Autowired
private OrderInfoMPDao orderInfoMPDao;
private OrderInfoDao orderInfoDao;
@Autowired
private EngineerInfoMPDao engineerInfoMPDao;
private EngineerInfoDao engineerInfoDao;
@Autowired
private WarehouseInfoMPDao warehouseInfoMPDao;
private OrgWarehouseInfoDao orgWarehouseInfoDao;
@Autowired
private OrgGroupMPDao orgGroupMPDao;
private OrgGroupDao orgGroupDao;
@Autowired
private OrderEventMPDao orderEventMPDao;
private EntityManager entityManager;
@Transactional
@Override
......@@ -42,14 +46,14 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
LocalDate localDate = TimeUtils.IsoDate2LocalDate(date);
// 工程師信息
EngineerInfo engineerInfo = engineerInfoMPDao.getByEngineerCode(engineerCode);
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(engineerCode);
// 获取工程师date日的订单数据
List<OrderInfo> orders = this.selectEngineerOrders(engineerCode, localDate);
List<OrderInfoEntity> orders = this.selectEngineerOrders(engineerCode, localDate);
// 获取工程师已完成的timeline数据
List<String> orderIds = orders.stream().map(OrderInfo::getOrderId).collect(Collectors.toList());
List<OrderEvent> timelines = this.engineerTimelines(orderIds, date);
List<String> orderIds = orders.stream().map(OrderInfoEntity::getOrderId).collect(Collectors.toList());
List<OrderEventEntity> timelines = this.engineerTimelines(orderIds, date);
// 获取客户地址
HashMap<String, String> orderLocations = this.orderRequestsLocation(orders);
......@@ -67,30 +71,39 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
return Result.success(res);
}
private List<OrderInfo> selectEngineerOrders(String engineerCode, LocalDate dt){
LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderInfo::getDt, dt);
lqw.eq(OrderInfo::getEngineerCode, engineerCode);
lqw.ne(OrderInfo::getAppointmentStatus, "INIT");
lqw.ne(OrderInfo::getOrderStatus, "CANCEL");
return orderInfoMPDao.selectList(lqw);
private List<OrderInfoEntity> selectEngineerOrders(String engineerCode, LocalDate dt){
List<OrderInfoEntity> orders = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn(
engineerCode, dt, List.of("PRE", "CONFIRM"));
return orders.stream().filter(o -> !o.getOrderStatus().equals("CANCEL")).collect(Collectors.toList());
}
private List<OrderEvent> engineerTimelines(List<String> orderIds, String date){
// 获取工程师timeline
List<String> events = Stream.of("分站取还配件", "已出发", "加单").collect(Collectors.toList());
LambdaQueryWrapper<OrderEvent> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderEvent::getOrderId, orderIds);
lqw.ge(OrderEvent::getHappen, date+" 00:00:00");
lqw.le(OrderEvent::getHappen, date + " 23:59:59");
lqw.in(OrderEvent::getEvent, events);
return orderEventMPDao.selectList(lqw);
public List<OrderEventEntity> engineerTimelines(List<String> orderIds, String date) {
List<String> events = Arrays.asList("分站取还配件", "已出发", "加单");
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<OrderEventEntity> criteriaQuery = criteriaBuilder.createQuery(OrderEventEntity.class);
Root<OrderEvent> root = criteriaQuery.from(OrderEvent.class);
List<Predicate> predicates = new ArrayList<>();
predicates.add(root.get("orderId").in(orderIds));
predicates.add(criteriaBuilder.greaterThanOrEqualTo(root.get("happen"), date + " 00:00:00"));
predicates.add(criteriaBuilder.lessThanOrEqualTo(root.get("happen"), date + " 23:59:59"));
predicates.add(root.get("event").in(events));
criteriaQuery.where(predicates.toArray(new Predicate[0]));
TypedQuery<OrderEventEntity> typedQuery = entityManager.createQuery(criteriaQuery);
List<OrderEventEntity> result = typedQuery.getResultList();
return result;
}
private HashMap<String, String> orderRequestsLocation(List<OrderInfo> orders) {
private HashMap<String, String> orderRequestsLocation(List<OrderInfoEntity> orders) {
// 获取客户地址location
HashMap<String, String> map = new HashMap<>();
for(OrderInfo o: orders){
for(OrderInfoEntity o: orders){
map.put(o.getOrderId(), String.format("%s,%s", o.getX(), o.getY()));
}
return map;
......@@ -98,38 +111,30 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
private String getWarehouseLocation(String branchId) {
// 获取配送站location
LambdaQueryWrapper<OrgWarehouseInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrgWarehouseInfo::getBranchId, branchId);
List<OrgWarehouseInfo> wares = warehouseInfoMPDao.selectList(lqw);
OrgWarehouseInfo w = wares.get(0);
List<OrgWarehouseInfoEntity> wares = orgWarehouseInfoDao.findByBranchId(branchId);
OrgWarehouseInfoEntity w = wares.get(0);
return String.format("%s,%s", w.getX(), w.getY());
}
private String getEngineerBranchId(String engineerCode) {
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
lqw.select(EngineerInfo::getGroupId);
lqw.eq(EngineerInfo::getEngineerCode, engineerCode);
EngineerInfo e = engineerInfoMPDao.selectOne(lqw);
EngineerInfoEntity e = engineerInfoDao.getByEngineerCode(engineerCode);
if (e == null) {
return "";
}
LambdaQueryWrapper<OrgGroup> lqw2 = new LambdaQueryWrapper<>();
lqw2.select(OrgGroup::getBranchId);
lqw2.eq(OrgGroup::getGroupId, e.getGroupId());
OrgGroup g = orgGroupMPDao.selectOne(lqw2);
OrgGroupEntity g = orgGroupDao.getByGroupId(e.getGroupId());
return (g==null)? "": g.getBranchId();
}
private List<EngineerTimelineResp.DynamicItem> packItems(List<OrderEvent> timelines, List<OrderInfo> orders, HashMap<String, String> locations, String warehouseLocation) {
private List<EngineerTimelineResp.DynamicItem> packItems(List<OrderEventEntity> timelines, List<OrderInfoEntity> orders,
HashMap<String, String> locations, String warehouseLocation) {
int index = 0;
String order_id, title, type, text, location;
List<EngineerTimelineResp.DynamicItem> items = new ArrayList<>();
Set<String> s = new HashSet<>();
for (OrderEvent t: timelines){
for (OrderEventEntity t: timelines){
EngineerTimelineResp.DynamicItem item = new EngineerTimelineResp.DynamicItem();
if (t.getEvent().equals("分站取还配件")) {
......@@ -146,7 +151,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
continue;
}
item.setTitle(title);
item.setTime(TimeUtils.IsoTimestamp2DateTime(t.getHappen()));
item.setTime(TimeUtils.IsoLocalDateTime2String(t.getHappen()));
item.setStatus(1);
item.setText(text);
......@@ -157,8 +162,8 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
s.add(t.getOrderId() + t.getSuborderId());
}
List<OrderInfo> records = orders.stream().sorted(Comparator.comparing(OrderInfo::getPlanStartTime)).collect(Collectors.toList());
for(OrderInfo o: records){
List<OrderInfoEntity> records = orders.stream().sorted(Comparator.comparing(OrderInfoEntity::getPlanStartTime)).collect(Collectors.toList());
for(OrderInfoEntity o: records){
order_id = o.getOrderId() + o.getSubId();
if (s.contains(order_id)) {
continue;
......@@ -166,7 +171,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
index += 1;
EngineerTimelineResp.DynamicItem item = new EngineerTimelineResp.DynamicItem();
item.setTitle(String.format("第%d单出发", index));
item.setTime(TimeUtils.IsoTimestamp2DateTime(o.getPlanStartTime()));
item.setTime(TimeUtils.IsoLocalDateTime2String(o.getPlanStartTime()));
item.setStatus(0);
item.setText(String.format("%d", index));
item.setLocation(locations.get(o.getOrderId()));
......
......@@ -210,9 +210,9 @@ public class OrderCreateServiceImpl implements OrderCreateService {
OrderAssignCheck.Result checkResult = null;
log.info("=== 准备调用指派,候选的技术员列表: {}", matchEngineerCodes);
for (String engineerCode : matchEngineerCodes) {
checkResult = orderAssignCheck.orderAssignCheck(entity.getOrderId(), engineerCode);
checkResult = orderAssignCheck.orderAssignCheck(entity.getOrderId(), entity.getDt(), engineerCode);
log.info("orderAssignCheck ===> orderId[{}]engineerCode[{}] ==> result[{}]", entity.getOrderId(), engineerCode, checkResult);
if (checkResult.getCanAssign()) {
if (checkResult.getIndex() < 0) {
assignEngineerCode = engineerCode;
break;
}
......@@ -221,16 +221,18 @@ public class OrderCreateServiceImpl implements OrderCreateService {
// 虚拟指派
if (StringUtils.isNotBlank(assignEngineerCode)) {
// 修改当前工单
OrderAssignCheck.OrderNode insertNode = checkResult.getCurOrderNode();
entity.setEngineerCode(assignEngineerCode);
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(assignEngineerCode);
entity.setEngineerName(engineerInfo.getName());
entity.setEngineerPhone(engineerInfo.getPhone());
entity.setAppointmentStatus("PRE");
entity.setDispatcher("AUTO_NOW");
entity.setPlanStartTime(checkResult.getStart());
entity.setPlanEndTime(checkResult.getEnd());
entity.setArriveDistance(checkResult.getDistanceAddition());
entity.setArriveElapsed(checkResult.getMinuteAddition());
entity.setPlanStartTime(insertNode.getPlanStartTime());
entity.setPlanEndTime(insertNode.getPlanEndTime());
entity.setArriveDistance(checkResult.getAdditionDistance());
entity.setArriveElapsed(checkResult.getAdditionElapsed());
orderInfoDao.save(entity);
// 如果影响到原有工单,修改原有工单
......
......@@ -28,10 +28,10 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
private OrderInfoMPDao orderInfoMPDao;
@Autowired
private EngineerInfoMPDao engineerInfoMPDao;
private EngineerInfoDao engineerInfoDao;
@Autowired
private OrgBranchMPDao orgBranchMPDao;
private OrgBranchDao orgBranchDao;
@Transactional
@Override
......@@ -167,8 +167,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
if(engineerCodes.isEmpty()){
return new HashMap<>();
}
List<EngineerInfo> engineers = engineerInfoMPDao.selectByEngineerCodes(new ArrayList<>(engineerCodes));
return engineers.stream().collect(Collectors.toMap(EngineerInfo::getEngineerCode, EngineerInfo::getName));
List<EngineerInfoEntity> engineers = engineerInfoDao.findByEngineerCodeIn(new ArrayList<>(engineerCodes));
return engineers.stream().collect(Collectors.toMap(EngineerInfoEntity::getEngineerCode, EngineerInfoEntity::getName));
}
private Map<String, String> getBranchNames(List<OrderInfo> orders){
......@@ -182,10 +182,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
if(branches.isEmpty()){
return new HashMap<>();
}
LambdaQueryWrapper<OrgBranch> lqw = new LambdaQueryWrapper<>();
lqw.in(OrgBranch::getBranchId, new ArrayList<>(branches));
List<OrgBranch> records = orgBranchMPDao.selectList(lqw);
return records.stream().collect(Collectors.toMap(OrgBranch::getBranchId, OrgBranch::getBranchName));
List<OrgBranchEntity> records = orgBranchDao.findByBranchIdIn(new ArrayList<>(branches));
return records.stream().collect(Collectors.toMap(OrgBranchEntity::getBranchId, OrgBranchEntity::getBranchName));
}
private List<String> getOrderEngineerNames(String engineerCode, String engineerCodeSub, Map<String,String> engineerNames){
......
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.CapacityAdjustDTO;
import com.dituhui.pea.order.dto.CapacityStatQueryDTO;
......@@ -87,7 +88,7 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
.setCapUsed(e.getCapUsedTotal())
.setCapLeft(e.getCapLeft())
.setEngineerNum(e.getEngineerCount())
.setUpdateTime(e.getUpdateTime());
.setUpdateTime(DateUtils.formatDateTime(e.getUpdateTime()));
} else {
// group查询,是capacity_team_stat
CapacityTeamStatEntity e = (CapacityTeamStatEntity) item;
......@@ -102,7 +103,7 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
.setCapLeft(e.getCapLeft())
.setCapAdjust(e.getCapAdjust())
.setEngineerNum(e.getEngineerCount())
.setUpdateTime(e.getUpdateTime());
.setUpdateTime(DateUtils.formatDateTime(e.getUpdateTime()));
}
contents.add(content);
}
......@@ -115,12 +116,13 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
@Override
public Result<?> adjustCapacity(CapacityAdjustDTO.Request reqDTO) {
if (reqDTO.getStartDate().isBefore(LocalDate.now())) {
if (LocalDate.parse(reqDTO.getStartDate()).isBefore(LocalDate.now())) {
return Result.failed("日期不能小于当天");
}
// 遍历 startDate 到 endDate 之间的所有日期
LocalDate currentDate = reqDTO.getStartDate();
while (!currentDate.isAfter(reqDTO.getEndDate())) {
LocalDate currentDate = LocalDate.parse(reqDTO.getStartDate());
LocalDate endDate = LocalDate.parse(reqDTO.getEndDate());
while (!currentDate.isAfter(endDate)) {
float adjuest = (float) (reqDTO.getCapAdjust() / 100.0);
ajustCapacityByDate(reqDTO.getTeamId(), currentDate, adjuest);
currentDate = currentDate.plusDays(1); // 增加一天
......
......@@ -27,16 +27,22 @@ public class ScheduleServiceImpl implements ScheduleService {
private OrderInfoMPDao orderInfoMPDao;
@Autowired
private OrderInfoDao orderInfoDao;
@Autowired
private OrgTeamMPDao orgTeamMPDao;
@Autowired
private OrgTeamEngineerMPDao orgTeamEngineerMPDao;
private OrgTeamEngineerDao orgTeamEngineerDao;
@Autowired
private OrgGroupMPDao orgGroupMPDao;
@Autowired
private EngineerInfoMPDao engineerInfoMPDao;
private OrgGroupDao orgGroupDao;
@Autowired
private EngineerInfoDao engineerInfoDao;
@Autowired
private SkillInfoMPDao skillInfoMPDao;
......@@ -97,21 +103,22 @@ public class ScheduleServiceImpl implements ScheduleService {
}
// 获取team技术员列表
List<OrgTeamEngineer> teamEngineers = this.queryOrgTeamEngineers(t.getTeamId());
List<String> engineerCodes = teamEngineers.stream().map(OrgTeamEngineer::getEngineerCode).collect(Collectors.toList());
List<EngineerInfo> engineerInfoList = engineerInfoMPDao.selectByEngineerCodes(engineerCodes);
Map<String, List<EngineerInfo>> engineers = engineerInfoList.stream().collect(Collectors.groupingBy(EngineerInfo::getEngineerCode));
List<OrgTeamEngineerEntity> teamEngineers = orgTeamEngineerDao.findAllByTeamId(t.getTeamId());
List<String> engineerCodes = teamEngineers.stream().map(OrgTeamEngineerEntity::getEngineerCode).collect(Collectors.toList());
List<EngineerInfoEntity> engineerInfoList = engineerInfoDao.findByEngineerCodeIn(engineerCodes);
Map<String, List<EngineerInfoEntity>> engineers = engineerInfoList.stream().collect(
Collectors.groupingBy(EngineerInfoEntity::getEngineerCode));
List<ScheduleOverviewResp.Item> children = new ArrayList<>();
for (Map.Entry<String, List<EngineerInfo>> entry : engineers.entrySet()) {
for (Map.Entry<String, List<EngineerInfoEntity>> entry : engineers.entrySet()) {
ScheduleOverviewResp.Item child = new ScheduleOverviewResp.Item();
//技术员信息
String engineerCode = entry.getKey();
EngineerInfo engineerInfo = entry.getValue().get(0);
EngineerInfoEntity engineerInfo = entry.getValue().get(0);
// 获取技术员已经指派的订单列表
List<OrderInfo> orders2 = engineerOrders.getOrDefault(engineerCode, new ArrayList<>());
List<OrderInfo> orders2 = engineerOrders.getOrDefault(engineerCode, new ArrayList<>());
child.setName(engineerInfo.getName());
child.setValue(engineerCode);
......@@ -144,28 +151,27 @@ public class ScheduleServiceImpl implements ScheduleService {
public Result<?> getScheduleEngineerOverview(LocalDate date, String engineerCode) throws BusinessException {
// 获取技术员已排班概况
EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode);
EngineerInfoEntity engineer = engineerInfoDao.getByEngineerCode(engineerCode);
if (engineer == null) {
throw new BusinessException("分销员不存在");
}
List<LabelValueDTO> emptyTips = new ArrayList<>();
LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderInfo::getDt, date).eq(OrderInfo::getEngineerCode, engineerCode).in(OrderInfo::getAppointmentStatus, List.of("PRE", "CONFIRM"));
List<OrderInfo> orderAppointments = orderInfoMPDao.selectList(lqw);
List<OrderInfoEntity> orderAppointments = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn(
engineerCode, date, List.of("PRE", "CONFIRM"));
List<TimeLineDTO> timelines = new ArrayList<>();
for (OrderInfo o : orderAppointments) {
for (OrderInfoEntity o : orderAppointments) {
TimeLineDTO item = new TimeLineDTO();
item.setOrderId(o.getOrderId());
item.setAppointmentStatus(o.getAppointmentStatus());
item.setStartTime(TimeUtils.IsoTimestamp2DateTime(o.getPlanStartTime()));
item.setEndTime(TimeUtils.IsoTimestamp2DateTime(o.getPlanEndTime()));
item.setStartTime(TimeUtils.IsoLocalDateTime2String(o.getPlanStartTime()));
item.setEndTime(TimeUtils.IsoLocalDateTime2String(o.getPlanEndTime()));
item.setTips(emptyTips);
timelines.add(item);
}
Map<String, List<OrderInfo>> statusGroup = orderAppointments.stream().collect(Collectors.groupingBy(OrderInfo::getServiceStatus));
List<OrderInfo> empty = new ArrayList<>();
Map<String, List<OrderInfoEntity>> statusGroup = orderAppointments.stream().collect(Collectors.groupingBy(OrderInfoEntity::getServiceStatus));
List<OrderInfoEntity> empty = new ArrayList<>();
Integer countPending = statusGroup.getOrDefault("INIT", empty).size() + statusGroup.getOrDefault("CONTACTED", empty).size() + statusGroup.getOrDefault("PENDING", empty).size();
List<LabelValueDTO> dynamics = new ArrayList<>();
......@@ -182,13 +188,13 @@ public class ScheduleServiceImpl implements ScheduleService {
dynamics.add(new LabelValueDTO("工作时间", "08:00-18:00"));
dynamics.add(new LabelValueDTO("交通工具", "电动车"));
List<String> orderIds = orderAppointments.stream().map(OrderInfo::getOrderId).collect(Collectors.toList());
List<OrderInfo> orderRequests = new ArrayList<>();
List<String> orderIds = orderAppointments.stream().map(OrderInfoEntity::getOrderId).collect(Collectors.toList());
List<OrderInfoEntity> orderRequests = new ArrayList<>();
if (orderIds != null && !orderIds.isEmpty()) {
orderRequests = orderInfoMPDao.selectByDtAndOrderIds(date, orderIds);
orderRequests = orderInfoDao.findAllByDtAndOrderIdIn(date, orderIds);
}
List<ScheduleEngineerOverviewResp.Order> orders = new ArrayList<>();
for (OrderInfo o : orderRequests) {
for (OrderInfoEntity o : orderRequests) {
ScheduleEngineerOverviewResp.Order item = new ScheduleEngineerOverviewResp.Order();
item.setOrderId(o.getOrderId());
item.setLocation(String.format("%s,%s", o.getX(), o.getY()));
......@@ -207,7 +213,7 @@ public class ScheduleServiceImpl implements ScheduleService {
}
String groupName = "";
OrgGroup group = orgGroupMPDao.getByGroupId(engineer.getGroupId());
OrgGroupEntity group = orgGroupDao.getByGroupId(engineer.getGroupId());
if (group != null) {
groupName = group.getGroupName();
}
......@@ -240,13 +246,6 @@ public class ScheduleServiceImpl implements ScheduleService {
return pg;
}
private List<OrgTeamEngineer> queryOrgTeamEngineers(String teamId) {
LambdaQueryWrapper<OrgTeamEngineer> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrgTeamEngineer::getTeamId, teamId);
lqw.eq(OrgTeamEngineer::getStatus, 1);
return orgTeamEngineerMPDao.selectList(lqw);
}
private List<OrderInfo> queryOrderRequests(String teamId, LocalDate date) {
LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderInfo::getDt, date);
......
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.SkillGroupMPDao;
import com.dituhui.pea.order.entity.SkillGroup;
import com.dituhui.pea.order.dao.SkillGroupDao;
import com.dituhui.pea.order.entity.SkillGroupEntity;
import com.dituhui.pea.order.service.SkillGroupCategoryService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -17,15 +17,15 @@ import java.util.stream.Collectors;
public class SkillGroupCategoryServiceImpl implements SkillGroupCategoryService {
@Autowired
SkillGroupMPDao skillGroupMPDao;
SkillGroupDao skillGroupDao;
@Override
public Result<?> querySkillGroupCategoryService() {
List<SkillGroup> records = skillGroupMPDao.selectList(null).stream().sorted(
Comparator.comparing(SkillGroup::getCategory)).collect(Collectors.toList());
List<SkillGroupEntity> records = skillGroupDao.findAll().stream().sorted(
Comparator.comparing(SkillGroupEntity::getCategory)).collect(Collectors.toList());
List<Category> items = new ArrayList<>();
for (SkillGroup r : records) {
for (SkillGroupEntity r : records) {
items.add(new Category(r.getSkillGroupCode(), r.getSkillGroup(), r.getCategory()));
}
Response res = new Response();
......
......@@ -3,12 +3,13 @@ package com.dituhui.pea.order.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.dao.OrderEventDao;
import com.dituhui.pea.order.dao.OrderInfoDao;
import com.dituhui.pea.order.dto.OrderChangeListDTO;
import com.dituhui.pea.order.dto.WorkbenchSummaryResp;
import com.dituhui.pea.order.entity.OrderEventEntity;
import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.entity.OrderInfo;
import com.dituhui.pea.order.service.WorkbenchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -17,8 +18,15 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
......@@ -28,44 +36,44 @@ public class WorkbenchServiceImpl implements WorkbenchService {
private OrderEventDao orderEventDao;
@Autowired
private OrderInfoMPDao orderInfoMPDao;
private OrderInfoDao orderInfoDao;
@Autowired
private OrderInfoDao orderInfoDao;
private EntityManager entityManager;
@Override
public Result<?> getOrderChangeList(OrderChangeListDTO.Request reqDTO) {
Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize());
Page<OrderEventEntity> page;
String levelType = reqDTO.getLevelType();
String levelValue = reqDTO.getLevelValue();
public Result<?> getOrderChangeList(OrderChangeListDTO.Request reqDTO) {
Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize());
Page<OrderEventEntity> page;
String levelType = reqDTO.getLevelType();
String levelValue = reqDTO.getLevelValue();
Date date = DateUtil.parse(reqDTO.getDate());
if ("cluster".equals(levelType)) {
page = orderEventDao.findAllByClusterId(levelValue, date, pageable);
} else if ("branch".equals(levelType)) {
page = orderEventDao.findAllByBranchId(levelValue, date, pageable);
} else {
page = orderEventDao.findAllByGroupId(levelValue, date, pageable);
}
List<OrderChangeListDTO.Content> contents = new ArrayList<>();
for (OrderEventEntity entity : page.getContent()) {
OrderChangeListDTO.Content content = new OrderChangeListDTO.Content();
OrderInfoEntity orderInfoEntity = orderInfoDao.getByOrderId(entity.getOrderId());
content.setOrderId(entity.getOrderId())
.setCustomerName(orderInfoEntity.getName())
.setOperator(entity.getOperator())
.setDescription(entity.getDescription())
.setMemo(entity.getMemo())
.setUpdateTime(entity.getUpdateTime());
contents.add(content);
}
OrderChangeListDTO.Result rs = new OrderChangeListDTO.Result();
rs.setTotal(page.getTotalElements())
.setPages(page.getTotalPages())
.setPageSize(page.getSize())
.setContent(contents);
return Result.success(rs);
}
if ("cluster".equals(levelType)) {
page = orderEventDao.findAllByClusterId(levelValue, date, pageable);
} else if ("branch".equals(levelType)) {
page = orderEventDao.findAllByBranchId(levelValue, date, pageable);
} else {
page = orderEventDao.findAllByGroupId(levelValue, date, pageable);
}
List<OrderChangeListDTO.Content> contents = new ArrayList<>();
for (OrderEventEntity entity : page.getContent()) {
OrderChangeListDTO.Content content = new OrderChangeListDTO.Content();
OrderInfoEntity orderInfoEntity = orderInfoDao.getByOrderId(entity.getOrderId());
content.setOrderId(entity.getOrderId())
.setCustomerName(orderInfoEntity.getName())
.setOperator(entity.getOperator())
.setDescription(entity.getDescription())
.setMemo(entity.getMemo())
.setUpdateTime(DateUtils.formatDateTime(entity.getUpdateTime()));
contents.add(content);
}
OrderChangeListDTO.Result rs = new OrderChangeListDTO.Result();
rs.setTotal(page.getTotalElements())
.setPages(page.getTotalPages())
.setPageSize(page.getSize())
.setContent(contents);
return Result.success(rs);
}
@Override
public Result<?> getWorkbenchSummary(String levelType, String levelValue, LocalDate dt) {
......@@ -89,27 +97,95 @@ public class WorkbenchServiceImpl implements WorkbenchService {
}
private List<Map<String, Object>> queryCountByAppointmentMethod(String levelType, String levelValue, LocalDate dt) {
QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>();
wrapper.select("appointment_method, appointment_status, COUNT(*) as count")
.lambda()
.eq(OrderInfo::getDt, dt)
.eq(levelType.equals("cluster"), OrderInfo::getOrgClusterId, levelValue)
.eq(levelType.equals("branch"), OrderInfo::getOrgBranchId, levelValue)
.eq(levelType.equals("group"), OrderInfo::getOrgGroupId, levelValue)
.groupBy(OrderInfo::getAppointmentMethod, OrderInfo::getAppointmentStatus);
return orderInfoMPDao.selectMaps(wrapper);
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Object[]> criteriaQuery = criteriaBuilder.createQuery(Object[].class);
Root<OrderInfoEntity> root = criteriaQuery.from(OrderInfoEntity.class);
criteriaQuery.multiselect(
root.get("appointmentMethod"),
root.get("appointmentStatus"),
criteriaBuilder.count(root).alias("count")
);
Predicate datePredicate = criteriaBuilder.equal(root.get("dt"), dt);
Predicate levelPredicate = null;
if ("cluster".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgClusterId"), levelValue);
} else if ("branch".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgBranchId"), levelValue);
} else if ("group".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgGroupId"), levelValue);
}
if (levelPredicate != null) {
criteriaQuery.where(datePredicate, levelPredicate);
} else {
criteriaQuery.where(datePredicate);
}
criteriaQuery.groupBy(root.get("appointmentMethod"), root.get("appointmentStatus"));
TypedQuery<Object[]> typedQuery = entityManager.createQuery(criteriaQuery);
List<Object[]> results = typedQuery.getResultList();
List<Map<String, Object>> mappedResults = results.stream()
.map(result -> {
Map<String, Object> map = Map.of(
"appointmentMethod", result[0],
"appointmentStatus", result[1],
"count", result[2]
);
return map;
})
.collect(Collectors.toList());
return mappedResults;
}
private List<Map<String, Object>> queryCountByOrderStatus(String levelType, String levelValue, LocalDate dt) {
QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>();
wrapper.select("service_status, COUNT(*) as count")
.lambda()
.eq(OrderInfo::getDt, dt)
.eq(levelType.equals("cluster"), OrderInfo::getOrgClusterId, levelValue)
.eq(levelType.equals("branch"), OrderInfo::getOrgBranchId, levelValue)
.eq(levelType.equals("group"), OrderInfo::getOrgGroupId, levelValue)
.groupBy(OrderInfo::getServiceStatus);
return orderInfoMPDao.selectMaps(wrapper);
public List<Map<String, Object>> queryCountByOrderStatus(String levelType, String levelValue, LocalDate dt) {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Object[]> criteriaQuery = criteriaBuilder.createQuery(Object[].class);
Root<OrderInfoEntity> root = criteriaQuery.from(OrderInfoEntity.class);
criteriaQuery.multiselect(
root.get("serviceStatus"),
criteriaBuilder.count(root).alias("count")
);
Predicate datePredicate = criteriaBuilder.equal(root.get("dt"), dt);
Predicate levelPredicate = null;
if ("cluster".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgClusterId"), levelValue);
} else if ("branch".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgBranchId"), levelValue);
} else if ("group".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgGroupId"), levelValue);
}
if (levelPredicate != null) {
criteriaQuery.where(datePredicate, levelPredicate);
} else {
criteriaQuery.where(datePredicate);
}
criteriaQuery.groupBy(root.get("serviceStatus"));
TypedQuery<Object[]> typedQuery = entityManager.createQuery(criteriaQuery);
List<Object[]> results = typedQuery.getResultList();
List<Map<String, Object>> mappedResults = results.stream()
.map(result -> {
Map<String, Object> map = Map.of(
"serviceStatus", result[0],
"count", result[1]
);
return map;
})
.collect(Collectors.toList());
return mappedResults;
}
private HashMap<String, Long> transAppointmentMethod(List<Map<String, Object>> results) {
......@@ -119,8 +195,8 @@ public class WorkbenchServiceImpl implements WorkbenchService {
Long autoTotal = 0L;
Long total = 0L;
for (Map<String, Object> result : results) {
String method = (String) result.get("appointment_method");
String status = (String) result.get("appointment_status");
String method = (String) result.get("appointmentMethod");
String status = (String) result.get("appointmentStatus");
Long count = (long) result.get("count");
total += count;
......@@ -147,7 +223,7 @@ public class WorkbenchServiceImpl implements WorkbenchService {
HashMap<String, Long> map = new HashMap<>();
for (Map<String, Object> result : results) {
String status = (String) result.get("service_status");
String status = (String) result.get("serviceStatus");
Long count = (long) result.get("count");
map.put(status, count);
}
......@@ -211,12 +287,10 @@ public class WorkbenchServiceImpl implements WorkbenchService {
return items;
}
private <T> HashMap<String, List<T>> packParams(String key, T ...values) {
private <T> HashMap<String, List<T>> packParams(String key, T... values) {
HashMap<String, List<T>> map = new HashMap<>();
List<T> value = new ArrayList<>();
for(T v: values){
value.add(v);
}
Collections.addAll(value, values);
map.put(key, value);
return map;
}
......
package com.dituhui.pea.order.utils;
import com.dituhui.pea.pojo.PointBase;
import com.dituhui.pea.pojo.RegionDTO;
import com.google.gson.Gson;
public class RegionUtils {
private final static Gson gson = new Gson();
public static String constructRegion(String x, String y) {
double xx = Double.parseDouble(x);
double yy = Double.parseDouble(y);
RegionDTO region = convertXyToRegion(xx, yy);
return gson.toJson(region);
}
public static RegionDTO convertXyToRegion(double x, double y) {
// 经纬度转墨卡托坐标
double xx = gcj02LngToMercator(x);
double yy = gcj02LatToMercator(y);
// 构造正方形
PointBase point1 = new PointBase();
point1.setX(xx);
point1.setY(yy);
PointBase point2 = new PointBase();
point2.setX(xx + 100);
point2.setY(yy);
PointBase point3 = new PointBase();
point3.setX(xx + 100);
point3.setY(yy + 100);
PointBase point4 = new PointBase();
point4.setX(xx);
point4.setY(yy + 100);
PointBase[] points = new PointBase[] { point1, point2, point3, point4, point1 };
RegionDTO region = new RegionDTO();
region.setPoints(points);
return region;
}
private static double gcj02LngToMercator(double x) {
double mx = x / 180.0D * 2.0037508342789244E7D;
return mx;
}
private static double gcj02LatToMercator(double y) {
double my = Math.log(Math.tan((90.0D + y) * 3.141592653589793D / 360.0D)) / 0.017453292519943295D;
my = my / 180.0D * 2.0037508342789244E7D;
return my;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!