Commit 18d27000 by 王志超

feat: 变更配置导出

parent 867b210b
Pipeline #86927 passed with stages
in 1 minute 43 seconds
package com.netease.mail.yanxuan.change.biz.callback; package com.netease.mail.yanxuan.change.biz.callback;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -14,7 +18,6 @@ import com.netease.mail.dp.des.process.api.entity.CallbackQueryReq; ...@@ -14,7 +18,6 @@ import com.netease.mail.dp.des.process.api.entity.CallbackQueryReq;
import com.netease.mail.dp.des.process.api.entity.ExcelCell; import com.netease.mail.dp.des.process.api.entity.ExcelCell;
import com.netease.mail.dp.des.process.api.entity.ExcelTitle; import com.netease.mail.dp.des.process.api.entity.ExcelTitle;
import com.netease.mail.dp.des.starter.callback.DesCallbackService; import com.netease.mail.dp.des.starter.callback.DesCallbackService;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeTypeService;
import com.netease.mail.yanxuan.change.common.enums.ChangeLevelEnum; import com.netease.mail.yanxuan.change.common.enums.ChangeLevelEnum;
import com.netease.mail.yanxuan.change.common.enums.ChangeSubjectEnum; import com.netease.mail.yanxuan.change.common.enums.ChangeSubjectEnum;
import com.netease.mail.yanxuan.change.common.enums.ChangeCommanderEnum; import com.netease.mail.yanxuan.change.common.enums.ChangeCommanderEnum;
...@@ -23,6 +26,7 @@ import com.netease.mail.yanxuan.change.common.util.DateUtils; ...@@ -23,6 +26,7 @@ import com.netease.mail.yanxuan.change.common.util.DateUtils;
import com.netease.mail.yanxuan.change.common.util.ExcelUtil; import com.netease.mail.yanxuan.change.common.util.ExcelUtil;
import com.netease.mail.yanxuan.change.dal.entity.ChangeType; import com.netease.mail.yanxuan.change.dal.entity.ChangeType;
import com.netease.mail.yanxuan.change.dal.mapper.ChangeConfigMapper; import com.netease.mail.yanxuan.change.dal.mapper.ChangeConfigMapper;
import com.netease.mail.yanxuan.change.dal.mapper.ChangeTypeMapper;
import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeConfigPo; import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeConfigPo;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigQueryReq; import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigQueryReq;
import com.netease.mail.yanxuan.change.integration.excel.ChangeConfigExcelDTO; import com.netease.mail.yanxuan.change.integration.excel.ChangeConfigExcelDTO;
...@@ -41,7 +45,7 @@ public class ChangeConfigExportCallback implements DesCallbackService { ...@@ -41,7 +45,7 @@ public class ChangeConfigExportCallback implements DesCallbackService {
private ChangeConfigMapper changeConfigMapper; private ChangeConfigMapper changeConfigMapper;
@Autowired @Autowired
private ChangeTypeService changeTypeService; private ChangeTypeMapper changeTypeMapper;
@Override @Override
public ExcelTitle queryExcelTitle(CallbackQueryReq req) { public ExcelTitle queryExcelTitle(CallbackQueryReq req) {
...@@ -73,7 +77,7 @@ public class ChangeConfigExportCallback implements DesCallbackService { ...@@ -73,7 +77,7 @@ public class ChangeConfigExportCallback implements DesCallbackService {
} }
private List<ChangeConfigExcelDTO> getExportList(ChangeConfigQueryReq query) { private List<ChangeConfigExcelDTO> getExportList(ChangeConfigQueryReq query) {
List<ChangeConfigPo> changeConfigPos = changeConfigMapper.selectChangeConfigPo(query); List<ChangeConfigPo> changeConfigPos = changeConfigMapper.selectChangeConfigPoWithLimit(query);
// 处理执行部门格式 // 处理执行部门格式
changeConfigPos.forEach(i -> { changeConfigPos.forEach(i -> {
...@@ -87,6 +91,30 @@ public class ChangeConfigExportCallback implements DesCallbackService { ...@@ -87,6 +91,30 @@ public class ChangeConfigExportCallback implements DesCallbackService {
} }
}); });
// 批量查询变更类型:收集所有的 parentChangeClassId 和 sonChangeClassId
Set<Long> changeTypeIds = new HashSet<>();
for (ChangeConfigPo po : changeConfigPos) {
if (po.getParentChangeClassId() != null) {
changeTypeIds.add(po.getParentChangeClassId().longValue());
}
if (po.getSonChangeClassId() != null) {
changeTypeIds.add(po.getSonChangeClassId().longValue());
}
}
Map<Long, ChangeType> changeTypeMap = new HashMap<>();
if (!changeTypeIds.isEmpty()) {
List<Long> idList = new java.util.ArrayList<>(changeTypeIds);
List<ChangeType> changeTypes = changeTypeMapper.selectByIds(idList);
if (changeTypes != null) {
for (ChangeType changeType : changeTypes) {
changeTypeMap.put(changeType.getId(), changeType);
}
}
}
final Map<Long, ChangeType> finalChangeTypeMap = changeTypeMap;
return changeConfigPos.stream().map(po -> { return changeConfigPos.stream().map(po -> {
ChangeConfigExcelDTO dto = new ChangeConfigExcelDTO(); ChangeConfigExcelDTO dto = new ChangeConfigExcelDTO();
dto.setId(po.getId()); dto.setId(po.getId());
...@@ -97,21 +125,20 @@ public class ChangeConfigExportCallback implements DesCallbackService { ...@@ -97,21 +125,20 @@ public class ChangeConfigExportCallback implements DesCallbackService {
? ChangeSubjectEnum.getChangeSubjectEnum(po.getChangeSubject()).getDesc() : ""); ? ChangeSubjectEnum.getChangeSubjectEnum(po.getChangeSubject()).getDesc() : "");
} }
// 变更类型 // 变更类型:从 Map 中获取,格式为"一级>二级"
String parentChangeType = ""; String changeType = "";
String sonChangeType = "";
if (po.getParentChangeClassId() != null && po.getSonChangeClassId() != null) { if (po.getParentChangeClassId() != null && po.getSonChangeClassId() != null) {
ChangeType parentType = changeTypeService.getChangeTypeById(po.getParentChangeClassId().longValue()); ChangeType parentType = finalChangeTypeMap.get(po.getParentChangeClassId().longValue());
ChangeType sonType = changeTypeService.getChangeTypeById(po.getSonChangeClassId().longValue()); ChangeType sonType = finalChangeTypeMap.get(po.getSonChangeClassId().longValue());
if (parentType != null) { if (parentType != null && sonType != null) {
parentChangeType = parentType.getTypeName(); changeType = parentType.getTypeName() + ">" + sonType.getTypeName();
} } else if (parentType != null) {
if (sonType != null) { changeType = parentType.getTypeName();
sonChangeType = sonType.getTypeName(); } else if (sonType != null) {
changeType = sonType.getTypeName();
} }
} }
dto.setParentChangeType(parentChangeType); dto.setChangeType(changeType);
dto.setSonChangeType(sonChangeType);
// 变更等级 // 变更等级
if (po.getChangeLevel() != null) { if (po.getChangeLevel() != null) {
......
...@@ -41,6 +41,13 @@ public interface ChangeConfigMapper extends tk.mybatis.mapper.common.Mapper<Chan ...@@ -41,6 +41,13 @@ public interface ChangeConfigMapper extends tk.mybatis.mapper.common.Mapper<Chan
List<ChangeConfigPo> selectChangeConfigPo(ChangeConfigQueryReq req); List<ChangeConfigPo> selectChangeConfigPo(ChangeConfigQueryReq req);
/**
* 分页查询变更配置
* @param req 查询请求,包含 offset 和 limit 分页参数
* @return 变更配置列表
*/
List<ChangeConfigPo> selectChangeConfigPoWithLimit(ChangeConfigQueryReq req);
List<ChangeType> queryByparentChangeClassId(); List<ChangeType> queryByparentChangeClassId();
//暂时弃用 //暂时弃用
//ChangeExecConfigPo queryChangeDepartment(@Param("id")Long id); //ChangeExecConfigPo queryChangeDepartment(@Param("id")Long id);
......
...@@ -36,4 +36,18 @@ public interface ChangeTypeMapper extends tk.mybatis.mapper.common.Mapper<Change ...@@ -36,4 +36,18 @@ public interface ChangeTypeMapper extends tk.mybatis.mapper.common.Mapper<Change
@Select("select * from TB_YX_QC_CHANGE_TYPE where parent_id = #{id} and delete_type = 0") @Select("select * from TB_YX_QC_CHANGE_TYPE where parent_id = #{id} and delete_type = 0")
List<ChangeType> queryParent(@Param("id") Long id); List<ChangeType> queryParent(@Param("id") Long id);
/**
* 批量根据ID列表查询变更类型
* @param ids ID列表
* @return 变更类型列表
*/
@Select("<script>" +
"SELECT * FROM TB_YX_QC_CHANGE_TYPE WHERE id IN " +
"<foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
"#{id}" +
"</foreach>" +
" AND delete_type = 0" +
"</script>")
List<ChangeType> selectByIds(@Param("ids") List<Long> ids);
} }
\ No newline at end of file
...@@ -62,6 +62,39 @@ ...@@ -62,6 +62,39 @@
order by create_time desc order by create_time desc
</select> </select>
<select id="selectChangeConfigPoWithLimit" resultMap="BaseResultPoMap" parameterType="com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigQueryReq">
select <include refid="Base_Column_List" />
from TB_YX_QC_CHANGE_CONFIG
<where>
<if test="parentChangeClassId != null ">
parent_change_class_id = #{parentChangeClassId} and
</if>
<if test="sonChangeClassId != null ">
son_change_class_id = #{sonChangeClassId} and
</if>
<if test="changeLevel != null and changeLevel != ''">
change_level = #{changeLevel} and
</if>
<if test="changeDepartment != null and changeDepartment != ''">
change_department = #{changeDepartment} and
</if>
<if test="createTime != null">
create_time <![CDATA[ > ]]> #{createTime} and
</if>
<if test="updateTime != null">
create_time <![CDATA[ < ]]> #{updateTime} and
</if>
<if test="changeExecDepartment != null and changeExecDepartment != ''">
participate_change_exec_department like "%" #{changeExecDepartment} "%" and
</if>
1=1
</where>
order by create_time desc
<if test="offset != null and limit != null">
limit #{offset},#{limit}
</if>
</select>
<select id="queryByparentChangeClassId" resultType="com.netease.mail.yanxuan.change.dal.entity.ChangeType"> <select id="queryByparentChangeClassId" resultType="com.netease.mail.yanxuan.change.dal.entity.ChangeType">
select * from TB_YX_QC_CHANGE_TYPE where id = #{parentId} or id = #{sonId} and delete_type = 0 order by parent_id select * from TB_YX_QC_CHANGE_TYPE where id = #{parentId} or id = #{sonId} and delete_type = 0 order by parent_id
</select> </select>
......
...@@ -15,11 +15,8 @@ public class ChangeConfigExcelDTO { ...@@ -15,11 +15,8 @@ public class ChangeConfigExcelDTO {
@Excel(name = "变更主体") @Excel(name = "变更主体")
private String changeSubject; private String changeSubject;
@Excel(name = "一级变更类型") @Excel(name = "变更类型")
private String parentChangeType; private String changeType;
@Excel(name = "二级变更类型")
private String sonChangeType;
@Excel(name = "变更等级") @Excel(name = "变更等级")
private String changeLevel; private String changeLevel;
......
...@@ -21,37 +21,34 @@ public class ChangeConfigExcelVo { ...@@ -21,37 +21,34 @@ public class ChangeConfigExcelVo {
@ExcelTitleName(title = "变更主体", order = 2) @ExcelTitleName(title = "变更主体", order = 2)
private String changeSubject; private String changeSubject;
@ExcelTitleName(title = "一级变更类型", order = 3) @ExcelTitleName(title = "变更类型", order = 3)
private String parentChangeType; private String changeType;
@ExcelTitleName(title = "二级变更类型", order = 4) @ExcelTitleName(title = "变更等级", order = 4)
private String sonChangeType;
@ExcelTitleName(title = "变更等级", order = 5)
private String changeLevel; private String changeLevel;
@ExcelTitleName(title = "变更负责部门", order = 6) @ExcelTitleName(title = "变更负责部门", order = 5)
private String changeDepartment; private String changeDepartment;
@ExcelTitleName(title = "变更执行部门", order = 7) @ExcelTitleName(title = "变更执行部门", order = 6)
private String participateChangeExecDepartment; private String participateChangeExecDepartment;
@ExcelTitleName(title = "变更负责人类型", order = 8) @ExcelTitleName(title = "变更负责人类型", order = 7)
private String changeCommanderType; private String changeCommanderType;
@ExcelTitleName(title = "变更负责人", order = 9) @ExcelTitleName(title = "变更负责人", order = 8)
private String changeCommander; private String changeCommander;
@ExcelTitleName(title = "是否需要资料", order = 10) @ExcelTitleName(title = "是否需要资料", order = 9)
private String needFile; private String needFile;
@ExcelTitleName(title = "创建人", order = 11) @ExcelTitleName(title = "创建人", order = 10)
private String creator; private String creator;
@ExcelTitleName(title = "创建时间", order = 12) @ExcelTitleName(title = "创建时间", order = 11)
private String createTime; private String createTime;
@ExcelTitleName(title = "更新时间", order = 13) @ExcelTitleName(title = "更新时间", order = 12)
private String updateTime; private String updateTime;
public static List<ExcelCell> init(ChangeConfigExcelDTO dto) { public static List<ExcelCell> init(ChangeConfigExcelDTO dto) {
...@@ -69,57 +66,52 @@ public class ChangeConfigExcelVo { ...@@ -69,57 +66,52 @@ public class ChangeConfigExcelVo {
excelCell.setValue(dto.getChangeSubject() != null ? dto.getChangeSubject() : ""); excelCell.setValue(dto.getChangeSubject() != null ? dto.getChangeSubject() : "");
cells.add(excelCell); cells.add(excelCell);
// 3. 一级变更类型 // 3. 变更类型
excelCell = new ExcelCell();
excelCell.setValue(dto.getParentChangeType() != null ? dto.getParentChangeType() : "");
cells.add(excelCell);
// 4. 二级变更类型
excelCell = new ExcelCell(); excelCell = new ExcelCell();
excelCell.setValue(dto.getSonChangeType() != null ? dto.getSonChangeType() : ""); excelCell.setValue(dto.getChangeType() != null ? dto.getChangeType() : "");
cells.add(excelCell); cells.add(excelCell);
// 5. 变更等级 // 4. 变更等级
excelCell = new ExcelCell(); excelCell = new ExcelCell();
excelCell.setValue(dto.getChangeLevel() != null ? dto.getChangeLevel() : ""); excelCell.setValue(dto.getChangeLevel() != null ? dto.getChangeLevel() : "");
cells.add(excelCell); cells.add(excelCell);
// 6. 变更负责部门 // 5. 变更负责部门
excelCell = new ExcelCell(); excelCell = new ExcelCell();
excelCell.setValue(dto.getChangeDepartment() != null ? dto.getChangeDepartment() : ""); excelCell.setValue(dto.getChangeDepartment() != null ? dto.getChangeDepartment() : "");
cells.add(excelCell); cells.add(excelCell);
// 7. 变更执行部门 // 6. 变更执行部门
excelCell = new ExcelCell(); excelCell = new ExcelCell();
excelCell.setValue(dto.getParticipateChangeExecDepartment() != null ? dto.getParticipateChangeExecDepartment() : ""); excelCell.setValue(dto.getParticipateChangeExecDepartment() != null ? dto.getParticipateChangeExecDepartment() : "");
cells.add(excelCell); cells.add(excelCell);
// 8. 变更负责人类型 // 7. 变更负责人类型
excelCell = new ExcelCell(); excelCell = new ExcelCell();
excelCell.setValue(dto.getChangeCommanderType() != null ? dto.getChangeCommanderType() : ""); excelCell.setValue(dto.getChangeCommanderType() != null ? dto.getChangeCommanderType() : "");
cells.add(excelCell); cells.add(excelCell);
// 9. 变更负责人 // 8. 变更负责人
excelCell = new ExcelCell(); excelCell = new ExcelCell();
excelCell.setValue(dto.getChangeCommander() != null ? dto.getChangeCommander() : ""); excelCell.setValue(dto.getChangeCommander() != null ? dto.getChangeCommander() : "");
cells.add(excelCell); cells.add(excelCell);
// 10. 是否需要资料 // 9. 是否需要资料
excelCell = new ExcelCell(); excelCell = new ExcelCell();
excelCell.setValue(dto.getNeedFile() != null ? dto.getNeedFile() : ""); excelCell.setValue(dto.getNeedFile() != null ? dto.getNeedFile() : "");
cells.add(excelCell); cells.add(excelCell);
// 11. 创建人 // 10. 创建人
excelCell = new ExcelCell(); excelCell = new ExcelCell();
excelCell.setValue(dto.getCreator() != null ? dto.getCreator() : ""); excelCell.setValue(dto.getCreator() != null ? dto.getCreator() : "");
cells.add(excelCell); cells.add(excelCell);
// 12. 创建时间 // 11. 创建时间
excelCell = new ExcelCell(); excelCell = new ExcelCell();
excelCell.setValue(dto.getCreateTime() != null ? dto.getCreateTime() : ""); excelCell.setValue(dto.getCreateTime() != null ? dto.getCreateTime() : "");
cells.add(excelCell); cells.add(excelCell);
// 13. 更新时间 // 12. 更新时间
excelCell = new ExcelCell(); excelCell = new ExcelCell();
excelCell.setValue(dto.getUpdateTime() != null ? dto.getUpdateTime() : ""); excelCell.setValue(dto.getUpdateTime() != null ? dto.getUpdateTime() : "");
cells.add(excelCell); cells.add(excelCell);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment