localizer
ljw 2025-10-13 10:54:51 +08:00
parent 47918629f7
commit ae3c856b28
9 changed files with 380 additions and 16 deletions

View File

@ -88,6 +88,11 @@
<artifactId>core</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.35</version>
</dependency>
</dependencies>

View File

@ -1,9 +1,11 @@
package com.njzscloud.supervisory.biz.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -22,12 +24,17 @@ import com.njzscloud.supervisory.biz.pojo.result.SearchTruckResult;
import com.njzscloud.supervisory.device.pojo.entity.DeviceLocalizerEntity;
import com.njzscloud.supervisory.device.service.DeviceLocalizerService;
import com.njzscloud.supervisory.sys.auth.pojo.result.MyResult;
import com.njzscloud.supervisory.sys.dict.pojo.DictItemEntity;
import com.njzscloud.supervisory.sys.dict.pojo.ObtainDictDataResult;
import com.njzscloud.supervisory.sys.dict.service.DictItemService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
*
@ -37,7 +44,8 @@ import java.util.List;
@RequiredArgsConstructor
public class BizTruckService extends ServiceImpl<BizTruckMapper, BizTruckEntity> implements IService<BizTruckEntity> {
private final DeviceLocalizerService deviceLocalizerService;
@Autowired
private DictItemService dictItemService;
/**
*
@ -95,7 +103,17 @@ public class BizTruckService extends ServiceImpl<BizTruckMapper, BizTruckEntity>
* @return BizTruckEntity
*/
public SearchTruckResult detail(Long id) {
return baseMapper.selectDetailById(id);
SearchTruckResult result = baseMapper.selectDetailById(id);
List<DictItemEntity> list = dictItemService.list(Wrappers.<DictItemEntity>lambdaQuery()
.eq(DictItemEntity::getDictKey, "vehicle_type"));
if (null != list && list.size() > 0) {
List<DictItemEntity> entityList = list.stream().filter(t-> t.getVal().equals(result.getTruckCategory()))
.collect(Collectors.toList());
if (entityList.size() > 0) {
result.setTruckCategory(entityList.get(0).getTxt());
}
}
return result;
}
/**
@ -125,7 +143,19 @@ public class BizTruckService extends ServiceImpl<BizTruckMapper, BizTruckEntity>
) {
ew.eq("b.user_id", userDetail.getUserId());
}
return PageResult.of(baseMapper.paging(pageParam.toPage(), ew));
IPage<SearchTruckResult> page = baseMapper.paging(pageParam.toPage(), ew);
List<DictItemEntity> list = dictItemService.list(Wrappers.<DictItemEntity>lambdaQuery()
.eq(DictItemEntity::getDictKey, "vehicle_type"));
if (null != list && list.size() > 0) {
for (SearchTruckResult result: page.getRecords()) {
List<DictItemEntity> entityList = list.stream().filter(t-> t.getVal().equals(result.getTruckCategory()))
.collect(Collectors.toList());
if (entityList.size() > 0) {
result.setTruckCategory(entityList.get(0).getTxt());
}
}
}
return PageResult.of(page);
}
@Transactional(rollbackFor = Exception.class)

View File

@ -16,6 +16,8 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
@ -236,4 +238,12 @@ public class OrderInfoController {
return R.success();
}
/**
*
*/
@GetMapping(value = "/export")
public void export(HttpServletResponse response, OrderPagingSearchParam param) throws IOException {
orderInfoService.export(response, param);
}
}

View File

@ -6,11 +6,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njzscloud.supervisory.biz.pojo.entity.BizCompanyEntity;
import com.njzscloud.supervisory.biz.pojo.entity.BizTruckEntity;
import com.njzscloud.supervisory.order.pojo.entity.OrderInfoEntity;
import com.njzscloud.supervisory.order.pojo.result.OrderExportResult;
import com.njzscloud.supervisory.order.pojo.result.OrderPagingResult;
import com.njzscloud.supervisory.order.pojo.result.PaymentContextResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
*/
@ -19,6 +22,8 @@ public interface OrderInfoMapper extends BaseMapper<OrderInfoEntity> {
Page<OrderPagingResult> paging(Page<OrderPagingResult> page, @Param("ew") QueryWrapper<OrderPagingResult> ew);
List<OrderExportResult> exportList(@Param("ew") QueryWrapper<OrderPagingResult> ew);
OrderPagingResult detail(@Param("ew") QueryWrapper<OrderPagingResult> ew);
OrderPagingResult pendingOrder(@Param("ew") QueryWrapper<Object> ew);

View File

@ -0,0 +1,89 @@
package com.njzscloud.supervisory.order.pojo.result;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
@Getter
@Setter
@ToString
@Accessors(chain = true)
public class OrderExportResult {
/**
*
*/
private Integer sort;
/**
*
*/
private String transTime;
/**
*
*/
private String stationName;
/**
*
*/
private String transCompanyName;
/**
*
*/
private String licensePlate;
/**
*
*/
private String truckCategory;
/**
*
*/
private String estimatedQuantity;
/**
*
*/
private String inTime;
/**
*
*/
private String cfCompanyName;
/**
*
*/
private String areaName;
/**
*
*/
private Integer roughWeight;
/**
*
*/
private Integer tareWeight;
/**
*
*/
private Integer settleWeight;
/**
*
*/
private String driverName;
/**
*
*/
private String checkerMemo;
}

View File

@ -39,6 +39,7 @@ import com.njzscloud.supervisory.order.mapper.OrderInfoMapper;
import com.njzscloud.supervisory.order.pojo.entity.*;
import com.njzscloud.supervisory.order.pojo.param.*;
import com.njzscloud.supervisory.order.pojo.result.*;
import com.njzscloud.supervisory.order.utils.FileUtil;
import com.njzscloud.supervisory.station.pojo.entity.StationManageEntity;
import com.njzscloud.supervisory.station.service.StationManageService;
import com.njzscloud.supervisory.sys.auth.pojo.result.MyResult;
@ -47,15 +48,14 @@ import com.njzscloud.supervisory.voicebox.service.CloudVoiceboxService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@ -80,7 +80,6 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
private final BizWarnService bizWarnService;
private final AppProperties appProperties;
private final StationManageService stationManageService;
private final PlatformTransactionManager transactionManager;
private final CloudVoiceboxService cloudVoiceboxService;
private static void stopTuqiangTrack(String gpsId) {
@ -320,8 +319,9 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
MyResult userDetail = SecurityUtil.loginUser();
Long userId = SecurityUtil.currentUserId();
BizObj bizObj = userDetail.getBizObj();
page.addOrder(OrderItem.desc("d.out_time"));
if (null != page) {
page.addOrder(OrderItem.desc("d.out_time"));
}
if (BizObj.isWaste(bizObj)) {
ew
@ -1126,4 +1126,41 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
add(addOrderInfoParam, orderSn == null ? null : orderSn + "-" + (i + 1));
}
}
public void export(HttpServletResponse response, OrderPagingSearchParam searchParam) throws IOException {
LocalDateTime startTime = searchParam.getStartTime();
LocalDateTime endTime = searchParam.getEndTime();
QueryWrapper<OrderPagingResult> ew = Wrappers.query();
ew.like(StrUtil.isNotBlank(searchParam.getSn()), "a.sn", searchParam.getSn());
ew.like(StrUtil.isNotBlank(searchParam.getLicensePlate()), "e.license_plate", searchParam.getLicensePlate());
ew.like(StrUtil.isNotBlank(searchParam.getPhone()), "a.phone", searchParam.getPhone());
ew.like(StrUtil.isNotBlank(searchParam.getNickname()), "a.contacts", searchParam.getNickname());
ew.ge(startTime != null, "a.create_time", startTime);
ew.le(endTime != null, "a.create_time", endTime);;
historyEW(searchParam, null, ew);
List<OrderExportResult> list = baseMapper.exportList(ew);
List<Map<String, Object>> downList = new ArrayList<>();
int i = 1;
for (OrderExportResult result: list) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("序号", i);
map.put("日期", result.getTransTime());
map.put("中转站", result.getStationName());
map.put("运输公司", result.getTransCompanyName());
map.put("车牌号", result.getLicensePlate());
map.put("车辆类型", result.getTruckCategory());
map.put("方量(方)", result.getEstimatedQuantity());
map.put("进场时间", result.getInTime());
map.put("产废单位", result.getCfCompanyName());
map.put("所属区域", result.getAreaName());
map.put("入场磅重(吨)", result.getRoughWeight());
map.put("皮重(吨)", result.getTareWeight());
map.put("净重(吨)", result.getSettleWeight());
map.put("驾驶员", result.getDriverName());
map.put("备注", result.getCheckerMemo());
downList.add(map);
i ++;
}
FileUtil.downloadExcel(downList, response, "收运统计表.xlsx");
}
}

View File

@ -0,0 +1,133 @@
package com.njzscloud.supervisory.order.utils;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.poi.excel.BigExcelWriter;
import cn.hutool.poi.excel.ExcelUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* File
*
* @author ljw
* @date 2505-10-13
*/
@Slf4j
public class FileUtil extends cn.hutool.core.io.FileUtil {
/**
*
* <br>
* windows Linux ,
* windows \\==\
*
* <pre>
* java.io.tmpdir
* windows : C:\Users/xxx\AppData\Local\Temp\
* linux: /temp
* </pre>
*/
public static final String SYS_TEM_DIR = System.getProperty("java.io.tmpdir") + File.separator;
/**
* excel
*/
public static void downloadExcel(List<Map<String, Object>> list, HttpServletResponse response, String fileName) throws IOException {
String tempPath = SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx";
File file = new File(tempPath);
BigExcelWriter writer = ExcelUtil.getBigWriter(file);
// 处理数据以防止CSV注入
List<Map<String, Object>> sanitizedList = list.parallelStream().map(map -> {
Map<String, Object> sanitizedMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (value instanceof String) {
String strValue = (String) value;
// 检查并处理以特殊字符开头的值
if (strValue.startsWith("=") || strValue.startsWith("+") || strValue.startsWith("-") || strValue.startsWith("@")) {
strValue = "'" + strValue; // 添加单引号前缀
}
sanitizedMap.put(key, strValue);
} else {
sanitizedMap.put(key, value);
}
});
return sanitizedMap;
}).collect(Collectors.toList());
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(sanitizedList, true);
SXSSFSheet sheet = (SXSSFSheet) writer.getSheet();
// 手动设置列宽,确保标题和数据内容都能完整显示
int columnCount = sheet.getRow(0).getLastCellNum();
for (int i = 0; i < columnCount; i++) {
String headerText = "";
int maxContentLength = 0;
try {
// 获取标题文本
if (sheet.getRow(0) != null && sheet.getRow(0).getCell(i) != null) {
headerText = sheet.getRow(0).getCell(i).getStringCellValue();
}
// 遍历所有数据行,找到最长的内容
for (int rowIndex = 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
if (sheet.getRow(rowIndex) != null && sheet.getRow(rowIndex).getCell(i) != null) {
String cellValue = sheet.getRow(rowIndex).getCell(i).getStringCellValue();
if (cellValue != null) {
maxContentLength = Math.max(maxContentLength, cellValue.length());
}
}
}
} catch (Exception e) {
// 忽略获取单元格值的异常
}
// 根据标题和内容的最大长度计算合适的列宽
int headerLength = headerText.length();
int contentLength = maxContentLength;
int maxLength = Math.max(headerLength, contentLength);
// 设置列宽每个字符约2个字符宽度最小8个字符最大50个字符
int calculatedWidth = Math.max(Math.min(maxLength * 2, 50), 8) * 256;
int currentWidth = sheet.getColumnWidth(i);
// 设置列宽,确保标题和内容都能完整显示
sheet.setColumnWidth(i, Math.max(calculatedWidth, currentWidth));
}
// 尝试自动调整列宽
// try {
// sheet.trackAllColumnsForAutoSizing();
// writer.autoSizeColumnAll();
// } catch (Exception e) {
// log.warn("自动调整列宽失败,使用手动设置的列宽", e);
// }
//response为HttpServletResponse对象
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
//设置文件名,支持中文文件名
try {
String encodedFileName = java.net.URLEncoder.encode(fileName, "UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + encodedFileName + ";filename*=UTF-8''" + encodedFileName);
} catch (Exception e) {
// 如果编码失败,使用默认文件名
response.setHeader("Content-Disposition", "attachment;filename=file.xlsx");
}
ServletOutputStream out = response.getOutputStream();
// 终止后删除临时文件
file.deleteOnExit();
writer.flush(out, true);
//此处记得关闭输出Servlet流
IoUtil.close(out);
}
}

View File

@ -106,8 +106,9 @@ public class StationLetterServiceImpl implements StationLetterService {
queryWrapper.eq("f.user_id", userId);
int sjOrderCount = stationLetterMapper.selectPendingOrderCount(queryWrapper);
sjAudit.setCount(sjOrderCount);
} else {
sjAudit.setCount(0);
}
sjAudit.setCount(0);
auditResults.add(sjAudit);
// 7.查询清运公司端:待派单订单数量
@ -120,8 +121,9 @@ public class StationLetterServiceImpl implements StationLetterService {
queryWrapper.eq("g.user_id", userId);
int transOrderCount = stationLetterMapper.selectPendingOrderCount(queryWrapper);
transAudit.setCount(transOrderCount);
} else {
transAudit.setCount(0);
}
transAudit.setCount(0);
auditResults.add(transAudit);
// 8.查询勘料员端:待勘料订单数量
@ -133,13 +135,14 @@ public class StationLetterServiceImpl implements StationLetterService {
if (null != stationManageEntityList && stationManageEntityList.size() > 0) {
List<Long> collect = stationManageEntityList.stream().map(StationManageEntity::getStationId).collect(Collectors.toList());
QueryWrapper<OrderPagingResult> queryWrapper = Wrappers.query();
queryWrapper.eq("a.check_status", CheckStatus.WeiKanLiao)
.eq("a.order_status", OrderStatus.YiJinChang)
.in("a.station_id", collect);
queryWrapper.eq("check_status", CheckStatus.WeiKanLiao)
.eq("order_status", OrderStatus.YiJinChang)
.in("station_id", collect);
int klyOrderCount = stationLetterMapper.selectPendingKlyOrderCount(queryWrapper);
klyAudit.setCount(klyOrderCount);
} else {
klyAudit.setCount(0);
}
klyAudit.setCount(0);
auditResults.add(klyAudit);
result.setAuditResultList(auditResults);
return result;

View File

@ -184,12 +184,64 @@
<result property="paymentStatus" column="payment_status" typeHandler="com.njzscloud.common.mp.support.handler.e.EnumTypeHandlerDealer"/>
<result property="moneyStrategy" column="money_strategy" typeHandler="com.njzscloud.common.mp.support.handler.e.EnumTypeHandlerDealer"/>
</resultMap>
<resultMap id="OrderExportResultMap" type="com.njzscloud.supervisory.order.pojo.result.OrderExportResult">
<result property="transTime" column="trans_time"/>
<result property="stationName" column="station_name"/>
<result property="transCompanyName" column="trans_company_name"/>
<result property="licensePlate" column="license_plate"/>
<result property="truckCategory" column="truck_category"/>
<result property="estimatedQuantity" column="estimated_quantity"/>
<result property="inTime" column="in_time"/>
<result property="cfCompanyName" column="cf_company_name"/>
<result property="areaName" column="area_name"/>
<result property="roughWeight" column="rough_weight"/>
<result property="tareWeight" column="tare_weight"/>
<result property="settleWeight" column="settle_weight"/>
<result property="driverName" column="driver_name"/>
<result property="checkerMemo" column="checker_memo"/>
</resultMap>
<select id="paging" resultMap="OrderPagingResultMap">
<include refid="base_select"/>
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
${ew.customSqlSegment}
</if>
</select>
<select id="exportList" resultMap="OrderExportResultMap">
SELECT
DATE_FORMAT( a.trans_time, '%Y-%m-%d' ) AS trans_time,
b.station_name,
c.company_name AS trans_company_name,
d.license_plate,
e.txt AS truck_category,
a.estimated_quantity,
TIME_FORMAT( f.in_time, '%H:%i' ) AS in_time,
g.company_name AS cf_company_name,
h.area_name,
ROUND( f.rough_weight / 1000, 2 ) AS rough_weight,
ROUND( f.tare_weight / 1000, 2 ) AS tare_weight,
ROUND( f.settle_weight / 1000, 2 ) AS settle_weight,
i.driver_name,
a.checker_memo
FROM
order_info a
LEFT JOIN biz_company b ON b.id = a.station_id
LEFT JOIN biz_company c ON c.id = a.trans_company_id
LEFT JOIN biz_truck d ON d.id = a.truck_id
LEFT JOIN sys_dict_item e ON d.truck_category = e.val
AND dict_key = 'vehicle_type'
LEFT JOIN order_car_in_out f ON f.id = a.car_in_out_id
LEFT JOIN biz_company g ON a.user_id = g.user_id
LEFT JOIN order_cargo_place h ON h.id = a.cargo_place_id
LEFT JOIN biz_driver i ON i.id = a.driver_id
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
${ew.customSqlSegment}
</if>
ORDER BY
a.create_time DESC
</select>
<select id="detail" resultMap="OrderPagingResultMap">
<include refid="base_select"/>
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">