Commit b3f05263 by 丁伟峰

Merge branch 'dev-gantt' into develop

2 parents 10cfc34e f91d118c
...@@ -21,4 +21,6 @@ public interface EngineerBusinessDao extends CrudRepository<EngineerBusinessEnti ...@@ -21,4 +21,6 @@ public interface EngineerBusinessDao extends CrudRepository<EngineerBusinessEnti
@Modifying @Modifying
@Query("UPDATE EngineerBusinessEntity tt SET tt.address = :address, tt.X= :x, tt.Y=:y WHERE tt.engineerCode = :engineerCode") @Query("UPDATE EngineerBusinessEntity tt SET tt.address = :address, tt.X= :x, tt.Y=:y WHERE tt.engineerCode = :engineerCode")
void updateEngineerCenter(String address, String x, String y, String engineerCode); void updateEngineerCenter(String address, String x, String y, String engineerCode);
EngineerBusinessEntity getByEngineerCode(String engineerCode);
} }
...@@ -80,9 +80,10 @@ public class EngineersGanttDTO { ...@@ -80,9 +80,10 @@ public class EngineersGanttDTO {
@lombok.Data @lombok.Data
public static class Slot { public static class Slot {
private String bgColor = "blue"; private String bgColor = "#016FFF";
private String borderColor = "blue"; private String borderColor = "#016FFF";
private String borderStyle = "solid"; private String borderStyle = "solid";
private String shapeSize = "normal";
private String btime; private String btime;
private String etime; private String etime;
private String text; private String text;
......
...@@ -18,41 +18,62 @@ import java.time.LocalDateTime; ...@@ -18,41 +18,62 @@ import java.time.LocalDateTime;
public class EngineerBusinessEntity implements Serializable { public class EngineerBusinessEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id; @Column(name = "id")
private Long id;
@Column(name = "engineer_code") @Column(name = "engineer_code", nullable = false, length = 50)
private String engineerCode; private String engineerCode;
@Column(name = "max_num") @Column(name = "work_on", nullable = false, length = 5, columnDefinition = "varchar(5) default '08:00'")
private Integer maxNum; private String workOn;
@Column(name = "max_minute") @Column(name = "work_off", nullable = false, length = 5, columnDefinition = "varchar(5) default '18:00'")
private Integer maxMinute; private String workOff;
@Column(name = "max_distance") @Column(name = "max_num", nullable = false)
private Integer maxDistance; private int maxNum;
@Column(name = "max_minute", nullable = false)
private int maxMinute;
@Column(name = "max_distance", nullable = false)
private int maxDistance;
@Column(name = "address", nullable = false, length = 50)
private String address; private String address;
@Column(name = "x") @Column(name = "x", nullable = false, length = 20)
private String X; private String X;
@Column(name = "y") @Column(name = "y", nullable = false, length = 20)
private String Y; private String Y;
private Integer priority; @Column(name = "vehicle", nullable = false, length = 10, columnDefinition = "varchar(10) default 'electric'")
private String vehicle;
@Column(name = "vehicle_no", nullable = false, length = 10, columnDefinition = "varchar(10) default ''")
private String vehicleNo;
private Integer departure; @Column(name = "priority", nullable = false, columnDefinition = "tinyint(4) default '1'")
private int priority;
@Column(name = "departure", nullable = false, columnDefinition = "tinyint(4) default '0'")
private int departure;
@Column(name = "dispatch_strategy", nullable = false, length = 32, columnDefinition = "varchar(32) default 'CENTER'")
private String dispatchStrategy;
@Column(name = "memo", nullable = false, length = 100, columnDefinition = "varchar(100) default ''")
private String memo; private String memo;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time") @Column(name = "create_time", nullable = false, updatable = false, columnDefinition = "timestamp default current_timestamp")
private LocalDateTime createTime; private LocalDateTime createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "update_time") @Column(name = "update_time", nullable = false, columnDefinition = "timestamp default current_timestamp on update current_timestamp")
private LocalDateTime updateTime; private LocalDateTime updateTime;
} }
...@@ -32,9 +32,14 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -32,9 +32,14 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
private EngineerUtils engineerUtils; private EngineerUtils engineerUtils;
@Autowired @Autowired
private OrderInfoDao orderInfoDao; private OrderInfoDao orderInfoDao;
@Autowired
private EngineerBusinessDao engineerBusinessDao;
private String getHourMinute(LocalDateTime time){ private String getHourMinute(LocalDateTime time){
return DateUtils.formatDateTime(time, "HH:mm"); return this.getHourMinute(time, 0);
}
private String getHourMinute(LocalDateTime time, int deltaMinute){
return DateUtils.formatDateTime(time.plusMinutes(deltaMinute), "HH:mm");
} }
@Override @Override
public Result<?> getEngineersGanttList(EngineersGanttDTO.Request reqDTO) { public Result<?> getEngineersGanttList(EngineersGanttDTO.Request reqDTO) {
...@@ -50,13 +55,12 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -50,13 +55,12 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
List<OrderInfoEntity> orders = orderInfoDao.findByDtAndEngineerCodeIn(reqDTO.getDate(), engineerCodes); List<OrderInfoEntity> orders = orderInfoDao.findByDtAndEngineerCodeIn(reqDTO.getDate(), engineerCodes);
HashMap<String, List<EngineersGanttDTO.Slot>> mapEngineers = new HashMap<>(); HashMap<String, List<EngineersGanttDTO.Slot>> mapEngineers = new HashMap<>();
for (OrderInfoEntity e : orders) { for (OrderInfoEntity e : orders) {
// log.info("===== order_id: [{}]", e.getOrderId()); // 服务工单本体
EngineersGanttDTO.Slot slot = new EngineersGanttDTO.Slot(); EngineersGanttDTO.Slot slot = new EngineersGanttDTO.Slot();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX // todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
slot.setBtime(getHourMinute(e.getExpectTimeBegin())); slot.setBtime(getHourMinute(e.getExpectTimeBegin()));
slot.setEtime(getHourMinute(e.getExpectTimeEnd())); slot.setEtime(getHourMinute(e.getExpectTimeEnd()));
slot.setTooltip(getOrderTips(e.getOrderId())); slot.setTooltip(getOrderTips(e.getOrderId()));
OrderSkillProjection orderSkill = orderInfoDao.getOrderSkillCaptionByOrderId(e.getOrderId()); OrderSkillProjection orderSkill = orderInfoDao.getOrderSkillCaptionByOrderId(e.getOrderId());
if (orderSkill != null) { if (orderSkill != null) {
slot.setText(orderSkill.getSkillCaption()); slot.setText(orderSkill.getSkillCaption());
...@@ -68,17 +72,29 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -68,17 +72,29 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
} else { } else {
slots = new ArrayList<>(); slots = new ArrayList<>();
} }
slot.setBgColor(getColor(e.getServiceStatus()));
slots.add(slot);
if(e.getArriveElapsed() > 0) {
// 有在途,起止时间,分别是订单的开始时间减去在途时间、订单的开始时间
slot = new EngineersGanttDTO.Slot();
slot.setBtime(getHourMinute(e.getExpectTimeBegin(), -e.getArriveElapsed()));
slot.setEtime(getHourMinute(e.getExpectTimeBegin()));
slot.setShapeSize("mini");
slot.setBgColor(getColor("ONWAY"));
slots.add(slot); slots.add(slot);
}
slots.sort(Comparator.comparing(EngineersGanttDTO.Slot::getBtime));
mapEngineers.put(e.getEngineerCode(), slots); mapEngineers.put(e.getEngineerCode(), slots);
} }
log.info("mapEngineers ===> {}", mapEngineers); log.info("mapEngineers ===> {}", mapEngineers);
List<EngineersGanttDTO.GanttChart> engineers = new ArrayList<>(); List<EngineersGanttDTO.GanttChart> engineers = new ArrayList<>();
for (String engineerCode : engineerCodes) { for (String engineerCode : engineerCodes) {
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(engineerCode); EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(engineerCode);
EngineerBusinessEntity engineerBusinessEntity = engineerBusinessDao.getByEngineerCode(engineerCode);
EngineersGanttDTO.GanttChart engineer = new EngineersGanttDTO.GanttChart(); EngineersGanttDTO.GanttChart engineer = new EngineersGanttDTO.GanttChart();
engineer.setEngineerCode(engineerCode) engineer.setEngineerCode(engineerCode)
.setStartTime(String.format("%s 08:00", reqDTO.getDate())) .setStartTime(String.format("%s %s", reqDTO.getDate(), engineerBusinessEntity.getWorkOn()))
.setEndTime(String.format("%s 18:00", reqDTO.getDate())) .setEndTime(String.format("%s %s", reqDTO.getDate(), engineerBusinessEntity.getWorkOff()))
.setHoliday(false) // todo .setHoliday(false) // todo
.setEngineerName(engineerInfo.getName()) .setEngineerName(engineerInfo.getName())
.setGrade(engineerInfo.getGrade()); .setGrade(engineerInfo.getGrade());
...@@ -87,7 +103,6 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -87,7 +103,6 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
if (capacityEngineerStat == null) { if (capacityEngineerStat == null) {
log.warn("技术员当日的容量数据不存在,{}{}", engineerCode, reqDTO.getDate()); log.warn("技术员当日的容量数据不存在,{}{}", engineerCode, reqDTO.getDate());
} else { } else {
log.info("====== {}", capacityEngineerStat);
engineer.setCapTotal(capacityEngineerStat.getCapTotal().toString()).setCapUsed(capacityEngineerStat.getCapUsed().toString()); engineer.setCapTotal(capacityEngineerStat.getCapTotal().toString()).setCapUsed(capacityEngineerStat.getCapUsed().toString());
} }
if (mapEngineers.containsKey(engineerCode)) { if (mapEngineers.containsKey(engineerCode)) {
...@@ -157,4 +172,22 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -157,4 +172,22 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
tips.add(new LabelValueDTO().setLabel("标签").setValue(order.getTags())); tips.add(new LabelValueDTO().setLabel("标签").setValue(order.getTags()));
return tips; return tips;
} }
private String getColor(String colorType){
String[][] bgColor = {
{"INIT", "#FFAA44"}, // 待定
{"FINISHED", "#016FFF"}, //完成
{"WARNING", "#FF3D44"}, // 警告
{"PAUSED", "#4E5969"}, //暂停
{"UNFINISHED", "#52EDED"}, //未完成
{"STARTED", "#469967"}, //已启动
{"ONWAY", "rgba(78, 89, 105, 0.5)"}, // 在途
{"CANCELED", "#4E5969"}, // 已取消
{"LEAVE", "#A8ABA9"}, //请假
{"WAREHOUSE", "#EDEDED"}, //仓库准备
};
Map<String, String> bgColorMap = Arrays.stream(bgColor).collect(Collectors.toMap(pair -> pair[0], pair->pair[1]));
return bgColorMap.getOrDefault(colorType, "#016FFF");
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!