Commit 3a272edc authored by jiaorz's avatar jiaorz

Merge branch 'master-vehicle-bg' into dev

parents 6b916523 c4bdf3dc
package com.xxfc.platform.vehicle.biz; package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.vehicle.entity.Constant; import com.xxfc.platform.vehicle.entity.Constant;
...@@ -15,7 +14,6 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -15,7 +14,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -138,8 +136,8 @@ public class ImportVehicleDataBiz extends BaseBiz<VehicleMapper, Vehicle> { ...@@ -138,8 +136,8 @@ public class ImportVehicleDataBiz extends BaseBiz<VehicleMapper, Vehicle> {
} }
} }
System.out.println("stringBuffer:"+stringBuffer); log.info("stringBuffer:"+stringBuffer);
System.out.println("stringBuffer2:"+stringBuffer2); log.info("stringBuffer2:"+stringBuffer2);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
......
...@@ -1516,4 +1516,8 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -1516,4 +1516,8 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return vehicles.stream().map(Vehicle::getId).collect(Collectors.toList()); return vehicles.stream().map(Vehicle::getId).collect(Collectors.toList());
} }
public List<VehicleExcelVo> getAllVehicleInfo() {
return mapper.getAllVehicleInfo();
}
} }
...@@ -92,4 +92,9 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl ...@@ -92,4 +92,9 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl
return arrayList; return arrayList;
} }
public List<VehicleExcelVo> getAllVehicleInfo() {
return vehicleBiz.getAllVehicleInfo();
}
} }
...@@ -53,4 +53,6 @@ public interface VehicleMapper extends Mapper<Vehicle> { ...@@ -53,4 +53,6 @@ public interface VehicleMapper extends Mapper<Vehicle> {
@Select("select `id` from `vehicle` where `is_del`=0") @Select("select `id` from `vehicle` where `is_del`=0")
List<String> findExistVehicleIds(); List<String> findExistVehicleIds();
List<VehicleExcelVo> getAllVehicleInfo();
} }
\ No newline at end of file
...@@ -7,6 +7,7 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign; ...@@ -7,6 +7,7 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO; import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.vehicle.biz.VehicleBiz; import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.biz.VehicleInformationDownloadBiz; import com.xxfc.platform.vehicle.biz.VehicleInformationDownloadBiz;
import com.xxfc.platform.vehicle.common.BaseController; import com.xxfc.platform.vehicle.common.BaseController;
...@@ -41,10 +42,10 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle ...@@ -41,10 +42,10 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle
HttpServletResponse response; HttpServletResponse response;
@GetMapping("/excel") @GetMapping("/excel")
public void downloadExcel(@RequestParam(value = "vehiclePageQueryVoJson",required = false) String vehiclePageQueryVoJson) throws Exception { public void downloadExcel(@RequestParam(value = "vehiclePageQueryVoJson", required = false) String vehiclePageQueryVoJson) throws Exception {
UserDTO userDTO = userFeign.userinfoByToken(userAuthConfig.getToken(request)).getData(); UserDTO userDTO = userFeign.userinfoByToken(userAuthConfig.getToken(request)).getData();
if (userDTO==null) { if (userDTO == null) {
throw new BaseException("token已失效"); throw new BaseException("token已失效");
} }
List<VehicleExcelVo> rows = baseBiz.getList(vehiclePageQueryVoJson, userDTO); List<VehicleExcelVo> rows = baseBiz.getList(vehiclePageQueryVoJson, userDTO);
ExcelWriter writer = ExcelUtil.getWriter(true); ExcelWriter writer = ExcelUtil.getWriter(true);
...@@ -67,4 +68,30 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle ...@@ -67,4 +68,30 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle
//此处记得关闭输出Servlet流 //此处记得关闭输出Servlet流
IoUtil.close(out); IoUtil.close(out);
} }
@GetMapping("/import")
public void exportVehicleInfo() throws Exception {
UserDTO userDTO = userFeign.userinfoByToken(userAuthConfig.getToken(request)).getData();
if (userDTO == null) {
throw new BaseException( ResultCode.getMsg(ResultCode.RSTOKEN_EXPIRED_CODE), ResultCode.RSTOKEN_EXPIRED_CODE);
}
List<VehicleExcelVo> rows = baseBiz.getAllVehicleInfo();
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("numberPlate", "车牌号");
writer.addHeaderAlias("code", "车辆编码");
writer.addHeaderAlias("parkBranchCompanyName", "停靠分公司");
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(rows, true);
//response为HttpServletResponse对象
response.setContentType("application/vnd.ms-excel;charset=utf-8");
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
response.setHeader("Content-Disposition", "attachment;filename=vehicleInfo.xlsx");
//out为OutputStream,需要写出到的目标流
ServletOutputStream out = response.getOutputStream();
writer.flush(out, true);
// 关闭writer,释放内存
writer.close();
//此处记得关闭输出Servlet流
IoUtil.close(out);
}
} }
...@@ -590,7 +590,12 @@ ...@@ -590,7 +590,12 @@
) r ORDER BY r.parkBranchCompanyName ) r ORDER BY r.parkBranchCompanyName
</select> </select>
<!--导出分公司停靠所有车辆-->
<select id="getAllVehicleInfo" resultType="com.xxfc.platform.vehicle.pojo.VehicleExcelVo">
select b1.name as parkBranchCompanyName, v1.number_plate as numberPlate, v1.code as code from branch_company b1
left join vehicle v1 on v1.park_branch_company_id on b1.id
where b1.is_del = 0 and v1.is_del = 0
</select>
<select id="lockByCode" resultType="com.xxfc.platform.vehicle.entity.Vehicle" <select id="lockByCode" resultType="com.xxfc.platform.vehicle.entity.Vehicle"
parameterType="com.xxfc.platform.vehicle.pojo.AddOrUpdateVehicleVo"> parameterType="com.xxfc.platform.vehicle.pojo.AddOrUpdateVehicleVo">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment