Commit e171ae61 by Ren Ping

fix:排班结果工程师详情修改

1 parent d28fc44a
...@@ -2,6 +2,7 @@ package com.dituhui.pea.dispatch.quartz; ...@@ -2,6 +2,7 @@ package com.dituhui.pea.dispatch.quartz;
import com.dituhui.pea.dispatch.service.SchedulerService; import com.dituhui.pea.dispatch.service.SchedulerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException; import org.quartz.JobExecutionException;
import org.quartz.JobKey; import org.quartz.JobKey;
...@@ -18,6 +19,7 @@ import javax.annotation.Resource; ...@@ -18,6 +19,7 @@ import javax.annotation.Resource;
*/ */
@Component @Component
@Slf4j @Slf4j
@DisallowConcurrentExecution
public class AutoDispatchJob extends QuartzJobBean { public class AutoDispatchJob extends QuartzJobBean {
public static final String TEAM_JOB_PREFIX="BOXI_TEAM_"; public static final String TEAM_JOB_PREFIX="BOXI_TEAM_";
......
...@@ -201,6 +201,10 @@ public class BatchServiceImpl implements BatchService { ...@@ -201,6 +201,10 @@ public class BatchServiceImpl implements BatchService {
String batchNo = ""; String batchNo = "";
String batchDay = ""; String batchDay = "";
if("team_suzhou_001".equals(teamId)){
System.out.println(teamId);
}
Optional<DispatchBatch> optional = batchRepository.findByTeamIdAndBatchDate(teamId, day); Optional<DispatchBatch> optional = batchRepository.findByTeamIdAndBatchDate(teamId, day);
if (!optional.isPresent()) { if (!optional.isPresent()) {
// 创建batch // 创建batch
...@@ -227,22 +231,26 @@ public class BatchServiceImpl implements BatchService { ...@@ -227,22 +231,26 @@ public class BatchServiceImpl implements BatchService {
log.info("写入新批次技术员、工单数据, teamId:{}, day:{}, batchNo:{}", teamId, batchDay, batchNo); log.info("写入新批次技术员、工单数据, teamId:{}, day:{}, batchNo:{}", teamId, batchDay, batchNo);
String sqlEngineer = "INSERT INTO dispatch_engineer (team_id, batch_no, engineer_code, engineer_name, x, y, max_num, max_minute, max_distance, vehicle_type)\n" String sqlEngineer = "INSERT INTO dispatch_engineer (team_id, batch_no, engineer_code, engineer_name, x, y, max_num, max_minute, max_distance, vehicle_type)\n"
+ "SELECT o.team_id,?,o.engineer_code, a.name , b.x, b.y , max_num, max_minute, max_distance, b.vehicle FROM `org_team_engineer` o,engineer_info a,engineer_business b \r\n" + "SELECT o.team_id,?,o.engineer_code, a.name , b.x, b.y , max_num, max_minute, max_distance, b.vehicle FROM `org_team_engineer` o,engineer_info a,engineer_business b \n"
+ " WHERE o.team_id=? AND `status`=1\r\n" + " WHERE o.team_id=? AND o.`status`=1\n"
+ " AND o.engineer_code=a.engineer_code AND a.engineer_code = b.engineer_code \r\n" + " AND o.engineer_code=a.engineer_code AND a.engineer_code = b.engineer_code \n"
+ " AND b.x IS NOT NULL AND b.x !=''" + " order by a.engineer_code asc"; + " AND b.x IS NOT NULL AND b.x !=''" + " order by a.engineer_code asc";
int engCount = jdbcTemplate.update(sqlEngineer, batchNo, teamId); int engCount = jdbcTemplate.update(sqlEngineer, batchNo, teamId);
if("team_suzhou_001".equals(teamId)){
System.out.println(teamId);
}
// 未派过的工单(已派过PRE状态还可以再次派) // 未派过的工单(已派过PRE状态还可以再次派)
String sqlOrder = "INSERT INTO dispatch_order (group_id, batch_no, team_id, order_id , dt, x, y, \n" String sqlOrder = "INSERT INTO dispatch_order (group_id, batch_no, team_id, order_id , dt, x, y, \n"
+ " expect_time_begin, expect_time_end, tags, priority , skills , take_time, status )\n" + " expect_time_begin, expect_time_end, tags, priority , skills , take_time, status )\n"
+ " SELECT a.org_group_id, ?, a.org_team_id , a.order_id, ?, a.x, a.y , \r\n" + " SELECT a.org_group_id, ?, a.org_team_id , a.order_id, ?, a.x, a.y , \n"
+ " a.expect_time_begin, a.expect_time_end, a.tags, a.priority , \r\n" + " a.expect_time_begin, a.expect_time_end, a.tags, a.priority , \n"
+ " CONCAT(a.brand, '-', a.type, '-', a.skill) skills , a.take_time , a.appointment_status\r\n" + " CONCAT(a.brand, '-', a.type, '-', a.skill) skills , a.take_time , a.appointment_status\n"
+ " FROM order_info a \r\n" + " WHERE a.org_team_id=? AND a.dt = ? AND bean_status='OPEN'\r\n" + " FROM order_info a \n" + " WHERE a.org_team_id=? AND a.dt = ? AND bean_status='OPEN'\n"
+ " AND appointment_method LIKE 'AUTO%' AND a.appointment_status IN ('INIT', 'PRE')\r\n" + " AND appointment_method LIKE 'AUTO%' AND a.appointment_status IN ('INIT', 'PRE')\n"
+ " AND order_status ='NORMAL' AND service_status='INIT'\r\n" + " AND order_status ='NORMAL' AND service_status='INIT'\n"
+ " ORDER BY a.expect_time_begin ASC \r\n"; + " ORDER BY a.expect_time_begin ASC \n";
int orderCount = jdbcTemplate.update(sqlOrder, batchNo, batchDay, teamId, batchDay); int orderCount = jdbcTemplate.update(sqlOrder, batchNo, batchDay, teamId, batchDay);
// confirm的要做预占用,所以也加入进来 // confirm的要做预占用,所以也加入进来
......
...@@ -57,15 +57,13 @@ public class SchedulerServiceImpl implements SchedulerService { ...@@ -57,15 +57,13 @@ public class SchedulerServiceImpl implements SchedulerService {
} }
@Override @Override
@Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
public void dispatchRun2(String teamId) { public void dispatchRun2(String teamId) {
OrgTeamEntity orgTeamEntity = orgTeamDao.findByTeamId(teamId); OrgTeamEntity orgTeamEntity = orgTeamDao.findByTeamId(teamId);
String groupId = orgTeamEntity.getGroupId(); String groupId = orgTeamEntity.getGroupId();
log.info("dispatchRun group:{}, team:{} done", groupId, teamId); log.info("dispatchRun group:{}, team:{} done", groupId, teamId);
try {
for (int i = 1; i <= nextDaysLimit; i++) { for (int i = 1; i <= nextDaysLimit; i++) {
String currDay = LocalDate.now().plusDays(i).format(DateTimeFormatter.ISO_LOCAL_DATE); String currDay = LocalDate.now().plusDays(i).format(DateTimeFormatter.ISO_LOCAL_DATE);
try {
log.info("dispatchRun begin----- teamId:{}, day:{}", teamId, currDay); log.info("dispatchRun begin----- teamId:{}, day:{}", teamId, currDay);
String batchNo = batchService.buildBatchData2(teamId, currDay); String batchNo = batchService.buildBatchData2(teamId, currDay);
...@@ -90,10 +88,10 @@ public class SchedulerServiceImpl implements SchedulerService { ...@@ -90,10 +88,10 @@ public class SchedulerServiceImpl implements SchedulerService {
exporter.write(solution, new File(String.format("dispatchSolution_%s_%s.json", teamId, currDay))); exporter.write(solution, new File(String.format("dispatchSolution_%s_%s.json", teamId, currDay)));
//log.info("dispatchRun group:{}, team:{} done", groupId, teamId); //log.info("dispatchRun group:{}, team:{} done", groupId, teamId);
}
} catch (Exception e) { } catch (Exception e) {
log.error(">>> (teamId:{})自动排班失败:{}", teamId, e.getMessage(), e); log.error(">>> (teamId:{}, day:{})自动排班失败:{}", teamId, currDay, e.getMessage(), e);
throw e; throw e;
} }
} }
}
} }
\ No newline at end of file
...@@ -416,7 +416,6 @@ public class SolveServiceImpl implements SolveService { ...@@ -416,7 +416,6 @@ public class SolveServiceImpl implements SolveService {
saveSolutionToDispatch2(teamId, batchNo, solution); saveSolutionToDispatch2(teamId, batchNo, solution);
} }
......
...@@ -6,6 +6,11 @@ import lombok.Data; ...@@ -6,6 +6,11 @@ import lombok.Data;
public class ScheduleEngineerOverviewDynamics { public class ScheduleEngineerOverviewDynamics {
/** /**
* 分站名称
*/
private String groupName;
/**
* 姓名 * 姓名
*/ */
private String name; private String name;
......
...@@ -239,11 +239,18 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -239,11 +239,18 @@ public class ScheduleServiceImpl implements ScheduleService {
sumElapsed += Objects.isNull(o.getArriveElapsed()) ? 0 : o.getArriveElapsed(); sumElapsed += Objects.isNull(o.getArriveElapsed()) ? 0 : o.getArriveElapsed();
} }
String groupName = "";
OrgGroupEntity group = orgGroupDao.getByGroupId(engineer.getGroupId());
if (group != null) {
groupName = group.getGroupName();
}
Map<String, List<OrderInfoEntity>> statusGroup = orderAppointments.stream().collect(Collectors.groupingBy(OrderInfoEntity::getServiceStatus)); Map<String, List<OrderInfoEntity>> statusGroup = orderAppointments.stream().collect(Collectors.groupingBy(OrderInfoEntity::getServiceStatus));
List<OrderInfoEntity> empty = new ArrayList<>(); List<OrderInfoEntity> empty = new ArrayList<>();
Integer countPending = statusGroup.getOrDefault("INIT", empty).size() + statusGroup.getOrDefault("CONTACTED", empty).size() + statusGroup.getOrDefault("PENDING", empty).size(); Integer countPending = statusGroup.getOrDefault("INIT", empty).size() + statusGroup.getOrDefault("CONTACTED", empty).size() + statusGroup.getOrDefault("PENDING", empty).size();
ScheduleEngineerOverviewDynamics dynamics = new ScheduleEngineerOverviewDynamics(); ScheduleEngineerOverviewDynamics dynamics = new ScheduleEngineerOverviewDynamics();
dynamics.setGroupName(groupName);
dynamics.setName(engineer.getName()); dynamics.setName(engineer.getName());
dynamics.setEngineerCode(engineer.getEngineerCode()); dynamics.setEngineerCode(engineer.getEngineerCode());
dynamics.setPhone(engineer.getPhone()); dynamics.setPhone(engineer.getPhone());
...@@ -310,12 +317,6 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -310,12 +317,6 @@ public class ScheduleServiceImpl implements ScheduleService {
orders.add(item); orders.add(item);
} }
String groupName = "";
OrgGroupEntity group = orgGroupDao.getByGroupId(engineer.getGroupId());
if (group != null) {
groupName = group.getGroupName();
}
ScheduleEngineerOverviewResp res = new ScheduleEngineerOverviewResp(); ScheduleEngineerOverviewResp res = new ScheduleEngineerOverviewResp();
// res.setTitle(String.format("%s_%s_%s_%s_%s", groupName, // res.setTitle(String.format("%s_%s_%s_%s_%s", groupName,
// engineer.getName(), // engineer.getName(),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!