Browse Source

update: 车辆管理模块

zhongwei
liwen 10 months ago
parent
commit
048caaf491
  1. 9
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/SafeProductConstant.java
  2. 4
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/CarMaintenanceConfirmationDTO.java
  3. 1
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckItemEntity.java
  4. 4
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarCheckRecordDetailVO.java
  5. 3
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarUsedRecordDetailVO.java
  6. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarUsedRecordMapper.xml
  7. 12
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java
  8. 11
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java
  9. 14
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java
  10. 70
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java
  11. 5
      hzims-service/safeproduct/src/main/resources/db/1.0.1.sql
  12. BIN
      hzims-service/safeproduct/src/main/resources/template/用车记录单.docx
  13. BIN
      hzims-service/safeproduct/src/main/resources/template/车辆检查表.docx

9
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/SafeProductConstant.java

@ -13,6 +13,15 @@ public interface SafeProductConstant {
int SUCCESS = 1;
int FAILURE = 0;
/**
* 文件后缀
*/
String DOCX_SUFFIX = ".docx";
String PDF_SUFFIX = ".pdf";
/**
* 培训管理
*/
int TRAIN_PLAN_HAS_TEST = 1;
int TRAIN_PLAN_HAS_NO_TEST = 0;
}

4
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/CarMaintenanceConfirmationDTO.java

@ -1,10 +1,12 @@
package com.hnac.hzims.safeproduct.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.Date;
@ -21,10 +23,12 @@ public class CarMaintenanceConfirmationDTO {
private Long carMaintenanceId;
@NotNull
@Size(max = 500, message = "车辆管理人意见长度不能超过500")
@ApiModelProperty("车辆管理人意见")
private String managerAdvice;
@NotNull
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty("下次维保时间")
private Date maintenanceNextTime;

1
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckItemEntity.java

@ -1,6 +1,5 @@
package com.hnac.hzims.safeproduct.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

4
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarCheckRecordDetailVO.java

@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
@ -19,6 +20,9 @@ public class CarCheckRecordDetailVO {
@ApiModelProperty("检查人")
private String checker;
@ApiModelProperty("检查时间")
private Date checkTime;
@ApiModelProperty("品牌")
private String carBrand;

3
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarUsedRecordDetailVO.java

@ -27,6 +27,9 @@ public class CarUsedRecordDetailVO {
@ApiModelProperty("品牌")
private String carBrand;
@ApiModelProperty("车辆类型")
private String carType;
@ApiModelProperty("车牌号")
private String plateNumber;

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

@ -5,7 +5,7 @@
<select id="getCarUsedRecord" resultType="com.hnac.hzims.safeproduct.vo.CarUsedRecordDetailVO">
SELECT
t1.code, t1.start_time, t1.used_location, t1.remark, t1.unit, t1.start_miles, t1.end_miles, t1.miles,
t1.img_path, t1.user, t1.end_time, t1.confirmation_time, t2.manager, t2.car_brand, t2.plate_number
t1.img_path, t1.user, t1.end_time, t1.confirmation_time, t2.manager, t2.car_brand, t2.car_type, t2.plate_number
FROM
hzims_car_used_record t1
LEFT JOIN hzims_car t2 ON t1.car_id = t2.id

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

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.safeproduct.constants.SafeProductConstant;
import com.hnac.hzims.safeproduct.dto.CarCheckRecordDTO;
import com.hnac.hzims.safeproduct.entity.CarCheckItemEntity;
import com.hnac.hzims.safeproduct.entity.CarCheckRecordEntity;
@ -87,6 +88,7 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper,
CarCheckRecordDetailVO carCheckRecordDetailVO = new CarCheckRecordDetailVO();
// 车检记录属性
carCheckRecordDetailVO.setCode(carCheckRecord.getCode());
carCheckRecordDetailVO.setCheckTime(carCheckRecord.getCheckTime());
carCheckRecordDetailVO.setChecker(carCheckRecord.getChecker());
carCheckRecordDetailVO.setConclusion(carCheckRecord.getConclusion());
carCheckRecordDetailVO.setRemark(carCheckRecord.getRemark());
@ -187,11 +189,11 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper,
*/
@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";
CarCheckRecordDetailVO carCheckRecordDetailVO = this.getCarCheckRecord(id);
Map<String, Object> params = BaseUtil.obj2Map(carCheckRecordDetailVO);
String templateFile = "template/车检记录单" + SafeProductConstant.DOCX_SUFFIX;
String wordPath = savePath + "/车检记录单" + SafeProductConstant.DOCX_SUFFIX;
String pdfPath = savePath + "/车检记录单" + SafeProductConstant.PDF_SUFFIX;
BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, response);
}

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

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.safeproduct.constants.SafeProductConstant;
import com.hnac.hzims.safeproduct.dto.CarMaintenanceConfirmationDTO;
import com.hnac.hzims.safeproduct.entity.CarEntity;
import com.hnac.hzims.safeproduct.entity.CarMaintenanceEntity;
@ -111,11 +112,11 @@ public class CarMaintenanceServiceImpl extends ServiceImpl<CarMaintenanceMapper,
*/
@Override
public void exportCarMaintenanceData(Long id, HttpServletResponse response) {
CarMaintenanceEntity carMaintenanceEntity = this.getById(id);
Map<String, Object> params = BaseUtil.obj2Map(carMaintenanceEntity);
String templateFile = "template/车辆维保记录单.docx";
String wordPath = savePath + "/车辆维保记录单.docx";
String pdfPath = savePath + "/车辆维保记录单.pdf";
CarMaintenanceDetailVO carMaintenanceDetailVO = this.getCarMaintenance(id);
Map<String, Object> params = BaseUtil.obj2Map(carMaintenanceDetailVO);
String templateFile = "template/车辆维保记录单" + SafeProductConstant.DOCX_SUFFIX;
String wordPath = savePath + "/车辆维保记录单" + SafeProductConstant.DOCX_SUFFIX;
String pdfPath = savePath + "/车辆维保记录单" + SafeProductConstant.PDF_SUFFIX;
BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, response);
}

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

@ -6,16 +6,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.safeproduct.constants.SafeProductConstant;
import com.hnac.hzims.safeproduct.dto.CarUsedRecordConfirmationDTO;
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;
@ -24,7 +23,6 @@ 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;
@ -111,11 +109,11 @@ 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";
CarUsedRecordDetailVO carUsedRecordDetailVO = this.getCarUsedRecord(id);
Map<String, Object> params = BaseUtil.obj2Map(carUsedRecordDetailVO);
String templateFile = "template/用车记录单" + SafeProductConstant.DOCX_SUFFIX;
String wordPath = savePath + "/用车记录单" + SafeProductConstant.DOCX_SUFFIX;
String pdfPath = savePath + "/用车记录单" + SafeProductConstant.PDF_SUFFIX;
BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, response);
}

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

@ -55,7 +55,28 @@ public class BaseUtil {
}
/**
* 文件导出
* pdf文件导出
* @param templateFile 模板文件路径
* @param params 数据参数
* @param wordPath 文件生成路径
* @param pdfPath pdf生成路径
* @param response 响应类
*/
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) {
log.error("文件导出异常: {}", e.getMessage());
}
AsposeUtil.wordToPdf(wordPath, pdfPath);
BaseUtil.readPdf(response,pdfPath);
}
/**
* word文件导出
* @param documents doc文件
* @param savePath 存储路径
*/
@ -67,22 +88,22 @@ public class BaseUtil {
document.write(out);
}
} catch (IOException e) {
log.error("文件导出异常: {}", e.getMessage());
log.error("word文件导出异常: {}", e.getMessage());
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
log.error("文件导出-输出流关闭异常: {}", e.getMessage());
log.error("word文件导出-输出流关闭异常: {}", e.getMessage());
}
}
}
}
/**
* 数据写入模板文件
* @param templatePath 模板路径
* @param params 数据
* 数据写入
* @param templatePath 模板文件路径
* @param params 数据参数
*/
public static XWPFDocument fillDocument(String templatePath, Map<String, Object> params) {
XWPFDocument xwpfDocument = null;
@ -113,7 +134,7 @@ public class BaseUtil {
"inline; filename= " + URLEncoder.encode(file.getName(), "UTF-8"));
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
log.error("本地pdf文件读取异常: {}", e.getMessage());
} finally {
try {
if (fileInputStream != null) {
@ -128,16 +149,21 @@ public class BaseUtil {
}
}
/**
* 对象转map
* @param obj 对象类
* @return map参数
*/
public static Map<String, Object> obj2Map(Object obj) {
if(ObjectUtil.isNotEmpty(obj) && null != obj.getClass()) {
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) {
while (clazz != null) {
fieldList.addAll(Arrays.asList(clazz.getDeclaredFields()));
clazz = clazz.getSuperclass();
}
fieldList.forEach(field -> {
fieldList.forEach (field -> {
field.setAccessible(true);
Object value;
try {
@ -145,11 +171,11 @@ public class BaseUtil {
} catch (IllegalAccessException e) {
throw new ServiceException("获取属性性出错");
}
if(value instanceof List) {
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) {
else if (value instanceof LocalDateTime) {
DateTimeToMap dateTimeToMap = field.getAnnotation(DateTimeToMap.class);
LocalDateTime time = (LocalDateTime) value;
if(ObjectUtil.isEmpty(dateTimeToMap)) {
@ -159,10 +185,10 @@ public class BaseUtil {
result.putAll(LocalDateConvertMap(time,dateTimeToMap.prefix(),dateTimeToMap.split()));
}
}
else if(value instanceof Date) {
else if (value instanceof Date) {
DateTimeToMap dateTimeToMap = field.getAnnotation(DateTimeToMap.class);
Date time = (Date) value;
if(ObjectUtil.isEmpty(dateTimeToMap)) {
if (ObjectUtil.isEmpty(dateTimeToMap)) {
result.put(field.getName(),DateUtil.format(time,DateUtil.PATTERN_DATETIME));
}
else {
@ -191,7 +217,7 @@ public class BaseUtil {
* @return map对象
*/
public static Map<String, Object> LocalDateConvertMap(LocalDateTime dateTime,String prefix,String split) {
HashMap<String, Object> result = new HashMap<String, Object>() {{
return new HashMap<String, Object>() {{
put(prefix + split + "year", dateTime.getYear());
put(prefix + split + "month", dateTime.getMonthValue());
put(prefix + split + "day", dateTime.getDayOfMonth());
@ -199,19 +225,5 @@ public class BaseUtil {
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);
}
}

5
hzims-service/safeproduct/src/main/resources/db/1.0.1.sql

@ -197,6 +197,7 @@ CREATE TABLE `hzims_hygiene_plan` (
CREATE TABLE `hzims_hygiene_zone` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`hygiene_plan_id` bigint(20) NOT NULL COMMENT '卫生自查计划id',
`unit` varchar(50) NOT NULL COMMENT '单位',
`zone` varchar(50) NOT NULL COMMENT '责任区',
`principal` varchar(20) NOT NULL COMMENT '责任人',
`check_item` mediumtext NOT NULL COMMENT '检查项',
@ -269,8 +270,8 @@ CREATE TABLE `hzims_car_maintenance` (
`code` varchar(50) NOT NULL COMMENT '编号',
`maintenance_type` varchar(50) NOT NULL COMMENT '维保类型',
`content` mediumtext NOT NULL COMMENT '维保内容',
`start_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '维保开始时间',
`end_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '维保结束时间',
`start_time` date NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '维保开始时间',
`end_time` date NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '维保结束时间',
`location` varchar(255) NOT NULL COMMENT '维保地点',
`cost` bigint(20) NOT NULL COMMENT '维保费用',
`maintainer` varchar(20) NOT NULL COMMENT '维保人',

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

Binary file not shown.

BIN
hzims-service/safeproduct/src/main/resources/template/车辆检查表.docx

Binary file not shown.
Loading…
Cancel
Save