# Conflicts: # hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/MhSystemBaseInfoDTO.javatags/24081603^0
@@ -0,0 +1,74 @@ | |||||
package com.hz.pm.api.projectlib.controller; | |||||
import cn.hutool.core.map.MapUtil; | |||||
import cn.hutool.poi.excel.ExcelReader; | |||||
import cn.hutool.poi.excel.ExcelUtil; | |||||
import cn.hutool.poi.excel.ExcelWriter; | |||||
import cn.hutool.poi.excel.StyleSet; | |||||
import com.hz.pm.api.projectlib.manage.MhSystemReplaceManage; | |||||
import com.hz.pm.api.projectlib.model.dto.MhSystemBaseInfoDTO; | |||||
import com.hz.pm.api.projectlib.model.req.MhSystemReplaceReq; | |||||
import com.ningdatech.basic.model.PageVo; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import lombok.RequiredArgsConstructor; | |||||
import org.apache.poi.ss.usermodel.CellStyle; | |||||
import org.springframework.web.bind.annotation.GetMapping; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
import java.io.File; | |||||
import java.time.LocalDateTime; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* <p> | |||||
* MhSystemReplaceController | |||||
* </p> | |||||
* | |||||
* @author WendyYang | |||||
* @since 15:10 2024/8/16 | |||||
*/ | |||||
@Api(tags = "系统替代情况底账") | |||||
@RestController | |||||
@RequiredArgsConstructor | |||||
@RequestMapping("/api/v1/mh/systemReplace") | |||||
public class MhSystemReplaceController { | |||||
private final MhSystemReplaceManage mhSystemReplaceManage; | |||||
@GetMapping("/page") | |||||
@ApiOperation("列表查询") | |||||
public PageVo<MhSystemBaseInfoDTO> page(MhSystemReplaceReq req) { | |||||
return mhSystemReplaceManage.page(req); | |||||
} | |||||
public static void main(String[] args) { | |||||
ExcelReader reader = ExcelUtil.getReader("/Users/wendy/Desktop/信息系统.xlsx"); | |||||
List<Map<String, Object>> maps = reader.readAll(); | |||||
List<MhSystemBaseInfoDTO> collect = maps.stream().map(w -> { | |||||
MhSystemBaseInfoDTO dto = new MhSystemBaseInfoDTO(); | |||||
dto.setSourceName(MapUtil.getStr(w, "系统名称")); | |||||
dto.setTargetName(MapUtil.getStr(w, "替代后系统名称")); | |||||
dto.setBuildOrgName(MapUtil.getStr(w, "建设单位")); | |||||
dto.setBuildOrgCode(MapUtil.getLong(w, "建设单位ID")); | |||||
dto.setReplaceType(MapUtil.getStr(w, "改造方式")); | |||||
dto.setSystemNum(MapUtil.getInt(w, "集成系统数量", 1)); | |||||
dto.setPlanStartDate(MapUtil.getInt(w, "计划改造开始时间")); | |||||
dto.setPlanFinishDate(MapUtil.getInt(w, "计划完成时间")); | |||||
dto.setActualStartDate(MapUtil.get(w, "开始时间", LocalDateTime.class)); | |||||
dto.setActualFinishDate(MapUtil.get(w, "完成时间", LocalDateTime.class)); | |||||
return dto; | |||||
}).collect(Collectors.toList()); | |||||
try (ExcelWriter writer = ExcelUtil.getWriter()) { | |||||
writer.write(collect) | |||||
.flush(new File("/Users/wendy/Desktop/mh-system-replace.xlsx")) | |||||
.close(); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,97 @@ | |||||
package com.hz.pm.api.projectlib.manage; | |||||
import cn.hutool.core.bean.BeanUtil; | |||||
import cn.hutool.core.io.resource.ClassPathResource; | |||||
import cn.hutool.core.util.StrUtil; | |||||
import cn.hutool.poi.excel.ExcelReader; | |||||
import cn.hutool.poi.excel.ExcelUtil; | |||||
import com.hz.pm.api.projectlib.model.dto.MhSystemBaseInfoDTO; | |||||
import com.hz.pm.api.projectlib.model.req.MhSystemReplaceReq; | |||||
import com.hz.pm.api.user.helper.MhUnitCache; | |||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.basic.util.CollUtils; | |||||
import lombok.RequiredArgsConstructor; | |||||
import org.springframework.stereotype.Component; | |||||
import java.io.InputStream; | |||||
import java.util.Comparator; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.Objects; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* <p> | |||||
* MhSystemReplaceManage | |||||
* </p> | |||||
* | |||||
* @author WendyYang | |||||
* @since 15:11 2024/8/16 | |||||
*/ | |||||
@Component | |||||
@RequiredArgsConstructor | |||||
public class MhSystemReplaceManage { | |||||
private final MhUnitCache mhUnitCache; | |||||
public PageVo<MhSystemBaseInfoDTO> page(MhSystemReplaceReq req) { | |||||
ClassPathResource resource = new ClassPathResource("/response/mh-system-replace.xlsx"); | |||||
InputStream stream = resource.getStream(); | |||||
ExcelReader reader = ExcelUtil.getReader(stream); | |||||
List<Map<String, Object>> data = reader.readAll(); | |||||
List<MhSystemBaseInfoDTO> actualData = BeanUtil.copyToList(data, MhSystemBaseInfoDTO.class); | |||||
List<Long> filterOrgCodes; | |||||
if (req.getBuildOrgCode() != null) { | |||||
filterOrgCodes = mhUnitCache.getViewChildIdsRecursion(req.getBuildOrgCode()); | |||||
} else { | |||||
filterOrgCodes = null; | |||||
} | |||||
List<MhSystemBaseInfoDTO> filterData = actualData.stream().filter(w -> { | |||||
if (filterOrgCodes != null && !filterOrgCodes.contains(w.getBuildOrgCode())) { | |||||
return false; | |||||
} | |||||
if (req.getFinish() != null | |||||
&& !req.getFinish() == Objects.nonNull(w.getActualFinishDate())) { | |||||
return false; | |||||
} | |||||
if (StrUtil.isNotBlank(req.getReplaceType()) | |||||
&& !req.getReplaceType().equals(w.getReplaceType())) { | |||||
return false; | |||||
} | |||||
if (req.getPlanStartDateMin() != null | |||||
&& req.getPlanStartDateMax() != null | |||||
&& (w.getPlanStartDate() == null | |||||
|| !(w.getPlanStartDate() >= req.getPlanStartDateMin() | |||||
&& w.getPlanStartDate() <= req.getPlanStartDateMax()))) { | |||||
return false; | |||||
} | |||||
if (req.getPlanFinishDateMin() != null | |||||
&& req.getPlanFinishDateMax() != null | |||||
&& (w.getPlanFinishDate() == null | |||||
|| !(w.getPlanFinishDate() >= req.getPlanFinishDateMin() | |||||
&& w.getPlanFinishDate() <= req.getPlanFinishDateMax()))) { | |||||
return false; | |||||
} | |||||
if (StrUtil.isNotBlank(req.getSystemName()) | |||||
&& (!w.getSourceName().contains(req.getSystemName()) | |||||
|| !w.getTargetName().contains(req.getSystemName()))) { | |||||
return false; | |||||
} | |||||
if (StrUtil.isNotBlank(req.getBuildOrgName())) { | |||||
return w.getBuildOrgName().contains(req.getBuildOrgName()); | |||||
} | |||||
return true; | |||||
}).collect(Collectors.toList()); | |||||
if (Boolean.TRUE.equals(req.getFinish())) { | |||||
filterData.sort(Comparator.comparing(MhSystemBaseInfoDTO::getActualFinishDate).reversed()); | |||||
} else { | |||||
filterData.sort(Comparator.comparing(MhSystemBaseInfoDTO::getPlanFinishDate).reversed()); | |||||
} | |||||
List<MhSystemBaseInfoDTO> pageData = CollUtils.page(filterData, req.getPageNumber(), req.getPageSize()); | |||||
return PageVo.of(pageData, filterData.size()); | |||||
} | |||||
} |
@@ -1,26 +1,10 @@ | |||||
package com.hz.pm.api.projectlib.model.dto; | package com.hz.pm.api.projectlib.model.dto; | ||||
import cn.hutool.core.io.FileUtil; | |||||
import cn.hutool.core.map.MapUtil; | |||||
import cn.hutool.core.util.StrUtil; | |||||
import cn.hutool.json.JSON; | |||||
import cn.hutool.json.JSONObject; | |||||
import cn.hutool.json.JSONUtil; | |||||
import cn.hutool.poi.excel.ExcelReader; | |||||
import cn.hutool.poi.excel.ExcelUtil; | |||||
import com.fasterxml.jackson.annotation.JsonFormat; | import com.fasterxml.jackson.annotation.JsonFormat; | ||||
import com.hz.pm.api.common.util.BizUtils; | |||||
import com.ningdatech.basic.util.CollUtils; | |||||
import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
import lombok.Data; | import lombok.Data; | ||||
import java.io.File; | |||||
import java.nio.charset.StandardCharsets; | |||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.util.Collection; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
@@ -42,20 +26,24 @@ public class MhSystemBaseInfoDTO { | |||||
@ApiModelProperty("建设单位") | @ApiModelProperty("建设单位") | ||||
private String buildOrgName; | private String buildOrgName; | ||||
@ApiModelProperty("建设单位代码") | |||||
private Long buildOrgCode; | |||||
@ApiModelProperty("替换类型: IM:改造提升 IT:综合集成 NE:自然淘汰") | @ApiModelProperty("替换类型: IM:改造提升 IT:综合集成 NE:自然淘汰") | ||||
private String replaceType; | private String replaceType; | ||||
@ApiModelProperty("集成系统数量") | @ApiModelProperty("集成系统数量") | ||||
private Integer systemNum; | private Integer systemNum; | ||||
@ApiModelProperty("计划开始时间") | |||||
private String planStartDate; | |||||
@ApiModelProperty("计划开始年份") | |||||
private Integer planStartDate; | |||||
@ApiModelProperty("计划开始时间") | @ApiModelProperty("计划开始时间") | ||||
private String planFinishDate; | |||||
private Integer planFinishDate; | |||||
@ApiModelProperty("实际开始时间") | @ApiModelProperty("实际开始时间") | ||||
private String actualStartDate; | |||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||||
private LocalDateTime actualStartDate; | |||||
@ApiModelProperty("实际完成时间") | @ApiModelProperty("实际完成时间") | ||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||||
@@ -0,0 +1,45 @@ | |||||
package com.hz.pm.api.projectlib.model.req; | |||||
import com.ningdatech.basic.model.PagePo; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
/** | |||||
* <p> | |||||
* MhSystemReplaceReq | |||||
* </p> | |||||
* | |||||
* @author WendyYang | |||||
* @since 15:13 2024/8/16 | |||||
*/ | |||||
@Data | |||||
@EqualsAndHashCode(callSuper = true) | |||||
public class MhSystemReplaceReq extends PagePo { | |||||
@ApiModelProperty("是否完成") | |||||
private Boolean finish; | |||||
@ApiModelProperty("系统名称") | |||||
private String systemName; | |||||
@ApiModelProperty("替代类型") | |||||
private String replaceType; | |||||
@ApiModelProperty("建设单位编码") | |||||
private Long buildOrgCode; | |||||
@ApiModelProperty("建设单位") | |||||
private String buildOrgName; | |||||
@ApiModelProperty("计划开始时间") | |||||
private Integer planStartDateMin; | |||||
@ApiModelProperty("计划开始时间") | |||||
private Integer planStartDateMax; | |||||
@ApiModelProperty("计划完成时间") | |||||
private Integer planFinishDateMin; | |||||
@ApiModelProperty("计划完成时间") | |||||
private Integer planFinishDateMax; | |||||
} |