Commit fc986e78 by chamberone

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

…oject.git into develop
2 parents 85d8723a 48ec3937
Showing with 161 additions and 68 deletions
...@@ -9,3 +9,4 @@ ...@@ -9,3 +9,4 @@
/*/.project /*/.project
/*/logs/ /*/logs/
/*/.gitignore /*/.gitignore
dispatchSolution-*.json
\ No newline at end of file
This diff could not be displayed because it is too large.
...@@ -20,7 +20,7 @@ public interface DispatchBatchRepository extends CrudRepository<DispatchBatch, L ...@@ -20,7 +20,7 @@ public interface DispatchBatchRepository extends CrudRepository<DispatchBatch, L
Optional<DispatchBatch> findByGroupIdAndBatchDate(String groupId, String batchDay); Optional<DispatchBatch> findByGroupIdAndBatchDate(String groupId, String batchDay);
@Query(value = "from DispatchBatch where groupId = ?1 and batchNo=?2 ") @Query(value = "from DispatchBatch where groupId = ?1 and batchNo=?2 ")
List<DispatchBatch> findLatestGroup(String groupId, String batchNo); Optional<DispatchBatch> findByGroupIdAndBatchNo(String groupId, String batchNo);
} }
\ No newline at end of file
package com.dituhui.pea.dispatch.dao; package com.dituhui.pea.dispatch.dao;
import com.dituhui.pea.dispatch.entity.OrderAppointment; import com.dituhui.pea.dispatch.entity.OrderAppointment;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import java.util.Optional; import java.util.Optional;
public interface OrderAppointmentRepository extends CrudRepository<OrderAppointment, Long> { public interface OrderAppointmentRepository extends CrudRepository<OrderAppointment, Long> {
@Query(value = "SELECT * FROM order_appointment WHERE order_id=:orderId ORDER BY id DESC LIMIT 1", nativeQuery = true)
Optional<OrderAppointment> findByOrderId(String orderId); Optional<OrderAppointment> findByOrderId(String orderId);
} }
...@@ -72,6 +72,12 @@ public class DispatchBatch implements Serializable { ...@@ -72,6 +72,12 @@ public class DispatchBatch implements Serializable {
@Column(name = "status") @Column(name = "status")
private String status; private String status;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "cutoffed_time")
private LocalDateTime cutoffedTime;
@Column(name = "memo") @Column(name = "memo")
private String memo; private String memo;
......
package com.dituhui.pea.dispatch.scheduler; package com.dituhui.pea.dispatch.scheduler;
import com.dituhui.pea.dispatch.constraint.DispatchConstraintProvider; import com.dituhui.pea.dispatch.constraint.DispatchConstraintProvider;
import com.dituhui.pea.dispatch.entity.DispatchBatch;
import com.dituhui.pea.dispatch.pojo.Customer; import com.dituhui.pea.dispatch.pojo.Customer;
import com.dituhui.pea.dispatch.pojo.DispatchSolution; import com.dituhui.pea.dispatch.pojo.DispatchSolution;
import com.dituhui.pea.dispatch.pojo.Technician; import com.dituhui.pea.dispatch.pojo.Technician;
...@@ -21,6 +22,8 @@ import java.io.File; ...@@ -21,6 +22,8 @@ import java.io.File;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Arrays; import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
...@@ -69,6 +72,32 @@ public class BatchScheduler { ...@@ -69,6 +72,32 @@ public class BatchScheduler {
String currDay = LocalDate.now().plusDays(i).format(DateTimeFormatter.ISO_LOCAL_DATE); String currDay = LocalDate.now().plusDays(i).format(DateTimeFormatter.ISO_LOCAL_DATE);
log.info("dispatchRun begin----- group:{}, day:{}", groupId, currDay); log.info("dispatchRun begin----- group:{}, day:{}", groupId, currDay);
LocalTime currentTime = LocalTime.now();
LocalTime cutoffTime = LocalTime.parse("16:00:00", DateTimeFormatter.ISO_LOCAL_TIME);
if (currentTime.isAfter(cutoffTime)) {
log.info("dispatchRun 已过cutoff时间,更新pre状态为confirm----- group:{}, day:{}", groupId, currDay);
DispatchBatch dispatchBatch = batchService.queryBatchInfoByDay(groupId, currDay);
if (null == dispatchBatch.getBatchNo()) {
log.info("dispatchRun 未查询到批次信息跳过----- group:{}, day:{}", groupId, currDay);
continue;
}
if (null == dispatchBatch.getCutoffedTime()) {
log.info("dispatchRun 已过cutoff时间,更新pre状态为confirm, 执行首次confirm----- group:{}, day:{}", groupId, currDay);
try {
this.extractService.extractDispatchToOrder(groupId, dispatchBatch.getBatchNo(), true);
dispatchBatch.setCutoffedTime(LocalDateTime.now());
batchService.saveDispatchBatch(dispatchBatch);
} catch (SQLException e) {
log.error("dispatchRun 已过cutoff时间,更新pre状态为confirm 异常 %s", e);
throw new RuntimeException(e);
}
} else {
log.info("dispatchRun 已过cutoff时间,更新pre状态为confirm, 已经执行confirm,跳过当次计算 ----- group:{}, day:{}", groupId, currDay);
}
continue;
}
String batchNo = batchService.buildBatchData(groupId, currDay); String batchNo = batchService.buildBatchData(groupId, currDay);
UUID problemId = solveService.generateProblemId(groupId, batchNo); UUID problemId = solveService.generateProblemId(groupId, batchNo);
log.info("dispatchRun group:{}, day:{}, batch:{}, problemId:{}", groupId, currDay, batchNo, problemId); log.info("dispatchRun group:{}, day:{}, batch:{}, problemId:{}", groupId, currDay, batchNo, problemId);
...@@ -81,13 +110,11 @@ public class BatchScheduler { ...@@ -81,13 +110,11 @@ public class BatchScheduler {
} }
log.info("dispatchRun prepare done, group:{}, day:{}, batch:{}, problemId:{}", groupId, currDay, batchNo, problemId); log.info("dispatchRun prepare done, group:{}, day:{}, batch:{}, problemId:{}", groupId, currDay, batchNo, problemId);
DispatchSolution solution = solver.solve(problem); DispatchSolution solution = solver.solve(problem);
log.info("dispatchRun run done, group:{}, day:{}, batch:{}, problemId:{}, score:{}", log.info("dispatchRun run done, group:{}, day:{}, batch:{}, problemId:{}, score:{}", groupId, currDay, batchNo, problemId, solution.getScore().toShortString());
groupId, currDay, batchNo, problemId, solution.getScore().toShortString());
this.extractService.saveAndExtractSolution(solution); this.extractService.saveAndExtractSolution(solution);
log.info("dispatchRun done ------ group:{}, day:{}", groupId, currDay); log.info("dispatchRun done ------ group:{}, day:{}", groupId, currDay);
JacksonSolutionFileIO<DispatchSolution> exporter = new JacksonSolutionFileIO<DispatchSolution>( JacksonSolutionFileIO<DispatchSolution> exporter = new JacksonSolutionFileIO<DispatchSolution>(DispatchSolution.class);
DispatchSolution.class);
// Set the output file. // Set the output file.
...@@ -98,11 +125,10 @@ public class BatchScheduler { ...@@ -98,11 +125,10 @@ public class BatchScheduler {
} }
} catch (InterruptedException e) {
} catch (SQLException e) {
log.info("error %s", e); log.info("error %s", e);
throw new RuntimeException(e); throw new RuntimeException(e);
} catch (InterruptedException e) { } catch (SQLException e) {
log.info("error %s", e); log.info("error %s", e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
......
...@@ -23,4 +23,6 @@ public interface BatchService { ...@@ -23,4 +23,6 @@ public interface BatchService {
String queryBatchNoByDay(String groupId, String day); String queryBatchNoByDay(String groupId, String day);
void saveDispatchBatch(DispatchBatch batchInfo);
} }
...@@ -2,6 +2,7 @@ package com.dituhui.pea.dispatch.service; ...@@ -2,6 +2,7 @@ package com.dituhui.pea.dispatch.service;
import com.dituhui.pea.dispatch.pojo.DispatchSolution; import com.dituhui.pea.dispatch.pojo.DispatchSolution;
import org.springframework.transaction.annotation.Transactional;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -18,12 +19,14 @@ public interface ExtractService { ...@@ -18,12 +19,14 @@ public interface ExtractService {
* 将计算结果回写到dispatch2个表、以及order两个表 * 将计算结果回写到dispatch2个表、以及order两个表
* 是下面两个方法的包装 * 是下面两个方法的包装
* */ * */
// @Transactional
void saveAndExtractSolution(DispatchSolution solution) throws RuntimeException; void saveAndExtractSolution(DispatchSolution solution) throws RuntimeException;
/* /*
* 将计算结果回写到dispatch_order表(更新补充技术员工号、上门时间) * 将计算结果回写到dispatch_order表(更新补充技术员工号、上门时间)
* */ * */
// @Transactional
void saveSolutionToDispatch(String groupId, String batchNo, DispatchSolution solution) throws RuntimeException; void saveSolutionToDispatch(String groupId, String batchNo, DispatchSolution solution) throws RuntimeException;
/* /*
...@@ -31,7 +34,8 @@ public interface ExtractService { ...@@ -31,7 +34,8 @@ public interface ExtractService {
* order_appointment(新增、更新) * order_appointment(新增、更新)
* order_request(主要更新状态) * order_request(主要更新状态)
* */ * */
void extractDispatchToOrder(String groupId, String batchNo) throws SQLException; // @Transactional
void extractDispatchToOrder(String groupId, String batchNo, boolean isConfirm) throws SQLException;
} }
...@@ -80,6 +80,7 @@ public class BatchServiceImpl implements BatchService { ...@@ -80,6 +80,7 @@ public class BatchServiceImpl implements BatchService {
// int engCount = queryEnginerCount(groupId); // int engCount = queryEnginerCount(groupId);
// int orderCount = queryOrderCount(groupId, batchDay); // int orderCount = queryOrderCount(groupId, batchDay);
log.info("清理原批次数据, groupId:{}, day:{}, batchNo:{}", groupId, batchDay, batchNo); log.info("清理原批次数据, groupId:{}, day:{}, batchNo:{}", groupId, batchDay, batchNo);
jdbcTemplate.update("delete from dispatch_engineer where group_id=? and batch_no=?", groupId, batchNo); jdbcTemplate.update("delete from dispatch_engineer where group_id=? and batch_no=?", groupId, batchNo);
jdbcTemplate.update("delete from dispatch_order where group_id=? and batch_no=?", groupId, batchNo); jdbcTemplate.update("delete from dispatch_order where group_id=? and batch_no=?", groupId, batchNo);
...@@ -94,23 +95,23 @@ public class BatchServiceImpl implements BatchService { ...@@ -94,23 +95,23 @@ public class BatchServiceImpl implements BatchService {
" order by a.engineer_code asc"; " order by a.engineer_code asc";
int engCount = jdbcTemplate.update(sqlEngineer, batchNo, groupId); int engCount = jdbcTemplate.update(sqlEngineer, batchNo, groupId);
// 未派过的工单 // 未派过的工单(虚拟指派不更改order_request.appointment_status,所以也包含在当前条件中)
String sqlOrder = "INSERT INTO dispatch_order (group_id, batch_no, order_id , x, y, expect_time_begin, expect_time_end, tags, priority , skills , take_time )\n" + String sqlOrder = "INSERT INTO dispatch_order (group_id, batch_no, order_id , x, y, expect_time_begin, expect_time_end, tags, priority , skills , take_time )\n" +
" select a.org_group_id, ? , a.order_id, a.x, a.y , \n" + " select a.org_group_id, ? , a.order_id, a.x, a.y , \n" +
" a.expect_time_begin, a.expect_time_end, a.tags, a.priority , concat(a.brand, a.type, a.skill) skills , b.take_time \n" + " a.expect_time_begin, a.expect_time_end, a.tags, a.priority , concat(a.brand, '-', a.type, '-', a.skill) skills , b.take_time \n" +
" from order_request a left join product_category b on (a.brand=b.brand and a.type=b.type and a.skill=b.skill )\n" + " from order_request a left join skill_info b on (a.brand=b.brand and a.type=b.type and a.skill=b.skill )\n" +
" where a.org_group_id=? and a.status='OPEN' " + " where a.org_group_id=? and a.status='OPEN' " +
" and a.dt = ? " + " and a.dt = ? " +
" and appointment_status ='NOT_ASSIGNED' and appointment_method like 'AUTO%' \n" + " and a.appointment_status ='NOT_ASSIGNED' and appointment_method like 'AUTO%' \n" +
" order by a.expect_time_begin asc "; " order by a.expect_time_begin asc ";
int orderCount = jdbcTemplate.update(sqlOrder, batchNo, groupId, batchDay); int orderCount = jdbcTemplate.update(sqlOrder, batchNo, groupId, batchDay);
// 已派过PRE状态还可以再次派 // 已派过PRE状态还可以再次派
String sqlOrderPre = "INSERT INTO dispatch_order (group_id, batch_no, order_id , x, y, expect_time_begin, expect_time_end, tags, priority , skills , take_time )\n" + String sqlOrderPre = "INSERT INTO dispatch_order (group_id, batch_no, order_id , x, y, expect_time_begin, expect_time_end, tags, priority , skills , take_time )\n" +
" select a.org_group_id, ?, a.order_id, a.x, a.y , \n" + " select a.org_group_id, ?, a.order_id, a.x, a.y , \n" +
" a.expect_time_begin, a.expect_time_end, a.tags, a.priority , concat(a.brand, a.type, a.skill) skills , b.take_time \n" + " a.expect_time_begin, a.expect_time_end, a.tags, a.priority , concat(a.brand,'-', a.type, '-', a.skill) skills , b.take_time \n" +
" from order_request a " + " from order_request a " +
" left join product_category b on (a.brand=b.brand and a.type=b.type and a.skill=b.skill )\n" + " left join skill_info b on (a.brand=b.brand and a.type=b.type and a.skill=b.skill )\n" +
" left join order_appointment o on (a.order_id =o.order_id)\n" + " left join order_appointment o on (a.order_id =o.order_id)\n" +
" where a.org_group_id=? and a.status='OPEN' \n" + " where a.org_group_id=? and a.status='OPEN' \n" +
" and a.dt = ? " + " and a.dt = ? " +
...@@ -119,8 +120,9 @@ public class BatchServiceImpl implements BatchService { ...@@ -119,8 +120,9 @@ public class BatchServiceImpl implements BatchService {
" order by a.expect_time_begin asc "; " order by a.expect_time_begin asc ";
int orderCountPre = jdbcTemplate.update(sqlOrderPre, batchNo, groupId, batchDay); int orderCountPre = jdbcTemplate.update(sqlOrderPre, batchNo, groupId, batchDay);
log.info("准备批次数据 order1 :{}", orderCount);
log.info("准备批次数据 order2 :{}", orderCountPre); log.info("准备批次数据 orderCount :{}", orderCount);
log.info("准备批次数据 orderCountPre :{}", orderCountPre);
jdbcTemplate.update("update dispatch_batch set engineer_num=? , order_num=?, start_time=?, end_time=null, status='RUNNING' where group_id=? and batch_no=?", jdbcTemplate.update("update dispatch_batch set engineer_num=? , order_num=?, start_time=?, end_time=null, status='RUNNING' where group_id=? and batch_no=?",
...@@ -148,5 +150,9 @@ public class BatchServiceImpl implements BatchService { ...@@ -148,5 +150,9 @@ public class BatchServiceImpl implements BatchService {
return optional.orElseGet(DispatchBatch::new); return optional.orElseGet(DispatchBatch::new);
} }
@Override
public void saveDispatchBatch(DispatchBatch batchInfo) {
batchRepository.save(batchInfo);
}
} }
...@@ -58,8 +58,8 @@ public class SolveServiceImpl implements SolveService { ...@@ -58,8 +58,8 @@ public class SolveServiceImpl implements SolveService {
// 查询技术员所有技能集 // 查询技术员所有技能集
private List<String> queryEngineerSkills(String engineerCode) { private List<String> queryEngineerSkills(String engineerCode) {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
String sql = "select concat( b.brand, b.type, b.skill) as skill from engineer_skill a left join product_category b \n" String sql = "select concat( b.brand, '-', b.type, '-', b.skill) as skill from engineer_skill_group a left join skill_info b \n" +
+ "\t on a.category_id= b.product_category_id where a.engineer_code=? and a.status=1 " + " on a.skill_group_code= b.skill_group_code where a.engineer_code=? and a.status=1 \n" +
" and b.brand is not null "; " and b.brand is not null ";
Object[] param = {engineerCode}; Object[] param = {engineerCode};
result = jdbcTemplate.queryForList(sql, param, String.class); result = jdbcTemplate.queryForList(sql, param, String.class);
...@@ -184,7 +184,7 @@ public class SolveServiceImpl implements SolveService { ...@@ -184,7 +184,7 @@ public class SolveServiceImpl implements SolveService {
SolverConfig solverConfig = new SolverConfig().withSolutionClass(DispatchSolution.class); SolverConfig solverConfig = new SolverConfig().withSolutionClass(DispatchSolution.class);
solverConfig.withEntityClassList(Arrays.asList(Technician.class, Customer.class));// 这里不能漏掉,否则约束不生效 solverConfig.withEntityClassList(Arrays.asList(Technician.class, Customer.class));// 这里不能漏掉,否则约束不生效
solverConfig.withConstraintProviderClass(DispatchConstraintProvider.class); solverConfig.withConstraintProviderClass(DispatchConstraintProvider.class);
solverConfig.withTerminationSpentLimit(Duration.ofSeconds(10)); solverConfig.withTerminationSpentLimit(Duration.ofSeconds(20));
SolverFactory<DispatchSolution> solverFactory = SolverFactory.create(solverConfig); SolverFactory<DispatchSolution> solverFactory = SolverFactory.create(solverConfig);
// Solve the problem // Solve the problem
......
...@@ -3,8 +3,8 @@ server: ...@@ -3,8 +3,8 @@ server:
dispatch: dispatch:
cron: cron:
expr: 0 36 8-18 * * ? expr: 0 43 8-18 * * ?
next-day-limit: 3 next-day-limit: 2
# expr: 0 */10 8-18 * * ? # expr: 0 */10 8-18 * * ?
spring: spring:
......
...@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.function.BooleanSupplier;
@RestController @RestController
@RequestMapping("/pea-order") @RequestMapping("/pea-order")
...@@ -18,6 +19,17 @@ public class ScheduleController { ...@@ -18,6 +19,17 @@ public class ScheduleController {
@Autowired @Autowired
private ScheduleService scheduleService; private ScheduleService scheduleService;
@GetMapping("/schedule/summary")
public Result<?> getScheduleSummary(@RequestParam String date, @RequestParam String levelType, @RequestParam("levelValue") List<String> levelIds){
Result<?> res = null;
try {
res = scheduleService.getScheduleSummary(date, levelType, levelIds);
} catch(BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@GetMapping("/schedule/overview") @GetMapping("/schedule/overview")
public Result<?> getScheduleOverview(@RequestParam long page, @RequestParam long size, @RequestParam String date, public Result<?> getScheduleOverview(@RequestParam long page, @RequestParam long size, @RequestParam String date,
@RequestParam String levelType, @RequestParam("levelValue") List<String> levelIds) { @RequestParam String levelType, @RequestParam("levelValue") List<String> levelIds) {
......
package com.dituhui.pea.order.dto; 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 lombok.experimental.Accessors;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -38,6 +43,10 @@ public class BusinessSkillListDTO { ...@@ -38,6 +43,10 @@ public class BusinessSkillListDTO {
@Accessors(chain = true) @Accessors(chain = true)
public static class Content { public static class Content {
private String brand; private String brand;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime; private LocalDateTime createTime;
private Boolean gasCert; private Boolean gasCert;
private String layerId; private String layerId;
...@@ -54,6 +63,10 @@ public class BusinessSkillListDTO { ...@@ -54,6 +63,10 @@ public class BusinessSkillListDTO {
private Integer takeTime; private Integer takeTime;
private String type; private String type;
private String typeCategory; private String typeCategory;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime; private LocalDateTime updateTime;
} }
} }
...@@ -22,6 +22,7 @@ public class DispatchOrderListReq { ...@@ -22,6 +22,7 @@ public class DispatchOrderListReq {
private List<Integer> priorities; private List<Integer> priorities;
private List<String> typeCategory; private List<String> typeCategory;
private List<String> skillCategory; private List<String> skillCategory;
private List<Integer> groupCategory;
private String phone; private String phone;
private String orderId; private String orderId;
private List<String> appointmentStatus; private List<String> appointmentStatus;
......
...@@ -28,6 +28,7 @@ public class OrderServiceListReq { ...@@ -28,6 +28,7 @@ public class OrderServiceListReq {
private List<Integer> priorities; private List<Integer> priorities;
private List<String> typeCategory; private List<String> typeCategory;
private List<String> skillCategory; private List<String> skillCategory;
private List<Integer> groupCategory;
private String phone; private String phone;
private String orderId; private String orderId;
private List<String> appointmentStatus; private List<String> appointmentStatus;
......
...@@ -7,7 +7,7 @@ import java.util.Date; ...@@ -7,7 +7,7 @@ import java.util.Date;
@Entity @Entity
@Data @Data
@Table(name = "map_layer_customize_entity") @Table(name = "map_layer_customize")
public class MapLayerCustomizeEntity { public class MapLayerCustomizeEntity {
@Id @Id
...@@ -27,7 +27,7 @@ public class MapLayerCustomizeEntity { ...@@ -27,7 +27,7 @@ public class MapLayerCustomizeEntity {
private String layerDescribe; private String layerDescribe;
@Column(name = "disabled", nullable = false) @Column(name = "disabled", nullable = false)
private boolean disabled; private Boolean disabled;
@Column(name = "memo", nullable = false, length = 100) @Column(name = "memo", nullable = false, length = 100)
private String memo; private String memo;
......
...@@ -17,6 +17,7 @@ public class OrgTeam { ...@@ -17,6 +17,7 @@ public class OrgTeam {
private String workdays; private String workdays;
private String memo; private String memo;
private String workOn; private String workOn;
private Integer status;
private Timestamp createTime; private Timestamp createTime;
private Timestamp updateTime; private Timestamp updateTime;
} }
...@@ -5,6 +5,9 @@ import com.dituhui.pea.common.Result; ...@@ -5,6 +5,9 @@ import com.dituhui.pea.common.Result;
import java.util.List; import java.util.List;
public interface ScheduleService { public interface ScheduleService {
Result<?> getScheduleSummary(String date, String levelType, List<String> levelIds);
Result<?> getScheduleOverview(long page, long size, String date, String levelType, List<String> levelIds); Result<?> getScheduleOverview(long page, long size, String date, String levelType, List<String> levelIds);
Result<?> getScheduleEngineerOverview(String date, String engineerCode); Result<?> getScheduleEngineerOverview(String date, String engineerCode);
......
...@@ -12,6 +12,7 @@ import com.dituhui.pea.order.entity.SkillGroupEntity; ...@@ -12,6 +12,7 @@ import com.dituhui.pea.order.entity.SkillGroupEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity; import com.dituhui.pea.order.entity.SkillInfoEntity;
import com.dituhui.pea.order.service.BusinessBaseService; import com.dituhui.pea.order.service.BusinessBaseService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
...@@ -46,28 +47,14 @@ public class BusinessBaseServiceImpl implements BusinessBaseService { ...@@ -46,28 +47,14 @@ public class BusinessBaseServiceImpl implements BusinessBaseService {
@Override @Override
public Result<?> getSkillList(BusinessSkillListDTO.Request req) { public Result<?> getSkillList(BusinessSkillListDTO.Request req) {
Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize()); Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize());
this.initMaps();
Page<SkillInfoEntity> page = skillInfoDao.findAll(pageable); Page<SkillInfoEntity> page = skillInfoDao.findAll(pageable);
List<BusinessSkillListDTO.Content> contents = page.getContent().stream().map(e -> { List<BusinessSkillListDTO.Content> contents = page.getContent().stream().map(e -> {
return new BusinessSkillListDTO.Content() BusinessSkillListDTO.Content content = new BusinessSkillListDTO.Content();
.setSkillCode(e.getSkillCode()) BeanUtils.copyProperties(e, content);
.setBrand(e.getBrand()) content.setSkillGroupName(mapSkillGroup.get(e.getSkillCode()));
.setType(e.getType()) content.setLayerName(mapLayer.get(e.getLayerId()));
.setSkill(e.getSkill()) return content;
.setTakeTime(e.getTakeTime())
.setTakeEngineer(e.getTakeEngineer())
.setLowElectricianCert(e.getLowElectricianCert())
.setGasCert(e.getGasCert())
//.setPriority(e.getPriority())
.setSkillGroupCode(e.getSkillGroupCode())
.setSkillGroupName(this.getSkillGroupName(e.getSkillCode()))
.setLayerId(e.getLayerId())
.setLayerName(this.getLayerName(e.getLayerId()))
.setTypeCategory(e.getTypeCategory())
.setSkillCategory(e.getSkillCategory())
.setMemo(e.getMemo())
.setCreateTime(e.getCreateTime())
.setUpdateTime(e.getUpdateTime());
}).collect(Collectors.toList()); }).collect(Collectors.toList());
BusinessSkillListDTO.Result rs = new BusinessSkillListDTO.Result(); BusinessSkillListDTO.Result rs = new BusinessSkillListDTO.Result();
rs.setTotal(page.getTotalElements()) rs.setTotal(page.getTotalElements())
...@@ -86,20 +73,6 @@ public class BusinessBaseServiceImpl implements BusinessBaseService { ...@@ -86,20 +73,6 @@ public class BusinessBaseServiceImpl implements BusinessBaseService {
// 技能组 // 技能组
mapSkillGroup = new HashMap<>(); mapSkillGroup = new HashMap<>();
mapSkillGroup.putAll(skillGroupDao.findAll().stream().collect(Collectors.toMap(SkillGroupEntity::getSkillGroupCode, SkillGroupEntity::getSkillGroup))); mapSkillGroup.putAll(skillGroupDao.findAll().stream().collect(Collectors.toMap(SkillGroupEntity::getSkillGroupCode, SkillGroupEntity::getSkillGroup)));
} log.info("initMaps ====> mapLayer ==> {}, mapSkillGroup ==> {}", mapLayer, mapSkillGroup);
String getLayerName(String layerId) {
if (mapLayer == null) {
initMaps();
}
return mapLayer.get(layerId);
}
String getSkillGroupName(String skillGroupCode) {
if (mapSkillGroup == null) {
initMaps();
;
}
return mapSkillGroup.get(skillGroupCode);
} }
} }
...@@ -286,10 +286,20 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -286,10 +286,20 @@ public class DispatchServiceImpl implements DispatchService {
lqw.in(ListUtils.isNotEmpty(reqDTO.getBranchIds()), OrderRequest::getOrgBranchId, reqDTO.getBranchIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getBranchIds()), OrderRequest::getOrgBranchId, reqDTO.getBranchIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderRequest::getOrgGroupId, reqDTO.getGroupIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderRequest::getOrgGroupId, reqDTO.getGroupIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderRequest::getOrgTeamId, reqDTO.getTeamIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderRequest::getOrgTeamId, reqDTO.getTeamIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getPriorities()), OrderRequest::getPriority, reqDTO.getPriorities());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderRequest::getAppointmentMethod, reqDTO.getAppointmentType()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderRequest::getAppointmentMethod, reqDTO.getAppointmentType());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderRequest::getAppointmentStatus, reqDTO.getAppointmentStatus()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderRequest::getAppointmentStatus, reqDTO.getAppointmentStatus());
if(ListUtils.isNotEmpty(reqDTO.getPriorities())) {
List<Integer> p = reqDTO.getPriorities();
if(p.contains(0) && p.contains(1)) {
lqw.ge(OrderRequest::getPriority, 1);
} else if (p.contains(0) && !p.contains(1)) {
lqw.le(OrderRequest::getPriority, 1);
} else if (p.contains(1) && !p.contains(0)) {
lqw.ge(OrderRequest::getPriority, 5);
}
}
if (ListUtils.isNotEmpty(reqDTO.getTypeCategory())) { if (ListUtils.isNotEmpty(reqDTO.getTypeCategory())) {
String types = "'" + String.join("','", reqDTO.getTypeCategory()) + "'"; String types = "'" + String.join("','", reqDTO.getTypeCategory()) + "'";
String sql = String.format("select 1 from skill_info sk where sk.brand = order_request.brand and sk.type = order_request.type and sk.skill = order_request.skill and type_category in (%s)", types); String sql = String.format("select 1 from skill_info sk where sk.brand = order_request.brand and sk.type = order_request.type and sk.skill = order_request.skill and type_category in (%s)", types);
...@@ -307,6 +317,11 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -307,6 +317,11 @@ public class DispatchServiceImpl implements DispatchService {
String sql = String.format("select 1 from order_appointment oa where oa.order_id = order_request.order_id and oa.dt = order_request.dt and oa.engineer_code in (%s)", engineerCodes); String sql = String.format("select 1 from order_appointment oa where oa.order_id = order_request.order_id and oa.dt = order_request.dt and oa.engineer_code in (%s)", engineerCodes);
lqw.exists(sql); lqw.exists(sql);
} }
if (ListUtils.isNotEmpty(reqDTO.getGroupCategory())) {
String groupCategory = reqDTO.getGroupCategory().stream().map(Object::toString).collect(Collectors.joining(","));
String sql = String.format("select 1 from org_group g where g.group_id = order_request.org_group_id and g.category in (%s)", groupCategory);
lqw.exists(sql);
}
return orderRequestMPDao.selectList(lqw); return orderRequestMPDao.selectList(lqw);
} }
......
...@@ -67,7 +67,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService { ...@@ -67,7 +67,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
rs.setTotal(page.getTotalElements()); rs.setTotal(page.getTotalElements());
rs.setPages(page.getTotalPages()); rs.setPages(page.getTotalPages());
rs.setPageSize(page.getSize()); rs.setPageSize(page.getSize());
rs.setPageCurrent(page.getNumber()); rs.setPageCurrent(page.getNumber() + 1);
rs.setEngineers(engineers); rs.setEngineers(engineers);
return Result.success(rs); return Result.success(rs);
} }
......
...@@ -56,10 +56,20 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -56,10 +56,20 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
lqw.in(ListUtils.isNotEmpty(reqDTO.getBranchIds()), OrderRequest::getOrgBranchId, reqDTO.getBranchIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getBranchIds()), OrderRequest::getOrgBranchId, reqDTO.getBranchIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderRequest::getOrgGroupId, reqDTO.getGroupIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderRequest::getOrgGroupId, reqDTO.getGroupIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderRequest::getOrgTeamId, reqDTO.getTeamIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderRequest::getOrgTeamId, reqDTO.getTeamIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getPriorities()), OrderRequest::getPriority, reqDTO.getPriorities());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderRequest::getAppointmentMethod, reqDTO.getAppointmentType()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderRequest::getAppointmentMethod, reqDTO.getAppointmentType());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderRequest::getAppointmentStatus, reqDTO.getAppointmentStatus()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderRequest::getAppointmentStatus, reqDTO.getAppointmentStatus());
if(ListUtils.isNotEmpty(reqDTO.getPriorities())) {
List<Integer> p = reqDTO.getPriorities();
if(p.contains(0) && p.contains(1)) {
lqw.ge(OrderRequest::getPriority, 1);
} else if (p.contains(0) && !p.contains(1)) {
lqw.le(OrderRequest::getPriority, 1);
} else if (p.contains(1) && !p.contains(0)) {
lqw.ge(OrderRequest::getPriority, 5);
}
}
if (ListUtils.isNotEmpty(reqDTO.getTypeCategory())) { if (ListUtils.isNotEmpty(reqDTO.getTypeCategory())) {
String types = "'" + String.join("','", reqDTO.getTypeCategory()) + "'"; String types = "'" + String.join("','", reqDTO.getTypeCategory()) + "'";
String sql = String.format("select 1 from skill_info sk where sk.brand = order_request.brand and sk.type = order_request.type and sk.skill = order_request.skill and type_category in (%s)", types); String sql = String.format("select 1 from skill_info sk where sk.brand = order_request.brand and sk.type = order_request.type and sk.skill = order_request.skill and type_category in (%s)", types);
...@@ -78,6 +88,12 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -78,6 +88,12 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
lqw.exists(sql); lqw.exists(sql);
} }
if (ListUtils.isNotEmpty(reqDTO.getGroupCategory())) {
String groupCategory = reqDTO.getGroupCategory().stream().map(Object::toString).collect(Collectors.joining(","));
String sql = String.format("select 1 from org_group g where g.group_id = order_request.org_group_id and g.category in (%s)", groupCategory);
lqw.exists(sql);
}
// 查询工单表列表 // 查询工单表列表
orderRequestMPDao.selectPage(pg, lqw); orderRequestMPDao.selectPage(pg, lqw);
......
...@@ -36,7 +36,7 @@ public class OrgCapacityServiceImpl implements OrgCapacityService { ...@@ -36,7 +36,7 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
@Override @Override
public Result<?> getOrgCapacityData(CapacityStatQueryDTO.Request reqDTO) { public Result<?> getOrgCapacityData(CapacityStatQueryDTO.Request reqDTO) {
// 根据大区/分部/分站查询,分别返回分部/分站/工作队的容量 // 根据大区/分部/分站查询,分别返回分部/分站/工作队的容量
Page<?> stats = null; Page<?> page = null;
Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize()); Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize());
Map<String, String> names = null; Map<String, String> names = null;
String levelType = reqDTO.getLevelType(); String levelType = reqDTO.getLevelType();
...@@ -47,27 +47,30 @@ public class OrgCapacityServiceImpl implements OrgCapacityService { ...@@ -47,27 +47,30 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
; ;
List<String> branchIds = new ArrayList<>(names.keySet()); List<String> branchIds = new ArrayList<>(names.keySet());
log.info("levelType: {} ==> branchIds: {}", levelType, branchIds); log.info("levelType: {} ==> branchIds: {}", levelType, branchIds);
stats = capacityOrgStatDao.findByBranchIdsAndWorkdayBetween(branchIds, reqDTO.getStartDate(), reqDTO.getEndDate(), pageable); page = capacityOrgStatDao.findByBranchIdsAndWorkdayBetween(branchIds, reqDTO.getStartDate(), reqDTO.getEndDate(), pageable);
} else if ("branch".equals(reqDTO.getLevelType())) { } else if ("branch".equals(reqDTO.getLevelType())) {
names = orgGroupDao.findAllByBranchId(levelValue).stream() names = orgGroupDao.findAllByBranchId(levelValue).stream()
.collect(Collectors.toMap(OrgGroupEntity::getGroupId, OrgGroupEntity::getGroupName)); .collect(Collectors.toMap(OrgGroupEntity::getGroupId, OrgGroupEntity::getGroupName));
List<String> groupIds = new ArrayList<>(names.keySet()); List<String> groupIds = new ArrayList<>(names.keySet());
log.info("levelType: {} ==> groupIds: {}", levelType, groupIds); log.info("levelType: {} ==> groupIds: {}", levelType, groupIds);
stats = capacityOrgStatDao.findByGroupIdsAndWorkdayBetween(groupIds, reqDTO.getStartDate(), reqDTO.getEndDate(), pageable); page = capacityOrgStatDao.findByGroupIdsAndWorkdayBetween(groupIds, reqDTO.getStartDate(), reqDTO.getEndDate(), pageable);
} else { } else {
names = orgTeamDao.findAllByGroupId(levelValue).stream() names = orgTeamDao.findAllByGroupId(levelValue).stream()
.collect(Collectors.toMap(OrgTeamEntity::getTeamId, OrgTeamEntity::getTeamName)); .collect(Collectors.toMap(OrgTeamEntity::getTeamId, OrgTeamEntity::getTeamName));
List<String> teamIds = new ArrayList<>(names.keySet()); List<String> teamIds = new ArrayList<>(names.keySet());
log.info("levelType: {} ==> teamIds: {}", levelType, teamIds); log.info("levelType: {} ==> teamIds: {}", levelType, teamIds);
stats = capacityTeamStatDao.findByTeamIdsAndWorkdayBetween(teamIds, reqDTO.getStartDate(), reqDTO.getEndDate(), pageable); page = capacityTeamStatDao.findByTeamIdsAndWorkdayBetween(teamIds, reqDTO.getStartDate(), reqDTO.getEndDate(), pageable);
} }
CapacityStatQueryDTO.Result rs = new CapacityStatQueryDTO.Result(); CapacityStatQueryDTO.Result rs = new CapacityStatQueryDTO.Result();
rs.setLevelType(levelType); rs.setLevelType(levelType);
rs.setTotal(stats.getTotalElements()).setPages(stats.getTotalPages()).setPageSize(pageable.getPageSize()).setPageCurrent(stats.getNumber()); rs.setTotal(page.getTotalElements())
.setPages(page.getTotalPages())
.setPageSize(pageable.getPageSize())
.setPageCurrent(page.getNumber() + 1);
List<CapacityStatQueryDTO.Content> contents = new ArrayList<>(); List<CapacityStatQueryDTO.Content> contents = new ArrayList<>();
for (Object item : stats.getContent()) { for (Object item : page.getContent()) {
CapacityStatQueryDTO.Content content = new CapacityStatQueryDTO.Content(); CapacityStatQueryDTO.Content content = new CapacityStatQueryDTO.Content();
if (item instanceof CapacityOrgStatEntity) { if (item instanceof CapacityOrgStatEntity) {
// cluster/branch查询,都是capacity_org_stat // cluster/branch查询,都是capacity_org_stat
......
...@@ -45,6 +45,11 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -45,6 +45,11 @@ public class ScheduleServiceImpl implements ScheduleService {
private EngineerInfoMPDao engineerInfoMPDao; private EngineerInfoMPDao engineerInfoMPDao;
@Override @Override
public Result<?> getScheduleSummary(String date, String levelType, List<String> levelIds) {
return null;
}
@Override
public Result<?> getScheduleOverview(long page, long size, String date, String levelType, List<String> levelIds) { public Result<?> getScheduleOverview(long page, long size, String date, String levelType, List<String> levelIds) {
// 获取team列表 // 获取team列表
...@@ -208,6 +213,7 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -208,6 +213,7 @@ public class ScheduleServiceImpl implements ScheduleService {
IPage<OrgTeam> pg = new Page<>(page, size); IPage<OrgTeam> pg = new Page<>(page, size);
LambdaQueryWrapper<OrgTeam> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrgTeam> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrgTeam::getStatus, 1);
lqw.in(levelType.equals("cluster"), OrgTeam::getClusterId, levelIds); lqw.in(levelType.equals("cluster"), OrgTeam::getClusterId, levelIds);
lqw.in(levelType.equals("branch"), OrgTeam::getBranchId, levelIds); lqw.in(levelType.equals("branch"), OrgTeam::getBranchId, levelIds);
lqw.in(levelType.equals("group"), OrgTeam::getGroupId, levelIds); lqw.in(levelType.equals("group"), OrgTeam::getGroupId, levelIds);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!