Browse Source

fix: 解决车检记录导出格式异常的问题

zhongwei
liwen 6 months ago
parent
commit
ee67e3d33f
  1. 16
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java
  2. 3
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java

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

@ -29,6 +29,7 @@ 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;
@ -198,6 +199,21 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper,
public void exportCarCheckRecordData(Long id, HttpServletResponse response) {
CarCheckRecordDetailVO carCheckRecordDetailVO = this.getCarCheckRecord(id);
// 数据处理
// 检查项
List<CarCheckItemEntity> checkList = carCheckRecordDetailVO.getCheckItemList();
List<CarCheckItemEntity> res = new ArrayList<>();
checkList.forEach(item -> {
String[] checkContent = item.getCheckContent().split(",");
String[] checkResult = item.getCheckResult().split(",");
for (int i = 0; i < checkContent.length; i++) {
CarCheckItemEntity carCheckItemEntity = new CarCheckItemEntity();
carCheckItemEntity.setCheckItem(item.getCheckItem());
carCheckItemEntity.setCheckContent(checkContent[i]);
carCheckItemEntity.setCheckResult(checkResult[i]);
res.add(carCheckItemEntity);
}
});
carCheckRecordDetailVO.setCheckItemList(res);
// 表头年月
String code = carCheckRecordDetailVO.getCode();
carCheckRecordDetailVO.setYear(code.substring(4, 8));

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

@ -147,6 +147,9 @@ public class BaseUtil {
if (templatePath.equals("template/卫生自查表.docx")) {
formatHygieneRecordTable(xwpfDocument);
}
if (templatePath.equals("template/车辆检查表.docx")) {
formatCarCheckRecordTable(xwpfDocument);
}
} catch (Exception e) {
e.printStackTrace();
}

Loading…
Cancel
Save