Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 11 months ago
parent
commit
9d14230c8a
  1. 8
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/ConferenceExportDTO.java
  2. 3
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygienePlanDTO.java
  3. 14
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java
  4. 3
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygienePlanEntity.java
  5. 3
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneRecordEntity.java
  6. 6
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygienePlanDetailVO.java
  7. 8
      hzims-service/safeproduct/pom.xml
  8. 10
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java
  9. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java
  10. 33
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/CarJob.java
  11. 6
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml
  12. 16
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.xml
  13. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.xml
  14. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml
  15. 16
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml
  16. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckRecordService.java
  17. 10
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarMaintenanceService.java
  18. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarService.java
  19. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarUsedRecordService.java
  20. 20
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java
  21. 86
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java
  22. 15
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java
  23. 21
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java
  24. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java
  25. 12
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java
  26. 12
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java
  27. 53
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/AsposeUtil.java
  28. 159
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java
  29. 15
      hzims-service/safeproduct/src/main/resources/License.xml
  30. BIN
      hzims-service/safeproduct/src/main/resources/template/车辆维保记录单.docx

8
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/ConferenceExportDTO.java

@ -45,14 +45,6 @@ public class ConferenceExportDTO {
@ExcelProperty(value = "主持人", index = 6)
private String host;
@ApiModelProperty("会议实际开始时间")
@ExcelProperty(value = "会议实际开始时间", index = 7)
private Date actualStartTime;
@ApiModelProperty("会议实际结束时间")
@ExcelProperty(value = "会议实际结束时间", index = 8)
private Date actualEndTime;
@ApiModelProperty("会议状态")
@ExcelProperty(value = "会议状态", index = 9)
private String conferenceStatus;

3
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygienePlanDTO.java

@ -24,6 +24,9 @@ public class HygienePlanDTO extends BaseEntity {
@ApiModelProperty("卫生自查计划id")
private Long id;
@ApiModelProperty("单位")
private String unit;
@ApiModelProperty("计划名称")
private String name;

14
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java

@ -37,19 +37,7 @@ public class RehearsalExportDTO {
@ExcelProperty(value = "演练地点", index = 4)
private String location;
@ApiModelProperty("参演人数")
@ExcelProperty(value = "参演人数", index = 5)
private Integer peopleNum;
@ApiModelProperty("演练实际开始时间")
@ExcelProperty(value = "演练实际开始时间", index = 6)
private Date actualStartTime;
@ApiModelProperty("演练实际结束时间")
@ExcelProperty(value = "演练实际结束时间", index = 7)
private Date actualEndTime;
@ApiModelProperty("演练状态")
@ExcelProperty(value = "演练状态", index = 8)
@ExcelProperty(value = "演练状态", index = 5)
private String rehearsalStatus;
}

3
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygienePlanEntity.java

@ -24,6 +24,9 @@ public class HygienePlanEntity extends BaseEntity {
@ApiModelProperty("计划名称")
private String name;
@ApiModelProperty("单位")
private String unit;
@ApiModelProperty("标准总分值")
private Integer standardScore;

3
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneRecordEntity.java

@ -59,7 +59,4 @@ public class HygieneRecordEntity extends BaseEntity {
@Size(max = 1000, message = "检查图片字段长度不能超过1000")
@ApiModelProperty("检查图片")
private String imgPath;
@ApiModelProperty("自查记录状态")
private String hygieneRecordStatus;
}

6
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygienePlanDetailVO.java

@ -21,6 +21,12 @@ import java.util.List;
@ApiModel(value = "卫生自查计划详情VO类")
public class HygienePlanDetailVO extends BaseEntity {
@ApiModelProperty("计划名称")
private String name;
@ApiModelProperty("单位")
private String unit;
@ApiModelProperty("标准总分值")
private Integer standardScore;

8
hzims-service/safeproduct/pom.xml

@ -160,6 +160,14 @@
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--设置为true,以便把本地的system的jar也包括进来-->
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
</project>

10
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java

@ -120,7 +120,6 @@ public class CarController extends BladeController {
@GetMapping("/carMaintenancePage")
@ApiImplicitParams({
@ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "endTime", value = "结束时间", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "carId", value = "车辆id", dataType = "query", paramType = "string")
@ -169,7 +168,6 @@ public class CarController extends BladeController {
@GetMapping("/carUsedRecordPage")
@ApiImplicitParams({
@ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "carId", value = "车辆id", dataType = "query", paramType = "string")
})
@ApiOperation(value = "用车记录分页")
@ -244,14 +242,14 @@ public class CarController extends BladeController {
@GetMapping("/exportCarUsedRecordData")
@ApiOperation(value = "导出用车记录单")
@ApiOperationSupport(order = 25)
public void exportCarUsedRecordData() {
public void exportCarUsedRecordData(@RequestParam Long id, HttpServletResponse response) {
carUsedRecordService.exportCarUsedRecordData(id, response);
}
@GetMapping("/exportCarCheckRecordData")
@ApiOperation(value = "导出车检记录单")
@ApiOperationSupport(order = 26)
public void exportCarCheckRecordData() {
public void exportCarCheckRecordData(@RequestParam Long id, HttpServletResponse response) {
carCheckRecordService.exportCarCheckRecordData(id, response);
}
}

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java

@ -72,6 +72,8 @@ public class HygieneController extends BladeController {
@GetMapping("/planPage")
@ApiImplicitParams({
@ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "name", value = "名称", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string")
})

33
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/CarJob.java

@ -1,12 +1,18 @@
package com.hnac.hzims.safeproduct.jobs;
import com.alibaba.excel.util.CollectionUtils;
import com.hnac.hzims.safeproduct.entity.CarEntity;
import com.hnac.hzims.safeproduct.entity.CarMaintenanceEntity;
import com.hnac.hzims.safeproduct.enums.CarInsuranceStatusEnum;
import com.hnac.hzims.safeproduct.enums.CarMaintenanceStatusEnum;
import com.hnac.hzims.safeproduct.service.ICarMaintenanceService;
import com.hnac.hzims.safeproduct.service.ICarService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@ -23,9 +29,13 @@ public class CarJob {
@Autowired
ICarService carService;
@Autowired
ICarMaintenanceService carMaintenanceService;
/**
* 车辆台账自动变更
*/
@Transactional(rollbackFor = Exception.class)
@XxlJob("autoChangeCarStatus")
public ReturnT<String> autoChangeCarStatus(String param) {
// 获取时间范围
@ -33,9 +43,26 @@ public class CarJob {
Date before = DateUtil.minusDays(current, 1);
String today = DateUtil.format(current, "yyyy-mm-dd");
String yesterday = DateUtil.format(before, "yyyy-mm-dd");
// 车包状态变更
List<CarEntity> uninsuredCarList = carService.getCarListByInsuranceTime(today, yesterday);
// uninsuredCarList.forEach(car -> car.setInsuranceStatus());
// List<CarEntity> carListByMaintenanceTime = carService.getCarListByMaintenanceTime(today, yesterday);
return ReturnT.SUCCESS;
uninsuredCarList.forEach(car -> car.setInsuranceStatus(CarInsuranceStatusEnum.UNINSURED.getValue()));
boolean insuranceUpdate = carService.updateBatchById(uninsuredCarList);
if (!insuranceUpdate) {
return ReturnT.FAIL;
}
// 维保状态变更
List<CarEntity> unMaintainedCarList = carService.getCarListByMaintenanceTime(today, yesterday);
unMaintainedCarList.forEach(car -> {
// 查询车辆在两次维保时间内是否有确认过的维保记录
String lastMaintenanceTime = DateUtil.format(car.getMaintenanceLastTime(), "yyyy-mm-dd");
String nextMaintenanceTime = DateUtil.format(car.getMaintenanceNextTime(), "yyyy-mm-dd");
List<CarMaintenanceEntity> carMaintenanceList = carMaintenanceService.getCarMaintenanceByCarIdAndTime(car.getId(),
lastMaintenanceTime, nextMaintenanceTime);
// 若无维保记录,说明在规定范围内未进行有效维保
if (CollectionUtils.isEmpty(carMaintenanceList)) {
car.setMaintenanceStatus(CarMaintenanceStatusEnum.UNMAINTAINED.getValue());
}
});
return carService.updateBatchById(unMaintainedCarList) ? ReturnT.SUCCESS : ReturnT.FAIL;
}
}

6
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml

@ -44,7 +44,7 @@
<select id="selectMilesByPlateNumber" resultType="java.math.BigDecimal">
SELECT
sum(t2.miles)
t2.end_miles
FROM
hzims_car t1
LEFT JOIN hzims_car_used_record t2 ON t1.id = t2.car_id
@ -53,6 +53,10 @@
<if test="plateNumber != null and plateNumber != ''">
AND t1.plate_number = #{plateNumber}
</if>
ORDER BY
t2.create_time DESC
LIMIT
1
</select>
</mapper>

16
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.xml

@ -3,23 +3,21 @@
<select id="getConferenceByUnitAndDate" resultType="com.hnac.hzims.safeproduct.dto.ConferenceExportDTO">
SELECT
t1.unit, t1.scheduled_start_time, t1.scheduled_end_time, t1.theme, t1.location, t1.conference_method,
t1.host, t2.actual_start_time, t2.actual_end_time, t1.conference_status
unit, scheduled_start_time, scheduled_end_time, theme, location, conference_method, host, conference_status
FROM
hzims_conference_plan t1
LEFT JOIN hzims_conference_record t2 ON t1.id = t2.conference_plan_id
hzims_conference_plan
WHERE
t1.is_deleted = 0
is_deleted = 0
<if test="unit != 'null' and unit != ''">
AND t1.unit like concat('%', #{unit}, '%')
AND unit like concat('%', #{unit}, '%')
</if>
<if test="startTime != 'null' and startTime != ''">
AND t1.scheduled_start_time >= #{startTime}
AND scheduled_start_time >= #{startTime}
</if>
<if test="endTime != 'null' and endTime != ''">
AND t1.scheduled_end_time &lt; #{endTime}
AND scheduled_end_time &lt; #{endTime}
</if>
ORDER BY
t1.create_time DESC
create_time DESC
</select>
</mapper>

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.xml

@ -20,9 +20,9 @@
<select id="selectFinishedDataByMonth" resultType="com.hnac.hzims.safeproduct.vo.HygieneMonthVO">
SELECT
unit, count(1) as finished_task_num
unit, count(1) as finished_check_num
FROM
hzims_hygiene_record
hzims_hygiene_plan
WHERE
is_deleted = 0
AND scheduled_end_time like concat('%', #{month}, '%')

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml

@ -20,7 +20,7 @@
WHERE
is_deleted = 0
<if test="param.hygienePlanId != null and param.hygienePlanId != ''">
AND hygiene_plan_id = #{hygienePlanId}
AND hygiene_plan_id = #{param.hygienePlanId}
</if>
ORDER BY
create_time DESC

16
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml

@ -73,23 +73,21 @@
<select id="getRehearsalByUnitAndDate" resultType="com.hnac.hzims.safeproduct.dto.RehearsalExportDTO">
SELECT
t1.unit, t1.subject, t1.scheduled_start_time, t1.scheduled_end_time, t1.location,
t2.people_num, t2.actual_start_time, t2.actual_end_time, t1.rehearsal_status
unit, subject, scheduled_start_time, scheduled_end_time, location, rehearsal_status
FROM
hzims_rehearsal_plan t1
LEFT JOIN hzims_rehearsal_record t2 ON t1.id = t2.rehearsal_plan_id
hzims_rehearsal_plan
WHERE
t1.is_deleted = 0
is_deleted = 0
<if test="unit != 'null' and unit != ''">
AND t1.unit like concat('%', #{unit}, '%')
AND unit like concat('%', #{unit}, '%')
</if>
<if test="startTime != 'null' and startTime != ''">
AND t1.scheduled_start_time >= #{startTime}
AND scheduled_start_time >= #{startTime}
</if>
<if test="endTime != 'null' and endTime != ''">
AND t1.scheduled_end_time &lt; #{endTime}
AND scheduled_end_time &lt; #{endTime}
</if>
ORDER BY
t1.create_time DESC
create_time DESC
</select>
</mapper>

8
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckRecordService.java

@ -8,6 +8,7 @@ import com.hnac.hzims.safeproduct.vo.CarCheckRecordDetailVO;
import com.hnac.hzims.safeproduct.vo.CarCheckRecordPageVO;
import org.springblade.core.mp.support.Query;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
@ -60,4 +61,11 @@ public interface ICarCheckRecordService extends IService<CarCheckRecordEntity> {
* @return true-成功false-失败
*/
boolean removeCarCheckRecord(Long id);
/**
* 导出车检记录单
* @param id 车检记录id
* @param response 响应类
*/
void exportCarCheckRecordData(Long id, HttpServletResponse response);
}

10
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarMaintenanceService.java

@ -10,6 +10,7 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
@ -55,4 +56,13 @@ public interface ICarMaintenanceService extends IService<CarMaintenanceEntity> {
* @param response 响应类
*/
void exportCarMaintenanceData(Long id, HttpServletResponse response);
/**
* 根据车辆id和时间查询相关维保记录
* @param carId 车辆id
* @param lastTime 上次维保时间
* @param nextTime 下次维保时间
* @return 车辆维保记录列表
*/
List<CarMaintenanceEntity> getCarMaintenanceByCarIdAndTime(Long carId, String lastTime, String nextTime);
}

8
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarService.java

@ -32,4 +32,12 @@ public interface ICarService extends IService<CarEntity> {
* @return 车辆列表数据
*/
List<CarEntity> getCarListByInsuranceTime(String today, String yesterday);
/**
* 根据维保时间查询车辆列表
* @param today 当天
* @param yesterday 昨天
* @return 车辆列表数据
*/
List<CarEntity> getCarListByMaintenanceTime(String today, String yesterday);
}

8
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarUsedRecordService.java

@ -9,6 +9,7 @@ import com.hnac.hzims.safeproduct.vo.CarUsedRecordPageVO;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
@ -54,4 +55,11 @@ public interface ICarUsedRecordService extends IService<CarUsedRecordEntity> {
* @return true-成功false-失败
*/
boolean updateCarUsedRecord(CarUsedRecordEntity carUsedRecordEntity);
/**
* 导出用车记录单
* @param id 用车记录id
* @param response 响应类
*/
void exportCarUsedRecordData(Long id, HttpServletResponse response);
}

20
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java

@ -15,18 +15,18 @@ import com.hnac.hzims.safeproduct.mapper.CarMapper;
import com.hnac.hzims.safeproduct.service.ICarCheckItemService;
import com.hnac.hzims.safeproduct.service.ICarCheckRecordService;
import com.hnac.hzims.safeproduct.utils.BaseUtil;
import com.hnac.hzims.safeproduct.vo.CarCheckItemVO;
import com.hnac.hzims.safeproduct.vo.CarCheckRecordDetailVO;
import com.hnac.hzims.safeproduct.vo.CarCheckRecordPageVO;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -46,6 +46,9 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper,
@Autowired
ICarCheckItemService carCheckItemService;
@Value("${hzims.car.savePath}")
private String savePath;
/**
* 新增车检记录
*/
@ -177,4 +180,17 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper,
}
return false;
}
/**
* 导出车检记录单
*/
@Override
public void exportCarCheckRecordData(Long id, HttpServletResponse response) {
CarCheckRecordEntity carCheckRecordEntity = this.getById(id);
Map<String, Object> params = BaseUtil.obj2Map(carCheckRecordEntity);
String templateFile = "template/车检记录单.docx";
String wordPath = savePath + "/车检记录单.docx";
String pdfPath = savePath + "/车检记录单.pdf";
BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, response);
}
}

86
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java

@ -1,10 +1,7 @@
package com.hnac.hzims.safeproduct.service.impl;
import cn.hutool.core.date.DatePattern;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.util.CollectionUtils;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -19,23 +16,15 @@ import com.hnac.hzims.safeproduct.service.ICarService;
import com.hnac.hzims.safeproduct.utils.BaseUtil;
import com.hnac.hzims.safeproduct.vo.CarMaintenanceDetailVO;
import com.hnac.hzims.safeproduct.vo.CarMaintenancePageVO;
import com.hnac.hzims.ticket.constants.WorkTicketConstants;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -52,6 +41,9 @@ public class CarMaintenanceServiceImpl extends ServiceImpl<CarMaintenanceMapper,
@Autowired
ICarService carService;
@Value("${hzims.car.savePath}")
private String savePath;
/**
* 新增车辆维保记录
*/
@ -119,57 +111,25 @@ public class CarMaintenanceServiceImpl extends ServiceImpl<CarMaintenanceMapper,
@Override
public void exportCarMaintenanceData(Long id, HttpServletResponse response) {
CarMaintenanceEntity carMaintenanceEntity = this.getById(id);
Map<String, Object> params = BaseUtil.convertObjectToMap(carMaintenanceEntity);
// String templateFile = ""
try {
List<XWPFDocument> res = new ArrayList<>();
XWPFDocument document = BaseUtil.fillDocument("template/", params);
res.add(document);
BaseUtil.exportWord(res, "");
} catch (Exception e) {
throw new RuntimeException(e);
}
// String pdfPath = this.getFileSavePath() + params.get("code") + "_" + params.get("addressEquName") +".pdf";
// AsposeUtil.wordToPdf(wordPath, pdfPath);
// PdfUtils.readPdf(response,pdfPath);
// ServletOutputStream outputStream = null;
// try {
// outputStream = response.getOutputStream();
// CarMaintenanceDetailVO carMaintenance = getCarMaintenance(id);
// // 设置响应头
// // URLEncoder.encode防止中文乱码
// String fileName = URLEncoder.encode("车辆维保记录单", "UTF-8");
// response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
// response.setContentType("application/vnd.ms-excel");
// response.setCharacterEncoding("UTF-8");
// List<CarMaintenanceDetailVO> dataList = new ArrayList<>();
// dataList.add(carMaintenance);
// String templatePath = "template/车辆维保记录单.xlsx";
// Resource resource = new ClassPathResource(templatePath);
// // ExcelWriter初始化
// ExcelWriter excelWriter = EasyExcel
// .write(response.getOutputStream(), CarMaintenanceDetailVO.class)
// .autoCloseStream(Boolean.TRUE)
// .withTemplate(resource.getInputStream())
// .build();
// WriteSheet writeSheet = EasyExcel.writerSheet(1, "车辆维保记录单").build();
// excelWriter.write(dataList, writeSheet);
// excelWriter.finish();
// } catch (Exception e) {
// // 重置response
// response.reset();
// response.setContentType("application/json");
// response.setCharacterEncoding("utf-8");
// throw new ServiceException("车辆维保记录单导出异常: " + e.getMessage());
// } finally {
// if (outputStream != null) {
// try {
// outputStream.close();
// } catch (IOException e) {
// log.error("车辆维保记录单导出响应头输出流关闭异常: " + e.getMessage());
// }
// }
// }
Map<String, Object> params = BaseUtil.obj2Map(carMaintenanceEntity);
String templateFile = "template/车辆维保记录单.docx";
String wordPath = savePath + "/车辆维保记录单.docx";
String pdfPath = savePath + "/车辆维保记录单.pdf";
BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, response);
}
/**
* 根据车辆id和时间查询相关维保记录
*/
@Override
public List<CarMaintenanceEntity> getCarMaintenanceByCarIdAndTime(Long carId, String lastTime, String nextTime) {
QueryWrapper<CarMaintenanceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(CarMaintenanceEntity::getCarId, carId)
.ge(CarMaintenanceEntity::getEndTime, lastTime)
.le(CarMaintenanceEntity::getEndTime, nextTime)
.eq(CarMaintenanceEntity::getMaintenanceStatus, CarMaintenanceStatusEnum.MAINTAINED.getValue())
.orderByDesc(CarMaintenanceEntity::getCreateTime);
return this.list(queryWrapper);
}
/**

15
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java

@ -110,8 +110,19 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, CarEntity> implements
@Override
public List<CarEntity> getCarListByInsuranceTime(String today, String yesterday) {
QueryWrapper<CarEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().le(CarEntity::getInsurancePayLastTime, today)
.ge(CarEntity::getInsurancePayNextTime, today);
queryWrapper.lambda().lt(CarEntity::getInsurancePayNextTime, today)
.ge(CarEntity::getInsurancePayNextTime, yesterday);
return this.list(queryWrapper);
}
/**
* 根据维保时间查询车辆列表
*/
@Override
public List<CarEntity> getCarListByMaintenanceTime(String today, String yesterday) {
QueryWrapper<CarEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().lt(CarEntity::getMaintenanceNextTime, today)
.ge(CarEntity::getMaintenanceNextTime, yesterday);
return this.list(queryWrapper);
}
}

21
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java

@ -11,15 +11,20 @@ import com.hnac.hzims.safeproduct.entity.CarUsedRecordEntity;
import com.hnac.hzims.safeproduct.enums.CarUsedRecordEnum;
import com.hnac.hzims.safeproduct.mapper.CarUsedRecordMapper;
import com.hnac.hzims.safeproduct.service.ICarUsedRecordService;
import com.hnac.hzims.safeproduct.utils.AsposeUtil;
import com.hnac.hzims.safeproduct.utils.BaseUtil;
import com.hnac.hzims.safeproduct.vo.CarUsedRecordDetailVO;
import com.hnac.hzims.safeproduct.vo.CarUsedRecordPageVO;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -33,6 +38,9 @@ import java.util.Map;
@Service
public class CarUsedRecordServiceImpl extends ServiceImpl<CarUsedRecordMapper, CarUsedRecordEntity> implements ICarUsedRecordService {
@Value("${hzims.car.savePath}")
private String savePath;
/**
* 新增用车记录
*/
@ -98,6 +106,19 @@ public class CarUsedRecordServiceImpl extends ServiceImpl<CarUsedRecordMapper, C
}
/**
* 导出用车记录单
*/
@Override
public void exportCarUsedRecordData(Long id, HttpServletResponse response) {
CarUsedRecordEntity carUsedRecordEntity = this.getById(id);
Map<String, Object> params = BaseUtil.obj2Map(carUsedRecordEntity);
String templateFile = "template/用车记录单.docx";
String wordPath = savePath + "/用车记录单.docx";
String pdfPath = savePath + "/用车记录单.pdf";
BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, response);
}
/**
* 查询是否存在同月编号
* @param currentMonth 当月
* @return 存在则返回上一编号否则返回null

8
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java

@ -79,12 +79,20 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
QueryWrapper<HygienePlanEntity> queryWrapper = new QueryWrapper<>();
String startTime = String.valueOf(param.get("scheduledStartTime"));
String endTime = String.valueOf(param.get("scheduledEndTime"));
String unit = String.valueOf(param.get("unit"));
String name = String.valueOf(param.get("name"));
if (!startTime.equals("null") && !startTime.equals("")) {
queryWrapper.lambda().ge(HygienePlanEntity::getScheduledStartTime, startTime);
}
if (!endTime.equals("null") && !endTime.equals("")) {
queryWrapper.lambda().le(HygienePlanEntity::getScheduledEndTime, endTime);
}
if (!unit.equals("null") && !unit.equals("")) {
queryWrapper.lambda().like(HygienePlanEntity::getUnit, unit);
}
if (!name.equals("null") && !name.equals("")) {
queryWrapper.lambda().like(HygienePlanEntity::getName, name);
}
queryWrapper.lambda().orderByDesc(HygienePlanEntity::getCreateTime);
return this.page(Condition.getPage(query), queryWrapper);
}

12
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java

@ -51,12 +51,13 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
if (trainPlanEntity.getIsTest().equals(SafeProductConstant.TRAIN_PLAN_HAS_NO_TEST)) {
return R.fail("该培训计划无法新增考试");
}
// 获取当月时间(yyyymm)
String currentMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date());
// 获取当月时间
String currentNormMonth = DatePattern.NORM_MONTH_FORMAT.format(new Date());
String currentSimpleMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date());
// 查询是否存在同月编号
String lastCode = getLastCode(currentMonth);
String lastCode = getLastCode(currentNormMonth);
// 若不存在,新增编号
String code = BaseUtil.getUniqueCode("KSJL", lastCode, currentMonth);
String code = BaseUtil.getUniqueCode("KSJL", lastCode, currentSimpleMonth);
testEntity.setCode(code);
boolean saveTest = this.save(testEntity);
// 若新增考试记录成功,添加相关的参考人员数据
@ -195,8 +196,7 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
* @return 存在则返回上一编号否则返回null
*/
private String getLastCode(String currentMonth) {
String month = currentMonth.substring(currentMonth.length() - 2);
List<TestEntity> list = getTestByMonth(month);
List<TestEntity> list = getTestByMonth(currentMonth);
if (CollectionUtils.isEmpty(list)) {
return null;
}

12
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java

@ -56,12 +56,13 @@ public class TrainRecordServiceImpl extends ServiceImpl<TrainRecordMapper, Train
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveTrainRecord(TrainRecordEntity trainRecordEntity) {
// 获取当月时间(yyyymm)
String currentMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date());
// 获取当月时间
String currentNormMonth = DatePattern.NORM_MONTH_FORMAT.format(new Date());
String currentSimpleMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date());
// 查询是否存在同月编号
String lastCode = getLastCode(currentMonth);
String lastCode = getLastCode(currentNormMonth);
// 若不存在,新增编号
String code = BaseUtil.getUniqueCode("PXJL", lastCode, currentMonth);
String code = BaseUtil.getUniqueCode("PXJL", lastCode, currentSimpleMonth);
trainRecordEntity.setCode(code);
boolean save = this.save(trainRecordEntity);
// 若培训记录新增成功,修改培训计划状态为已完成
@ -183,8 +184,7 @@ public class TrainRecordServiceImpl extends ServiceImpl<TrainRecordMapper, Train
* @return 存在则返回上一编号否则返回null
*/
private String getLastCode(String currentMonth) {
String month = currentMonth.substring(currentMonth.length() - 2);
List<TrainRecordEntity> list = getTrainByMonth(month);
List<TrainRecordEntity> list = getTrainByMonth(currentMonth);
if (CollectionUtils.isEmpty(list)) {
return null;
}

53
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/AsposeUtil.java

@ -0,0 +1,53 @@
package com.hnac.hzims.safeproduct.utils;
import cn.hutool.system.SystemUtil;
import com.aspose.words.Document;
import com.aspose.words.FontSettings;
import com.aspose.words.License;
import com.aspose.words.SaveFormat;
import lombok.SneakyThrows;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
/**
*
*/
public class AsposeUtil {
/**
* 加载license 用于破解 不生成水印
*
* @author LCheng
* @date 2020/12/25 13:51
*/
@SneakyThrows
private static void getLicense() {
try (InputStream is = AsposeUtil.class.getClassLoader().getResourceAsStream("License.xml")) {
License license = new License();
license.setLicense(is);
}
}
/**
* word转pdf
*
* @param wordPath word文件保存的路径
* @param pdfPath 转换后pdf文件保存的路径
* @author LCheng
* @date 2020/12/25 13:51
*/
@SneakyThrows
public static void wordToPdf(String wordPath, String pdfPath) {
getLicense();
File file = new File(pdfPath);
try (FileOutputStream os = new FileOutputStream(file)) {
if(SystemUtil.getOsInfo().isLinux()) {
FontSettings.setFontsFolder("/usr/share/fonts/chinese", true);
}
Document doc = new Document(wordPath);
doc.save(os, SaveFormat.PDF);
}
}
}

159
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java

@ -2,16 +2,21 @@ package com.hnac.hzims.safeproduct.utils;
import cn.afterturn.easypoi.word.WordExportUtil;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.ticket.annotation.DateTimeToMap;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
* 公用工具类
@ -50,26 +55,6 @@ public class BaseUtil {
}
/**
* 对象转map
* @param entity 对象
* @return map
*/
public static Map<String, Object> convertObjectToMap(Object entity) {
Map<String, Object> map = new HashMap<>();
Field[] fields = entity.getClass().getFields();
try {
for (Field field : fields) {
field.setAccessible(true);
Object value = field.get(entity);
map.put(field.getName(), value);
}
} catch (IllegalAccessException e) {
log.info("对象转map异常: {}", e.getMessage());
}
return map;
}
/**
* 文件导出
* @param documents doc文件
* @param savePath 存储路径
@ -81,7 +66,6 @@ public class BaseUtil {
for (XWPFDocument document : documents) {
document.write(out);
}
out.close();
} catch (IOException e) {
log.error("文件导出异常: {}", e.getMessage());
} finally {
@ -109,4 +93,125 @@ public class BaseUtil {
}
return xwpfDocument;
}
/**
* 读取本地pdf,这里设置的是预览
* @param response 响应类
* @param filePath 文件路径
*/
public static void readPdf(HttpServletResponse response, String filePath) {
response.reset();
response.setContentType("application/pdf");
FileInputStream fileInputStream = null;
OutputStream outputStream = null;
try {
File file = new File(filePath);
fileInputStream = new FileInputStream(file);
outputStream = response.getOutputStream();
IOUtils.write(IOUtils.toByteArray(fileInputStream), outputStream);
response.setHeader("Content-Disposition",
"inline; filename= " + URLEncoder.encode(file.getName(), "UTF-8"));
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fileInputStream != null) {
fileInputStream.close();
}
if (outputStream != null) {
outputStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static Map<String, Object> obj2Map(Object obj) {
if(ObjectUtil.isNotEmpty(obj) && null != obj.getClass()) {
Map<String, Object> result = new HashMap<>();
List<Field> fieldList = new ArrayList<>();
Class<?> clazz = obj.getClass();
while(clazz != null) {
fieldList.addAll(Arrays.asList(clazz.getDeclaredFields()));
clazz = clazz.getSuperclass();
}
fieldList.forEach(field -> {
field.setAccessible(true);
Object value;
try {
value = field.get(obj);
} catch (IllegalAccessException e) {
throw new ServiceException("获取属性性出错");
}
if(value instanceof List) {
List<Map<String, Object>> list = ((List<?>) value).stream().map(BaseUtil::obj2Map).collect(Collectors.toList());
result.put(field.getName(),list);
}
else if(value instanceof LocalDateTime) {
DateTimeToMap dateTimeToMap = field.getAnnotation(DateTimeToMap.class);
LocalDateTime time = (LocalDateTime) value;
if(ObjectUtil.isEmpty(dateTimeToMap)) {
result.put(field.getName(),time.format(DateUtil.TIME_FORMATTER));
}
else {
result.putAll(LocalDateConvertMap(time,dateTimeToMap.prefix(),dateTimeToMap.split()));
}
}
else if(value instanceof Date) {
DateTimeToMap dateTimeToMap = field.getAnnotation(DateTimeToMap.class);
Date time = (Date) value;
if(ObjectUtil.isEmpty(dateTimeToMap)) {
result.put(field.getName(),DateUtil.format(time,DateUtil.PATTERN_DATETIME));
}
else {
result.put(dateTimeToMap.prefix()+dateTimeToMap.split()+"year", time.getYear());
result.put(dateTimeToMap.prefix()+dateTimeToMap.split()+"month", time.getMonth());
result.put(dateTimeToMap.prefix()+dateTimeToMap.split()+"day", time.getDay());
result.put(dateTimeToMap.prefix()+dateTimeToMap.split()+"hour", time.getHours());
result.put(dateTimeToMap.prefix()+dateTimeToMap.split()+"minuter", time.getMinutes());
result.put(dateTimeToMap.prefix()+dateTimeToMap.split()+"second", time.getSeconds());
}
}
else {
result.put(field.getName(),value);
}
});
return result;
}
return null;
}
/**
* 将时间按格式转化为map对象
* @param dateTime 待转换时间
* @param prefix 转换格式Key前缀
* @param split 转换格式Key分隔符
* @return map对象
*/
public static Map<String, Object> LocalDateConvertMap(LocalDateTime dateTime,String prefix,String split) {
HashMap<String, Object> result = new HashMap<String, Object>() {{
put(prefix + split + "year", dateTime.getYear());
put(prefix + split + "month", dateTime.getMonthValue());
put(prefix + split + "day", dateTime.getDayOfMonth());
put(prefix + split + "hour", dateTime.getHour());
put(prefix + split + "minuter", dateTime.getMinute());
put(prefix + split + "second", dateTime.getSecond());
}};
return result;
}
public static void exportDocument(String templateFile, Map<String, Object> params, String wordPath, String pdfPath, HttpServletResponse response) {
try {
List<XWPFDocument> res = new ArrayList<>();
XWPFDocument document = BaseUtil.fillDocument(templateFile, params);
res.add(document);
BaseUtil.exportWord(res, wordPath);
} catch (Exception e) {
throw new RuntimeException(e);
}
AsposeUtil.wordToPdf(wordPath, pdfPath);
BaseUtil.readPdf(response,pdfPath);
}
}

15
hzims-service/safeproduct/src/main/resources/License.xml

@ -0,0 +1,15 @@
<License>
<Data>
<Products>
<Product>Aspose.Total for Java</Product>
<Product>Aspose.Words for Java</Product>
</Products>
<EditionType>Enterprise</EditionType>
<SubscriptionExpiry>20991231</SubscriptionExpiry>
<LicenseExpiry>20991231</LicenseExpiry>
<SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber>
</Data>
<Signature>
sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=
</Signature>
</License>

BIN
hzims-service/safeproduct/src/main/resources/template/车辆维保记录单.docx

Binary file not shown.
Loading…
Cancel
Save