|
@@ -86,7 +86,8 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
|
|
|
|
|
|
@Override
|
|
|
public CommonPage<PatrolInspectionRecord> patrolInspectionRecordLsit(String areaName, String siteName, String name,
|
|
|
- Integer planType, String startDateTime, String endDateTime,
|
|
|
+ Integer planType, Integer routeId,
|
|
|
+ String startDateTime, String endDateTime,
|
|
|
Integer pageNum, Integer pageSize) {
|
|
|
IPage<PatrolInspectionRecord> page = new Page<>(pageNum, pageSize);
|
|
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
@@ -100,6 +101,7 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
|
|
|
.like(StringUtils.isNotBlank(siteName), PatrolInspectionRecord::getSiteName, siteName)
|
|
|
.like(StringUtils.isNotBlank(name), PatrolInspectionRecord::getName, name)
|
|
|
.eq(planType != null && planType != 0, PatrolInspectionRecord::getPlanType, planType)
|
|
|
+ .eq(routeId != null, PatrolInspectionRecord::getRouteId, routeId)
|
|
|
.between(StringUtils.isNotBlank(startDateTime) && StringUtils.isNotBlank(endDateTime), PatrolInspectionRecord::getCreateTime, startDateTime, endDateTime)
|
|
|
.eq("00".equals(userType), PatrolInspectionRecord::getCreator, SecurityUtils.getUsername());
|
|
|
queryWrapper.orderByDesc(PatrolInspectionRecord::getId);
|
|
@@ -108,11 +110,6 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
|
|
|
}
|
|
|
|
|
|
|
|
|
-// public List<PatrolInspectionPlan> getPatrolInspectionPlan(){
|
|
|
-// LambdaQueryWrapper<PatrolInspectionRecord> queryWrapper = Wrappers.lambdaQuery();
|
|
|
-// queryWrapper.eq(PatrolInspectionRecord::getTenantId, SecurityUtils.getTenantId());
|
|
|
-// }
|
|
|
-
|
|
|
@Override
|
|
|
public List<PatrolInspectionRecordVo> patrolInspectionRecordDetails(Integer id) {
|
|
|
//记录查询
|
|
@@ -428,6 +425,17 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导出巡检记录
|
|
|
+ * @param areaName
|
|
|
+ * @param siteName
|
|
|
+ * @param name
|
|
|
+ * @param planType
|
|
|
+ * @param startDateTime
|
|
|
+ * @param endDateTime
|
|
|
+ * @param idList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
public List<PatrolInspectionRecordExportVo> exportImage(String areaName, String siteName, String name,
|
|
|
Integer planType, String startDateTime,
|
|
@@ -452,7 +460,7 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
|
|
|
for (int i = 0; i < idArray.length; i++) {
|
|
|
listId.add(Integer.parseInt(idArray[i]));
|
|
|
}
|
|
|
- if (!listId.isEmpty()){
|
|
|
+ if (!listId.isEmpty()) {
|
|
|
queryWrapper.in(PatrolInspectionRecord::getId, listId);
|
|
|
}
|
|
|
}
|
|
@@ -515,287 +523,6 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
|
|
|
}
|
|
|
|
|
|
|
|
|
- /*public void exportImage(HttpServletResponse response, String areaName, String siteName, String name, Integer planType,
|
|
|
- String startDateTime, String endDateTime, String idList) throws IOException {
|
|
|
- DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
- String userType = null;
|
|
|
- if (loginUser != null && !"".equals(loginUser)) {
|
|
|
- userType = loginUser.getUserType();
|
|
|
- }
|
|
|
- LambdaQueryWrapper<PatrolInspectionRecord> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(PatrolInspectionRecord::getTenantId, SecurityUtils.getTenantId())
|
|
|
- .like(StringUtils.isNotBlank(areaName), PatrolInspectionRecord::getAreaName, areaName)
|
|
|
- .like(StringUtils.isNotBlank(siteName), PatrolInspectionRecord::getSiteName, siteName)
|
|
|
- .like(StringUtils.isNotBlank(name), PatrolInspectionRecord::getName, name)
|
|
|
- .eq(planType != null && planType != 0, PatrolInspectionRecord::getPlanType, planType)
|
|
|
- .between(StringUtils.isNotBlank(startDateTime) && StringUtils.isNotBlank(endDateTime), PatrolInspectionRecord::getCreateTime, startDateTime, endDateTime)
|
|
|
- .eq("00".equals(userType), PatrolInspectionRecord::getCreator, SecurityUtils.getUsername());
|
|
|
- if (StringUtils.isNotBlank(idList)) {
|
|
|
- List<Integer> listId = new ArrayList<>();
|
|
|
- String[] idArray = idList.split(",");
|
|
|
- for (int i = 0; i < idArray.length; i++) {
|
|
|
- listId.add(Integer.parseInt(idArray[i]));
|
|
|
- }
|
|
|
- queryWrapper.in(PatrolInspectionRecord::getId, listId);
|
|
|
- }
|
|
|
- queryWrapper.orderByDesc(PatrolInspectionRecord::getId);
|
|
|
- List<PatrolInspectionRecord> patrolInspectionRecordList = this.list(queryWrapper);
|
|
|
- List<PatrolInspectionRecordExportVo> list = new ArrayList<>();
|
|
|
- for (int i = 0; i < patrolInspectionRecordList.size(); i++) {
|
|
|
- PatrolInspectionRecordExportVo patrolInspectionRecordExportVo = new PatrolInspectionRecordExportVo();
|
|
|
- patrolInspectionRecordExportVo.setXh(i + 1);
|
|
|
- patrolInspectionRecordExportVo.setId(patrolInspectionRecordList.get(i).getId());
|
|
|
- patrolInspectionRecordExportVo.setSiteNubmber(patrolInspectionRecordList.get(i).getSiteNubmber());
|
|
|
- patrolInspectionRecordExportVo.setSiteType(patrolInspectionRecordList.get(i).getSiteType());
|
|
|
- patrolInspectionRecordExportVo.setAreaName(patrolInspectionRecordList.get(i).getAreaName());
|
|
|
- patrolInspectionRecordExportVo.setSiteName(patrolInspectionRecordList.get(i).getSiteName());
|
|
|
- patrolInspectionRecordExportVo.setName(patrolInspectionRecordList.get(i).getName());
|
|
|
- patrolInspectionRecordExportVo.setPhone(patrolInspectionRecordList.get(i).getPhone());
|
|
|
- patrolInspectionRecordExportVo.setPlanType(patrolInspectionRecordList.get(i).getPlanType());
|
|
|
- patrolInspectionRecordExportVo.setLongitude(patrolInspectionRecordList.get(i).getLongitude());
|
|
|
- patrolInspectionRecordExportVo.setLatitude(patrolInspectionRecordList.get(i).getLatitude());
|
|
|
- patrolInspectionRecordExportVo.setStartDate(patrolInspectionRecordList.get(i).getStartDate().format(df));
|
|
|
- patrolInspectionRecordExportVo.setEndDate(patrolInspectionRecordList.get(i).getEndDate().format(df));
|
|
|
- patrolInspectionRecordExportVo.setCreateTime(patrolInspectionRecordList.get(i).getCreateTime().format(df));
|
|
|
- LambdaQueryWrapper<PatrolInspectionRecordPicture> queryWrapperJpg = Wrappers.lambdaQuery();//导出图片
|
|
|
- queryWrapperJpg.select(PatrolInspectionRecordPicture::getPictureUrl)
|
|
|
- .eq(PatrolInspectionRecordPicture::getRecordId, patrolInspectionRecordList.get(i).getId());
|
|
|
- List<PatrolInspectionRecordPicture> pictures = orphansInspectionRecordPictureMapper.selectList(queryWrapperJpg);
|
|
|
- if (pictures.size() > 0) {
|
|
|
- for (int j = 0; j < pictures.size() && j < 5; j++) {
|
|
|
- String pictureUrl = pictures.get(j).getPictureUrl();
|
|
|
- switch (j) {
|
|
|
- case 0:
|
|
|
- patrolInspectionRecordExportVo.setImagePath1(pictureUrl);
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- patrolInspectionRecordExportVo.setImagePath2(pictureUrl);
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- patrolInspectionRecordExportVo.setImagePath3(pictureUrl);
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- patrolInspectionRecordExportVo.setImagePath4(pictureUrl);
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- patrolInspectionRecordExportVo.setImagePath5(pictureUrl);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- list.add(patrolInspectionRecordExportVo);
|
|
|
- }
|
|
|
- XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
- XSSFSheet sheet = workbook.createSheet("巡检记录");
|
|
|
- // 添加列标题行
|
|
|
- Row headerRow = sheet.createRow(1);
|
|
|
- String[] headers = {
|
|
|
- "序号", "地点号码", "地点类型", "区域名称", "地点名称", "巡检人员", "联系电话",
|
|
|
- "计划类型", "经度", "纬度", "开始时间", "结束时间", "巡检时间", "巡检照片1",
|
|
|
- "巡检照片2", "巡检照片3", "巡检照片4", "巡检照片5"
|
|
|
- };
|
|
|
- // 添加总标题行
|
|
|
- Row titleRow = sheet.createRow(0);
|
|
|
- Cell titleCell = titleRow.createCell(0);
|
|
|
- titleCell.setCellValue("巡检记录");
|
|
|
- CellStyle titleCellStyle = workbook.createCellStyle();
|
|
|
- // 设置字体为黑色加粗
|
|
|
- Font titleFont = workbook.createFont();
|
|
|
- titleFont.setFontName("宋体");
|
|
|
- titleFont.setFontHeightInPoints((short) 16);
|
|
|
- titleFont.setColor(IndexedColors.BLACK.getIndex());
|
|
|
- titleFont.setBold(true);
|
|
|
- titleCellStyle.setFont(titleFont);
|
|
|
- // 设置水平居中和垂直居中
|
|
|
- titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
- titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
- titleCell.setCellStyle(titleCellStyle);
|
|
|
- titleRow.setHeightInPoints(30);
|
|
|
- // 合并标题单元格以横跨所有列
|
|
|
- int totalColumns = headers.length;
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, totalColumns - 1));
|
|
|
- //设置列标题
|
|
|
- for (int i = 0; i < headers.length; i++) {
|
|
|
- Cell cell = headerRow.createCell(i);
|
|
|
- cell.setCellValue(headers[i]);
|
|
|
- CellStyle headerCellStyle = workbook.createCellStyle();
|
|
|
- headerCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
- headerCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
- headerCellStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
- headerCellStyle.setBorderTop(BorderStyle.THIN);
|
|
|
- headerCellStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
- headerCellStyle.setBorderRight(BorderStyle.THIN);
|
|
|
- // 设置背景颜色为灰色
|
|
|
- headerCellStyle.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
|
|
- headerCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
|
- // 设置字体为白色
|
|
|
- Font headerFont = workbook.createFont();
|
|
|
- headerFont.setFontName("宋体");
|
|
|
- headerFont.setFontHeightInPoints((short) 10);
|
|
|
- headerFont.setColor(IndexedColors.WHITE.getIndex());
|
|
|
- headerFont.setBold(true);
|
|
|
- headerRow.setHeightInPoints(13.5f);
|
|
|
- headerCellStyle.setFont(headerFont);
|
|
|
- cell.setCellStyle(headerCellStyle);
|
|
|
- }
|
|
|
-
|
|
|
- Row fixedRow = sheet.createRow(list.size() + 3); // 数据行数 + 标题行数(1) + 固定行(1) + 空一行
|
|
|
- CellStyle fixedCellStyle = workbook.createCellStyle();
|
|
|
-
|
|
|
- // 创建字体样式
|
|
|
- Font fixedFont = workbook.createFont();
|
|
|
- fixedFont.setFontName("宋体");
|
|
|
- fixedFont.setBold(true);
|
|
|
- fixedFont.setFontHeightInPoints((short) 12);
|
|
|
- fixedCellStyle.setFont(fixedFont);
|
|
|
-
|
|
|
- // 创建“负责人签名”单元格
|
|
|
- Cell cellSign = fixedRow.createCell(0);
|
|
|
- cellSign.setCellValue("负责人签名:");
|
|
|
- cellSign.setCellStyle(fixedCellStyle);
|
|
|
-
|
|
|
- // 创建“日期”单元格
|
|
|
- Cell cellDate = fixedRow.createCell(4); // 假设日期单元格在第五列
|
|
|
- cellDate.setCellValue("日期:");
|
|
|
- cellDate.setCellStyle(fixedCellStyle);
|
|
|
-
|
|
|
- // 合并单元格
|
|
|
-// sheet.addMergedRegion(new CellRangeAddress(list.size() + 2, list.size() + 2, 0, 0)); // 负责人签名
|
|
|
-// sheet.addMergedRegion(new CellRangeAddress(list.size() + 2, list.size() + 2, 4, 4)); // 日期
|
|
|
-
|
|
|
- // 设置固定行的高度
|
|
|
- fixedRow.setHeightInPoints(20);
|
|
|
-
|
|
|
- // 设置数据行样式
|
|
|
- CellStyle dataCellStyle = workbook.createCellStyle();
|
|
|
- Font dataFont = workbook.createFont();
|
|
|
- dataFont.setFontName("Arial");
|
|
|
- dataFont.setFontHeightInPoints((short) 10);
|
|
|
- dataCellStyle.setFont(dataFont);
|
|
|
- dataCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
- dataCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
- dataCellStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
- dataCellStyle.setBorderTop(BorderStyle.THIN);
|
|
|
- dataCellStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
- dataCellStyle.setBorderRight(BorderStyle.THIN);
|
|
|
- // 添加数据
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- PatrolInspectionRecordExportVo record = list.get(i);
|
|
|
- Row row = sheet.createRow(i + 2);
|
|
|
-
|
|
|
- for (int j = 0; j < headers.length; j++) {
|
|
|
- Cell cell = row.createCell(j);
|
|
|
- cell.setCellStyle(dataCellStyle);
|
|
|
-
|
|
|
- // 根据 j 变量来确定应该填充数据的单元格索引
|
|
|
- switch (j) {
|
|
|
- case 0:
|
|
|
- cell.setCellValue(record.getXh());
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- cell.setCellValue(record.getSiteNubmber());
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- cell.setCellValue(record.getSiteType() == 1 ? "二维码" : "NFC");
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- cell.setCellValue(record.getAreaName());
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- cell.setCellValue(record.getSiteName());
|
|
|
- break;
|
|
|
- case 5:
|
|
|
- cell.setCellValue(record.getName());
|
|
|
- break;
|
|
|
- case 6:
|
|
|
- cell.setCellValue(record.getPhone());
|
|
|
- break;
|
|
|
- case 7:
|
|
|
- cell.setCellValue(record.getPlanType() == 1 ? "普通计划" : "按次计划");
|
|
|
- break;
|
|
|
- case 8:
|
|
|
- cell.setCellValue(record.getLongitude());
|
|
|
- break;
|
|
|
- case 9:
|
|
|
- cell.setCellValue(record.getLatitude());
|
|
|
- break;
|
|
|
- case 10:
|
|
|
- cell.setCellValue(record.getStartDate());
|
|
|
- break;
|
|
|
- case 11:
|
|
|
- cell.setCellValue(record.getEndDate());
|
|
|
- break;
|
|
|
- case 12:
|
|
|
- cell.setCellValue(record.getCreateTime());
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- CreationHelper helper = workbook.getCreationHelper();
|
|
|
- Drawing<?> drawing = sheet.createDrawingPatriarch();
|
|
|
- ClientAnchor anchor;
|
|
|
- if (record.getImagePath1() != null || record.getImagePath2() != null
|
|
|
- || record.getImagePath3() != null || record.getImagePath4() != null || record.getImagePath5() != null) {
|
|
|
- for (int k = 0; k < 5; k++) {
|
|
|
- String imagePath = null;
|
|
|
- switch (k) {
|
|
|
- case 0:
|
|
|
- imagePath = record.getImagePath1();
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- imagePath = record.getImagePath2();
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- imagePath = record.getImagePath3();
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- imagePath = record.getImagePath4();
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- imagePath = record.getImagePath5();
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (imagePath != null) {
|
|
|
- byte[] imageBytes = getImageBytes(imagePath);
|
|
|
- int pictureIdx = workbook.addPicture(imageBytes, Workbook.PICTURE_TYPE_JPEG);
|
|
|
-
|
|
|
- anchor = helper.createClientAnchor();
|
|
|
- anchor.setCol1(headers.length - 5 + k);
|
|
|
- anchor.setRow1(i + 2);
|
|
|
-
|
|
|
- Picture pict = drawing.createPicture(anchor, pictureIdx);
|
|
|
- pict.resize(1, 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- for (int i = 0; i < headers.length; i++) {
|
|
|
- sheet.setColumnWidth(i, (int) (16.09 * 256));
|
|
|
- }
|
|
|
-
|
|
|
- // 输出Excel文件
|
|
|
- response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
- response.setHeader("Content-Disposition", "attachment; filename=巡检记录.xlsx");
|
|
|
- workbook.write(response.getOutputStream());
|
|
|
- workbook.close();
|
|
|
- }
|
|
|
-
|
|
|
- //处理图片
|
|
|
- public byte[] getImageBytes(String imageUrl) throws IOException {
|
|
|
- URL url = new URL(imageUrl);
|
|
|
- BufferedImage image = ImageIO.read(url);
|
|
|
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
- ImageIO.write(image, "jpg", baos);
|
|
|
- return baos.toByteArray();
|
|
|
- }*/
|
|
|
-
|
|
|
/**
|
|
|
* 获取内容选项备注
|
|
|
*
|
|
@@ -914,18 +641,18 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
|
|
|
List<Integer> list = getContentOptionId(recordId);
|
|
|
System.out.println(list);
|
|
|
LambdaQueryWrapper<PatrolInspectionRecordOption> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
- queryWrapper1.eq(PatrolInspectionRecordOption::getRecordId,recordId)
|
|
|
- .in(PatrolInspectionRecordOption::getContentId,list)
|
|
|
+ queryWrapper1.eq(PatrolInspectionRecordOption::getRecordId, recordId)
|
|
|
+ .in(PatrolInspectionRecordOption::getContentId, list)
|
|
|
.orderByAsc(PatrolInspectionRecordOption::getId);
|
|
|
List<PatrolInspectionRecordOption> list2 = patrolInspectionRecordOptionMapper.selectList(queryWrapper1);
|
|
|
List<String> optionNameList = new ArrayList<>();
|
|
|
for (int i = 0; i < list2.size(); i++) {
|
|
|
- if (list2.get(i).getContentOptionId() == null || " ".equals(list2.get(i).getContentOptionId())){
|
|
|
+ if (list2.get(i).getContentOptionId() == null || " ".equals(list2.get(i).getContentOptionId())) {
|
|
|
optionNameList.add(list2.get(i).getContent());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
LambdaQueryWrapper<PatrolInspectionContentOption> queryWrapper2 = Wrappers.lambdaQuery();
|
|
|
queryWrapper2.select(PatrolInspectionContentOption::getOptionName)
|
|
|
- .eq(PatrolInspectionContentOption::getId,list2.get(i).getContentOptionId())
|
|
|
+ .eq(PatrolInspectionContentOption::getId, list2.get(i).getContentOptionId())
|
|
|
.orderByAsc(PatrolInspectionContentOption::getId);
|
|
|
PatrolInspectionContentOption optionName1 = patrolInspectionContentOptionMapper.selectOne(queryWrapper2);
|
|
|
optionNameList.add(optionName1.getOptionName());
|
|
@@ -935,5 +662,4 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|