From 52492c65b3229425f806e16faf4fe062b8dccfe2 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期二, 10 三月 2026 11:33:37 +0800
Subject: [PATCH] 合并代码
---
xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpSchedulingDetailServiceImpl.java | 71 ++++++++++++++++++++++++++++-------
1 files changed, 57 insertions(+), 14 deletions(-)
diff --git a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpSchedulingDetailServiceImpl.java b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpSchedulingDetailServiceImpl.java
index 2709dd2..7895544 100644
--- a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpSchedulingDetailServiceImpl.java
+++ b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpSchedulingDetailServiceImpl.java
@@ -32,6 +32,9 @@
import com.xiaopeng.maintenance.service.IXpSchedulingService;
import com.xiaopeng.maintenance.service.IXpShiftService;
import com.xiaopeng.maintenance.vo.*;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -182,6 +185,7 @@
/**
* 给每天的字段赋值
+ *
* @param day
* @param dto
* @param map
@@ -286,6 +290,7 @@
/**
* 给每天的字段赋值
+ *
* @param day
* @param dto
* @param shiftName
@@ -401,7 +406,7 @@
List<XpSchedulingDetail> list = this.list(new QueryWrapper<XpSchedulingDetail>().eq("is_deleted", 0).last(" and DATE_FORMAT(plan_time,'%Y-%m') = '" + month + "'"));
//保存排班数据
XpScheduling xpScheduling = xpSchedulingService.getOne(new QueryWrapper<XpScheduling>().eq("is_deleted", 0).last(" and DATE_FORMAT(scheduling_date,'%Y-%m') = '" + month + "'"));
- if(null == xpScheduling){
+ if (null == xpScheduling) {
xpScheduling = new XpScheduling();
xpScheduling.setDeleted(false);
xpScheduling.setCreateTime(LocalDateTime.now());
@@ -434,23 +439,23 @@
&& s.getPlanTime().equals(parse)
).findAny().orElse(null);
//构建存储对象
- if(null == schedulingDetail){
+ if (null == schedulingDetail) {
schedulingDetail = new XpSchedulingDetail();
schedulingDetail.setCreateBy(userId.toString());
schedulingDetail.setCreateTime(LocalDateTime.now());
schedulingDetail.setUpdateBy(userId.toString());
schedulingDetail.setUpdateTime(LocalDateTime.now());
schedulingDetail.setDeleted(false);
- }else{
+ } else {
//构建通知消息
Long old_shiftId = schedulingDetail.getShiftId();
- if(!old_shiftId.equals(shiftId)){
+ if (!old_shiftId.equals(shiftId)) {
//获取车队的所有人员
XpShift xpShift1 = xpShifts.stream().filter(s -> s.getId().equals(old_shiftId)).findAny().orElse(null);
XpShift xpShift2 = xpShifts.stream().filter(s -> s.getId().equals(shiftId)).findAny().orElse(null);
List<Long> operationsIds = xpFleetOperationsClient.getOperationsIdsByFleetId(fleetId).getData();
- if(null != operationsIds && !operationsIds.isEmpty()){
+ if (null != operationsIds && !operationsIds.isEmpty()) {
List<XpOperationsUser> data1 = xpOperationUserClient.listByIds(operationsIds).getData();
for (XpOperationsUser xpOperationsUser : data1) {
String nickName = xpOperationsUser.getNickName();
@@ -471,7 +476,7 @@
schedulingDetail.setShiftId(shiftId);
XpShift xpShift = xpShifts.stream().filter(s -> s.getId().equals(shiftId)).findAny().orElse(null);
- if(null != xpShift){
+ if (null != xpShift) {
schedulingDetail.setIsAllDay(xpShift.getShiftName().contains("全天"));
schedulingDetail.setPlanTime(parse);
schedulingDetails.add(schedulingDetail);
@@ -479,7 +484,7 @@
}
}
//批量保存排班明细数据
- if(!schedulingDetails.isEmpty()){
+ if (!schedulingDetails.isEmpty()) {
this.saveOrUpdateBatch(schedulingDetails);
}
//异步处理消息通知数据
@@ -490,11 +495,12 @@
/**
* 构建推送消息对象
+ *
* @param message
* @param xpOperationsUser
* @return
*/
- private AliPushMessageDTO buildPushMessage(String message, XpOperationsUser xpOperationsUser){
+ private AliPushMessageDTO buildPushMessage(String message, XpOperationsUser xpOperationsUser) {
JSONObject body = new JSONObject();
body.put("content", message);
body.put("strategy", 4);
@@ -513,11 +519,12 @@
/**
* 构建消息存储
+ *
* @param body
* @param xpOperationsUser
* @return
*/
- private XpOperationsUserNotification buildXpOperationsUserNotification(String message, String body, XpOperationsUser xpOperationsUser){
+ private XpOperationsUserNotification buildXpOperationsUserNotification(String message, String body, XpOperationsUser xpOperationsUser) {
XpOperationsUserNotification operationsUserNotification = new XpOperationsUserNotification();
operationsUserNotification.setNotificationType(NotificationTypeEnum.SCHEDULE_CHANGED.getCode());
operationsUserNotification.setNotificationContent(message);
@@ -530,11 +537,12 @@
/**
* 异步处理消息推送
+ *
* @param pushMessage
* @param notifications
*/
private void pushMessage(List<AliPushMessageDTO> pushMessage, List<XpOperationsUserNotification> notifications) {
- if(pushMessage.isEmpty()){
+ if (pushMessage.isEmpty()) {
return;
}
ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
@@ -547,10 +555,9 @@
}
-
-
/**
* 导出排班数据
+ *
* @param month
* @param response
*/
@@ -559,6 +566,40 @@
PageInfo<SchedulingDetailDto> pageInfo = new PageInfo<>(0, 10000);
List<SchedulingDetailDto> schedulingDetailDtos = this.baseMapper.pageList(pageInfo, month);
List<ExportSchedulingDetailDto> exportSchedulingDetailDtos = new ArrayList<>();
+ HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
+// for (int i = 0; i < titles.size(); i++) {
+// HSSFSheet hssfSheet = hssfWorkbook.createSheet();
+// hssfSheet.setColumnWidth(0, 6 * 256);
+// hssfSheet.setDefaultRowHeightInPoints(20f);
+//
+// HSSFRow hssfRow = hssfSheet.createRow(0);//设置第一行数据(标题)
+// HSSFCellStyle style = hssfWorkbook.createCellStyle();
+// HSSFFont font = hssfWorkbook.createFont();
+// font.setBold(true);
+// style.setFont(font);
+// style.setAlignment(HorizontalAlignment.CENTER);
+// for (int l = 0; l < titles.get(i).size(); l++) {
+// HSSFCell hssfCell = hssfRow.createCell(l);
+// hssfCell.setCellType(CellType.STRING);//设置表格类型
+// hssfCell.setCellValue(titles.get(i).get(l));
+// hssfCell.setCellStyle(style);
+// hssfSheet.setColumnWidth(l, 20 * 256);
+// }
+//
+// //将数据添加到表格中
+// List<String> data = null;
+// for (int l = 0; l < datas.get(i).size(); l++) {
+// hssfRow = hssfSheet.createRow(l + 1);
+// data = datas.get(i).get(l);
+// for (int j = 0; j < data.size(); j++) {
+// HSSFCell hssfCell = hssfRow.createCell(j);
+// hssfCell.setCellType(CellType.STRING);//设置表格类型
+// hssfCell.setCellValue(data.get(j));
+// }
+// }
+// }
+
+
//获取月份的最大天数
LocalDate parse1 = LocalDate.parse(month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
int dayOfMonth = parse1.with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth();
@@ -568,7 +609,7 @@
for (int i = 1; i <= dayOfMonth; i++) {
LocalDate parse = LocalDate.parse(month + "-" + String.format("%02d", i), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
String week = "";
- switch (parse.getDayOfWeek()){
+ switch (parse.getDayOfWeek()) {
case MONDAY:
week = "一";
break;
@@ -626,7 +667,7 @@
exportSchedulingDetailDto.setMorning(morning + "");
exportSchedulingDetailDto.setMidDay(midDay + "");
exportSchedulingDetailDto.setEvening(evening + "");
- }else{
+ } else {
for (int i = 1; i <= 31; i++) {
String shiftName = "休";
setEnglishDay(i, exportSchedulingDetailDto, shiftName);
@@ -644,4 +685,6 @@
excelUtil.exportExcel(response, exportSchedulingDetailDtos, "排班计划[日期:" + split[0] + "年" + split[1] + "月]");
}
+
+
}
--
Gitblit v1.7.1