| | |
| | | /swagger-ui.html |
| | | /profile/** |
| | | /system/dict/data/type/** |
| | | /websocket/** |
| | | /websocket/** |
| | | driver: |
| | | template1: /data/cwgl/chqjkcns.pdf |
| | | template2: /data/cwgl/zjsf.pdf |
| | | font: /data/cwgl/msyh.ttf |
| | |
| | | driver: |
| | | template1: /data/cwgl/chqjkcns.pdf |
| | | template2: /data/cwgl/zjsf.pdf |
| | | font: /data/cwgl/simsun.ttc |
| | | font: /data/cwgl/msyh.ttf |
| | |
| | | driver: |
| | | template1: D:/temp/chqjkcns.pdf |
| | | template2: D:/temp/zjsf.pdf |
| | | font: D:/temp/simsun.ttc |
| | | font: D:/temp/msyh.ttf |
| | |
| | | @Value("${custom.upload.network-path}") |
| | | private String networkPath; |
| | | |
| | | @Value("${custom.driver.template1}") |
| | | private String template1; |
| | | |
| | | @Value("${custom.driver.template2}") |
| | | private String template2; |
| | | @Value("${custom.driver.font}") |
| | | private String fontPath; |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private ITmsDriverService tmsDriverService; |
| | | |
| | | /** |
| | | * 登录方法[pda] |
| | |
| | | * 上传行程 |
| | | */ |
| | | @PostMapping("/uploadTrip") |
| | | public AjaxResult uploadTrip(@RequestBody TmsTrip tmsTrip){ |
| | | public AjaxResult uploadTrip(@RequestBody TmsTrip tmsTrip) throws Exception { |
| | | tmsTrip.setDataSource("1"); |
| | | return AjaxResult.success(tmsTripService.insertTmsTrip(tmsTrip)); |
| | | } |
| | |
| | | } |
| | | return AjaxResult.success(data); |
| | | } |
| | | @GetMapping("/resource/jkcns") |
| | | public void jkcns( HttpServletResponse response) throws Exception { |
| | | |
| | | Integer deviceId = userService.getDeviceId(SecurityUtils.getUserId()); |
| | | if (deviceId == null){ |
| | | return; |
| | | } |
| | | TmsDriver byId = tmsDriverService.getById(deviceId); |
| | | if (byId != null){ |
| | | HashMap<String, String> objectObjectHashMap = new HashMap<>(); |
| | | objectObjectHashMap.put("date", DateUtils.getDate()); |
| | | objectObjectHashMap.put("name", byId.getDriverName()); |
| | | objectObjectHashMap.put("idCard", byId.getLicenseNumber()); |
| | | |
| | | // 下载名称 |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | FileUtils.setAttachmentResponseHeader(response, "货车司机出车前健康承诺书_"+byId.getDriverName()+"pdf"); |
| | | FileUtils.writeBytes(template1, response.getOutputStream()); |
| | | PdfTemplateUtil.fillPdf(template2, response.getOutputStream(),objectObjectHashMap , fontPath); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | @GetMapping("/resource/zjsfcns") |
| | | public void zjsfcns( HttpServletResponse response) throws Exception { |
| | | // 下载名称 |
| | | |
| | | Integer deviceId = userService.getDeviceId(SecurityUtils.getUserId()); |
| | | if (deviceId == null){ |
| | | return; |
| | | } |
| | | TmsDriver byId = tmsDriverService.getById(deviceId); |
| | | if (byId != null){ |
| | | HashMap<String, String> objectObjectHashMap = new HashMap<>(); |
| | | objectObjectHashMap.put("date", DateUtils.getDate()); |
| | | // 下载名称 |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | FileUtils.setAttachmentResponseHeader(response, "遵纪守法承诺书_"+byId.getDriverName()+"pdf"); |
| | | PdfTemplateUtil.fillPdf(template2, response.getOutputStream(),objectObjectHashMap , fontPath); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('tms:tmsTrip:add')") |
| | | @Log(title = "行程", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody TmsTrip tmsTrip) |
| | | { |
| | | public AjaxResult add(@RequestBody TmsTrip tmsTrip) throws Exception { |
| | | return toAjax(tmsTripService.insertTmsTrip(tmsTrip)); |
| | | } |
| | | |
| | |
| | | @TableField("voucher_url") |
| | | private String voucherUrl; |
| | | |
| | | @TableField("sign_img") |
| | | private String signImg; |
| | | |
| | | /** |
| | | * 创建人 |
| | |
| | | @TableField("data_source") |
| | | private String dataSource; |
| | | |
| | | /** |
| | | * 遵纪守法pdf |
| | | */ |
| | | @TableField("zjsf_url") |
| | | private String zjsfUrl; |
| | | |
| | | /** |
| | | * 出行pdf |
| | | */ |
| | | @TableField("chqjkcns_url") |
| | | private String chqjkcnsUrl; |
| | | |
| | | |
| | | } |
| | |
| | | * @param tmsTrip 行程 |
| | | * @return 结果 |
| | | */ |
| | | public int insertTmsTrip(TmsTrip tmsTrip); |
| | | public int insertTmsTrip(TmsTrip tmsTrip) throws Exception; |
| | | public AjaxResult submitDropHook(TmsTrip tmsTrip); |
| | | public AjaxResult submitPickHook(TmsTrip tmsTrip); |
| | | /** |
| New file |
| | |
| | | package com.ruoyi.tms.service.impl; |
| | | |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.PdfTemplateUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.file.FileUploadUtils; |
| | | import com.ruoyi.common.utils.uuid.Seq; |
| | | import com.ruoyi.tms.domain.TmsDispatchOrder; |
| | | import com.ruoyi.tms.domain.TmsDriver; |
| | | import com.ruoyi.tms.domain.TmsTrip; |
| | | import com.ruoyi.tms.mapper.TmsTripMapper; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class AsyncPdfService { |
| | | @Resource |
| | | private TmsTripMapper tmsTripMapper; |
| | | @Value("${custom.driver.template1}") |
| | | private String template1; |
| | | |
| | | @Value("${custom.driver.template2}") |
| | | private String template2; |
| | | @Value("${custom.driver.font}") |
| | | private String fontPath; |
| | | @Value("${custom.upload.network-path}") |
| | | private String networkPath; |
| | | @Async |
| | | public void generateTripPdfAsync(TmsTrip tmsTrip, TmsDispatchOrder order, TmsDriver driver) { |
| | | |
| | | try { |
| | | Map<String,String> data = new HashMap<>(); |
| | | data.put("name", driver.getDriverName()); |
| | | data.put("date", DateUtils.getDate()); |
| | | data.put("signImage", tmsTrip.getSignImg()); |
| | | |
| | | String uploadPath = RuoYiConfig.getUploadPath(); |
| | | |
| | | // 1. 生成 PDF A |
| | | String format1 = StringUtils.format("{}/{}_{}_{}.pdf", |
| | | DateUtils.datePath(), "chqjkcns", order.getDispatchNo(), Seq.getId(Seq.uploadSeqType)); |
| | | |
| | | File absoluteFile1 = FileUploadUtils.getAbsoluteFile(uploadPath, format1); |
| | | PdfTemplateUtil.fillPdf(template1, absoluteFile1.getAbsolutePath(), data, fontPath); |
| | | String url1 = networkPath + FileUploadUtils.getPathFileName(uploadPath, format1); |
| | | |
| | | // 2. 生成 PDF B |
| | | String format2 = StringUtils.format("{}/{}_{}_{}.pdf", |
| | | DateUtils.datePath(), "zjsf", order.getDispatchNo(), Seq.getId(Seq.uploadSeqType)); |
| | | |
| | | File absoluteFile2 = FileUploadUtils.getAbsoluteFile(uploadPath, format2); |
| | | PdfTemplateUtil.fillPdf(template2, absoluteFile2.getAbsolutePath(), data, fontPath); |
| | | String url2 = networkPath + FileUploadUtils.getPathFileName(uploadPath, format2); |
| | | |
| | | // 3. 更新数据库 PDF URL |
| | | TmsTrip update = new TmsTrip(); |
| | | update.setId(tmsTrip.getId()); |
| | | update.setChqjkcnsUrl(url1); |
| | | update.setZjsfUrl(url2); |
| | | |
| | | tmsTripMapper.updateTmsTrip(update); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.tms.service.impl; |
| | | |
| | | import java.io.File; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.file.FileUploadUtils; |
| | | import com.ruoyi.common.utils.uuid.Seq; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.tms.domain.*; |
| | | import com.ruoyi.tms.mapper.TmsDispatchOrderMapper; |
| | | import com.ruoyi.tms.mapper.TmsDriverDispatchMapper; |
| | | import com.ruoyi.tms.mapper.TmsDriverMapper; |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.annotation.DataSource; |
| | | import com.ruoyi.common.enums.DataSourceType; |
| | |
| | | @Autowired |
| | | private TmsVehicleServiceImpl tmsVehicleServiceImpl; |
| | | |
| | | @Autowired |
| | | private AsyncPdfService asyncPdfService; |
| | | /** |
| | | * 查询行程 |
| | | * |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertTmsTrip(TmsTrip tmsTrip) |
| | | { |
| | | public int insertTmsTrip(TmsTrip tmsTrip) throws Exception { |
| | | Integer dispatchOrderId = tmsTrip.getDispatchOrderId(); |
| | | TmsDispatchOrder tmsDispatchOrder = tmsDispatchOrderMapper.selectTmsDispatchOrderById(dispatchOrderId); |
| | | if (tmsDispatchOrder == null){ |
| | |
| | | if (tmsDispatchOrder.getStatus() != 1 && tmsDispatchOrder.getStatus() != 2){ |
| | | throw new RuntimeException("调度单数据状态异常"); |
| | | } |
| | | TmsDriver tmsDriver = tmsDriverMapper.selectTmsDriverById(tmsDispatchOrder.getMainDriverId()); |
| | | if (tmsDriver == null){ |
| | | throw new RuntimeException("未找到司机数据"); |
| | | } |
| | | |
| | | tmsDispatchOrder.setStatus(2); |
| | | tmsDispatchOrderMapper.updateTmsDispatchOrder(tmsDispatchOrder); |
| | | tmsTrip.setDriverName(tmsDispatchOrder.getMainDriverName()); |
| | |
| | | tmsTrip.setVehicleNumber(tmsDispatchOrder.getLicensePlate()); |
| | | tmsTrip.setCreateBy(SecurityUtils.getUsername()); |
| | | tmsTrip.setCreateTime(DateUtils.getNowDate()); |
| | | return tmsTripMapper.insertTmsTrip(tmsTrip); |
| | | tmsTripMapper.insertTmsTrip(tmsTrip); |
| | | if (StringUtils.isNotEmpty(tmsTrip.getSignImg())){ |
| | | asyncPdfService.generateTripPdfAsync(tmsTrip,tmsDispatchOrder,tmsDriver); |
| | | } |
| | | return 1; |
| | | } |
| | | @Override |
| | | public AjaxResult submitDropHook(TmsTrip tmsTrip){ |
| | |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="dataSource" column="data_source" /> |
| | | <result property="signImg" column="sign_img" /> |
| | | <result property="zjsfUrl" column="zjsf_url" /> |
| | | <result property="chqjkcnsUrl" column="chqjkcns_url" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectTmsTripVo"> |
| | | select thisTab.id, thisTab.dispatch_order_id, thisTab.driver_id, thisTab.driver_name, thisTab.vehicle_id, thisTab.vehicle_number, thisTab.trip_type, thisTab.trip_time, thisTab.odometer, thisTab.address, thisTab.voucher_url, thisTab.create_by, thisTab.create_time, thisTab.update_time, thisTab.data_source from tms_trip AS thisTab |
| | | select thisTab.id, thisTab.dispatch_order_id, thisTab.driver_id, thisTab.driver_name, thisTab.vehicle_id, thisTab.vehicle_number, thisTab.trip_type, thisTab.trip_time, thisTab.odometer, thisTab.address, thisTab.voucher_url, thisTab.create_by, thisTab.create_time, thisTab.update_time, thisTab.data_source, thisTab.sign_img, thisTab.zjsf_url, thisTab.chqjkcns_url from tms_trip AS thisTab |
| | | </sql> |
| | | <sql id="selectTmsTripVoCount"> |
| | | select count(0) from tms_trip as thisTab |
| | |
| | | <if test="createTime != null">create_time,</if> |
| | | <if test="updateTime != null">update_time,</if> |
| | | <if test="dataSource != null">data_source,</if> |
| | | <if test="signImg != null">sign_img,</if> |
| | | <if test="zjsfUrl != null">zjsf_url,</if> |
| | | <if test="chqjkcnsUrl != null">chqjkcns_url,</if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="dispatchOrderId != null">#{dispatchOrderId},</if> |
| | |
| | | <if test="createTime != null">#{createTime},</if> |
| | | <if test="updateTime != null">#{updateTime},</if> |
| | | <if test="dataSource != null">#{dataSource},</if> |
| | | <if test="signImg != null">#{signImg},</if> |
| | | <if test="zjsfUrl != null">#{zjsfUrl},</if> |
| | | <if test="chqjkcnsUrl != null">#{chqjkcnsUrl},</if> |
| | | </trim> |
| | | </insert> |
| | | |
| | | <insert id="insertTmsTripBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id"> |
| | | insert into tms_trip |
| | | <trim prefix="(" suffix=") values" suffixOverrides=","> |
| | | id,dispatch_order_id,driver_id,driver_name,vehicle_id,vehicle_number,trip_type,trip_time,odometer,address,voucher_url,create_by,create_time,update_time,data_source, |
| | | id,dispatch_order_id,driver_id,driver_name,vehicle_id,vehicle_number,trip_type,trip_time,odometer,address,voucher_url,create_by,create_time,update_time,data_source,sign_img,zjsf_url,chqjkcns_url, |
| | | </trim> |
| | | <foreach item="item" index="index" collection="list" separator=","> |
| | | <trim prefix="(" suffix=") " suffixOverrides=","> |
| | | #{item.id},#{item.dispatchOrderId},#{item.driverId},#{item.driverName},#{item.vehicleId},#{item.vehicleNumber},#{item.tripType},#{item.tripTime},#{item.odometer},#{item.address},#{item.voucherUrl},#{item.createBy},#{item.createTime},#{item.updateTime},#{item.dataSource}, |
| | | #{item.id},#{item.dispatchOrderId},#{item.driverId},#{item.driverName},#{item.vehicleId},#{item.vehicleNumber},#{item.tripType},#{item.tripTime},#{item.odometer},#{item.address},#{item.voucherUrl},#{item.createBy},#{item.createTime},#{item.updateTime},#{item.dataSource},#{item.signImg},#{item.zjsfUrl},#{item.chqjkcnsUrl}, |
| | | </trim> |
| | | </foreach> |
| | | </insert> |
| | |
| | | <if test="createTime != null">create_time = #{createTime},</if> |
| | | <if test="updateTime != null">update_time = #{updateTime},</if> |
| | | <if test="dataSource != null">data_source = #{dataSource},</if> |
| | | <if test="signImg != null">sign_img = #{signImg},</if> |
| | | <if test="zjsfUrl != null">zjsf_url = #{zjsfUrl},</if> |
| | | <if test="chqjkcnsUrl != null">chqjkcns_url = #{chqjkcnsUrl},</if> |
| | | </trim> |
| | | where id = #{id} |
| | | </update> |
| | |
| | | <if test="item.createTime != null">create_time = #{item.createTime},</if> |
| | | <if test="item.updateTime != null">update_time = #{item.updateTime},</if> |
| | | <if test="item.dataSource != null">data_source = #{item.dataSource},</if> |
| | | <if test="item.signImg != null">sign_img = #{item.signImg},</if> |
| | | <if test="item.zjsfUrl != null">zjsf_url = #{item.zjsfUrl},</if> |
| | | <if test="item.chqjkcnsUrl != null">chqjkcns_url = #{item.chqjkcnsUrl},</if> |
| | | </trim> |
| | | where id = #{item.id} |
| | | </foreach> |