|
@@ -1,19 +1,30 @@
|
|
|
package com.pj.project.tb_business_car;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.pj.current.config.PartConfig;
|
|
|
+import com.pj.current.config.SystemObject;
|
|
|
import com.pj.project.tb_business.TbBusiness;
|
|
|
import com.pj.project.tb_business.TbBusinessService;
|
|
|
import com.pj.project.tb_business_item.TbBusinessItem;
|
|
|
import com.pj.project.tb_business_item.TbBusinessItemService;
|
|
|
import com.pj.project.tb_fee_details.TbFeeDetails;
|
|
|
import com.pj.project.tb_fee_details.TbFeeDetailsService;
|
|
|
+import com.pj.project4sp.uploadfile.UploadConfig;
|
|
|
import com.pj.utils.so.SoMap;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
@@ -48,6 +59,9 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
@Lazy
|
|
|
TbFeeDetailsService tbFeeDetailsService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private UploadConfig uploadConfig;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查集合 - 根据条件(参数为空时代表忽略指定条件)
|
|
@@ -91,7 +105,7 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
|
|
|
|
|
|
public List<TbBusinessCar> searchPartCar(String carNo) {
|
|
|
- return tbBusinessCarMapper.searchPartCar(carNo.toUpperCase());
|
|
|
+ return tbBusinessCarMapper.searchPartCar(carNo.toUpperCase());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -206,10 +220,10 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
}
|
|
|
|
|
|
public void updateCarRecord(TbBusinessCar t) throws Exception {
|
|
|
- if(StrUtil.isEmpty(t.getBusinessId())) {
|
|
|
+ if (StrUtil.isEmpty(t.getBusinessId())) {
|
|
|
t.setBusinessId(null);
|
|
|
}
|
|
|
- if(StrUtil.isEmpty(t.getCustomerId())) {
|
|
|
+ if (StrUtil.isEmpty(t.getCustomerId())) {
|
|
|
t.setCustomerId(null);
|
|
|
}
|
|
|
String carNo = t.getCarNo().toUpperCase();
|
|
@@ -227,12 +241,12 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
|
|
|
this.updateById(t);
|
|
|
TbBusiness tbBusiness = tbBusinessService.getById(t.getBusinessId());
|
|
|
- if(tbBusiness != null) {
|
|
|
- if (!CAR_LIST.contains(carNo.substring(0,1))) {
|
|
|
+ if (tbBusiness != null) {
|
|
|
+ if (!CAR_LIST.contains(carNo.substring(0, 1))) {
|
|
|
tbBusiness.setCardNo(carNo);
|
|
|
} else {
|
|
|
List<TbBusinessCar> cars = this.findByBusinessId(t.getBusinessId());
|
|
|
- String chiaCarNo = cars.stream().filter(obj -> CAR_LIST.contains(obj.getCarNo().substring(0,1))).map(TbBusinessCar::getCarNo).collect(Collectors.joining("、"));
|
|
|
+ String chiaCarNo = cars.stream().filter(obj -> CAR_LIST.contains(obj.getCarNo().substring(0, 1))).map(TbBusinessCar::getCarNo).collect(Collectors.joining("、"));
|
|
|
tbBusiness.setChinaCarNo(chiaCarNo);
|
|
|
}
|
|
|
tbBusinessService.updateById(tbBusiness);
|
|
@@ -247,4 +261,30 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
public List<TbBusinessCar> findTheNoBusinessCar(String carNo) {
|
|
|
return tbBusinessCarMapper.findTheNoBusinessCar(carNo);
|
|
|
}
|
|
|
+
|
|
|
+ public String export(SoMap soMap) {
|
|
|
+ List<TbBusinessCar> cars = this.getList(soMap);
|
|
|
+ List<ExportTbBusinessDTO> list = new ArrayList<>(cars.size());
|
|
|
+ cars.forEach(tbBusinessCar -> {
|
|
|
+ ExportTbBusinessDTO dto = new ExportTbBusinessDTO();
|
|
|
+ BeanUtil.copyProperties(tbBusinessCar, dto);
|
|
|
+ Double carSize = tbBusinessCar.getCarSize();
|
|
|
+ dto.setSize(carSize + "");
|
|
|
+ if (carSize == null || carSize == 0) {
|
|
|
+ dto.setSize("-");
|
|
|
+ }
|
|
|
+ list.add(dto);
|
|
|
+ });
|
|
|
+ String flieTypeFolder = "/export/";
|
|
|
+ String currDateFolder = DateUtil.today();
|
|
|
+ String fileName = "car-record-" + RandomUtil.randomNumbers(6) + ".xlsx";
|
|
|
+ String fileFolder = new File(uploadConfig.rootFolder).getAbsolutePath() +
|
|
|
+ uploadConfig.httpPrefix + flieTypeFolder + currDateFolder + "/";
|
|
|
+ if (!FileUtil.exist(fileFolder)) {
|
|
|
+ FileUtil.mkdir(fileFolder);
|
|
|
+ }
|
|
|
+ EasyExcel.write(fileFolder + fileName, ExportTbBusinessDTO.class).sheet("车辆放行记录")
|
|
|
+ .doWrite(() -> list);
|
|
|
+ return SystemObject.config.getDomain() + uploadConfig.httpPrefix + flieTypeFolder + currDateFolder + "/" + fileName;
|
|
|
+ }
|
|
|
}
|