diff --git a/src/main/java/com/biutag/supervision/controller/data/DataPetitionComplaintController.java b/src/main/java/com/biutag/supervision/controller/data/DataPetitionComplaintController.java index 2c66eaf..bf35495 100644 --- a/src/main/java/com/biutag/supervision/controller/data/DataPetitionComplaintController.java +++ b/src/main/java/com/biutag/supervision/controller/data/DataPetitionComplaintController.java @@ -9,6 +9,7 @@ import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.read.metadata.ReadSheet; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.biutag.supervision.common.UserContextHolder; import com.biutag.supervision.constants.enums.*; @@ -16,6 +17,7 @@ import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.dto.DataDataPetitionComplainDistribute; import com.biutag.supervision.pojo.dto.DataPetitionComplaintGjImportDto; import com.biutag.supervision.pojo.dto.DataPetitionComplaintImportDto; +import com.biutag.supervision.pojo.dto.DataPetitionComplaintReplenishDto; import com.biutag.supervision.pojo.entity.DataPetitionComplaint; import com.biutag.supervision.pojo.entity.NegativeTask; import com.biutag.supervision.pojo.entity.SupDepart; @@ -25,7 +27,7 @@ import com.biutag.supervision.pojo.vo.DataPetitionComplaintVo; import com.biutag.supervision.service.DataPetitionComplaintService; import com.biutag.supervision.service.NegativeTaskService; import com.biutag.supervision.service.SupDepartService; -import jakarta.validation.Validator; +import dm.jdbc.util.StringUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; @@ -41,7 +43,6 @@ import java.util.ArrayList; import java.util.List; /** - * * @author wxc * @date */ @@ -99,8 +100,10 @@ public class DataPetitionComplaintController { } } } + list.add(data); } + @Override public void doAfterAllAnalysed(AnalysisContext analysisContext) { } @@ -111,6 +114,37 @@ public class DataPetitionComplaintController { return Result.success(list); } + @PostMapping("gab/replenish") + public Result replenishExcel(@RequestPart("file") MultipartFile file) throws IOException { + log.info("文件导入中------------------------------"); + String fileNameType = FileUtil.extName(file.getOriginalFilename()); + if (!"xls".equals(fileNameType) && !"xlsx".equals(fileNameType)) { + throw new RuntimeException("仅支持 xls/xlsx 格式文件的导入"); + } + EasyExcel.read(file.getInputStream(), DataPetitionComplaintReplenishDto.class, new ReadListener() { + @Override + public void invoke(DataPetitionComplaintReplenishDto data, AnalysisContext analysisContext) { + + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() + .eq(DataPetitionComplaint::getOriginId, data.getOriginId()); + if (StringUtil.isNotEmpty(data.getInitialPetition())) { + updateWrapper.set(DataPetitionComplaint::getInitialPetition, data.getInitialPetition().contains("初") ? "1" : "2"); + } + if (StringUtil.isNotEmpty(data.getMassVisits())) { + updateWrapper.set(DataPetitionComplaint::getMassVisits, data.getMassVisits().contains("是")); + } + dataPetitionComplaintService.update(updateWrapper); + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + + } + }).sheet(0).headRowNumber(2).doRead(); + return Result.success(); + } + + @PostMapping("gab") @Transactional(rollbackFor = Exception.class) public Result add(@RequestBody List list) { @@ -127,6 +161,11 @@ public class DataPetitionComplaintController { } catch (Exception e) { log.error(e.getMessage(), e); } + try { + dataPetitionComplaint.setDiscoveryTime(LocalDate.parse(item.getDiscoveryTime(), DateTimeFormatter.ofPattern("yyyy-M-d H:m")).atStartOfDay()); + } catch (Exception e) { + log.error(e.getMessage(), e); + } } if (StrUtil.isNotBlank(item.getDepartId())) { SupDepart depart = departService.getById(item.getDepartId()); @@ -184,6 +223,7 @@ public class DataPetitionComplaintController { } list.add(data); } + @Override public void doAfterAllAnalysed(AnalysisContext analysisContext) { } diff --git a/src/main/java/com/biutag/supervision/pojo/dto/DataPetitionComplaintReplenishDto.java b/src/main/java/com/biutag/supervision/pojo/dto/DataPetitionComplaintReplenishDto.java new file mode 100644 index 0000000..f7b0e66 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/dto/DataPetitionComplaintReplenishDto.java @@ -0,0 +1,26 @@ +package com.biutag.supervision.pojo.dto; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class DataPetitionComplaintReplenishDto { + /** + * 信访编号 + * */ + @ExcelProperty(index = 2) + private String originId; + /** + * 初重信访 + * */ + @ExcelProperty(index = 24) + private String initialPetition; + /** + * 群众集访 + * */ + @ExcelProperty(index = 26) + private String massVisits; +} diff --git a/src/main/java/com/biutag/supervision/pojo/entity/DataPetitionComplaint.java b/src/main/java/com/biutag/supervision/pojo/entity/DataPetitionComplaint.java index 25efa77..a8d2b40 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/DataPetitionComplaint.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/DataPetitionComplaint.java @@ -2,8 +2,10 @@ package com.biutag.supervision.pojo.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Getter; import lombok.Setter; +import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; @@ -25,11 +27,12 @@ public class DataPetitionComplaint { // 受理层级 @TableField("acceptance_level") private String acceptanceLevel; - // 登记时间 + + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm") private LocalDateTime discoveryTime; - // 投诉人 @TableField("responder_name") private String responderName; @@ -99,4 +102,4 @@ public class DataPetitionComplaint { // 信访办理情况 private String petitionProcessingStatus; -} \ No newline at end of file +}