diff --git a/adc-da-activiti/src/main/java/com/adc/da/workFlow/controller/WorkFlowController.java b/adc-da-activiti/src/main/java/com/adc/da/workFlow/controller/WorkFlowController.java index e3fc6633..6b07ccdf 100644 --- a/adc-da-activiti/src/main/java/com/adc/da/workFlow/controller/WorkFlowController.java +++ b/adc-da-activiti/src/main/java/com/adc/da/workFlow/controller/WorkFlowController.java @@ -1484,7 +1484,8 @@ public class WorkFlowController extends BaseController { String s = ""; if (StringUtils.isBlank(prcName) || StringUtils.isBlank(json) || StringUtils.isBlank(sort)) { return Result.error("参数为空"); - } else { + } + else { prcName = sort + "-" + prcName + "-计划立项"; } JSONObject jsonObject = JSON.parseObject(json); @@ -1515,26 +1516,31 @@ public class WorkFlowController extends BaseController { } } }else { - s = workFlowFeignClient.endPrcName(prcName, esId); - String[] split = s.split("-"); - List asList = Arrays.asList(split); - if(split[0].equals("成功")){ - if(asList.size()>1){ + if ("4".equals(jsonObject.getString("type")) || "3".equals(jsonObject.getString("type"))) { + s = workFlowFeignClient.endPrcName(prcName, esId); + if (StringUtils.isBlank(s)) { + return Result.error(); + } + String[] split = s.split("-"); + List asList = Arrays.asList(split); + if(split[0].equals("成功")){ + if(asList.size()>1){ + EndPrcName endPrcName = new EndPrcName(); + Map objectObjectMap = new HashMap<>(); + objectObjectMap.put("ids",split[1]); + objectObjectMap.put("prcCreateUser","xxx"); + String s1 = JSONObject.toJSONString(objectObjectMap); + endPrcName.setIds(s1); + endPrcName.setIsNot("1"); + return Result.success(endPrcName); + } EndPrcName endPrcName = new EndPrcName(); - Map objectObjectMap = new HashMap<>(); - objectObjectMap.put("ids",split[1]); - objectObjectMap.put("prcCreateUser","xxx"); - String s1 = JSONObject.toJSONString(objectObjectMap); - endPrcName.setIds(s1); - endPrcName.setIsNot("1"); + endPrcName.setIsNot("2"); + endPrcName.setIds("xxx"); return Result.success(endPrcName); + }else { + return Result.error(); } - EndPrcName endPrcName = new EndPrcName(); - endPrcName.setIsNot("2"); - endPrcName.setIds("xxx"); - return Result.success(endPrcName); - }else { - return Result.error(); } } return Result.success(); diff --git a/adc-da-activiti/src/main/java/com/adc/da/workFlow/service/ActSarLawsInformationEOService.java b/adc-da-activiti/src/main/java/com/adc/da/workFlow/service/ActSarLawsInformationEOService.java index 2d4860be..88fc5f50 100644 --- a/adc-da-activiti/src/main/java/com/adc/da/workFlow/service/ActSarLawsInformationEOService.java +++ b/adc-da-activiti/src/main/java/com/adc/da/workFlow/service/ActSarLawsInformationEOService.java @@ -39,8 +39,9 @@ public class ActSarLawsInformationEOService { }else { createAndApproveBy = applyUserId + "," + approverId; } - sarLawsInformation.setDownloadableBy(createAndApproveBy); - sarLawsInformation.setViewableBy(createAndApproveBy); +// sarLawsInformation.setDownloadableBy(createAndApproveBy); +// sarLawsInformation.setViewableBy(createAndApproveBy); + sarLawsInformation.setCreateAndApproveBy(createAndApproveBy); logger.info("政策法规资料入库:" + sarLawsInformation); informationService.addLawsInformation(sarLawsInformation); } diff --git a/adc-da-jwtLogin/src/main/java/com/adc/da/login/rest/LoginRestController.java b/adc-da-jwtLogin/src/main/java/com/adc/da/login/rest/LoginRestController.java index 0f93f85a..1c2900c1 100644 --- a/adc-da-jwtLogin/src/main/java/com/adc/da/login/rest/LoginRestController.java +++ b/adc-da-jwtLogin/src/main/java/com/adc/da/login/rest/LoginRestController.java @@ -142,10 +142,10 @@ public class LoginRestController { if(userEO.getDisableFlag()==1){ return Result.error("r0011", "帐号已禁用"); } - String position = userService.selectPositionByUserId(account); - if(StringUtils.isBlank(position)){ - return Result.error("r0011", "无配置岗位"); - } +// String position = userService.selectPositionByUserId(account); +// if(StringUtils.isBlank(position)){ +// return Result.error("r0011", "无配置岗位"); +// } String token = jwtUtils.generateToken(userEO.getUsid()); userEO.setToken(token); // 加密重要信息 @@ -212,10 +212,10 @@ public class LoginRestController { if(userEO.getDisableFlag()==1){ return Result.error("r0011", "帐号已禁用"); } - String position = userService.selectPositionByUserId(account); - if(StringUtils.isBlank(position)){ - return Result.error("r0011", "无配置岗位"); - } +// String position = userService.selectPositionByUserId(account); +// if(StringUtils.isBlank(position)){ +// return Result.error("r0011", "无配置岗位"); +// } String token = jwtUtils.generateToken(userEO.getUsid()); userEO.setToken(token); // 加密重要信息 diff --git a/adc-da-jwtLogin/src/main/java/com/adc/da/login/security/WebMvcConfig.java b/adc-da-jwtLogin/src/main/java/com/adc/da/login/security/WebMvcConfig.java index 82921098..43ebc05c 100644 --- a/adc-da-jwtLogin/src/main/java/com/adc/da/login/security/WebMvcConfig.java +++ b/adc-da-jwtLogin/src/main/java/com/adc/da/login/security/WebMvcConfig.java @@ -154,6 +154,7 @@ public class WebMvcConfig implements WebMvcConfigurer { addInterceptor.excludePathPatterns("/api/OtConvert/convertFileToFileId"); addInterceptor.excludePathPatterns("/api/att/attFile/downloadFileForSarNew"); + addInterceptor.excludePathPatterns("/api/att/attFile/downloadFileForSarNewOnlyOffice"); addInterceptor.excludePathPatterns("/api/att/attFile/downloadFileForSarWaterMarkNew"); addInterceptor.excludePathPatterns("/api/att/attFile/uploadNew"); addInterceptor.excludePathPatterns("/api/lawss/sarBussionessStand/importSarBussionessStandFile"); @@ -216,14 +217,23 @@ public class WebMvcConfig implements WebMvcConfigurer { // 内外部会议模板下载 addInterceptor.excludePathPatterns("/api/lawss/insideOutsideMeeting/exportTemplateFile"); + // 内外部会议导入 + addInterceptor.excludePathPatterns("/api/lawss/insideOutsideMeeting/importMeetingInfo"); // 政策课题模板下载 addInterceptor.excludePathPatterns("/api/lawss/sarLawsTopic/exportTemplateFile"); + // 政策课题导入 + addInterceptor.excludePathPatterns("/api/lawss/sarLawsTopic/importLawsTopicInfo"); // 政策资料模板下载 addInterceptor.excludePathPatterns("/api/lawss/sarLawsInformation/exportTemplateFile"); + // 政策法规资料导入 + addInterceptor.excludePathPatterns("/api/lawss/sarLawsInformation/importLawsInformationInfo"); -// // 添加自定义拦截器,并拦截对应 url + // 标准体系列表导出 + addInterceptor.excludePathPatterns("/api/lawss/sarMenuStandardLimit/standardSystemListExport"); + + // 添加自定义拦截器,并拦截对应 url addInterceptor.addPathPatterns("/**"); } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/scheduled/dao/SarStandardInfoDao.java b/adc-da-slrs/src/main/java/com/adc/da/scheduled/dao/SarStandardInfoDao.java index 5fcefabf..b25a4db6 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/scheduled/dao/SarStandardInfoDao.java +++ b/adc-da-slrs/src/main/java/com/adc/da/scheduled/dao/SarStandardInfoDao.java @@ -15,4 +15,5 @@ public interface SarStandardInfoDao{ public int updateStandardInfo(@Param("id")String id, @Param("textStatus") String textStatus); + int deleteStandSystem(@Param("menuName") String menuName); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/controller/InsideOutSideMeetingController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/controller/InsideOutSideMeetingController.java index b0b3895a..208b8f25 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/controller/InsideOutSideMeetingController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/controller/InsideOutSideMeetingController.java @@ -11,8 +11,7 @@ import com.adc.da.exception.AdcDaBaseException; import com.adc.da.http.PageInfo; import com.adc.da.http.ResponseMessage; import com.adc.da.http.Result; -import com.adc.da.slrs.InsideOntSideMeeting.entity.InsideOutsideMeeting; -import com.adc.da.slrs.InsideOntSideMeeting.entity.InsideOutsideMeetingVO; +import com.adc.da.slrs.InsideOntSideMeeting.entity.*; import com.adc.da.slrs.InsideOntSideMeeting.service.InsideOutsideMeetingService; import com.adc.da.util.UUIDUtils; import com.adc.da.utils.util.FieldConvertUtil; @@ -27,6 +26,7 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.util.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.text.ParseException; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -122,11 +123,26 @@ public class InsideOutSideMeetingController extends BaseController dataExportList = new ArrayList<>(); + for (InsideOutsideMeetingVO data : datas) { + InsideOutsideMeetingExport dataExport = new InsideOutsideMeetingExport(); + BeanUtils.copyProperties(data, dataExport); + if (data.getMeetingTopicList()!= null) { + List topicExportList = new ArrayList<>(); + for (MeetingTopic meetingTopic : data.getMeetingTopicList()) { + MeetingTopicExport topicExport = new MeetingTopicExport(); + BeanUtils.copyProperties(meetingTopic, topicExport); + topicExportList.add(topicExport); + } + dataExport.setMeetingTopicList(topicExportList); + } + dataExportList.add(dataExport); + } ExportParams exportParams = new ExportParams(); exportParams.setType(ExcelType.XSSF); exportParams.setSheetName(insideOutsideMeetingVO.getExportName()); // workbook = InsideOutsideMeetingExportUtil.exportDatas(datas); - workbook = ExcelExportUtil.exportExcel(exportParams, InsideOutsideMeetingVO.class, datas); + workbook = ExcelExportUtil.exportExcel(exportParams, InsideOutsideMeetingExport.class, dataExportList); os = response.getOutputStream(); workbook.write(os); os.flush(); @@ -169,11 +185,11 @@ public class InsideOutSideMeetingController extends BaseController { - List queryByPageCount(InsideOutsideMeetingVO page); + Integer queryByPageCount(InsideOutsideMeetingVO page); List queryByPage(InsideOutsideMeetingVO page); diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/InsideOutsideMeeting.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/InsideOutsideMeeting.java index a45c1f00..13583910 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/InsideOutsideMeeting.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/InsideOutsideMeeting.java @@ -2,6 +2,7 @@ package com.adc.da.slrs.InsideOntSideMeeting.entity; import com.adc.da.att.entity.AttFileEO; import com.adc.da.base.entity.BaseEntity; +import com.adc.da.utils.annotation.CompareField; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -35,6 +36,7 @@ public class InsideOutsideMeeting extends BaseEntity { @TableId(value = "ID", type = IdType.ID_WORKER_STR) private String id; + @CompareField(fieldName = "会议名称") @ApiModelProperty(value = "会议名称") @TableField("MEETING_NAME") private String meetingName; @@ -42,27 +44,33 @@ public class InsideOutsideMeeting extends BaseEntity { /** * 课题名称,可通过调取功能从政策课题模块中获取 */ + @CompareField(fieldName = "课题名称") @ApiModelProperty(value = "课题名称") @TableField("TOPIC_NAME") private String topicName; + @CompareField(fieldName = "会议主办单位") @ApiModelProperty(value = "会议主办单位") @TableField("MEETING_ORGANIZER") private String meetingOrganizer; + @CompareField(fieldName = "会议时间") @ApiModelProperty(value = "会议时间") @TableField("MEETING_TIME") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") private Date meetingTime; + @CompareField(fieldName = "会议地点") @ApiModelProperty(value = "会议地点") @TableField("MEETING_ADDRESS") private String meetingAddress; + @CompareField(fieldName = "参会人员") @ApiModelProperty(value = "参会人员") @TableField("PARTICIPANTS") private String participants; + @CompareField(fieldName = "会议纪要") @ApiModelProperty(value = "会议纪要") @TableField("MEETING_MINUTES") private String meetingMinutes; @@ -71,26 +79,30 @@ public class InsideOutsideMeeting extends BaseEntity { @TableField(exist = false) private List meetingMinutesList; + @CompareField(fieldName = "会议主要内容") @ApiModelProperty(value = "会议主要内容") @TableField("MEETING_CONTENT") private String meetingContent; - @ApiModelProperty(value = "1级会议类别") + @CompareField(fieldName = "1级会议分类") + @ApiModelProperty(value = "1级会议分类") @TableField("FIRST_MEETING_TYPE") private String firstMeetingType; - @ApiModelProperty(value = "1级会议类别名称") + @ApiModelProperty(value = "1级会议分类名称") @TableField(exist = false) private String firstMeetingTypeName; - @ApiModelProperty(value = "2级会议类别") + @CompareField(fieldName = "2级会议分类") + @ApiModelProperty(value = "2级会议分类") @TableField("SECOND_MEETING_TYPE") private String secondMeetingType; - @ApiModelProperty(value = "2级会议类别名称") + @ApiModelProperty(value = "2级会议分类名称") @TableField(exist = false) private String secondMeetingTypeName; + @CompareField(fieldName = "会议议题") @ApiModelProperty(value = "会议议题") @TableField(exist = false) private List meetingTopicList; diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/InsideOutsideMeetingExport.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/InsideOutsideMeetingExport.java new file mode 100644 index 00000000..5cd3a682 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/InsideOutsideMeetingExport.java @@ -0,0 +1,51 @@ +package com.adc.da.slrs.InsideOntSideMeeting.entity; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.afterturn.easypoi.excel.annotation.ExcelCollection; +import com.adc.da.att.entity.AttFileEO; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author tjzdw + * @description + * @date 2023/11/23 + */ +@Data +public class InsideOutsideMeetingExport { + + private String id; + + @Excel(name = "会议名称", needMerge = true) + private String meetingName; + + @Excel(name = "课题名称", needMerge = true) + private String topicName; + + @Excel(name = "会议主办单位", needMerge = true) + private String meetingOrganizer; + + @Excel(name = "会议时间", exportFormat = "yyyy-MM-dd", needMerge = true) + private Date meetingTime; + + @Excel(name = "会议地点", needMerge = true) + private String meetingAddress; + + @Excel(name = "参会人员", needMerge = true) + private String participants; + + @Excel(name = "会议主要内容", needMerge = true) + private String meetingContent; + + @Excel(name = "1级会议分类", needMerge = true) + private String firstMeetingTypeName; + + @Excel(name = "2级会议分类", needMerge = true) + private String secondMeetingTypeName; + + @ExcelCollection(name = "会议议题") + private List meetingTopicList; +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/InsideOutsideMeetingVO.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/InsideOutsideMeetingVO.java index 4967e9aa..734d7dbe 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/InsideOutsideMeetingVO.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/InsideOutsideMeetingVO.java @@ -24,41 +24,42 @@ public class InsideOutsideMeetingVO extends BasePage { private String id; - @Excel(name = "会议名称", needMerge = true) + @Excel(name = "*会议名称", needMerge = true) private String meetingName; @Excel(name = "课题名称", needMerge = true) private String topicName; - @Excel(name = "会议主办单位", needMerge = true) + @Excel(name = "*会议主办单位", needMerge = true) private String meetingOrganizer; @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") - @Excel(name = "会议时间", exportFormat = "yyyy-MM-dd", needMerge = true) + @Excel(name = "*会议时间", exportFormat = "yyyy-MM-dd", needMerge = true) private Date meetingTime; - @Excel(name = "会议地点", needMerge = true) + @Excel(name = "*会议地点", needMerge = true) private String meetingAddress; - @Excel(name = "参会人员", needMerge = true) + private String agendaNameStr; + + @Excel(name = "*参会人员", needMerge = true) private String participants; - private List participantsList; private String meetingMinutes; private List meetingMinutesList; - @Excel(name = "会议主要内容", needMerge = true) + @Excel(name = "*会议主要内容", needMerge = true) private String meetingContent; private String firstMeetingType; - @Excel(name = "1级会议类别", needMerge = true) + @Excel(name = "*1级会议分类", needMerge = true) private String firstMeetingTypeName; private String secondMeetingType; - @Excel(name = "2级会议类别", needMerge = true) + @Excel(name = "*2级会议分类", needMerge = true) private String secondMeetingTypeName; @ExcelCollection(name = "会议议题") @@ -82,13 +83,13 @@ public class InsideOutsideMeetingVO extends BasePage { @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") private Date modifyTime; - private String sortField = "ID"; + private String sortField = "meetingTime"; - private String sortMode = "asc"; + private String sortMode = "desc"; // 会议时间查询字段 - private Date meetingTimeBegin; - private Date meetingTimeEnd; + private String meetingTimeBegin; + private String meetingTimeEnd; // 导出使用字段 // 被前端选中的记录的ids diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/MeetingTopic.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/MeetingTopic.java index dd9435f5..4b13c46a 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/MeetingTopic.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/MeetingTopic.java @@ -1,6 +1,7 @@ package com.adc.da.slrs.InsideOntSideMeeting.entity; import cn.afterturn.easypoi.excel.annotation.Excel; +import com.adc.da.att.entity.AttFileEO; import com.adc.da.base.entity.BaseEntity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; @@ -11,6 +12,10 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import org.apache.commons.lang3.StringUtils; + +import java.util.Date; +import java.util.List; /** * @author tjzdw @@ -34,25 +39,46 @@ public class MeetingTopic extends BaseEntity { @ApiModelProperty(value = "议题名称") @TableField("AGENDA_NAME") - @Excel(name = "议题名称") + @Excel(name = "*议题名称") private String agendaName; @ApiModelProperty(value = "议题材料") @TableField("AGENDA_MATERIALS") private String agendaMaterials; + @TableField(exist = false) + private List agendaMaterialsList; @ApiModelProperty(value = "汇报人") @TableField("REPORTER") - @Excel(name = "汇报人") + @Excel(name = "*汇报人") private String reporter; @ApiModelProperty(value = "汇报单位") @TableField("REPORTING_UNIT") - @Excel(name = "汇报单位") + @Excel(name = "*汇报单位") private String reportingUnit; @ApiModelProperty(value = "议题主要内容") @TableField("AGENDA_CONTENT") - @Excel(name = "议题主要内容") + @Excel(name = "*议题主要内容") private String agendaContent; + + @ApiModelProperty(value = "创建时间") + @TableField("CREATE_TIME") + private Date createTime; + + @ApiModelProperty(value = "修改时间") + @TableField("MODIFY_TIME") + private Date modifyTime; + + public static MeetingTopic emptyValueProcess(MeetingTopic meetingTopic) { + if (StringUtils.isBlank(meetingTopic.getAgendaName()) && + StringUtils.isBlank(meetingTopic.getAgendaMaterials()) && + StringUtils.isBlank(meetingTopic.getReporter()) && + StringUtils.isBlank(meetingTopic.getReportingUnit()) && + StringUtils.isBlank(meetingTopic.getAgendaContent())) { + return null; + } + return meetingTopic; + } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/MeetingTopicExport.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/MeetingTopicExport.java new file mode 100644 index 00000000..7b1443bc --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/entity/MeetingTopicExport.java @@ -0,0 +1,34 @@ +package com.adc.da.slrs.InsideOntSideMeeting.entity; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.adc.da.att.entity.AttFileEO; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author tjzdw + * @description + * @date 2023/11/23 + */ +@Data +public class MeetingTopicExport { + private String id; + + @Excel(name = "议题名称") + private String agendaName; + + @Excel(name = "汇报人") + private String reporter; + + @Excel(name = "汇报单位") + private String reportingUnit; + + @Excel(name = "议题主要内容") + private String agendaContent; +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/service/impl/InsideOutsideMeetingServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/service/impl/InsideOutsideMeetingServiceImpl.java index 250c16d0..1698ac45 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/service/impl/InsideOutsideMeetingServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/service/impl/InsideOutsideMeetingServiceImpl.java @@ -2,6 +2,7 @@ package com.adc.da.slrs.InsideOntSideMeeting.service.impl; import com.adc.da.att.entity.AttFileEO; import com.adc.da.att.service.IAttFileEOService; +import com.adc.da.att.vo.AttFileVo; import com.adc.da.common.FileUnZip; import com.adc.da.http.ResponseMessage; import com.adc.da.http.Result; @@ -11,18 +12,19 @@ import com.adc.da.slrs.InsideOntSideMeeting.entity.InsideOutsideMeetingVO; import com.adc.da.slrs.InsideOntSideMeeting.entity.MeetingTopic; import com.adc.da.slrs.InsideOntSideMeeting.service.InsideOutsideMeetingService; import com.adc.da.slrs.InsideOntSideMeeting.service.MeetingTopicService; -import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation; import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog; import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService; import com.adc.da.slrs.tsDictionaryType.entity.TsDicType; import com.adc.da.slrs.tsDictionaryType.service.ITsDicTypeService; import com.adc.da.util.LoginUserUtil; import com.adc.da.util.UUIDUtils; +import com.adc.da.utils.annotation.CompareField; import com.adc.da.utils.util.FieldConvertUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import io.swagger.annotations.ApiModelProperty; +import lombok.Cleanup; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.hssf.usermodel.HSSFDateUtil; @@ -34,7 +36,9 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -72,7 +76,9 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl meetingMinutesList = new ArrayList<>(); for (String attId : insideOutsideMeeting.getMeetingMinutes().split(",")) { AttFileEO fileInfo = attFileEOService.getFileInfo(attId); - meetingMinutesList.add(fileInfo); + if (fileInfo != null) { + meetingMinutesList.add(fileInfo); + } } insideOutsideMeeting.setMeetingMinutesList(meetingMinutesList); } @@ -81,7 +87,18 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(MeetingTopic::getMeetingId, meetingId); + wrapper.orderByAsc(MeetingTopic::getCreateTime); List meetingTopicList = meetingTopicService.list(wrapper); + for (MeetingTopic meetingTopic : meetingTopicList) { + if (StringUtils.isNotBlank(meetingTopic.getAgendaMaterials())) { + List agendaMaterialsList = new ArrayList<>(); + for (String attId : meetingTopic.getAgendaMaterials().split(",")) { + AttFileEO fileInfo = attFileEOService.getFileInfo(attId); + agendaMaterialsList.add(fileInfo); + } + meetingTopic.setAgendaMaterialsList(agendaMaterialsList); + } + } insideOutsideMeeting.setMeetingTopicList(meetingTopicList); } return insideOutsideMeeting; @@ -108,7 +125,7 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl diffList = compareInsideOutsideMeeting(insideOutsideMeetingDB, insideOutsideMeeting); if (diffList.size() > 0) { insideOutsideMeeting.setModifyTime(new Date()); @@ -175,19 +192,16 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl queryByPage(InsideOutsideMeetingVO page){ - if (StringUtils.isNotBlank(page.getParticipants())) { - page.setParticipantsList(Arrays.asList(page.getParticipants().split(","))); - } // 设置排序字段 if (StringUtils.isNotBlank(page.getSortField())) { // 小驼峰变成 ABC_DEF String sortField = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(page.getSortField()),"_").toUpperCase(); page.setSortField(sortField); } else { - page.setSortField("ID"); - page.setSortMode("asc"); + page.setSortField("MEETING_TIME"); + page.setSortMode("desc"); } - int rowCount = this.baseMapper.queryByPageCount(page).size(); + int rowCount = this.baseMapper.queryByPageCount(page); page.getPager().setRowCount(rowCount); List insideOutsideMeetingVOList = this.baseMapper.queryByPage(page); for (InsideOutsideMeetingVO insideOutsideMeeting : insideOutsideMeetingVOList) { @@ -233,6 +247,7 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl fileList = readImpExcelFile(zipEntryName); //判断获取到的文件数量 - if (fileList.size() != 1) { - return Result.error("上传的文件只能有一个"); + if (fileList.size() < 1) { + return Result.error("上传的文件不能为空"); } - File importFile = fileList.get(0); - if (!importFile.getName().contains(".xls") && !importFile.getName().contains(".xlsx")) { - return Result.error("文件必须是EXCEL文件"); + File excelFile = null; + int excelCount = 0; + // 将文件转换为Map,文件名为建,文件为值 + Map fileMap = new HashMap<>(); + for (File file1 : fileList) { + fileMap.put(file1.getName(), file1); + if (file1.getName().toLowerCase().contains(".xls") || file1.getName().toLowerCase().contains(".xlsx")) { + excelFile = file1; + excelCount ++; + } + } + if (excelCount > 1) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("导入了多个Excel文件"); + } + if (excelCount < 1){ + FileUnZip.deleteDir(saveDirectory); + return Result.error("文件必须包含一个EXCEL文件"); } Workbook workbook = null; + InputStream inputStream = null; try { - workbook = WorkbookFactory.create(importFile); + inputStream = new FileInputStream(excelFile); + workbook = WorkbookFactory.create(inputStream); } catch (IOException e) { FileUnZip.deleteDir(saveDirectory); - return Result.error("导入失败,需要导入的数据有问题或导入的企标标号和企标名称已存在"); + return Result.error("导入失败,需要导入的数据有问题"); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Sheet sheet = workbook.getSheetAt(0); if (sheet == null) { + FileUnZip.deleteDir(saveDirectory); return Result.error("工作表为空"); } StringBuilder sb = new StringBuilder(); List headerList = new ArrayList<>(); // 获取excel表头 Row headerRow = sheet.getRow(1); - for (int i = 0; i <= 12; i++) { - headerList.add(headerRow.getCell(i).getStringCellValue()); + try { + for (int i = 0; i <= 14; i++) { + headerList.add(headerRow.getCell(i).getStringCellValue()); + } + } catch (Exception e) { + return Result.error("表头读取失败,请严格按照模板文件导入数据"); + } finally { + FileUnZip.deleteDir(saveDirectory); } - // 判断表头字段是否相同 if (!String.join(",",headerList).equals(FieldConvertUtil.exportFieldNamesInsideOutsideMeeting + "," + FieldConvertUtil.exportFieldNamesMeetingTopic)) { try { workbook.close(); } catch (IOException e) { + FileUnZip.deleteDir(saveDirectory); return Result.error("文件关闭出错"); } //删除原上传文件 @@ -294,7 +334,7 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl rowMap = new LinkedHashMap<>(); // 总列数 - int columnNum = 13; + int columnNum = 15; // 遍历每个单元格 for (int columnIndex = 0; columnIndex < columnNum; columnIndex++) { // 获取单元格 @@ -305,14 +345,16 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl 500) { - return Result.error("单元格输入过长"); + FileUnZip.deleteDir(saveDirectory); + return Result.error("第"+(rowIndex-1)+"行第"+(columnIndex + 1)+"个单元格输入过长"); } rowMap.put(headerCell.getStringCellValue(), cell.getStringCellValue()); } @@ -322,6 +364,21 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl firstMeetingTypeList = dicTypeService.selectAllDicTypeNameByDicCode("firstMeetingType"); @@ -333,70 +390,150 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl meetingTopicList = new ArrayList<>(); - for (Map dataMap : importDataList) { - String meetingName = dataMap.get("会议名称"); - // 如果会议名称为空,则表示该行为会议课题行,是之前会议的会议课题,不提交之前的会议信息。不为空则进入 - if (StringUtils.isNotBlank(meetingName)) { - // 如果计数器大于0,表示进入了新的会议信息中,提交之前的会议信息 - if (count > 0) { - insideOutsideMeeting.setMeetingTopicList(meetingTopicList); - addMeetingInfo(insideOutsideMeeting); - // 初始化会议课题列表 - meetingTopicList.clear(); - // 初始化会议对象 - insideOutsideMeeting = new InsideOutsideMeeting(); - // 计数器归零 - count = 0; - } - insideOutsideMeeting.setMeetingName(meetingName); - insideOutsideMeeting.setTopicName(dataMap.get("课题名称")); - insideOutsideMeeting.setMeetingOrganizer(dataMap.get("会议主办单位")); - insideOutsideMeeting.setMeetingTime(sdf.parse(dataMap.get("会议时间"))); - insideOutsideMeeting.setMeetingAddress(dataMap.get("会议地点")); - insideOutsideMeeting.setParticipants(dataMap.get("参会人员")); - insideOutsideMeeting.setMeetingContent(dataMap.get("会议主要内容")); - if (StringUtils.isNotBlank(dataMap.get("一级会议类别"))) { - if (!firstMeetingTypeNameSet.contains(dataMap.get("一级会议类别"))){ - return Result.error("一级会议类别不符合输入要求"); + try { + for (Map dataMap : importDataList) { + String meetingName = dataMap.get("*会议名称"); + // 如果会议名称为空,则表示该行为会议课题行,是之前会议的会议课题,不提交之前的会议信息。不为空则进入 + if (StringUtils.isNotBlank(meetingName)) { + // 如果计数器大于0,表示进入了新的会议信息中,提交之前的会议信息 + if (count > 0) { + insideOutsideMeeting.setMeetingTopicList(meetingTopicList); + addMeetingInfo(insideOutsideMeeting); + // 初始化会议课题列表 + meetingTopicList.clear(); + // 初始化会议对象 + insideOutsideMeeting = new InsideOutsideMeeting(); + // 计数器归零 + count = 0; } - for (TsDicType tsDicType : firstMeetingTypeList) { - if (dataMap.get("一级会议类别").equals(tsDicType.getDicTypeName())) { - insideOutsideMeeting.setFirstMeetingType(tsDicType.getDicTypeCode()); + insideOutsideMeeting.setMeetingName(meetingName); + insideOutsideMeeting.setTopicName(dataMap.get("课题名称")); + if (StringUtils.isNotBlank(dataMap.get("*会议主办单位"))) { + insideOutsideMeeting.setMeetingOrganizer(dataMap.get("*会议主办单位")); + } else { + return Result.error("第"+ (count+1) +"行会议主办单位不能为空"); + } + if (StringUtils.isNotBlank(dataMap.get("*会议时间"))) { + Date meetingTime = null; + try { + meetingTime = sdf.parse(dataMap.get("*会议时间")); + insideOutsideMeeting.setMeetingTime(meetingTime); + } catch (ParseException e) { + return Result.error("第"+ (count+1) +"行会议时间格式必须为年-月-日"); } + } else { + return Result.error("第"+ (count+1) +"行会议时间不能为空"); } - } - if (StringUtils.isNotBlank(dataMap.get("二级会议类别"))) { - if (!secondMeetingTypeNameSet.contains(dataMap.get("二级会议类别"))){ - return Result.error("二级会议类别不符合输入要求"); + if (StringUtils.isNotBlank(dataMap.get("*会议地点"))) { + insideOutsideMeeting.setMeetingAddress(dataMap.get("*会议地点")); + } else { + return Result.error("第"+ (count+1) +"行会议地点不能为空"); } - for (TsDicType tsDicType : secondMeetingTypeList) { - if (dataMap.get("二级会议类别").equals(tsDicType.getDicTypeName())) { - insideOutsideMeeting.setSecondMeetingType(tsDicType.getDicTypeCode()); + if (StringUtils.isNotBlank(dataMap.get("*参会人员"))) { + insideOutsideMeeting.setParticipants(dataMap.get("*参会人员")); + } else { + return Result.error("第"+ (count+1) +"行参会人员不能为空"); + } + String meetingMinutesFileNameStr = dataMap.get("会议纪要"); + String meetingMinutesFileAtt = null; + try { + meetingMinutesFileAtt = getFileAtt("会议纪要",meetingMinutesFileNameStr, fileMap, count); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + if (StringUtils.isNotBlank(meetingMinutesFileAtt)) { + insideOutsideMeeting.setMeetingMinutes(meetingMinutesFileAtt); + } + if (StringUtils.isNotBlank(dataMap.get("*会议主要内容"))) { + insideOutsideMeeting.setMeetingContent(dataMap.get("*会议主要内容")); + }else { + return Result.error("第"+ (count+1) +"行会议主要内容不能为空"); + } + if (StringUtils.isNotBlank(dataMap.get("*一级会议分类"))) { + if (!firstMeetingTypeNameSet.contains(dataMap.get("*一级会议分类"))){ + return Result.error("一级会议分类不符合输入要求"); } + for (TsDicType tsDicType : firstMeetingTypeList) { + if (dataMap.get("*一级会议分类").equals(tsDicType.getDicTypeName())) { + insideOutsideMeeting.setFirstMeetingType(tsDicType.getDicTypeCode()); + } + } + }else { + return Result.error("第"+ (count+1) +"行一级会议分类不能为空"); } + if (StringUtils.isNotBlank(dataMap.get("*二级会议分类"))) { + if (!secondMeetingTypeNameSet.contains(dataMap.get("*二级会议分类"))){ + return Result.error("二级会议分类不符合输入要求"); + } + for (TsDicType tsDicType : secondMeetingTypeList) { + if (dataMap.get("*二级会议分类").equals(tsDicType.getDicTypeName())) { + insideOutsideMeeting.setSecondMeetingType(tsDicType.getDicTypeCode()); + } + } + }else { + return Result.error("第"+ (count+1) +"行二级会议分类不能为空"); + } + // 会议课题信息 + MeetingTopic meetingTopic = new MeetingTopic(); + if (StringUtils.isNotBlank(dataMap.get("*议题名称"))) { + meetingTopic.setAgendaName(dataMap.get("*议题名称")); + } else { + return Result.error("第"+ (count+1) +"行议题名称不能为空"); + } + String agendaMaterialsFileNameStr = dataMap.get("议题材料"); + String agendaMaterialsFileNameAtt = null; + try { + agendaMaterialsFileNameAtt = getFileAtt("议题材料",agendaMaterialsFileNameStr, fileMap, count); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + if (StringUtils.isNotBlank(agendaMaterialsFileNameAtt)) { + meetingTopic.setAgendaMaterials(agendaMaterialsFileNameAtt); + } + if (StringUtils.isNotBlank(dataMap.get("*汇报人"))) { + meetingTopic.setReporter(dataMap.get("*汇报人")); + } else { + return Result.error("第"+ (count+1) +"行汇报人不能为空"); + } + if (StringUtils.isNotBlank(dataMap.get("*汇报单位"))) { + meetingTopic.setReportingUnit(dataMap.get("*汇报单位")); + } else { + return Result.error("第"+ (count+1) +"行汇报单位不能为空"); + } + if (StringUtils.isNotBlank(dataMap.get("*议题主要内容"))) { + meetingTopic.setAgendaContent(dataMap.get("*议题主要内容")); + } else { + return Result.error("第"+ (count+1) +"行议题主要内容不能为空"); + } + meetingTopicList.add(meetingTopic); + count++; + } else { + // 进入else 表示该行是会议课题行 + MeetingTopic meetingTopic = new MeetingTopic(); + meetingTopic.setAgendaName(dataMap.get("议题名称")); + String agendaMaterialsFileNameStr = dataMap.get("议题材料"); + String agendaMaterialsFileNameAtt = null; + try { + agendaMaterialsFileNameAtt = getFileAtt("议题材料",agendaMaterialsFileNameStr, fileMap, count); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + if (StringUtils.isNotBlank(agendaMaterialsFileNameAtt)) { + meetingTopic.setAgendaMaterials(agendaMaterialsFileNameAtt); + } + meetingTopic.setReporter(dataMap.get("*汇报人")); + meetingTopic.setReportingUnit(dataMap.get("*汇报单位")); + meetingTopic.setAgendaContent(dataMap.get("*议题主要内容")); + meetingTopicList.add(meetingTopic); + count++; } - // 会议课题信息 - MeetingTopic meetingTopic = new MeetingTopic(); - meetingTopic.setAgendaName(dataMap.get("议题名称")); - meetingTopic.setReporter(dataMap.get("汇报人")); - meetingTopic.setReportingUnit(dataMap.get("汇报单位")); - meetingTopic.setAgendaContent(dataMap.get("议题主要内容")); - meetingTopicList.add(meetingTopic); - count++; - } else { - // 进入else 表示该行是会议课题行 - MeetingTopic meetingTopic = new MeetingTopic(); - meetingTopic.setAgendaName(dataMap.get("议题名称")); - meetingTopic.setReporter(dataMap.get("汇报人")); - meetingTopic.setReportingUnit(dataMap.get("汇报单位")); - meetingTopic.setAgendaContent(dataMap.get("议题主要内容")); - meetingTopicList.add(meetingTopic); - count++; } + // 插入最后一条记录 + insideOutsideMeeting.setMeetingTopicList(meetingTopicList); + addMeetingInfo(insideOutsideMeeting); + } finally { + FileUnZip.deleteDir(saveDirectory); } - // 插入最后一条记录 - insideOutsideMeeting.setMeetingTopicList(meetingTopicList); - addMeetingInfo(insideOutsideMeeting); return Result.success("导入完成"); } @@ -425,34 +562,43 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl compareInsideOutsideMeeting(InsideOutsideMeeting oldMeeting, InsideOutsideMeeting newMeeting) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); List changes = new ArrayList<>(); - // 不需要比较的字段 - String[] ignoreFields = {"id","validFlag","createTime","modifyTime", "firstMeetingTypeName", "secondMeetingTypeName"}; - List ignoreFieldList = Arrays.asList(ignoreFields); // 获取SarLawsInformation类的所有字段 Field[] fields = InsideOutsideMeeting.class.getDeclaredFields(); for (Field field : fields) { - if (!ignoreFieldList.contains(field.getName())) { + boolean annotationPresent = field.isAnnotationPresent(CompareField.class); + if (annotationPresent) { try { field.setAccessible(true); - String oldValue = String.valueOf(field.get(oldMeeting)); - String newValue = String.valueOf(field.get(newMeeting)); + Object oldValue = field.get(oldMeeting); + Object newValue = field.get(newMeeting); + if (oldValue instanceof Date){ + oldValue = sdf.format((Date)oldValue); + } + if( newValue instanceof Date) { + newValue = sdf.format((Date)newValue); + } if (!Objects.equals(oldValue, newValue)) { if ("firstMeetingType".equals(field.getName()) || "secondMeetingType".equals(field.getName())) { + String oldValueStr = String.valueOf(oldValue); + String newValueStr = String.valueOf(newValue); String typeName = ""; - if (StringUtils.isNotBlank(newValue)) { - typeName = dicTypeService.getDicTypeNameByDicCode(newValue); + if (StringUtils.isNotBlank(newValueStr)) { + typeName = dicTypeService.getDicTypeNameByDicCode(newValueStr); } // 获取资料类型名称 String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1); Method method = InsideOutsideMeeting.class.getMethod("get" + fieldName + "Name"); Object oldTypeName = method.invoke(oldMeeting); - ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0]; - changes.add(annotationsByType.value() + "由\"" + oldTypeName + "\"改为\"" + typeName + "\""); + CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0]; + changes.add(annotationsByType.fieldName() + "由\"" + Optional.ofNullable(oldTypeName).orElse("空") + "\"改为\"" + Optional.ofNullable(typeName).orElse("空") + "\""); } else if ("meetingMinutes".equals(field.getName())) { + String oldValueStr = String.valueOf(oldValue); + String newValueStr = String.valueOf(newValue); List fileNameList = new ArrayList<>(); - if (StringUtils.isNotBlank(newValue)) { - String[] split = newValue.split(","); + if (StringUtils.isNotBlank(newValueStr)) { + String[] split = newValueStr.split(","); for (String attId : split) { AttFileEO fileInfo = attFileEOService.getFileInfo(attId); fileNameList.add(fileInfo.getOldFileName()); @@ -469,17 +615,33 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl oldList = (List) oldInvoke; + List newList = (List) newInvoke; + if (!isListEqual(oldList, newList)) { + CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0]; + changes.add(annotationsByType.fieldName() + "被变更"); + } + } else { + CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0]; + changes.add(annotationsByType.fieldName() + "由\"" + Optional.ofNullable(oldValue).orElse("空") + "\"改为\"" + Optional.ofNullable(newValue).orElse("空") + "\""); } } } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { @@ -509,4 +671,64 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl fileMap, int count) throws Exception { + if (fileNameStr != null) { + List fileAttList = new ArrayList<>(); + for (String meetingMinutesFileName : fileNameStr.split(",")) { + int lastIndexOf = meetingMinutesFileName.lastIndexOf("."); + if (meetingMinutesFileName.lastIndexOf(".") != -1) { + String lastName = meetingMinutesFileName.substring(lastIndexOf + 1).toLowerCase(); + if (lastName.equals("pdf") || lastName.equals("ppt") || lastName.equals("pptx") || lastName.equals("doc") || lastName.equals("docx")) { + File file1 = fileMap.get(meetingMinutesFileName); + if (file1 == null) { + throw new Exception(fieldName + "中第" + (count+1) +"行" + meetingMinutesFileName + "文件不存在,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + AttFileVo attFileVo = attFileEOService.saveFileInfo(file1); + if (StringUtils.isNotBlank(attFileVo.getId())) { + fileAttList.add(attFileVo.getAttId()); + } + } else { + throw new Exception(fieldName + "中第" + (count+1) +"行" + meetingMinutesFileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + } else { + throw new Exception(fieldName + "中第" + (count+1) +"行" + meetingMinutesFileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + } + return String.join(",", fileAttList); + } + return null; + } + + public boolean isListEqual(List l0, List l1){ + if (l0 == l1) + return true; + if (l0 == null && l1 == null) + return true; + if (l0 == null || l1 == null) + return false; + if (l1.size() > 0) { + Iterator iterator = l1.iterator(); + while(iterator.hasNext()) { + Object iterato = iterator.next(); + MeetingTopic meetingTopic = (MeetingTopic) iterato; + MeetingTopic meetingTopic1 = MeetingTopic.emptyValueProcess(meetingTopic); + if (meetingTopic1 == null) { + iterator.remove(); + } + } + } + if (l0.size() != l1.size()) + return false; + for (Object o : l0) { + if (!l1.contains(o)) + return false; + } + for (Object o : l1) { + if (!l0.contains(o)) + return false; + } + return true; + } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/fileMaterialCenter/service/impl/FileMaterialServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/fileMaterialCenter/service/impl/FileMaterialServiceImpl.java index 49f72ee1..dc23da79 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/fileMaterialCenter/service/impl/FileMaterialServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/fileMaterialCenter/service/impl/FileMaterialServiceImpl.java @@ -5,12 +5,12 @@ import com.adc.da.slrs.fileMaterialCenter.entity.FileMaterial; import com.adc.da.slrs.fileMaterialCenter.dao.FileMaterialDao; import com.adc.da.slrs.fileMaterialCenter.entity.FileMaterialPage; import com.adc.da.slrs.fileMaterialCenter.service.IFileMaterialService; -import com.adc.da.slrs.sarPosition.service.ITsPositionService; import com.adc.da.slrs.sarUser.dao.TsUserDao; import com.adc.da.slrs.sarUser.service.ITsUserService; import com.adc.da.slrs.tsRoleMeunData.entity.TsRoleMenuData; import com.adc.da.slrs.tsRoleMeunData.service.ITsRoleMenuDataService; import com.adc.da.slrs.zlTree.service.IZlTreeService; +import com.adc.da.sys.service.IUserRoleEOService; import com.adc.da.util.LoginUserUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -22,6 +22,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import javax.management.Query; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -44,12 +45,11 @@ public class FileMaterialServiceImpl extends ServiceImpl getFileMaterial(FileMaterialPage queryPage) { @@ -63,8 +63,9 @@ public class FileMaterialServiceImpl extends ServiceImpl positionIds = tsUserDao.selectPositionIds(loginUserId); - List roleIds = tsPositionService.getRoleIdsByPositionIds(positionIds); +// List positionIds = tsUserDao.selectPositionIds(loginUserId); +// List roleIds = tsPositionService.getRoleIdsByPositionIds(positionIds); + List roleIds = userRoleEOService.getRoleIdsByUserId(loginUserId); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.in("ROLE_ID", roleIds); List tsRoleMenuData = iTsRoleMenuDataService.list(wrapper); @@ -105,8 +106,9 @@ public class FileMaterialServiceImpl extends ServiceImpl positionIds = tsUserDao.selectPositionIds(userId); - List roleIds = tsPositionService.getRoleIdsByPositionIds(positionIds); +// List positionIds = tsUserDao.selectPositionIds(userId); +// List roleIds = tsPositionService.getRoleIdsByPositionIds(positionIds); + List roleIds = userRoleEOService.getRoleIdsByUserId(userId); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.in("ROLE_ID", roleIds); List tsRoleMenuData = iTsRoleMenuDataService.list(wrapper); diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/controller/RoleReplacePositionController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/controller/RoleReplacePositionController.java new file mode 100644 index 00000000..2373ba2e --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/controller/RoleReplacePositionController.java @@ -0,0 +1,34 @@ +package com.adc.da.slrs.roleReplacePosition.controller; + +import com.adc.da.slrs.roleReplacePosition.service.UserPositionService; +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @author: Mzaxd + * @Date: 2023/11/14 13:46 + */ + +@RestController +@Api(tags = "福田标准法规--角色替换岗位") +@RequestMapping("/api/roleReplacePosition") +public class RoleReplacePositionController { + + @Resource + private UserPositionService userPositionService; + + /** + * 角色替换岗位 + * + * @return + */ + @GetMapping("/start") + public void roleReplacePosition() { + userPositionService.roleReplacePosition(); + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/dao/PositionRoleMapper.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/dao/PositionRoleMapper.java new file mode 100644 index 00000000..c7b0d80a --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/dao/PositionRoleMapper.java @@ -0,0 +1,20 @@ +package com.adc.da.slrs.roleReplacePosition.dao; + +import com.adc.da.slrs.roleReplacePosition.domain.PositionRole; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +/** +* @author ThinkBook +* @description 针对表【ts_position_role】的数据库操作Mapper +* @createDate 2023-11-14 13:53:47 +* @Entity com.adc.da.slrs.roleReplacePosition.domain.PositionRole +*/ +@Repository +public interface PositionRoleMapper extends BaseMapper { + +} + + + + diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/dao/UserPositionMapper.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/dao/UserPositionMapper.java new file mode 100644 index 00000000..54d22e19 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/dao/UserPositionMapper.java @@ -0,0 +1,20 @@ +package com.adc.da.slrs.roleReplacePosition.dao; + +import com.adc.da.slrs.roleReplacePosition.domain.UserPosition; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +/** +* @author ThinkBook +* @description 针对表【ts_user_position】的数据库操作Mapper +* @createDate 2023-11-14 13:49:37 +* @Entity com.adc.da.slrs.roleReplacePosition.domain.UserPosition +*/ +@Repository +public interface UserPositionMapper extends BaseMapper { + +} + + + + diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/domain/PositionRole.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/domain/PositionRole.java new file mode 100644 index 00000000..029b3b6d --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/domain/PositionRole.java @@ -0,0 +1,95 @@ +package com.adc.da.slrs.roleReplacePosition.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; + +/** + * + * @TableName ts_position_role + */ +@TableName(value ="ts_position_role") +public class PositionRole implements Serializable { + /** + * 角色ID + */ + @TableId + private String roleId; + + /** + * 岗位ID + */ + @TableId + private String positionId; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + public String getRoleId() { + return roleId; + } + + /** + * 角色ID + */ + public void setRoleId(String roleId) { + this.roleId = roleId; + } + + /** + * 岗位ID + */ + public String getPositionId() { + return positionId; + } + + /** + * 岗位ID + */ + public void setPositionId(String positionId) { + this.positionId = positionId; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + PositionRole other = (PositionRole) that; + return (this.getRoleId() == null ? other.getRoleId() == null : this.getRoleId().equals(other.getRoleId())) + && (this.getPositionId() == null ? other.getPositionId() == null : this.getPositionId().equals(other.getPositionId())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getRoleId() == null) ? 0 : getRoleId().hashCode()); + result = prime * result + ((getPositionId() == null) ? 0 : getPositionId().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", roleId=").append(roleId); + sb.append(", positionId=").append(positionId); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/domain/UserPosition.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/domain/UserPosition.java new file mode 100644 index 00000000..e3b71a16 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/domain/UserPosition.java @@ -0,0 +1,93 @@ +package com.adc.da.slrs.roleReplacePosition.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; + +/** + * + * @TableName ts_user_position + */ +@TableName(value ="ts_user_position") +public class UserPosition implements Serializable { + /** + * 用户ID + */ + private String userId; + + /** + * 岗位ID + */ + private String positionId; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + /** + * 用户ID + */ + public String getUserId() { + return userId; + } + + /** + * 用户ID + */ + public void setUserId(String userId) { + this.userId = userId; + } + + /** + * 岗位ID + */ + public String getPositionId() { + return positionId; + } + + /** + * 岗位ID + */ + public void setPositionId(String positionId) { + this.positionId = positionId; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + UserPosition other = (UserPosition) that; + return (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) + && (this.getPositionId() == null ? other.getPositionId() == null : this.getPositionId().equals(other.getPositionId())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); + result = prime * result + ((getPositionId() == null) ? 0 : getPositionId().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", userId=").append(userId); + sb.append(", positionId=").append(positionId); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/service/PositionRoleService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/service/PositionRoleService.java new file mode 100644 index 00000000..e160e34a --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/service/PositionRoleService.java @@ -0,0 +1,13 @@ +package com.adc.da.slrs.roleReplacePosition.service; + +import com.adc.da.slrs.roleReplacePosition.domain.PositionRole; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author ThinkBook +* @description 针对表【ts_position_role】的数据库操作Service +* @createDate 2023-11-14 13:53:47 +*/ +public interface PositionRoleService extends IService { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/service/UserPositionService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/service/UserPositionService.java new file mode 100644 index 00000000..27c81bfc --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/service/UserPositionService.java @@ -0,0 +1,14 @@ +package com.adc.da.slrs.roleReplacePosition.service; + +import com.adc.da.slrs.roleReplacePosition.domain.UserPosition; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author ThinkBook +* @description 针对表【ts_user_position】的数据库操作Service +* @createDate 2023-11-14 13:49:37 +*/ +public interface UserPositionService extends IService { + + void roleReplacePosition(); +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/service/impl/PositionRoleServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/service/impl/PositionRoleServiceImpl.java new file mode 100644 index 00000000..75472fb1 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/service/impl/PositionRoleServiceImpl.java @@ -0,0 +1,22 @@ +package com.adc.da.slrs.roleReplacePosition.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.adc.da.slrs.roleReplacePosition.domain.PositionRole; +import com.adc.da.slrs.roleReplacePosition.service.PositionRoleService; +import com.adc.da.slrs.roleReplacePosition.dao.PositionRoleMapper; +import org.springframework.stereotype.Service; + +/** +* @author ThinkBook +* @description 针对表【ts_position_role】的数据库操作Service实现 +* @createDate 2023-11-14 13:53:47 +*/ +@Service +public class PositionRoleServiceImpl extends ServiceImpl + implements PositionRoleService{ + +} + + + + diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/service/impl/UserPositionServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/service/impl/UserPositionServiceImpl.java new file mode 100644 index 00000000..61c4eb5f --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/roleReplacePosition/service/impl/UserPositionServiceImpl.java @@ -0,0 +1,68 @@ +package com.adc.da.slrs.roleReplacePosition.service.impl; + +import com.adc.da.slrs.roleReplacePosition.domain.PositionRole; +import com.adc.da.slrs.roleReplacePosition.service.PositionRoleService; +import com.adc.da.sys.entity.UserRoleEO; +import com.adc.da.sys.service.IUserRoleEOService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.adc.da.slrs.roleReplacePosition.domain.UserPosition; +import com.adc.da.slrs.roleReplacePosition.service.UserPositionService; +import com.adc.da.slrs.roleReplacePosition.dao.UserPositionMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +/** +* @author ThinkBook +* @description 针对表【ts_user_position】的数据库操作Service实现 +* @createDate 2023-11-14 13:49:37 +*/ +@Service +public class UserPositionServiceImpl extends ServiceImpl + implements UserPositionService{ + + @Resource + private PositionRoleService positionRoleService; + + @Resource + private IUserRoleEOService userRoleEOService; + + @Override + public void roleReplacePosition() { + // 找到所有对应关系 + List userPositions = this.list(); + + // 转换对应关系 + Map> positionRoleMap = positionRoleService.list().stream() + .collect(Collectors.groupingBy(PositionRole::getPositionId)); + + Set userRoleEOSet = new HashSet<>(); + for (UserPosition userPosition : userPositions) { + // 去除空指针异常 + if (positionRoleMap.get(userPosition.getPositionId()) == null) { + continue; + } + List roleIds = positionRoleMap.get(userPosition.getPositionId()).stream() + .map(PositionRole::getRoleId).collect(Collectors.toList()); + for (String roleId : roleIds) { + UserRoleEO userRoleEO = new UserRoleEO(); + userRoleEO.setUserId(userPosition.getUserId()); + userRoleEO.setRoleId(roleId); + userRoleEOSet.add(userRoleEO); + } + } + // 保存对应关系 + // 先找出所有用户角色,然后和构建好的用户角色去重后再进行添加,避免出现多条重复数据 + List userRoleEOList = userRoleEOService.list(); + userRoleEOList.forEach(userRoleEOSet::remove); + userRoleEOService.saveBatch(userRoleEOSet, userRoleEOSet.size()); + } + + +} + + + + diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandAttrInfo/entity/SarBussStandAttrInfoExecl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandAttrInfo/entity/SarBussStandAttrInfoExecl.java index f763e8e1..5dfdc5be 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandAttrInfo/entity/SarBussStandAttrInfoExecl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandAttrInfo/entity/SarBussStandAttrInfoExecl.java @@ -43,7 +43,7 @@ public class SarBussStandAttrInfoExecl extends BaseEntity { @ApiModelProperty(value = "修改时间") private Date modifyTime; - @ApiModelProperty(value = "体系类别") + @ApiModelProperty(value = "标准体系") private String txlbbuss; private String glwj; diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/dao/SarBussStandMenuDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/dao/SarBussStandMenuDao.java index a5d69489..14e6fa4c 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/dao/SarBussStandMenuDao.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/dao/SarBussStandMenuDao.java @@ -37,4 +37,5 @@ public interface SarBussStandMenuDao extends BaseMapper { int updateMenuidByMenuid (@Param("oldMenuid") String oldMenuid ,@Param("newMenuid") String newMenuid); + List getESStandMenu(); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/service/ISarBussStandMenuService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/service/ISarBussStandMenuService.java index 85587e22..001e0e99 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/service/ISarBussStandMenuService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/service/ISarBussStandMenuService.java @@ -18,4 +18,8 @@ public interface ISarBussStandMenuService extends IService { List selectAllMenuByStandId(SarBussStandMenu sarStandMenuEO); int deleteByMenuId (SarBussStandMenu sarStandMenuEO); + + void deleteStandSystemByStandId(String id); + + void addStandSystemRelation(String standSystemId, String id); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/service/impl/SarBussStandMenuServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/service/impl/SarBussStandMenuServiceImpl.java index ba1309d8..79184a17 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/service/impl/SarBussStandMenuServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/service/impl/SarBussStandMenuServiceImpl.java @@ -1,17 +1,25 @@ package com.adc.da.slrs.sarBussStandMenu.service.impl; +import com.adc.da.exception.AdcDaBaseException; import com.adc.da.slrs.sarBussStandMenu.entity.SarBussStandMenu; import com.adc.da.slrs.sarBussStandMenu.dao.SarBussStandMenuDao; import com.adc.da.slrs.sarBussStandMenu.service.ISarBussStandMenuService; import com.adc.da.slrs.sarResource.service.ITsResourceService; +import com.adc.da.slrs.sarStandMenu.entity.SarStandMenu; +import com.adc.da.sys.sarMenuStandard.entity.SarMenuStandard; import com.adc.da.sys.sarMenuStandard.service.ISarMenuStandardService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** *

@@ -30,6 +38,7 @@ public class SarBussStandMenuServiceImpl extends ServiceImpl menuIds = new ArrayList<>(); @@ -42,6 +51,42 @@ public class SarBussStandMenuServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SarBussStandMenu::getBussStandId, id); + List list = list(wrapper); + Set collect = list.stream().map(SarBussStandMenu::getMenuId).collect(Collectors.toSet()); + List menuIds = new ArrayList<>(); + for (String menuId : collect) { + SarMenuStandard menuStand = iSarMenuStandardService.getById(menuId); + if (menuStand != null) { + menuIds.add(menuStand.getId()); + } + } + if (menuIds.size() > 0) { + LambdaUpdateWrapper sarStandMenuWrapper = new LambdaUpdateWrapper<>(); + sarStandMenuWrapper.eq(SarBussStandMenu::getBussStandId, id); + sarStandMenuWrapper.in(SarBussStandMenu::getMenuId,menuIds); + remove(sarStandMenuWrapper); + } + } + + @Override + public void addStandSystemRelation(String standSystem, String id) { + // 校验standSystem是否有效 + SarMenuStandard standMenu = iSarMenuStandardService.getById(standSystem); + if (standMenu == null) { + throw new AdcDaBaseException("无效的标准体系"); + } + SarBussStandMenu sarBussStandMenu = new SarBussStandMenu(); + // 生成不带横杠的UUID + sarBussStandMenu.setId(java.util.UUID.randomUUID().toString().replaceAll("-", "")); + sarBussStandMenu.setBussStandId(id).setMenuId(standSystem).setValidFlag(0); + save(sarBussStandMenu); + } + @Override public List selectAllMenuByStandId(SarBussStandMenu sarStandMenuEO){ return this.baseMapper.selectAllMenuByStandId(sarStandMenuEO); diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/controller/SarBussionessStandController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/controller/SarBussionessStandController.java index d7c55e74..4bf0593d 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/controller/SarBussionessStandController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/controller/SarBussionessStandController.java @@ -1,6 +1,7 @@ package com.adc.da.slrs.sarBussionessStand.controller; +import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.ZipUtil; import com.adc.da.Log.BusinessType; import com.adc.da.Log.EpcLog; @@ -11,6 +12,7 @@ import com.adc.da.person.service.IPersonCollectEOService; import com.adc.da.slrs.esRevisePlan.entity.EsRevisePlanInfo; import com.adc.da.slrs.sarBussStandAttrInfo.dao.SarBussStandAttrInfoDao; import com.adc.da.slrs.sarBussStandAttrInfo.entity.SarBussStandAttrInfo; +import com.adc.da.slrs.sarBussStandMenu.service.ISarBussStandMenuService; import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStandExport; import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService; import com.adc.da.slrs.sarLawsInfo.service.ISarLawsInfoService; @@ -52,6 +54,7 @@ import io.swagger.annotations.Api; import com.adc.da.base.web.BaseController; import org.springframework.web.multipart.MultipartFile; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; @@ -105,6 +108,9 @@ public class SarBussionessStandController extends BaseController updateSarBussionessStand(@RequestBody SarBussionessStand sarBussionessStandEO) throws Exception { + // 标准体系 + String standSystemId = sarBussionessStandEO.getTxlbId(); + sarBussStandMenuService.deleteStandSystemByStandId(sarBussionessStandEO.getId()); + if (StrUtil.isNotBlank(standSystemId)) { + sarBussStandMenuService.addStandSystemRelation(standSystemId, sarBussionessStandEO.getId()); + } //校验编号和名称是否存在 QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq(null!=sarBussionessStandEO.getStandCode(),"STAND_CODE",sarBussionessStandEO.getStandCode()) @@ -725,8 +737,8 @@ public class SarBussionessStandController extends BaseController { List selectAllStandStatus(); String selectMaxStandSn(String standSort); + + List getESSystemData(@Param("param") StandSystemDTO standSystemDTO); + + void deleteStandSystem(@Param("menuName") String menuName); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/ISarBussionessStandService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/ISarBussionessStandService.java index 29c1a0d8..d60f56e4 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/ISarBussionessStandService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/ISarBussionessStandService.java @@ -69,7 +69,7 @@ public interface ISarBussionessStandService extends IService ResponseMessage cleaningDataReview(); - ResponseMessage repeal(String id, String type); + ResponseMessage repeal(String id, String type,String prcNum); String selectMaxStandSn(String standSort); diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/impl/SarBussionessStandServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/impl/SarBussionessStandServiceImpl.java index 45394527..4a961208 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/impl/SarBussionessStandServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/impl/SarBussionessStandServiceImpl.java @@ -49,10 +49,12 @@ import com.adc.da.slrs.sarBussionessStandState.entity.SarBussionessStandState; import com.adc.da.slrs.sarResource.entity.TsResource; import com.adc.da.slrs.sarResource.service.ITsResourceService; import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao; +import com.adc.da.slrs.sarStandMenu.entity.SarStandMenu; import com.adc.da.slrs.sarStandardsInfo.dao.SarStandardsInfoDao; import com.adc.da.slrs.sarStandardsInfo.entity.SarAdvanceSearchVO; import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage; import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo; +import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog; import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService; import com.adc.da.slrs.sarUser.dao.TsUserDao; import com.adc.da.slrs.sarUser.service.ITsUserService; @@ -1390,6 +1392,8 @@ public class SarBussionessStandServiceImpl extends ServiceImpl list = Arrays.asList(txlbbuss.toString().split("/")); + txlbbuss = list.get(list.size() - 1); // 配置体系类别 String txlbBussLevel = getParentNodePathRecursive((String) txlbbuss); sarBussionessStandEO.getAttrInfoCaseMap().put("txlbbuss",txlbBussLevel); @@ -1417,6 +1421,23 @@ public class SarBussionessStandServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SarMenuStandard::getMenuName, String.valueOf(txlbbuss)); + wrapper.eq(SarMenuStandard::getDicId, "9m4qqqaansxmox5e82zm"); + List list1 = sarMenuStandardService.list(wrapper); + if (list1.size() > 0) { + sarBussionessStandEO.setTxlbId(list1.get(0).getId()); + } + List list = Arrays.asList(txlbbuss.toString().split("/")); + txlbbuss = list.get(list.size() - 1); + // 配置体系类别 + String txlbBussLevel = getParentNodePathRecursive((String) txlbbuss); + sarBussionessStandEO.getAttrInfoCaseMap().put("txlbbuss",txlbBussLevel); + sarBussionessStandEO.getAttrInfoMap().put("TXLBBUSS",txlbBussLevel); + } } return sarBussionessStandEO; } @@ -2154,7 +2175,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl importSarBussionessStandFile(MultipartFile file,String menuId,String userId)throws Exception { //给出头部信息 - String[] headerExcel = {"*企标类别,*企标编号,*标准年份,*企标名称,企标英文名称,*文本状态,发布日期,企标实施日期,起草部门,起草人,适用车型,能源类型,适用产品线,体系类别,关联模块-乘用车VPPS编码,关联模块--卡车VPPS编码,发布稿,编制说明,历史版本,其他文件,修改单,代替企标编号,采用标准,采标程度,引用标准,关联文件,"}; + String[] headerExcel = {"*企标类别,*企标编号,*标准年份,*企标名称,企标英文名称,*文本状态,发布日期,企标实施日期,起草部门,起草人,适用车型,能源类型,适用产品线,标准体系,关联模块-乘用车VPPS编码,关联模块--卡车VPPS编码,发布稿,编制说明,历史版本,其他文件,修改单,代替企标编号,采用标准,采标程度,引用标准,关联文件,"}; //获取文件全称 String fileNameStr = file.getOriginalFilename(); @@ -2612,8 +2633,20 @@ public class SarBussionessStandServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SarMenuStandard::getValidFlag, "0"); + wrapper.eq(SarMenuStandard::getDicId, "9m4qqqaansxmox5e82zm"); + wrapper.eq(SarMenuStandard::getMenuName, txlbbuss); + List list = sarMenuStandardService.list(wrapper); + if (list.size() > 0) { + sarBussStandAttrInfo.setTxlbbuss(list.get(0).getMenuName()); + }else { + return Result.error("第"+ count +"行请输入正确的标准体系"); + } + } + //关联模块-乘用车VPPS编码 23 String cycvppsbmbuss = rowList.get("关联模块-乘用车VPPS编码"); @@ -2640,7 +2673,11 @@ public class SarBussionessStandServiceImpl extends ServiceImpl map = sarBussStandAttrInfoEODao.selectStandFieldAndData("XGLC", id); + String content = ""; + if(map!=null){ + Object xglc = map.get("XGLC"); + String xglcStr = Optional.ofNullable(xglc).orElse("").toString(); + String newXglcStr = ""; + if (StringUtils.isNotBlank(xglcStr)) { + newXglcStr = xglcStr + ","+ prcNum; + } else { + newXglcStr = prcNum; + } + sarBussStandAttrInfoEODao.updateStandInfo(id,"XGLC",newXglcStr); + try { + content = "标准号:" + sarBussionessStandDB.getStandCode() + "《"+ sarBussionessStandDB.getStandName() + "》" + "关联流程由\""+ xglcStr +"\"变为\""+ newXglcStr +"\""; + sarUpdLogEOService.createBaseLog(id,"BUSINESS",content); + } catch (Exception e) { + throw new AdcDaBaseException("日志添加失败"); + } + } + List dicTypeEOS = new ArrayList<>(); + // 添加删除记录 + if (StringUtils.isNotBlank(sarBussionessStandDB.getTextStatusBuss())) { + dicTypeEOS = dicTypeEODao.getDicEOByDicTypeCode(sarBussionessStandDB.getTextStatusBuss()); + } + if (dicTypeEOS.size()>0) { + content = "标准号:" + sarBussionessStandDB.getStandCode() + "《"+ sarBussionessStandDB.getStandName() + "》" + "文本状态由\""+ dicTypeEOS.get(0).getDicTypeName() +"\"变为\"废止\""; + } + try { + sarUpdLogEOService.createBaseLog(id,"BUSINESS",content); + } catch (Exception e) { + throw new AdcDaBaseException("日志添加失败"); + } }else { //有效 SarBussionessStand sarBussionessStand = new SarBussionessStand(); @@ -4918,6 +4988,25 @@ public class SarBussionessStandServiceImpl extends ServiceImpl attrInfoMap = JSON.parseObject(sarStandAttrEOStr1, Map.class); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SarMenuStandard::getMenuName, attrInfoMap.get("TXLBBUSS")); + queryWrapper.eq(SarMenuStandard::getValidFlag, "0"); + queryWrapper.eq(SarMenuStandard::getDicId, "9m4qqqaansxmox5e82zm"); + List list = sarMenuStandardService.list(queryWrapper); + if (list.size() > 0) { + if (StringUtils.isNotBlank(attrInfoMap.get("TXLBBUSS"))) { + SarBussStandMenu sarBussStandMenuEO = new SarBussStandMenu(); + sarBussStandMenuEO.setBussStandId(sarBussionessStandEO.getId()); + sarBussStandMenuEO.setMenuId(list.get(0).getId()); + sarBussStandMenuEO.setValidFlag(ValueStateEnum.VALUE_TRUE.getValue()); + sarBussStandMenuEO.setId(UUIDUtils.randomUUID20()); + sarBussStandMenuEODao.insert(sarBussStandMenuEO); + } + } + } if (insertresult >= 1) { // 根据代替标准号 ,修改代替标准号标准中的,被代替标准号 updateReplaceConnect(sarBussionessStandEO); diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsDetailedList/controller/SarLawsDetailedListController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsDetailedList/controller/SarLawsDetailedListController.java index cc7a758e..2c86309e 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsDetailedList/controller/SarLawsDetailedListController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsDetailedList/controller/SarLawsDetailedListController.java @@ -131,7 +131,11 @@ public class SarLawsDetailedListController extends BaseController exportLawsInformationInfo(SarLawsInformation sarLawsInformation, HttpServletResponse response, + public ResponseMessage exportLawsInformationInfo(SarLawsInformation sarLawsInformation, String userId, HttpServletResponse response, HttpServletRequest request) { OutputStream os = null; Workbook workbook = null; @@ -116,18 +119,27 @@ public class SarLawsInformationController extends BaseController idList = Arrays.asList(sarLawsInformation.getExportIds().split(",")); datas = informationService.getLawsInformationByIds(idList); } else { // 导出所有数据 - datas = informationService.getAllLawsInformation(sarLawsInformation); + datas = informationService.getAllLawsInformation(sarLawsInformation, userId); + } + List datasExport = new ArrayList<>(); + for (SarLawsInformation data : datas) { + SarLawsInformationExport dataExport = new SarLawsInformationExport(); + BeanUtils.copyProperties(data,dataExport); + datasExport.add(dataExport); } ExportParams exportParams = new ExportParams(); exportParams.setType(ExcelType.XSSF); exportParams.setSheetName(sarLawsInformation.getExportName()); - workbook = ExcelExportUtil.exportExcel(exportParams,SarLawsInformation.class,datas); + workbook = ExcelExportUtil.exportExcel(exportParams, SarLawsInformationExport.class,datasExport); os = response.getOutputStream(); workbook.write(os); os.flush(); @@ -170,7 +182,7 @@ public class SarLawsInformationController extends BaseController * @param sarLawsInformation 法规资料对象,用于查询 * @return 法规资料列表 */ - List getAllLawsInformation(SarLawsInformation sarLawsInformation); + List getAllLawsInformation(SarLawsInformation sarLawsInformation, String userId); ResponseMessage importLawsInformationInfo(MultipartFile file); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/service/impl/SarLawsInformationServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/service/impl/SarLawsInformationServiceImpl.java index 072b1504..527c6c91 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/service/impl/SarLawsInformationServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/service/impl/SarLawsInformationServiceImpl.java @@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil; import cn.afterturn.easypoi.excel.entity.ImportParams; import com.adc.da.att.entity.AttFileEO; import com.adc.da.att.service.IAttFileEOService; +import com.adc.da.att.vo.AttFileVo; import com.adc.da.common.FileUnZip; import com.adc.da.http.ResponseMessage; import com.adc.da.http.Result; @@ -20,6 +21,7 @@ import com.adc.da.slrs.tsDictionaryType.entity.TsDicType; import com.adc.da.slrs.tsDictionaryType.service.ITsDicTypeService; import com.adc.da.util.LoginUserUtil; import com.adc.da.util.UUIDUtils; +import com.adc.da.utils.annotation.CompareField; import com.adc.da.utils.util.FieldConvertUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -27,20 +29,21 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation; import com.adc.da.slrs.sarLawsInformation.service.SarLawsInformationService; import com.adc.da.slrs.sarLawsInformation.dao.SarLawsInformationDao; -import io.swagger.annotations.ApiModelProperty; +import lombok.Cleanup; +import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.*; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -87,7 +90,9 @@ public class SarLawsInformationServiceImpl extends ServiceImpl fileNameList = new ArrayList<>(); for (String attId : split) { AttFileEO fileInfo = attFileEOService.getFileInfo(attId); - fileNameList.add(fileInfo); + if (fileInfo != null) { + fileNameList.add(fileInfo); + } } sarLawsInformation.setInformationFileList(fileNameList); } @@ -135,8 +140,6 @@ public class SarLawsInformationServiceImpl extends ServiceImpl wrapper3 = new LambdaQueryWrapper<>(); wrapper3.eq(SarLawsInformationAuth::getLawsInformationId, sarLawsInformation.getId()); @@ -158,8 +161,9 @@ public class SarLawsInformationServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SarLawsInformationAuth::getUserId, userId); - wrapper.eq(SarLawsInformationAuth::getAuthType, "viewableBy"); - wrapper.or().eq(SarLawsInformationAuth::getAuthType, "createAndApproveBy"); + wrapper.and(each -> each.eq(SarLawsInformationAuth::getAuthType, "viewableBy") + .or().eq(SarLawsInformationAuth::getAuthType, "createAndApproveBy") + .or().eq(SarLawsInformationAuth::getAuthType, "downloadableBy")); wrapper.select(SarLawsInformationAuth::getLawsInformationId); List informationAuthList = authService.list(wrapper); if (informationAuthList.size() > 0) { @@ -175,8 +179,8 @@ public class SarLawsInformationServiceImpl extends ServiceImpl fileNameList = new ArrayList<>(); for (String attId : split) { AttFileEO fileInfo = attFileEOService.getFileInfo(attId); - fileNameList.add(fileInfo); + if (fileInfo!= null) { + fileNameList.add(fileInfo); + } } sarLawsInformation.setInformationFileList(fileNameList); } @@ -230,9 +236,6 @@ public class SarLawsInformationServiceImpl extends ServiceImpl viewableByList = extractContentInParentheses(sarLawsInformation.getViewableBy()); - if (!viewableByList.contains(userId)) { - viewableByList.add(userId); - } viewableByList.forEach(viewableBy -> { SarLawsInformationAuth auth = new SarLawsInformationAuth(); auth.setLawsInformationId(sarLawsInformation.getId()); @@ -243,14 +246,11 @@ public class SarLawsInformationServiceImpl extends ServiceImpl downloadableByList = extractContentInParentheses(sarLawsInformation.getDownloadableBy()); - if (!downloadableByList.contains(userId)) { - downloadableByList.add(userId); - } - downloadableByList.forEach(viewableBy -> { + downloadableByList.forEach(downloadableBy -> { SarLawsInformationAuth auth = new SarLawsInformationAuth(); auth.setLawsInformationId(sarLawsInformation.getId()); auth.setAuthType("downloadableBy"); - auth.setUserId(viewableBy); + auth.setUserId(downloadableBy); authService.save(auth); }); } @@ -348,21 +348,21 @@ public class SarLawsInformationServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.in(SarLawsInformation::getId, idList); List sarLawsInformationList = this.baseMapper.selectList(wrapper); -// for (SarLawsInformation sarLawsInformation : sarLawsInformationList) { -// // 将字典编号变更为字典值 -// convertCodeToName(sarLawsInformation); -// } + for (SarLawsInformation sarLawsInformation : sarLawsInformationList) { + // 将字典编号变更为字典值 + convertCodeToName(sarLawsInformation); + } return sarLawsInformationList; } @Override - public List getAllLawsInformation(SarLawsInformation sarLawsInformation) { - String userId = LoginUserUtil.getUserId(); + public List getAllLawsInformation(SarLawsInformation sarLawsInformation, String userId) { // 查询有权限的资料ID LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SarLawsInformationAuth::getUserId, userId); - wrapper.eq(SarLawsInformationAuth::getAuthType, "viewableBy"); - wrapper.or().eq(SarLawsInformationAuth::getAuthType, "createAndApproveBy"); + wrapper.and(each -> each.eq(SarLawsInformationAuth::getAuthType, "viewableBy") + .or().eq(SarLawsInformationAuth::getAuthType, "createAndApproveBy") + .or().eq(SarLawsInformationAuth::getAuthType, "downloadableBy")); wrapper.select(SarLawsInformationAuth::getLawsInformationId); List informationAuthList = authService.list(wrapper); if (informationAuthList.size() > 0) { @@ -372,7 +372,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl sarLawsInformationList = this.baseMapper.getAllLawsInformation(sarLawsInformation); for (SarLawsInformation lawsInformation : sarLawsInformationList) { // 将字典编号变更为字典值 -// convertCodeToName(lawsInformation); + convertCodeToName(lawsInformation); // 查询文件信息 if (StringUtils.isNotBlank(lawsInformation.getInformationFile())) { String[] split = lawsInformation.getInformationFile().split(","); @@ -387,6 +387,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl importLawsInformationInfo(MultipartFile file) { //获取文件全称 @@ -422,24 +423,41 @@ public class SarLawsInformationServiceImpl extends ServiceImpl fileList = readImpExcelFile(zipEntryName); //判断获取到的文件数量 - if (fileList.size() != 1) { - return Result.error("上传的文件只能有一个"); + if (fileList.size() < 1) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("上传的文件不能为空"); } - File importFile = fileList.get(0); - if (!importFile.getName().contains(".xls") && !importFile.getName().contains(".xlsx")) { - return Result.error("文件必须是EXCEL文件"); + File excelFile = null; + int excelCount = 0; + // 将文件转换为Map,文件名为建,文件为值 + Map fileMap = new HashMap<>(); + for (File file1 : fileList) { + fileMap.put(file1.getName(), file1); + if (file1.getName().toLowerCase().contains(".xls") || file1.getName().toLowerCase().contains(".xlsx")) { + excelFile = file1; + excelCount ++; + } + } + if (excelCount > 1) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("导入了多个Excel文件"); + } + if (excelCount < 1){ + FileUnZip.deleteDir(saveDirectory); + return Result.error("文件必须包含一个EXCEL文件"); } Workbook workbook = null; try { - workbook = WorkbookFactory.create(importFile); + workbook = WorkbookFactory.create(excelFile); } catch (IOException e) { FileUnZip.deleteDir(saveDirectory); - return Result.error("导入失败,需要导入的数据有问题或导入的企标标号和企标名称已存在"); + return Result.error("导入失败,需要导入的数据有问题"); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Sheet sheet = workbook.getSheetAt(0); @@ -450,8 +468,14 @@ public class SarLawsInformationServiceImpl extends ServiceImpl headerList = new ArrayList<>(); // 获取excel表头 Row headerRow = sheet.getRow(1); - for (int i = 0; i < 8; i++) { - headerList.add(headerRow.getCell(i).getStringCellValue()); + try { + for (int i = 0; i < 9; i++) { + headerList.add(headerRow.getCell(i).getStringCellValue()); + } + } catch (Exception e) { + return Result.error("表头读取失败,请严格按照模板文件导入数据"); + } finally { + FileUnZip.deleteDir(saveDirectory); } // 判断表头字段是否相同 @@ -465,10 +489,57 @@ public class SarLawsInformationServiceImpl extends ServiceImpl> importDataList = new ArrayList<>(); + for (int rowIndex = 2; rowIndex < rowNum; rowIndex++) { + // 获取每一行 + Row row = sheet.getRow(rowIndex); + // 用于存储每行的键值对数据,对应一条数据 + Map rowMap = new LinkedHashMap<>(); + // 总列数 + int columnNum = 9; + // 遍历每个单元格 + for (int columnIndex = 0; columnIndex < columnNum; columnIndex++) { + // 获取单元格 + Cell cell = row.getCell(columnIndex); + // 获取表头单元格 + Cell headerCell = headerRow.getCell(columnIndex); + if (cell != null) { + if (CellType.NUMERIC == cell.getCellType() && HSSFDateUtil.isCellDateFormatted(cell)) { + Date d = cell.getDateCellValue(); + if (d.before(sdf.parse("1900-01-01")) || d.after(sdf.parse("2500-01-01"))) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("第"+(rowIndex-1)+"行第"+(columnIndex + 1)+"个单元格输入的日期异常,请按照实际日期填写"); + } + // 将单元格数据存入Map中 + rowMap.put(headerCell.getStringCellValue(), sdf.format(d)); + } else { + cell.setCellType(CellType.STRING); + if (cell.getStringCellValue().length() > 500) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("第"+(rowIndex-1)+"行第"+(columnIndex + 1)+"个单元格输入过长"); + } + rowMap.put(headerCell.getStringCellValue(), cell.getStringCellValue()); + } + } else { + rowMap.put(headerCell.getStringCellValue(), ""); + } + } + importDataList.add(rowMap); + } + if (importDataList.size() < 1) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("您输入的数据为空"); + } ImportParams importParams = new ImportParams(); importParams.setTitleRows(1); - List sarLawsInformationList = ExcelImportUtil.importExcel(readImpExcelFile(zipEntryName).get(0), SarLawsInformation.class, importParams); +// @Cleanup + InputStream inputStream = new FileInputStream(excelFile); + List sarLawsInformationList = ExcelImportUtil.importExcel(inputStream, SarLawsInformation.class, importParams); + workbook.close(); + inputStream.close(); + FileUnZip.delete(excelFile); // 获取需要校验的字段 List firstMaterialTypeList = dicTypeService.selectAllDicTypeNameByDicCode("firstMaterialType"); Set firstMaterialTypeNameSet = firstMaterialTypeList.stream().map(TsDicType::getDicTypeName).collect(Collectors.toSet()); @@ -487,68 +558,94 @@ public class SarLawsInformationServiceImpl extends ServiceImpl firstTypeCodeList = new ArrayList<>(); - for (String firstTypeName : sarLawsInformation.getFirstTypeName().split(",")) { - if (!firstMaterialTypeNameSet.contains(firstTypeName)){ - return Result.error("第" + index + "条记录的一级会议类别不符合输入要求"); - } - for (TsDicType tsDicType : firstMaterialTypeList) { - if (firstTypeName.equals(tsDicType.getDicTypeName())) { - firstTypeCodeList.add(tsDicType.getDicTypeCode()); + if (sarLawsInformationListNew.size() < 1) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("您输入的数据为空"); + } + try { + for (SarLawsInformation sarLawsInformation : sarLawsInformationListNew){ + if (StringUtils.isBlank(sarLawsInformation.getDepartment())) { + return Result.error("第" + index + "条记录的资料归属部门不能为空"); + } + // 把excel表中的类别名转换为类别编号,并对类别名做检测 + if (StringUtils.isNotBlank(sarLawsInformation.getFirstTypeName())) { + List firstTypeCodeList = new ArrayList<>(); + for (String firstTypeName : sarLawsInformation.getFirstTypeName().split(",")) { + if (!firstMaterialTypeNameSet.contains(firstTypeName)){ + return Result.error("第" + index + "条记录的一级会议类别不符合输入要求"); + } + for (TsDicType tsDicType : firstMaterialTypeList) { + if (firstTypeName.equals(tsDicType.getDicTypeName())) { + firstTypeCodeList.add(tsDicType.getDicTypeCode()); + } } } + sarLawsInformation.setFirstType(String.join(",", firstTypeCodeList)); + }else { + return Result.error("第" + index + "条记录的1级资料分类不能为空"); } - sarLawsInformation.setFirstType(String.join(",", firstTypeCodeList)); - } - if (StringUtils.isNotBlank(sarLawsInformation.getSecondTypeName())) { - List secondTypeCodeList = new ArrayList<>(); - for (String secondTypeName : sarLawsInformation.getSecondTypeName().split(",")) { - if (!secondMaterialTypeNameSet.contains(secondTypeName)){ - return Result.error("第" + index + "条记录的二级会议类别不符合输入要求"); - } - for (TsDicType tsDicType : secondMaterialTypeList) { - if (secondTypeName.equals(tsDicType.getDicTypeName())) { - secondTypeCodeList.add(tsDicType.getDicTypeCode()); + if (StringUtils.isNotBlank(sarLawsInformation.getSecondTypeName())) { + List secondTypeCodeList = new ArrayList<>(); + for (String secondTypeName : sarLawsInformation.getSecondTypeName().split(",")) { + if (!secondMaterialTypeNameSet.contains(secondTypeName)){ + return Result.error("第" + index + "条记录的二级会议类别不符合输入要求"); + } + for (TsDicType tsDicType : secondMaterialTypeList) { + if (secondTypeName.equals(tsDicType.getDicTypeName())) { + secondTypeCodeList.add(tsDicType.getDicTypeCode()); + } } } + sarLawsInformation.setSecondType(String.join(",", secondTypeCodeList)); + }else { + return Result.error("第" + index + "条记录的2级资料分类不能为空"); } - sarLawsInformation.setSecondType(String.join(",", secondTypeCodeList)); - } - if (StringUtils.isNotBlank(sarLawsInformation.getThirdTypeName())) { - List thirdTypeCodeList = new ArrayList<>(); - for (String thirdTypeName : sarLawsInformation.getThirdTypeName().split(",")) { - if (!thirdMaterialTypeNameSet.contains(thirdTypeName)){ - return Result.error("第" + index + "条记录的三级会议类别不符合输入要求"); - } - for (TsDicType tsDicType : thirdMaterialTypeList) { - if (thirdTypeName.equals(tsDicType.getDicTypeName())) { - thirdTypeCodeList.add(tsDicType.getDicTypeCode()); + if (StringUtils.isNotBlank(sarLawsInformation.getThirdTypeName())) { + List thirdTypeCodeList = new ArrayList<>(); + for (String thirdTypeName : sarLawsInformation.getThirdTypeName().split(",")) { + if (!thirdMaterialTypeNameSet.contains(thirdTypeName)){ + return Result.error("第" + index + "条记录的三级会议类别不符合输入要求"); + } + for (TsDicType tsDicType : thirdMaterialTypeList) { + if (thirdTypeName.equals(tsDicType.getDicTypeName())) { + thirdTypeCodeList.add(tsDicType.getDicTypeCode()); + } } } + sarLawsInformation.setThirdType(String.join(",", thirdTypeCodeList)); + }else { + return Result.error("第" + index + "条记录的3级资料分类不能为空"); } - sarLawsInformation.setThirdType(String.join(",", thirdTypeCodeList)); - } - if (StringUtils.isNotBlank(sarLawsInformation.getFourthTypeName())) { - List fourthTypeCodeList = new ArrayList<>(); - for (String fourthTypeName : sarLawsInformation.getFourthTypeName().split(",")) { - if (!fourthMaterialTypeNameSet.contains(fourthTypeName)){ - return Result.error("第" + index + "条记录的四级会议类别不符合输入要求"); - } - for (TsDicType tsDicType : fourthMaterialTypeList) { - if (fourthTypeName.equals(tsDicType.getDicTypeName())) { - fourthTypeCodeList.add(tsDicType.getDicTypeCode()); + if (StringUtils.isNotBlank(sarLawsInformation.getFourthTypeName())) { + List fourthTypeCodeList = new ArrayList<>(); + for (String fourthTypeName : sarLawsInformation.getFourthTypeName().split(",")) { + if (!fourthMaterialTypeNameSet.contains(fourthTypeName)){ + return Result.error("第" + index + "条记录的四级会议类别不符合输入要求"); + } + for (TsDicType tsDicType : fourthMaterialTypeList) { + if (fourthTypeName.equals(tsDicType.getDicTypeName())) { + fourthTypeCodeList.add(tsDicType.getDicTypeCode()); + } } } + sarLawsInformation.setFourthType(String.join(",", fourthTypeCodeList)); + } else { + return Result.error("第" + index + "条记录的4级资料分类不能为空"); } - sarLawsInformation.setFourthType(String.join(",", fourthTypeCodeList)); + String informationFileAtt = null; + try { + informationFileAtt = getFileAtt("资料文件",sarLawsInformation.getInformationFile(), fileMap, index); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + sarLawsInformation.setInformationFile(informationFileAtt); + // 索引 +1 + index++; + // 存入数据库 + addLawsInformation(sarLawsInformation); } - // 索引 +1 - index++; - // 存入数据库 - addLawsInformation(sarLawsInformation); + } finally { + FileUnZip.deleteDir(saveDirectory); } return Result.success("导入成功"); } @@ -591,45 +688,33 @@ public class SarLawsInformationServiceImpl extends ServiceImpl compareSarLawsInformation(SarLawsInformation oldInfo, SarLawsInformation newInfo) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); List changes = new ArrayList<>(); - // 需要比较的字段 - String[] fieldArr = {"firstType","secondType","thirdType","fourthType","name", - "department","author","description","informationFile","treeNodeId","viewableBy","downloadableBy"}; - List fieldList = Arrays.asList(fieldArr); // 获取SarLawsInformation类的所有字段 Field[] fields = SarLawsInformation.class.getDeclaredFields(); for (Field field : fields) { - if (fieldList.contains(field.getName())) { + boolean annotationPresent = field.isAnnotationPresent(CompareField.class); + if (annotationPresent) { try { field.setAccessible(true); - String oldValue = String.valueOf(field.get(oldInfo)); - String newValue = String.valueOf(field.get(newInfo)); +// String oldValue = String.valueOf(field.get(oldInfo)); +// String newValue = String.valueOf(field.get(newInfo)); + Object oldValue = field.get(oldInfo); + Object newValue = field.get(newInfo); + if (oldValue instanceof Date){ + oldValue = sdf.format((Date)oldValue); + } + if( newValue instanceof Date) { + newValue = sdf.format((Date)newValue); + } if (!Objects.equals(oldValue, newValue)) { switch (field.getName()) { -// case "firstType": -// case "secondType": -// case "thirdType": -// case "fourthType": { -// List typeNameList = new ArrayList<>(); -// if (StringUtils.isNotBlank(newValue)) { -// for (String type : newValue.split(",")) { -// if (StringUtils.isNotBlank(type)) { -// typeNameList.add(dicTypeService.getDicTypeNameByDicCode(type)); -// } -// } -// } -// // 获取资料类型名称 -// String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1); -// Method method = SarLawsInformation.class.getMethod("get" + fieldName + "Name"); -// Object oldTypeName = method.invoke(oldInfo); -// ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0]; -// changes.add(annotationsByType.value() + "由\"" + oldTypeName + "\"改为\"" + String.join(",", typeNameList) + "\""); -// break; -// } case "informationFile": { List fileNameList = new ArrayList<>(); - if (StringUtils.isNotBlank(newValue)) { - String[] split = newValue.split(","); + String oldValueStr = String.valueOf(field.get(oldInfo)); + String newValueStr = String.valueOf(field.get(newInfo)); + if (StringUtils.isNotBlank(newValueStr)) { + String[] split = newValueStr.split(","); for (String attId : split) { AttFileEO fileInfo = attFileEOService.getFileInfo(attId); fileNameList.add(fileInfo.getOldFileName()); @@ -646,14 +731,24 @@ public class SarLawsInformationServiceImpl extends ServiceImpl fileMap, int count) throws Exception { + if (fileNameStr != null) { + List fileAttList = new ArrayList<>(); + for (String fileName : fileNameStr.split(",")) { + int lastIndexOf = fileName.lastIndexOf("."); + if (fileName.lastIndexOf(".") != -1) { + String lastName = fileName.substring(lastIndexOf + 1).toLowerCase(); + if (lastName.equals("pdf") || lastName.equals("ppt") || lastName.equals("pptx") || lastName.equals("doc") || lastName.equals("docx")) { + File file1 = fileMap.get(fileName); + if (file1 == null) { + throw new Exception(fieldName + "中第" + (count+1) +"行" + fileName + "文件不存在,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + AttFileVo attFileVo = attFileEOService.saveFileInfo(file1); + if (StringUtils.isNotBlank(attFileVo.getId())) { + fileAttList.add(attFileVo.getAttId()); + } + } else { + throw new Exception(fieldName + "中第" + (count+1) +"行" + fileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + } else { + throw new Exception(fieldName + "中第" + (count+1) +"行" + fileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + } + return String.join(",", fileAttList); + } + return null; + } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsStandInfo/controller/SarLawsStandInfoController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsStandInfo/controller/SarLawsStandInfoController.java index 4420065b..6427da14 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsStandInfo/controller/SarLawsStandInfoController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsStandInfo/controller/SarLawsStandInfoController.java @@ -77,7 +77,7 @@ public class SarLawsStandInfoController extends BaseController case "issueTime": page.setOrderByA("SAR_LAWS_STAND_INFO.ISSUE_TIME");//发布日期 break; - case "SSRQLAWS": + case "ssrqlaws": page.setOrderByA("SSRQLAWS"); break; case "LAWSSYCX": @@ -103,6 +103,9 @@ public class SarLawsStandInfoController extends BaseController break; } } + } else { + page.setOrderByA("SAR_LAWS_STAND_INFO.LAWS_NAME"); + page.setOrder1("asc"); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsStandInfo/service/impl/SarLawsStandInfoServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsStandInfo/service/impl/SarLawsStandInfoServiceImpl.java index 767f5ade..976284cb 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsStandInfo/service/impl/SarLawsStandInfoServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsStandInfo/service/impl/SarLawsStandInfoServiceImpl.java @@ -242,6 +242,28 @@ public class SarLawsStandInfoServiceImpl extends ServiceImpl list = new ArrayList<>(); + if (StringUtils.isNotBlank(sarLawsStandInfo.getLawsTypeFirstLevel())) { + list = Arrays.asList(sarLawsStandInfo.getLawsTypeFirstLevel().split(",")); + levelName = dicTypeEODao.getDicNamesByCodes(list, "xf1g55oztafkxisxie1i"); + sarLawsStandInfo.setLawTypeFirstLevelName(levelName); + } + if (StringUtils.isNotBlank(sarLawsStandInfo.getLawsTypeSecondLevel())) { + list = Arrays.asList(sarLawsStandInfo.getLawsTypeSecondLevel().split(",")); + levelName = dicTypeEODao.getDicNamesByCodes(list, "r09bcearrmv0qoqoc8w4"); + sarLawsStandInfo.setLawTypeSecondLevelName(levelName); + } + if (StringUtils.isNotBlank(sarLawsStandInfo.getLawsTypeThirdLevel())) { + list = Arrays.asList(sarLawsStandInfo.getLawsTypeThirdLevel().split(",")); + levelName = dicTypeEODao.getDicNamesByCodes(list, "h05q1gegpth2jbp9k447"); + sarLawsStandInfo.setLawTypeThirdLevelName(levelName); + } + if (StringUtils.isNotBlank(sarLawsStandInfo.getLawsTypeFourthLevel())) { + list = Arrays.asList(sarLawsStandInfo.getLawsTypeFourthLevel().split(",")); + levelName = dicTypeEODao.getDicNamesByCodes(list, "5pl1o1zufypbyiqapssf"); + sarLawsStandInfo.setLawTypeFourthLevelName(levelName); + } } return sarLawsStandInfo; } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/controller/SarLawsTopicController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/controller/SarLawsTopicController.java index d2f908f0..d0efb10a 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/controller/SarLawsTopicController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/controller/SarLawsTopicController.java @@ -13,6 +13,7 @@ import com.adc.da.http.ResponseMessage; import com.adc.da.http.Result; import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation; import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopic; +import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicExport; import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicVO; import com.adc.da.slrs.sarLawsTopic.service.SarLawsTopicService; import com.adc.da.util.UUIDUtils; @@ -27,6 +28,7 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.util.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -36,6 +38,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.text.ParseException; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -123,10 +126,16 @@ public class SarLawsTopicController extends BaseController { // 导出所有数据 datas = lawsTopicService.getAllLawsTopic(sarLawsTopicVO); } + List dataExportList = new ArrayList<>(); + for (SarLawsTopicVO data : datas) { + SarLawsTopicExport dataExport = new SarLawsTopicExport(); + BeanUtils.copyProperties(data, dataExport); + dataExportList.add(dataExport); + } ExportParams exportParams = new ExportParams(); exportParams.setType(ExcelType.XSSF); exportParams.setSheetName(sarLawsTopicVO.getExportName()); - workbook = ExcelExportUtil.exportExcel(exportParams, SarLawsTopicVO.class, datas); + workbook = ExcelExportUtil.exportExcel(exportParams, SarLawsTopicExport.class, dataExportList); os = response.getOutputStream(); workbook.write(os); os.flush(); @@ -141,7 +150,7 @@ public class SarLawsTopicController extends BaseController { @ApiOperation("Excel文件导入政策资料信息") @PostMapping("/importLawsTopicInfo") - public ResponseMessage importLawsTopicInfo(@RequestParam(value = "file",required = false) MultipartFile file) throws ParseException { + public ResponseMessage importLawsTopicInfo(@RequestParam(value = "file",required = false) MultipartFile file) throws Exception { if (file == null) { return Result.error("文件为空,请重新上传"); } @@ -171,14 +180,14 @@ public class SarLawsTopicController extends BaseController { HSSFSheet sheetItems = workbook.createSheet("模板"); sheetItems.setDefaultColumnWidth(13); Row rowHeader = sheetItems.createRow(1);//开始创建标题行 - sheetItems.addMergedRegion(new CellRangeAddress(0, 0, 0, 21)); + sheetItems.addMergedRegion(new CellRangeAddress(0, 0, 0, 31)); Row row2 = sheetItems.createRow(0);//开始创建填写说明 // 表头样式 HSSFCellStyle cellStyle1 = workbook.createCellStyle(); cellStyle1.setAlignment(HorizontalAlignment.CENTER); cellStyle1.setVerticalAlignment(VerticalAlignment.CENTER); - String exportFieldName = "课题名称,课题承办单位,课题指导单位,课题参与单位,启动时间,结题时间,课题费用(万元)"; + String exportFieldName = "*课题名称,*课题承办单位,课题指导单位,课题参与单位,*启动时间,结题时间,课题费用(万元),协议"; String[] headerArr = exportFieldName.split(","); for (int i=0;i < headerArr.length; i++) { Cell cell = rowHeader.createCell(i); @@ -186,33 +195,54 @@ public class SarLawsTopicController extends BaseController { sheetItems.addMergedRegion(new CellRangeAddress(1,2,i,i)); cell.setCellStyle(cellStyle1); } - - String exportFieldListName = "课题组会议列表,课题组联系方式,内部联系方式"; - String[] headerListArr = exportFieldListName.split(","); - for (int i=0;i < headerListArr.length; i++) { - Cell cell = rowHeader.createCell(7 + (i * 5)); - cell.setCellValue(headerListArr[i]); - sheetItems.addMergedRegion(new CellRangeAddress(1,1,7+(i*5),7+(i*5)+4)); - cell.setCellStyle(cellStyle1); - } - HSSFRow rowHeader2 = sheetItems.createRow(2); + Cell cell = rowHeader.createCell(8); + cell.setCellValue("课题组会议"); + sheetItems.addMergedRegion(new CellRangeAddress(1,1,8,12)); + cell.setCellStyle(cellStyle1); String exportFieldMeetingName = "会议名称,会议时间,会议地点,参会人员(内部),会议主要内容"; String[] headerMeetingListArr = exportFieldMeetingName.split(","); + HSSFRow rowHeader2 = sheetItems.createRow(2); for (int i=0;i < headerMeetingListArr.length; i++) { - Cell cell = rowHeader2.createCell(7 + i); - cell.setCellValue(headerMeetingListArr[i]); - cell.setCellStyle(cellStyle1); - } - String exportFieldContactName = "姓名,单位,电话,邮箱,身份"; - String[] headerContactListArr = exportFieldContactName.split(","); - for (int i=0;i < headerContactListArr.length; i++) { - Cell cell1 = rowHeader2.createCell(12 + i); - cell1.setCellValue(headerContactListArr[i]); - cell1.setCellStyle(cellStyle1); - Cell cell2 = rowHeader2.createCell(17 + i); - cell2.setCellValue(headerContactListArr[i]); + Cell cell2 = rowHeader2.createCell(8 + i); + cell2.setCellValue(headerMeetingListArr[i]); cell2.setCellStyle(cellStyle1); } + String topicGroupFieldName = "课题组研究方案,课题组研究成果,课题组其他,课题组会议资料"; + headerArr = topicGroupFieldName.split(","); + for (int i=0;i < headerArr.length; i++) { + Cell cell2 = rowHeader.createCell(13+i); + cell2.setCellValue(headerArr[i]); + sheetItems.addMergedRegion(new CellRangeAddress(1,2,i+13,i+13)); + cell2.setCellStyle(cellStyle1); + } + Cell cell3 = rowHeader.createCell(17); + cell3.setCellValue("课题组联系方式"); + sheetItems.addMergedRegion(new CellRangeAddress(1,1,17,21)); + cell3.setCellStyle(cellStyle1); + String exportFieldContactName = "姓名,单位,电话,邮箱,身份"; + headerMeetingListArr = exportFieldContactName.split(","); + for (int i=0;i < headerMeetingListArr.length; i++) { + Cell cell4 = rowHeader2.createCell(17 + i); + cell4.setCellValue(headerMeetingListArr[i]); + cell4.setCellStyle(cellStyle1); + } + String insideFieldName = "内部立项报告,内部研究方案,内部会议资料,内部研究成果,内部其他"; + headerArr = insideFieldName.split(","); + for (int i=0;i < headerArr.length; i++) { + Cell cell5 = rowHeader.createCell(22+i); + cell5.setCellValue(headerArr[i]); + sheetItems.addMergedRegion(new CellRangeAddress(1,2,i+22,i+22)); + cell5.setCellStyle(cellStyle1); + } + Cell cell6 = rowHeader.createCell(27); + cell6.setCellValue("内部联系方式"); + sheetItems.addMergedRegion(new CellRangeAddress(1,1,27,31)); + cell6.setCellStyle(cellStyle1); + for (int i=0;i < headerMeetingListArr.length; i++) { + Cell cell7 = rowHeader2.createCell(27 + i); + cell7.setCellValue(headerMeetingListArr[i]); + cell7.setCellStyle(cellStyle1); + } Cell cellA2 = row2.createCell(0); cellA2.setCellValue(FieldConvertUtil.exportLawsTopicDesc); //sheetItems.setColumnWidth(0, 20 * 150); diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/dao/SarLawsTopicMapper.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/dao/SarLawsTopicMapper.java index 62169489..ddbd8f2b 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/dao/SarLawsTopicMapper.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/dao/SarLawsTopicMapper.java @@ -17,7 +17,7 @@ import java.util.List; @Mapper public interface SarLawsTopicMapper extends BaseMapper { - List queryByPageCount(SarLawsTopicVO page); + Integer queryByPageCount(SarLawsTopicVO page); List queryByPage(SarLawsTopicVO page); diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsContactInformation.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsContactInformation.java index c5c7db0a..cbafc458 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsContactInformation.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsContactInformation.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import lombok.Data; +import org.apache.commons.lang3.StringUtils; /** * 政策课题组联系方式 @@ -70,4 +71,16 @@ public class SarLawsContactInformation implements Serializable { @TableField(exist = false) private static final long serialVersionUID = 1L; + + public static SarLawsContactInformation emptyValueProcess(SarLawsContactInformation sarLawsContactInformation) { + if (StringUtils.isBlank(sarLawsContactInformation.getName()) && + StringUtils.isBlank(sarLawsContactInformation.getGroupType()) && + StringUtils.isBlank(sarLawsContactInformation.getDepartment()) && + StringUtils.isBlank(sarLawsContactInformation.getEmail()) && + StringUtils.isBlank(sarLawsContactInformation.getPhone()) && + StringUtils.isBlank(sarLawsContactInformation.getIdentity())) { + return null; + } + return sarLawsContactInformation; + } } \ No newline at end of file diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopic.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopic.java index de104c22..94b96605 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopic.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopic.java @@ -1,6 +1,7 @@ package com.adc.da.slrs.sarLawsTopic.entity; import com.adc.da.att.entity.AttFileEO; +import com.adc.da.utils.annotation.CompareField; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -30,6 +31,7 @@ public class SarLawsTopic implements Serializable { /** * 课题名称 */ + @CompareField(fieldName = "课题名称") @ApiModelProperty(value = "课题名称") @TableField(value = "TOPIC_NAME") private String topicName; @@ -37,6 +39,7 @@ public class SarLawsTopic implements Serializable { /** * 课题承办单位 */ + @CompareField(fieldName = "课题承办单位") @ApiModelProperty(value = "课题承办单位") @TableField(value = "ORGANIZER") private String organizer; @@ -44,6 +47,7 @@ public class SarLawsTopic implements Serializable { /** * 课题指导单位 */ + @CompareField(fieldName = "课题指导单位") @ApiModelProperty(value = "课题指导单位") @TableField(value = "GUIDANCE_UNIT") private String guidanceUnit; @@ -51,6 +55,7 @@ public class SarLawsTopic implements Serializable { /** * 课题参与单位 */ + @CompareField(fieldName = "课题参与单位") @ApiModelProperty(value = "课题参与单位") @TableField(value = "PARTICIPATING_UNIT") private String participatingUnit; @@ -58,6 +63,7 @@ public class SarLawsTopic implements Serializable { /** * 开始时间 */ + @CompareField(fieldName = "启动时间") @ApiModelProperty(value = "启动时间") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @TableField(value = "START_TIME") @@ -66,6 +72,7 @@ public class SarLawsTopic implements Serializable { /** * 结题时间 */ + @CompareField(fieldName = "结题时间") @ApiModelProperty(value = "结题时间") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @TableField(value = "CLOSE_TIME") @@ -74,6 +81,7 @@ public class SarLawsTopic implements Serializable { /** * 课题状态 */ + @CompareField(fieldName = "课题状态") @ApiModelProperty(value = "课题状态") @TableField(value = "TOPIC_STATUS") private String topicStatus; @@ -81,6 +89,7 @@ public class SarLawsTopic implements Serializable { /** * 课题费用(万元) */ + @CompareField(fieldName = "课题费用") @ApiModelProperty(value = "课题费用") @TableField(value = "TOPIC_COST") private String topicCost; @@ -88,6 +97,7 @@ public class SarLawsTopic implements Serializable { /** * 协议 */ + @CompareField(fieldName = "协议文件") @ApiModelProperty("协议文件") @TableField(value = "AGREEMENT") private String agreement; @@ -99,6 +109,7 @@ public class SarLawsTopic implements Serializable { /** * 课题组会议列表 */ + @CompareField(fieldName = "课题组会议列表") @ApiModelProperty(value = "课题组会议列表") @TableField(exist = false) private List meetingList; @@ -106,6 +117,7 @@ public class SarLawsTopic implements Serializable { /** * 课题组研究方案 */ + @CompareField(fieldName = "课题研究方案") @ApiModelProperty(value = "课题研究方案") @TableField(value = "RESEARCH_PLAN") private String researchPlan; @@ -117,6 +129,7 @@ public class SarLawsTopic implements Serializable { /** * 课题组研究成果 */ + @CompareField(fieldName = "课题组研究成果") @ApiModelProperty(value = "课题组研究成果") @TableField(value = "RESEARCH_FINDINGS") private String researchFindings; @@ -131,6 +144,7 @@ public class SarLawsTopic implements Serializable { /** * 课题组其他 */ + @CompareField(fieldName = "课题组其他文件") @ApiModelProperty(value = "课题组其他文件") @TableField(value = "RESEARCH_GROUP_OTHER") private String researchGroupOther; @@ -142,6 +156,7 @@ public class SarLawsTopic implements Serializable { /** * 课题组会议资料 */ + @CompareField(fieldName = "课题组会议资料") @ApiModelProperty(value = "课题组会议资料") @TableField(value = "CONFERENCE_MATERIALS") private String conferenceMaterials; @@ -153,6 +168,7 @@ public class SarLawsTopic implements Serializable { /** * 课题组联系方式 */ + @CompareField(fieldName = "课题组联系方式") @ApiModelProperty(value = "课题组联系方式列表") @TableField(exist = false) private List topicContactInformationList; @@ -160,6 +176,7 @@ public class SarLawsTopic implements Serializable { /** * 内部资料立项报告 */ + @CompareField(fieldName = "内部资料立项报告") @ApiModelProperty(value = "内部资料立项报告") @TableField(value = "INSIDE_PROJECT_PROPOSAL_REPORT") private String insideProjectProposalRepost; @@ -171,6 +188,7 @@ public class SarLawsTopic implements Serializable { /** * 内部资料研究方案 */ + @CompareField(fieldName = "内部资料研究方案") @ApiModelProperty(value = "内部资料研究方案") @TableField(value = "INSIDE_RESEARCH_PLAN") private String insideResearchPlan; @@ -182,6 +200,7 @@ public class SarLawsTopic implements Serializable { /** * 内部资料会议资料 */ + @CompareField(fieldName = "内部资料会议资料") @ApiModelProperty(value = "内部资料会议资料") @TableField(value = "INSIDE_CONFERENCE_MATERIALS") private String insideConferenceMaterials; @@ -193,6 +212,7 @@ public class SarLawsTopic implements Serializable { /** * 内部会议研究成果 */ + @CompareField(fieldName = "内部会议研究成果") @ApiModelProperty(value = "内部会议研究成果") @TableField(value = "INSIDE_RESEARCH_FINDINGS") private String insideResearchFindings; @@ -204,6 +224,7 @@ public class SarLawsTopic implements Serializable { /** * 内部会议其他 */ + @CompareField(fieldName = "内部会议其他文件") @ApiModelProperty(value = "内部会议其他文件") @TableField(value = "INSIDE_OTHER") private String insideOther; @@ -215,6 +236,7 @@ public class SarLawsTopic implements Serializable { /** * 内部联系方式 */ + @CompareField(fieldName = "内部联系方式列表") @ApiModelProperty(value = "内部联系方式列表") @TableField(exist = false) private List insideContactInformationList; diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicExport.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicExport.java new file mode 100644 index 00000000..add71400 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicExport.java @@ -0,0 +1,87 @@ +package com.adc.da.slrs.sarLawsTopic.entity; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.afterturn.easypoi.excel.annotation.ExcelCollection; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author tjzdw + * @description + * @date 2023/11/23 + */ +@Data +public class SarLawsTopicExport { + /** + * 主键 + */ + private String id; + + /** + * 课题名称 + */ + @Excel(name = "课题名称", orderNum = "0", type = 1, needMerge = true) + private String topicName; + + /** + * 课题承办单位 + */ + @Excel(name = "课题承办单位", orderNum = "1",type = 1, needMerge = true) + private String organizer; + + /** + * 课题指导单位 + */ + @Excel(name = "课题指导单位", orderNum = "2", type = 1, needMerge = true) + private String guidanceUnit; + + /** + * 课题参与单位 + */ + @Excel(name = "课题参与单位", orderNum = "3", type = 1, needMerge = true) + private String participatingUnit; + + /** + * 开始时间 + */ + @Excel(name = "启动时间", orderNum = "4", exportFormat = "yyyy-MM-dd", needMerge = true) + private Date startTime; + + /** + * 结题时间 + */ + @Excel(name = "结题时间", orderNum = "5", exportFormat = "yyyy-MM-dd", needMerge = true) + private Date closeTime; + + /** + * 课题状态 + */ + @Excel(name = "课题状态", orderNum = "6", type = 1, needMerge = true) + private String topicStatus; + + /** + * 课题费用(万元) + */ + @Excel(name = "课题费用(万元)", orderNum = "7", type = 1, needMerge = true) + private String topicCost; + + /** + * 课题组会议列表 + */ + @ExcelCollection(name = "课题组会议列表", orderNum = "8") + private List meetingList; + + /** + * 课题组联系方式 + */ + @ExcelCollection(name = "课题组联系方式", orderNum = "9") + private List topicContactInformationList; + + /** + * 内部联系方式 + */ + @ExcelCollection(name = "内部联系方式", orderNum = "10") + private List insideContactInformationList; +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicMeeting.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicMeeting.java index cd7d6cde..95f2df21 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicMeeting.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicMeeting.java @@ -1,6 +1,7 @@ package com.adc.da.slrs.sarLawsTopic.entity; import cn.afterturn.easypoi.excel.annotation.Excel; +import com.adc.da.utils.annotation.CompareField; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import lombok.Data; +import org.apache.commons.lang3.StringUtils; /** * 政策课题组会议 @@ -31,6 +33,7 @@ public class SarLawsTopicMeeting implements Serializable { /** * 会议名称 */ + @CompareField(fieldName = "会议名称") @TableField(value = "MEETING_NAME") @Excel(name = "会议名称", orderNum = "0", type = 1) private String meetingName; @@ -38,6 +41,7 @@ public class SarLawsTopicMeeting implements Serializable { /** * 会议时间 */ + @CompareField(fieldName = "会议时间") @TableField(value = "MEETING_TIME") @Excel(name = "会议时间", orderNum = "1", type = 1) private String meetingTime; @@ -45,6 +49,7 @@ public class SarLawsTopicMeeting implements Serializable { /** * 会议地点 */ + @CompareField(fieldName = "会议地点") @TableField(value = "MEETING_ADDRESS") @Excel(name = "会议地点", orderNum = "2", type = 1) private String meetingAddress; @@ -52,6 +57,7 @@ public class SarLawsTopicMeeting implements Serializable { /** * 参会人员(内部) */ + @CompareField(fieldName = "参会人员(内部)") @TableField(value = "PARTICIPANTS") @Excel(name = "参会人员(内部)", orderNum = "3", type = 1) private String participants; @@ -59,10 +65,22 @@ public class SarLawsTopicMeeting implements Serializable { /** * 会议主要内容 */ + @CompareField(fieldName = "会议主要内容") @TableField(value = "MEETING_CONTENT") @Excel(name = "会议主要内容", orderNum = "4", type = 1) private String meetingContent; @TableField(exist = false) private static final long serialVersionUID = 1L; + + public static SarLawsTopicMeeting emptyValueProcess(SarLawsTopicMeeting sarLawsTopicMeeting) { + if (StringUtils.isBlank(sarLawsTopicMeeting.getMeetingName()) && + StringUtils.isBlank(sarLawsTopicMeeting.getMeetingTime()) && + StringUtils.isBlank(sarLawsTopicMeeting.getMeetingAddress()) && + StringUtils.isBlank(sarLawsTopicMeeting.getParticipants()) && + StringUtils.isBlank(sarLawsTopicMeeting.getMeetingContent())) { + return null; + } + return sarLawsTopicMeeting; + } } \ No newline at end of file diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicVO.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicVO.java index 9ac842d3..badde501 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicVO.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicVO.java @@ -30,13 +30,13 @@ public class SarLawsTopicVO extends BasePage { /** * 课题名称 */ - @Excel(name = "课题名称", orderNum = "0", type = 1, needMerge = true) + @Excel(name = "*课题名称", orderNum = "0", type = 1, needMerge = true) private String topicName; /** * 课题承办单位 */ - @Excel(name = "课题承办单位", orderNum = "1",type = 1, needMerge = true) + @Excel(name = "*课题承办单位", orderNum = "1",type = 1, needMerge = true) private String organizer; /** @@ -56,7 +56,7 @@ public class SarLawsTopicVO extends BasePage { */ @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") - @Excel(name = "启动时间", orderNum = "4", exportFormat = "yyyy-MM-dd", needMerge = true) + @Excel(name = "*启动时间", orderNum = "4", exportFormat = "yyyy-MM-dd", needMerge = true) private Date startTime; /** @@ -82,6 +82,7 @@ public class SarLawsTopicVO extends BasePage { /** * 协议 */ + @Excel(name = "协议", orderNum = "8", type = 1, needMerge = true) private String agreement; private List agreementList; @@ -89,7 +90,7 @@ public class SarLawsTopicVO extends BasePage { /** * 课题组会议列表 */ - @ExcelCollection(name = "课题组会议列表", orderNum = "8") + @ExcelCollection(name = "课题组会议列表", orderNum = "9") private List meetingList; /** @@ -123,6 +124,7 @@ public class SarLawsTopicVO extends BasePage { /** * 课题组研究方案 */ + @Excel(name = "课题组研究方案", orderNum = "10",type = 1, needMerge = true) private String researchPlan; private List researchPlanList; @@ -130,6 +132,7 @@ public class SarLawsTopicVO extends BasePage { /** * 课题组研究成果 */ + @Excel(name = "课题组研究成果", orderNum = "11",type = 1, needMerge = true) private String researchFindings; private List researchFindingsList; @@ -137,6 +140,7 @@ public class SarLawsTopicVO extends BasePage { /** * 课题组其他 */ + @Excel(name = "课题组其他", orderNum = "12",type = 1, needMerge = true) private String researchGroupOther; private List researchGroupOtherList; @@ -144,6 +148,7 @@ public class SarLawsTopicVO extends BasePage { /** * 课题组会议资料 */ + @Excel(name = "课题组会议资料", orderNum = "13",type = 1, needMerge = true) private String conferenceMaterials; private List conferenceMaterialsList; @@ -151,7 +156,7 @@ public class SarLawsTopicVO extends BasePage { /** * 课题组联系方式 */ - @ExcelCollection(name = "课题组联系方式", orderNum = "9") + @ExcelCollection(name = "课题组联系方式", orderNum = "14") private List topicContactInformationList; // 课题组用户名称 @@ -168,6 +173,7 @@ public class SarLawsTopicVO extends BasePage { /** * 内部资料立项报告 */ + @Excel(name = "内部立项报告", orderNum = "15", needMerge = true) private String insideProjectProposalRepost; private List insideProjectProposalRepostList; @@ -175,6 +181,7 @@ public class SarLawsTopicVO extends BasePage { /** * 内部资料研究方案 */ + @Excel(name = "内部研究方案", orderNum = "16", needMerge = true) private String insideResearchPlan; private List insideResearchPlanList; @@ -182,6 +189,7 @@ public class SarLawsTopicVO extends BasePage { /** * 内部资料会议资料 */ + @Excel(name = "内部会议资料", orderNum = "17", needMerge = true) private String insideConferenceMaterials; private List insideConferenceMaterialsList; @@ -189,6 +197,7 @@ public class SarLawsTopicVO extends BasePage { /** * 内部会议研究成果 */ + @Excel(name = "内部研究成果", orderNum = "18", needMerge = true) private String insideResearchFindings; private List insideResearchFindingsList; @@ -196,6 +205,7 @@ public class SarLawsTopicVO extends BasePage { /** * 内部会议其他 */ + @Excel(name = "内部其他", orderNum = "19", needMerge = true) private String insideOther; private List insideOtherList; @@ -203,7 +213,7 @@ public class SarLawsTopicVO extends BasePage { /** * 内部联系方式 */ - @ExcelCollection(name = "内部联系方式", orderNum = "10") + @ExcelCollection(name = "内部联系方式", orderNum = "20") private List insideContactInformationList; // 内部人员名称 @@ -234,13 +244,13 @@ public class SarLawsTopicVO extends BasePage { @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") private Date modifyTime; - private String sortField = "ID"; + private String sortField = "startTime"; - private String sortMode = "asc"; + private String sortMode = "desc"; // 排序字段 - private Date startTimeBegin; - private Date startTimeEnd; + private String startTimeBegin; + private String startTimeEnd; // 导出使用的属性 // 导出文件名 diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/SarLawsTopicMeetingService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/SarLawsTopicMeetingService.java index 0b79192f..e449f900 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/SarLawsTopicMeetingService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/SarLawsTopicMeetingService.java @@ -3,6 +3,8 @@ package com.adc.da.slrs.sarLawsTopic.service; import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicMeeting; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** * @author tjzdw * @description 针对表【sar_laws_topic_meeting(政策课题组会议)】的数据库操作Service @@ -10,4 +12,6 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface SarLawsTopicMeetingService extends IService { + public List compareTopicMeeting(SarLawsTopicMeeting oldTopicMeeting, SarLawsTopicMeeting newTopicMeeting); + } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/SarLawsTopicService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/SarLawsTopicService.java index bd9b409c..ec72bf88 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/SarLawsTopicService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/SarLawsTopicService.java @@ -1,7 +1,6 @@ package com.adc.da.slrs.sarLawsTopic.service; import com.adc.da.http.ResponseMessage; -import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation; import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopic; import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicVO; import com.baomidou.mybatisplus.extension.service.IService; @@ -30,5 +29,5 @@ public interface SarLawsTopicService extends IService { List getAllLawsTopic(SarLawsTopicVO sarLawsTopicVO); - ResponseMessage importLawsTopicInfo(MultipartFile file); + ResponseMessage importLawsTopicInfo(MultipartFile file) throws Exception; } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicMeetingServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicMeetingServiceImpl.java index c694e6ba..7d9e7683 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicMeetingServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicMeetingServiceImpl.java @@ -1,11 +1,17 @@ package com.adc.da.slrs.sarLawsTopic.service.impl; +import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopic; +import com.adc.da.utils.annotation.CompareField; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicMeeting; import com.adc.da.slrs.sarLawsTopic.service.SarLawsTopicMeetingService; import com.adc.da.slrs.sarLawsTopic.dao.SarLawsTopicMeetingMapper; import org.springframework.stereotype.Service; +import java.lang.reflect.Field; +import java.text.SimpleDateFormat; +import java.util.*; + /** * @author tjzdw * @description 针对表【sar_laws_topic_meeting(政策课题组会议)】的数据库操作Service实现 @@ -15,6 +21,35 @@ import org.springframework.stereotype.Service; public class SarLawsTopicMeetingServiceImpl extends ServiceImpl implements SarLawsTopicMeetingService{ + public List compareTopicMeeting(SarLawsTopicMeeting oldTopicMeeting, SarLawsTopicMeeting newTopicMeeting) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + List changes = new ArrayList<>(); + // 获取TopicMeeting类的所有字段 + Field[] fields = SarLawsTopic.class.getDeclaredFields(); + for (Field field : fields) { + boolean annotationPresent = field.isAnnotationPresent(CompareField.class); + if (annotationPresent) { + try { + field.setAccessible(true); + Object oldValue = field.get(oldTopicMeeting); + Object newValue = field.get(newTopicMeeting); + if (oldValue instanceof Date && newValue instanceof Date) { + oldValue = sdf.format((Date)oldValue); + newValue = sdf.format((Date)newValue); + } + if (!Objects.equals(oldValue, newValue)) { + // 对比其他字段 + CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0]; + changes.add(annotationsByType.fieldName() + "由\"" + oldValue + "\"改为\"" + newValue + "\""); + } + } catch (IllegalAccessException e) { + // 处理异常 + e.printStackTrace(); + } + } + } + return changes; + } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicServiceImpl.java index c8fad2fb..9c0456e0 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicServiceImpl.java @@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil; import cn.afterturn.easypoi.excel.entity.ImportParams; import com.adc.da.att.entity.AttFileEO; import com.adc.da.att.service.impl.AttFileEOServiceImpl; +import com.adc.da.att.vo.AttFileVo; import com.adc.da.common.FileUnZip; import com.adc.da.http.ResponseMessage; import com.adc.da.http.Result; @@ -16,6 +17,7 @@ import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog; import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService; import com.adc.da.util.LoginUserUtil; import com.adc.da.util.UUIDUtils; +import com.adc.da.utils.annotation.CompareField; import com.adc.da.utils.util.FieldConvertUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -24,12 +26,11 @@ import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopic; import com.adc.da.slrs.sarLawsTopic.service.SarLawsTopicService; import com.adc.da.slrs.sarLawsTopic.dao.SarLawsTopicMapper; import io.swagger.annotations.ApiModelProperty; +import lombok.Cleanup; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.*; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -37,11 +38,11 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; -import java.io.File; -import java.io.IOException; +import java.io.*; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -149,6 +150,7 @@ public class SarLawsTopicServiceImpl extends ServiceImpl sarLawsTopicVOList = this.baseMapper.queryByPage(page); for (SarLawsTopicVO lawsTopicVO : sarLawsTopicVOList) { @@ -237,7 +239,7 @@ public class SarLawsTopicServiceImpl extends ServiceImpl importLawsTopicInfo(MultipartFile file) { + public ResponseMessage importLawsTopicInfo(MultipartFile file) throws Exception { //获取文件全称 String fileNameStr = file.getOriginalFilename(); //获取最后.的位置 @@ -263,6 +265,7 @@ public class SarLawsTopicServiceImpl extends ServiceImpl fileList = readImpExcelFile(zipEntryName); //判断获取到的文件数量 - if (fileList.size() != 1) { - return Result.error("上传的文件只能有一个"); + if (fileList.size() < 1) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("上传的文件不能为空"); } - File importFile = fileList.get(0); - if (!importFile.getName().contains(".xls") && !importFile.getName().contains(".xlsx")) { - return Result.error("文件必须是EXCEL文件"); + File excelFile = null; + int excelCount = 0; + // 将文件转换为Map,文件名为建,文件为值 + Map fileMap = new HashMap<>(); + for (File file1 : fileList) { + fileMap.put(file1.getName(), file1); + if (file1.getName().toLowerCase().contains(".xls") || file1.getName().toLowerCase().contains(".xlsx")) { + excelFile = file1; + excelCount ++; + } + } + if (excelCount > 1) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("导入了多个Excel文件"); + } + if (excelCount < 1){ + FileUnZip.deleteDir(saveDirectory); + return Result.error("文件必须包含一个EXCEL文件"); } Workbook workbook = null; try { - workbook = WorkbookFactory.create(importFile); + workbook = WorkbookFactory.create(excelFile); } catch (IOException e) { FileUnZip.deleteDir(saveDirectory); - return Result.error("导入失败,需要导入的数据有问题或导入的企标标号和企标名称已存在"); + return Result.error("导入失败,需要导入的数据有问题"); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Sheet sheet = workbook.getSheetAt(0); if (sheet == null) { return Result.error("工作表为空"); } - StringBuilder sb = new StringBuilder(); + // 获取excel表头 List headerList = new ArrayList<>(); Row headerRow = sheet.getRow(1); - for (int i = 0; i < 22; i++) { - headerList.add(headerRow.getCell(i).getStringCellValue()); - } - // 获取关联表表头 - Row relationRow = sheet.getRow(2); - List relationList = new ArrayList<>(); - for (int i = 7; i < 22; i++) { - relationList.add(relationRow.getCell(i).getStringCellValue()); + List relationList = null; + try { + for (int i = 0; i < 8; i++) { + headerList.add(headerRow.getCell(i).getStringCellValue()); + } + for (int i = 13; i < 17; i++) { + headerList.add(headerRow.getCell(i).getStringCellValue()); + } + for (int i = 22; i < 27; i++) { + headerList.add(headerRow.getCell(i).getStringCellValue()); + } + // 获取关联表表头 + Row relationRow = sheet.getRow(2); + relationList = new ArrayList<>(); + for (int i = 8; i < 13; i++) { + relationList.add(relationRow.getCell(i).getStringCellValue()); + } + for (int i = 17; i < 22; i++) { + relationList.add(relationRow.getCell(i).getStringCellValue()); + } + for (int i = 27; i < 32; i++) { + relationList.add(relationRow.getCell(i).getStringCellValue()); + } + } catch (Exception e) { + return Result.error("表头读取失败,请严格按照模板文件导入数据"); + }finally { + FileUnZip.deleteDir(saveDirectory); } // 判断表头字段是否相同 if (!String.join(",",headerList).equals(FieldConvertUtil.exportFieldLawsTopic) - && !String.join(",",relationList).equals(FieldConvertUtil.exportFieldLawsTopicRelation)) { + || !String.join(",",relationList).equals(FieldConvertUtil.exportFieldLawsTopicRelation)) { try { workbook.close(); } catch (IOException e) { @@ -322,23 +361,159 @@ public class SarLawsTopicServiceImpl extends ServiceImpl> importDataList = new ArrayList<>(); + for (int rowIndex = 3; rowIndex < rowNum; rowIndex++) { + // 获取每一行 + Row row = sheet.getRow(rowIndex); + // 用于存储每行的键值对数据,对应一条数据 + Map rowMap = new LinkedHashMap<>(); + // 总列数 + int columnNum = 32; + // 遍历每个单元格 + for (int columnIndex = 0; columnIndex < columnNum; columnIndex++) { + // 获取单元格 + Cell cell = row.getCell(columnIndex); + // 获取表头单元格 + Cell headerCell = headerRow.getCell(columnIndex); + if (cell != null) { + if (CellType.NUMERIC == cell.getCellType() && HSSFDateUtil.isCellDateFormatted(cell)) { + Date d = cell.getDateCellValue(); + try { + if (d.before(sdf.parse("1900-01-01")) || d.after(sdf.parse("2500-01-01"))) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("第"+(rowIndex-1)+"行第"+(columnIndex + 1)+"个单元格输入的日期异常,请按照实际日期填写"); + } + } catch (ParseException e) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("第"+(rowIndex-1)+"行第"+(columnIndex + 1)+"个单元格输入的日期异常,请按照实际日期填写"); + } + // 将单元格数据存入Map中 + rowMap.put(headerCell.getStringCellValue(), sdf.format(d)); + } else { + cell.setCellType(CellType.STRING); + if (cell.getStringCellValue().length() > 500) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("第"+(rowIndex-1)+"行第"+(columnIndex + 1)+"个单元格输入过长"); + } + rowMap.put(headerCell.getStringCellValue(), cell.getStringCellValue()); + } + } else { + rowMap.put(headerCell.getStringCellValue(), ""); + } + } + importDataList.add(rowMap); + } + if (importDataList.size() < 1) { + FileUnZip.deleteDir(saveDirectory); + return Result.error("您输入的数据为空"); + } + ImportParams importParams = new ImportParams(); importParams.setTitleRows(1); importParams.setHeadRows(2); - List lawsTopicVOList = ExcelImportUtil.importExcel(readImpExcelFile(zipEntryName).get(0), SarLawsTopicVO.class, importParams); - // 去除空数据 - for (SarLawsTopicVO lawsTopicVO : lawsTopicVOList) { - if (StringUtils.isNotBlank(lawsTopicVO.getTopicName())) { - // 存入数据库 - SarLawsTopic sarLawsTopic = new SarLawsTopic(); - BeanUtils.copyProperties(lawsTopicVO,sarLawsTopic); - if (sarLawsTopic.getStartTime() != null && sarLawsTopic.getCloseTime() != null) { - sarLawsTopic.setTopicStatus("已结题"); - } else { - sarLawsTopic.setTopicStatus("进行中"); +// @Cleanup + InputStream inputStream = new FileInputStream(excelFile); + List lawsTopicVOList = ExcelImportUtil.importExcel(inputStream, SarLawsTopicVO.class, importParams); + workbook.close(); + inputStream.close(); + FileUnZip.delete(excelFile); + try{ + // 去除空数据 + int index = 1; + for (SarLawsTopicVO lawsTopicVO : lawsTopicVOList) { + if (StringUtils.isNotBlank(lawsTopicVO.getTopicName())) { + // 存入数据库 + SarLawsTopic sarLawsTopic = new SarLawsTopic(); + BeanUtils.copyProperties(lawsTopicVO,sarLawsTopic); + if (StringUtils.isBlank(sarLawsTopic.getOrganizer())) { + return Result.error("第" + index + "条记录的课题承办单位不能为空"); + } + if (sarLawsTopic.getStartTime() == null) { + return Result.error("第" + index + "条记录的启动时间不能为空"); + } + if (sarLawsTopic.getStartTime() != null && sarLawsTopic.getCloseTime() != null) { + sarLawsTopic.setTopicStatus("已结题"); + } else { + sarLawsTopic.setTopicStatus("进行中"); + } + String agreementFileAtt = null; + try { + agreementFileAtt = getFileAtt("协议",sarLawsTopic.getAgreement(), fileMap, index); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + sarLawsTopic.setAgreement(agreementFileAtt); + String researchPlanFileAtt = null; + try { + researchPlanFileAtt = getFileAtt("课题组研究方案",sarLawsTopic.getResearchPlan(), fileMap, index); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + sarLawsTopic.setResearchPlan(researchPlanFileAtt); + String researchFindingsFileAtt = null; + try { + researchFindingsFileAtt = getFileAtt("课题组研究成果",sarLawsTopic.getResearchFindings(), fileMap, index); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + sarLawsTopic.setResearchFindings(researchFindingsFileAtt); + String researchGroupOtherFileAtt = null; + try { + researchGroupOtherFileAtt = getFileAtt("课题组其他",sarLawsTopic.getResearchGroupOther(), fileMap, index); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + sarLawsTopic.setResearchGroupOther(researchGroupOtherFileAtt); + String conferenceMaterialsFileAtt = null; + try { + conferenceMaterialsFileAtt = getFileAtt("课题组会议资料",sarLawsTopic.getConferenceMaterials(), fileMap, index); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + sarLawsTopic.setConferenceMaterials(conferenceMaterialsFileAtt); + String insideProjectProposalRepostFileAtt = null; + try { + insideProjectProposalRepostFileAtt = getFileAtt("内部立项报告",sarLawsTopic.getInsideProjectProposalRepost(), fileMap, index); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + sarLawsTopic.setInsideProjectProposalRepost(insideProjectProposalRepostFileAtt); + String insideResearchPlanFileAtt = null; + try { + insideResearchPlanFileAtt = getFileAtt("内部研究方案",sarLawsTopic.getInsideResearchPlan(), fileMap, index); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + sarLawsTopic.setInsideResearchPlan(insideResearchPlanFileAtt); + String insideConferenceMaterialsFileAtt = null; + try { + insideConferenceMaterialsFileAtt = getFileAtt("内部会议资料",sarLawsTopic.getInsideConferenceMaterials(), fileMap, index); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + sarLawsTopic.setInsideConferenceMaterials(insideConferenceMaterialsFileAtt); + String insideResearchFindingsFileAtt = null; + try { + insideResearchFindingsFileAtt = getFileAtt("内部研究成果",sarLawsTopic.getInsideResearchFindings(), fileMap, index); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + sarLawsTopic.setInsideResearchFindings(insideResearchFindingsFileAtt); + String insideOtherFileAtt = null; + try { + insideOtherFileAtt = getFileAtt("内部其他",sarLawsTopic.getInsideOther(), fileMap, index); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + sarLawsTopic.setInsideOther(insideOtherFileAtt); + addLawsTopicInfo(sarLawsTopic); } - addLawsTopicInfo(sarLawsTopic); + index++; } + }finally { + FileUnZip.deleteDir(saveDirectory); } return Result.success("导入成功"); } @@ -356,7 +531,9 @@ public class SarLawsTopicServiceImpl extends ServiceImpl fileList = new ArrayList<>(); for (String attId : fileAttId.split(",")) { AttFileEO fileInfo = attFileEOService.getFileInfo(attId); - fileList.add(fileInfo); + if (fileInfo != null) { + fileList.add(fileInfo); + } } String setMethod = "set" + StringUtils.capitalize(field) + "List"; method = SarLawsTopic.class.getMethod(setMethod, List.class); @@ -380,7 +557,9 @@ public class SarLawsTopicServiceImpl extends ServiceImpl fileList = new ArrayList<>(); for (String attId : fileAttId.split(",")) { AttFileEO fileInfo = attFileEOService.getFileInfo(attId); - fileList.add(fileInfo); + if (fileInfo != null) { + fileList.add(fileInfo); + } } String setMethod = "set" + StringUtils.capitalize(field) + "List"; method = SarLawsTopicVO.class.getMethod(setMethod, List.class); @@ -399,23 +578,27 @@ public class SarLawsTopicServiceImpl extends ServiceImpl compareLawsTopic(SarLawsTopic oldLawsTopic, SarLawsTopic newLawsTopic) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); List changes = new ArrayList<>(); - // 不需要比较的字段 - String[] ignoreFields = {"id","validFlag","createTime","modifyTime","agreementList","researchPlanList", - "researchFindingsList","researchGroupOtherList","conferenceMaterialsList","insideProjectProposalRepostList", - "insideResearchPlanList","insideConferenceMaterialsList","insideResearchFindingsList","insideOtherList","serialVersionUID"}; + // 文件字段 String[] fileAttIdFields = {"agreement","researchPlan","researchFindings","researchGroupOther","conferenceMaterials", "insideProjectProposalRepost","insideResearchPlan","insideConferenceMaterials","insideResearchFindings","insideOther"}; - List ignoreFieldList = Arrays.asList(ignoreFields); List fileAttIdFieldList = Arrays.asList(fileAttIdFields); // 获取SarLawsTopic类的所有字段 Field[] fields = SarLawsTopic.class.getDeclaredFields(); for (Field field : fields) { - if (!ignoreFieldList.contains(field.getName())) { + boolean annotationPresent = field.isAnnotationPresent(CompareField.class); + if (annotationPresent) { try { field.setAccessible(true); Object oldValue = field.get(oldLawsTopic); Object newValue = field.get(newLawsTopic); + if (oldValue instanceof Date){ + oldValue = sdf.format((Date)oldValue); + } + if( newValue instanceof Date) { + newValue = sdf.format((Date)newValue); + } if (!Objects.equals(oldValue, newValue)) { // 对比文件字段 if (fileAttIdFieldList.contains(field.getName())) { @@ -442,31 +625,34 @@ public class SarLawsTopicServiceImpl extends ServiceImpl oldList = (List) oldInvoke; + List newList = (List) newInvoke; + if (!isListEqual(oldList, newList)) { + CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0]; + changes.add(annotationsByType.fieldName() + "被变更"); } - if (oldValue!= null) { - Date newDate = (Date) oldValue; - newDateStr = sdf.format(newDate); - } - changes.add(annotationsByType.value() + "由\"" + oldDateStr + "\"改为\"" + newDateStr + "\""); - }else { + } else { // 对比其他字段 - ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0]; - changes.add(annotationsByType.value() + "由\"" + oldValue + "\"改为\"" + newValue + "\""); + CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0]; + changes.add(annotationsByType.fieldName() + "由\"" + Optional.ofNullable(oldValue).orElse("空") + "\"改为\"" + Optional.ofNullable(newValue).orElse("空") + "\""); } } } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { @@ -494,6 +680,75 @@ public class SarLawsTopicServiceImpl extends ServiceImpl fileMap, int count) throws Exception { + if (fileNameStr != null) { + List fileAttList = new ArrayList<>(); + for (String fileName : fileNameStr.split(",")) { + int lastIndexOf = fileName.lastIndexOf("."); + if (fileName.lastIndexOf(".") != -1) { + String lastName = fileName.substring(lastIndexOf + 1).toLowerCase(); + if (lastName.equals("pdf") || lastName.equals("ppt") || lastName.equals("pptx") || lastName.equals("doc") || lastName.equals("docx")) { + File file1 = fileMap.get(fileName); + if (file1 == null) { + throw new Exception(fieldName + "中第" + (count+1) +"行" + fileName + "文件不存在,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + AttFileVo attFileVo = attFileEOService.saveFileInfo(file1); + if (StringUtils.isNotBlank(attFileVo.getId())) { + fileAttList.add(attFileVo.getAttId()); + } + } else { + throw new Exception(fieldName + "中第" + (count+1) +"行" + fileName + "文件格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + } else { + throw new Exception(fieldName + "中第" + (count+1) +"行" + fileName + "文件格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + } + return String.join(",", fileAttList); + } + return null; + } + + + public boolean isListEqual(List l0, List l1){ + if (l0 == l1) + return true; + if (l0 == null && l1 == null) + return true; + if (l0 == null || l1 == null) + return false; + if (l1.size() > 0) { + Iterator iterator = l1.iterator(); + while(iterator.hasNext()) { + Object iterato = iterator.next(); + if (iterato instanceof SarLawsTopicMeeting) { + SarLawsTopicMeeting oldMeeting = (SarLawsTopicMeeting) iterato; + SarLawsTopicMeeting meeting = SarLawsTopicMeeting.emptyValueProcess(oldMeeting); + if (meeting == null) { + iterator.remove(); + } + } + if (iterato instanceof SarLawsContactInformation) { + SarLawsContactInformation oldContactInformation = (SarLawsContactInformation) iterato; + SarLawsContactInformation information = SarLawsContactInformation.emptyValueProcess(oldContactInformation); + if (information == null) { + iterator.remove(); + } + } + } + } + if (l0.size() != l1.size()) + return false; + for (Object o : l0) { + if (!l1.contains(o)) + return false; + } + for (Object o : l1) { + if (!l0.contains(o)) + return false; + } + return true; + } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/controller/SarMenuStandardNewController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/controller/SarMenuStandardNewController.java index 95a63b1f..86e8a179 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/controller/SarMenuStandardNewController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/controller/SarMenuStandardNewController.java @@ -1,34 +1,38 @@ package com.adc.da.slrs.sarMenuStandard.controller; - import com.adc.da.base.web.BaseController; import com.adc.da.http.ResponseMessage; import com.adc.da.http.Result; import com.adc.da.slrs.sarMenuStandard.entity.SarMenuStandardNew; +import com.adc.da.slrs.sarMenuStandard.entity.StandSystemDTO; import com.adc.da.slrs.sarMenuStandard.service.ISarMenuStandardNewService; import com.adc.da.slrs.sarUser.service.ITsUserService; import com.adc.da.sys.sarMenuStandard.entity.SarMenuStandard; import com.adc.da.util.LoginUserUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; /** -*

- * 前端控制器 - *

-* -* @author super_liu -* @since 2021-07-07 -*/ + *

+ * 前端控制器 + *

+ * + * @author super_liu + * @since 2021-07-07 + */ @RestController @Api(tags = "福田标准法规--标准法规库-菜单标准体系") @RequestMapping("/${restPath}/lawss/sarMenuStandardLimit") +@Slf4j public class SarMenuStandardNewController extends BaseController { @Autowired @@ -39,16 +43,16 @@ public class SarMenuStandardNewController extends BaseController getTopMenu(SarMenuStandardNew sarMenuStandardNew){ - String tsResources= iSarMenuStandardNewService.getTopMenu(sarMenuStandardNew); + public ResponseMessage getTopMenu(SarMenuStandardNew sarMenuStandardNew) { + String tsResources = iSarMenuStandardNewService.getTopMenu(sarMenuStandardNew); return Result.success(tsResources); } @ApiOperation("查询有权限资源") @GetMapping("/getListStandLimit") - public ResponseMessage> getListStandLimit(SarMenuStandardNew sarMenuStandardNew){ + public ResponseMessage> getListStandLimit(SarMenuStandardNew sarMenuStandardNew) { List access = tsUserService.getResourceUserId(LoginUserUtil.getUserId()); - List tsResources= iSarMenuStandardNewService.getListStandLimit(sarMenuStandardNew,access); + List tsResources = iSarMenuStandardNewService.getListStandLimit(sarMenuStandardNew, access); return Result.success(tsResources); } @@ -64,7 +68,7 @@ public class SarMenuStandardNewController extends BaseController getMenuStandardById(@RequestParam String menuId){ + public ResponseMessage getMenuStandardById(@RequestParam String menuId) { if (StringUtils.isBlank(menuId)) { return Result.error("获取失败,菜单ID为空"); } @@ -86,6 +90,27 @@ public class SarMenuStandardNewController extends BaseController standardSystemTree() { + return Result.success(iSarMenuStandardNewService.standardSystemTree()); + } + + @ApiOperation("法规弹窗列表") + @PostMapping("/standardSystemList") + public ResponseMessage standardSystemList(@RequestBody StandSystemDTO standSystemDTO) { + return Result.success(iSarMenuStandardNewService.standardSystemList(standSystemDTO)); + } + + @ApiOperation("法规列表弹窗Excel导出") + @GetMapping("/standardSystemListExport") + public ResponseMessage standardSystemListExport(StandSystemDTO standSystemDTO, + HttpServletResponse response, HttpServletRequest request) { + iSarMenuStandardNewService.standardSystemListExport(standSystemDTO, response, request); + return Result.success(); } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/entity/SarMenuStandardNew.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/entity/SarMenuStandardNew.java index 452e55ae..9a067161 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/entity/SarMenuStandardNew.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/entity/SarMenuStandardNew.java @@ -7,6 +7,7 @@ import com.adc.da.sys.utils.treetool.annotation.TreeNodeParentId; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -30,6 +31,7 @@ import java.util.List; @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) @ApiModel(value="SarMenuStandard对象", description="") +@TableName("sar_menu_standard") public class SarMenuStandardNew extends BaseEntity { public interface update{ } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/entity/StandCategoryEnum.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/entity/StandCategoryEnum.java new file mode 100644 index 00000000..ce8c946d --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/entity/StandCategoryEnum.java @@ -0,0 +1,85 @@ +package com.adc.da.slrs.sarMenuStandard.entity; + +import com.adc.da.exception.AdcDaBaseException; + +/** + * @author: Mzaxd + * @Date: 2023/11/15 17:36 + */ +public enum StandCategoryEnum { + // INLAND 类型的枚举实例 + INLAND_GB("INLAND", "GB", 0), + INLAND_GBT("INLAND", "GB/T", 1), + INLAND_QCT("INLAND", "QC/T", 2), + INLAND_JT("INLAND", "JT", 3), + INLAND_JB("INLAND", "JB", 4), + INLAND_GA("INLAND", "GA", 5), + INLAND_GJB("INLAND", "GJB", 6), + INLAND_HJ("INLAND", "HJ", 7), + + // FOREIGN 类型的枚举实例 + FOREIGN_ECE("FOREIGN", "ECE", 0), + FOREIGN_EU("FOREIGN", "EU", 1), + FOREIGN_EC("FOREIGN", "EC", 2), + FOREIGN_EEC("FOREIGN", "EEC", 3), + FOREIGN_ISO("FOREIGN", "ISO", 4), + FOREIGN_IEC("FOREIGN", "IEC", 5), + FOREIGN_GTR("FOREIGN", "GTR", 6), + FOREIGN_CFR("FOREIGN", "CFR", 7), + FOREIGN_JASO("FOREIGN", "JASO", 8), + FOREIGN_JIS("FOREIGN", "JIS", 9), + FOREIGN_GSO("FOREIGN", "GSO", 10), + FOREIGN_GOST("FOREIGN", "GOST", 11), + FOREIGN_ΓOCT("FOREIGN", "ΓOCT", 12), + FOREIGN_TP("FOREIGN", "TP", 13), + FOREIGN_SASO("FOREIGN", "SASO", 14), + FOREIGN_UAE("FOREIGN", "UAE", 15), + FOREIGN_CONTRAN("FOREIGN", "CONTRAN", 16), + FOREIGN_DENATRAN("FOREIGN", "DENATRAN", 17), + FOREIGN_ABNT_NBR("FOREIGN", "ABNT NBR", 18), + FOREIGN_NBR("FOREIGN", "NBR", 19), + FOREIGN_INMETRO("FOREIGN", "INMETRO", 20), + FOREIGN_CONAMA("FOREIGN", "CONAMA", 21), + FOREIGN_Normative_Instruction("FOREIGN", "Normative Instruction", 22), + FOREIGN_ADR("FOREIGN", "ADR", 23), + ; + + private final String standType; + private final String standSort; + private final int sortValue; + + StandCategoryEnum(String standType, String standSort, int sortValue) { + this.standType = standType; + this.standSort = standSort; + this.sortValue = sortValue; + } + + // 根据 standSort 返回 value 的静态方法 + public static int getSortByStandType(String standType, String standSort) { + for (StandCategoryEnum category : StandCategoryEnum.values()) { + if (category.getStandType().equals(standType) && category.getStandSort().equals(standSort)) { + return category.getSortValue(); + } + // 给国标 外标默认值 + if (category.getStandType().equals("INLAND")) { + return 8; + } else if (category.getStandType().equals("FOREIGN")) { + return 24; + } + } + throw new AdcDaBaseException("标准类型错误"); + } + + // Getter 方法 + public String getStandType() { + return standType; + } + + public String getStandSort() { + return standSort; + } + + public int getSortValue() { + return sortValue; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/entity/StandSystemDTO.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/entity/StandSystemDTO.java new file mode 100644 index 00000000..e599c3a5 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/entity/StandSystemDTO.java @@ -0,0 +1,202 @@ +package com.adc.da.slrs.sarMenuStandard.entity; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.hutool.core.util.StrUtil; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import org.springframework.format.annotation.DateTimeFormat; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +/** + * @author: Mzaxd + * @Date: 2023/11/14 17:20 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class StandSystemDTO { + + @ApiModelProperty(value = "节点Id") + private String menuId; + + @Excel(name = "体系结构", width = 40, orderNum = "1") + @ApiModelProperty(value = "体系结构") + private String standSystem; + + @ApiModelProperty(value = "体系结构ID(树状结构选取)") + private String standSystemId; + + @ApiModelProperty(value = "体系结构IDList(树状结构选取)") + private List standSystemIdList; + + @ApiModelProperty(value = "标准Id") + private String standId; + + @Excel(name = "标准编号", width = 25, orderNum = "2") + @ApiModelProperty(value = "标准编号") + private String standNo; + + @Excel(name = "标准名称", width = 25, orderNum = "3") + @ApiModelProperty(value = "标准名称") + private String standName; + + @ApiModelProperty(value = "标准状态") + private String standState; + + @ApiModelProperty(value = "文本状态") + private String textStatus; + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ApiModelProperty(value = "开始发布日期") + private Date startReleaseDate; + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ApiModelProperty(value = "开始发布日期字符串") + private String startReleaseDateString; + + @Excel(name = "发布日期", width = 25, orderNum = "4", exportFormat = "yyyy-MM-dd") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ApiModelProperty(value = "发布日期") + private Date releaseDate; + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ApiModelProperty(value = "结束发布日期") + private Date endReleaseDate; + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ApiModelProperty(value = "结束发布日期字符串") + private String endReleaseDateString; + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ApiModelProperty(value = "开始实施日期") + private Date startImplementDate; + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ApiModelProperty(value = "开始实施日期") + private String startImplementDateString; + + @Excel(name = "实施日期", width = 25, orderNum = "5") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ApiModelProperty(value = "实施日期") + private String implementDate; + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ApiModelProperty(value = "结束实施日期") + private Date endImplementDate; + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ApiModelProperty(value = "结束实施日期") + private String endImplementDateString; + + @Excel(name = "代替标准", width = 25, orderNum = "5") + @ApiModelProperty(value = "代替标准") + private String replaceStandardNo; + + @Excel(name = "编制单位", width = 25, orderNum = "5") + @ApiModelProperty(value = "编制单位") + private String dept; + + @Excel(name = "起草人", width = 25, orderNum = "5") + @ApiModelProperty(value = "起草人") + private String draftUserName; + + @Excel(name = "数据来源", width = 25, orderNum = "5") + @ApiModelProperty(value = "数据来源") + private String dataSource; + + @ApiModelProperty(value = "排序字段") + private String sortField; + + @ApiModelProperty(value = "排序规则") + private String sortMode; + + @ApiModelProperty(value = "标准类型(数据排序用)") + private String standSort; + + private String selectIds; + + private List selectIdList; + + @ApiModelProperty(value = "页码") + private int page; + + @ApiModelProperty(value = "每页数量") + private int pageSize; + + @ApiModelProperty(value = "体系排序顺序号") + private int systemSort; + + @ApiModelProperty(value = "国标外表企标排序号") + private int standTypeSort; + + @ApiModelProperty(value = "标准类别排序号") + private int standCategorySort; + + @ApiModelProperty(value = "相关联的节点ID列表(数据库查询用)") + private List menuIdList; + + @ApiModelProperty(value = "导出文件名称") + private String exportName; + + public void setSelectIds(String selectIds) { + this.selectIds = selectIds; + this.selectIdList = java.util.Arrays.asList(selectIds.split(",")); + } + + public void setStartReleaseDate(Date startReleaseDate) { + this.startReleaseDate = startReleaseDate; + if (startReleaseDate != null) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + this.startReleaseDateString = sdf.format(startReleaseDate); + } + } + + public void setEndReleaseDate(Date endReleaseDate) { + this.endReleaseDate = endReleaseDate; + if (endReleaseDate != null) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + this.endReleaseDateString = sdf.format(endReleaseDate); + } + } + + public void setStartImplementDate(Date startImplementDate) { + this.startImplementDate = startImplementDate; + if (startImplementDate != null) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + this.startImplementDateString = sdf.format(startImplementDate); + } + } + + public void setEndImplementDate(Date endImplementDate) { + this.endImplementDate = endImplementDate; + if (endImplementDate != null) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + this.endImplementDateString = sdf.format(endImplementDate); + } + } + + public void setStandSystemId(String standSystemId) { + this.standSystemId = standSystemId; + if (StrUtil.isNotBlank(standSystemId)) { + this.standSystemIdList = java.util.Arrays.asList(standSystemId.split(",")); + } + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/ISarMenuStandardNewService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/ISarMenuStandardNewService.java index bbd48c1b..6e2a0472 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/ISarMenuStandardNewService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/ISarMenuStandardNewService.java @@ -1,9 +1,13 @@ package com.adc.da.slrs.sarMenuStandard.service; import com.adc.da.slrs.sarMenuStandard.entity.SarMenuStandardNew; +import com.adc.da.slrs.sarMenuStandard.entity.StandSystemDTO; import com.adc.da.sys.sarMenuStandard.entity.SarMenuStandard; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; /** @@ -26,7 +30,13 @@ public interface ISarMenuStandardNewService extends IService Integer updateMenuStandard(SarMenuStandardNew sarMenuStandardNew); - Integer deleteMenuStandard(String menuId); + void deleteMenuStandard(String menuId); SarMenuStandard getMenuStandardById(String menuId); + + List standardSystemTree(); + + IPage standardSystemList(StandSystemDTO standSystemDTO); + + void standardSystemListExport(StandSystemDTO standSystemDTO, HttpServletResponse response, HttpServletRequest request); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/impl/SarMenuStandardNewServiceNewImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/impl/SarMenuStandardNewServiceNewImpl.java index 630b7970..4c7e5156 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/impl/SarMenuStandardNewServiceNewImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/impl/SarMenuStandardNewServiceNewImpl.java @@ -1,33 +1,70 @@ package com.adc.da.slrs.sarMenuStandard.service.impl; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; +import cn.hutool.core.util.StrUtil; +import com.adc.da.common.ReadExcel; +import com.adc.da.exception.AdcDaBaseException; +import com.adc.da.scheduled.dao.SarStandardInfoDao; +import com.adc.da.slrs.sarBussStandMenu.dao.SarBussStandMenuDao; +import com.adc.da.slrs.sarBussStandMenu.entity.SarBussStandMenu; +import com.adc.da.slrs.sarBussStandMenu.service.ISarBussStandMenuService; +import com.adc.da.slrs.sarBussionessStand.dao.SarBussionessStandDao; +import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicVO; import com.adc.da.slrs.sarMenuStandard.dao.SarMenuStandardNewDao; import com.adc.da.slrs.sarMenuStandard.entity.SarMenuStandardNew; +import com.adc.da.slrs.sarMenuStandard.entity.StandCategoryEnum; +import com.adc.da.slrs.sarMenuStandard.entity.StandSystemDTO; import com.adc.da.slrs.sarMenuStandard.service.ISarMenuStandardNewService; import com.adc.da.slrs.sarResource.dao.TsResourceDao; import com.adc.da.slrs.sarRole.dao.TsRoleDao; +import com.adc.da.slrs.sarStandMenu.dao.SarStandMenuDao; +import com.adc.da.slrs.sarStandMenu.entity.SarStandMenu; +import com.adc.da.slrs.sarStandMenu.service.ISarStandMenuService; +import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo; +import com.adc.da.slrs.tsDictionaryType.entity.TsDicType; +import com.adc.da.slrs.tsDictionaryType.service.ITsDicTypeService; +import com.adc.da.slrs.tsRoleMeunData.dao.TsRoleMenuDataDao; +import com.adc.da.slrs.tsRoleMeunData.service.ITsRoleMenuDataService; import com.adc.da.sys.sarMenuStandard.dao.SarMenuStandardDao; import com.adc.da.sys.sarMenuStandard.entity.SarMenuStandard; +import com.adc.da.sys.sarMenuStandard.entity.StandMenuRelation; +import com.adc.da.sys.util.BeanCopyUtils; import com.adc.da.util.LoginUserUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.util.IOUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.OutputStream; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** *

- * 服务实现类 + * 服务实现类 *

* * @author super_liu * @since 2021-07-07 */ +@Slf4j @Service public class SarMenuStandardNewServiceNewImpl extends ServiceImpl implements ISarMenuStandardNewService { @@ -37,30 +74,48 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl list = dao.selectList(qw); - if(!list.isEmpty()){ - if(StringUtils.isNotBlank(list.get(0).getParentIds())){ + if (!list.isEmpty()) { + if (StringUtils.isNotBlank(list.get(0).getParentIds())) { List topIdList = Arrays.stream(list.get(0).getParentIds().split(",")).map(String::trim).collect(Collectors.toList()); QueryWrapper wrapper = new QueryWrapper(); - wrapper.in("ID",topIdList); - List topList = dao.selectTopList(wrapper,list.get(0).getParentIds()); + wrapper.in("ID", topIdList); + List topList = dao.selectTopList(wrapper, list.get(0).getParentIds()); List filterList = topList.stream().map(SarMenuStandard::getMenuName).collect(Collectors.toList()); - if(!filterList.isEmpty()){ - return StringUtils.join(filterList, "/")+'/'+list.get(0).getMenuName(); + if (!filterList.isEmpty()) { + return StringUtils.join(filterList, "/") + '/' + list.get(0).getMenuName(); } - }else { + } else { return list.get(0).getMenuName(); } @@ -73,7 +128,7 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl roleIdList = tsRoleDao.getRoleByUserId(LoginUserUtil.getUserId()); for (String roleId : roleIdList) { HashMap map = new HashMap<>(); - map.put("resourceId",sarMenuStandard.getId()); - map.put("roleId",roleId); + map.put("resourceId", sarMenuStandard.getId()); + map.put("roleId", roleId); + map.put("menuId", sarMenuStandard.getId()); resourceDao.insertTsRoleResource(map); + // 添加权限 + roleMenuDataDao.insertResourceMenuData(map); } } @Override public SarMenuStandard getMenuStandardById(String menuId) { SarMenuStandard sarMenuStandard = dao.selectById(menuId); - if(sarMenuStandard != null && StringUtils.isNotBlank(sarMenuStandard.getParentIds())){ + if (sarMenuStandard != null && StringUtils.isNotBlank(sarMenuStandard.getParentIds())) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SarMenuStandard::getId,Arrays.asList(sarMenuStandard.getParentIds().split(","))); + wrapper.in(SarMenuStandard::getId, Arrays.asList(sarMenuStandard.getParentIds().split(","))); List menuStandards = dao.selectList(wrapper); - if(!menuStandards.isEmpty()){ + if (!menuStandards.isEmpty()) { String parentIdsName = menuStandards.stream().map(SarMenuStandard::getMenuName).collect(Collectors.joining(",")); sarMenuStandard.setParentIdsName(parentIdsName); } @@ -112,6 +170,240 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl standardSystemTree() { + // 构造树 + List TsResources; + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("DIC_ID", "9m4qqqaansxmox5e82zm"); + queryWrapper.eq("VALID_FLAG", 0); + queryWrapper.isNull("PARENT_ID"); + queryWrapper.orderByAsc("DISPLAY_SEQ"); + TsResources = dao.selectList(queryWrapper); + + for (SarMenuStandard resource : TsResources) { + resource.setTreeType("sarMs"); + QueryWrapper TsResourceQueryWrapper = new QueryWrapper<>(); + TsResourceQueryWrapper.like("PARENT_IDS", resource.getId()); + TsResourceQueryWrapper.eq("VALID_FLAG", 0); + TsResourceQueryWrapper.orderByAsc("DISPLAY_SEQ"); + List children = dao.selectList(TsResourceQueryWrapper); + resource.setChildren(recursionGetListChildrenStand((resource), (children))); + } + // 把所有关联表中的数据拉出来 + // 国标 + List gbStandMenu = sarStandMenuDao.getGBStandMenu().stream().filter(item -> item.getStandId() != null).collect(Collectors.toList()); + List gbRelations = BeanCopyUtils.copyBeanList(gbStandMenu, StandMenuRelation.class); + + // 外标 + List fbStandMenu = sarStandMenuDao.getFBStandMenu().stream().filter(item -> item.getStandId() != null).collect(Collectors.toList()); + ; + List fbRelations = BeanCopyUtils.copyBeanList(fbStandMenu, StandMenuRelation.class); + + // 企标 + List esStandMenu = sarBussStandMenuDao.getESStandMenu().stream().filter(item -> item.getBussStandId() != null).collect(Collectors.toList()); + List esRelations = new ArrayList<>(); + for (SarBussStandMenu s : esStandMenu) { + StandMenuRelation standMenuRelation = new StandMenuRelation(s.getBussStandId(), s.getMenuId()); + esRelations.add(standMenuRelation); + } + // 计算每个节点的数值 + if (!TsResources.isEmpty()) { + TsResources.get(0).calculateAndSetCounts(gbRelations, fbRelations, esRelations, 0); + } + // 拼接返回 + return TsResources; + } + + @Override + public IPage standardSystemList(StandSystemDTO standSystemDTO) { + boolean timeSort = StrUtil.isNotBlank(standSystemDTO.getSortField()); + boolean select = standSystemDTO.getSelectIdList() != null; + String menuId = standSystemDTO.getMenuId(); + // 校验menuId不能为空 + if (StringUtils.isBlank(menuId)) { + throw new AdcDaBaseException("menuId不能为空"); + } + + // 体系树 + SarMenuStandard sarMenuStandard = this.standardSystemTree().get(0); + + // 找到menuId对应的节点 + SarMenuStandard targetNode = SarMenuStandard.findNodeById(sarMenuStandard, menuId); + // 收集目标节点及其所有子节点的ID + List childIds = new ArrayList<>(); + targetNode.collectChildIds(childIds); + standSystemDTO.setMenuIdList(childIds); + + // 找到standSystemId对应的节点 + String standSystemId = standSystemDTO.getStandSystemId(); + if (StrUtil.isNotBlank(standSystemId)) { + SarMenuStandard findNode = SarMenuStandard.findNodeById(sarMenuStandard, standSystemDTO.getStandSystemId()); + // 收集目标节点及其所有子节点的ID + List standSystemChildIds = new ArrayList<>(); + findNode.collectChildIds(standSystemChildIds); + standSystemDTO.setStandSystemIdList(standSystemChildIds); + } + if (!select) { + standSystemDTO.setSelectIdList(targetNode.getGbStandIdList()); + } + // 查国标 + Set gbList = new HashSet<>(sarStandMenuDao.getStandInfoSystemData(standSystemDTO, "INLAND")); + if (!select) { + standSystemDTO.setSelectIdList(targetNode.getFbStandIdList()); + } + // 查外标 + Set fbList = new HashSet<>(sarStandMenuDao.getStandInfoSystemData(standSystemDTO, "FOREIGN")); + if (!select) { + standSystemDTO.setSelectIdList(targetNode.getEsStandIdList()); + } + // 查企标 + Set esList = new HashSet<>(sarBussionessStandDao.getESSystemData(standSystemDTO)); + // 数据转换后整合 + List resultList = new ArrayList<>(); + resultList.addAll(gbList); + resultList.addAll(fbList); + resultList.addAll(esList); + + // 默认排序 + // 构造体系路径映射 + Map pathMap = new HashMap<>(); + sarMenuStandard.buildPathMap(pathMap, ""); + + // 为树设置systemSort +// SarMenuStandard.setSystemSort(sarMenuStandard, ""); + AtomicInteger currentNumber = new AtomicInteger(1); + SarMenuStandard.setSystemSortDFS(sarMenuStandard, currentNumber); + + // 国标外标标准状态字典 +// List gbStateDictList = dicItemService.selectAllDicTypeNameByDicCode("STANDSTATE"); + // 国标外标标准文本状态 + List gbTextStateDictList = dicItemService.selectAllDicTypeNameByDicCode("WBZTCLASS"); + // 企标标准状态字典 + List esStateDictList = dicItemService.selectAllDicTypeNameByDicCode("TEXTSTATUSBUSS"); + + // 构造体系路径 && 设置标准内部类别排序号 && 翻译 + for (StandSystemDTO dto : resultList) { + String fullPath = pathMap.get(dto.getMenuId()); + dto.setStandSystem(fullPath); + dto.setStandCategorySort(StandCategoryEnum.getSortByStandType(dto.getDataSource(), dto.getStandSort())); + // 设置体系排序号 + SarMenuStandard node = SarMenuStandard.findNodeById(targetNode, dto.getMenuId()); + dto.setSystemSort(node.getSystemSort()); + // 翻译 +// this.translateStandardSystemDTO(dto, gbStateDictList, esStateDictList); + this.translateStandardSystemDTO(dto, gbTextStateDictList, esStateDictList); + } + + // 两个时间排序 + if (timeSort) { + // 时间排序 + String sortField = standSystemDTO.getSortField(); + String sortMode = standSystemDTO.getSortMode(); + Comparator comparatorReleaseDate = Comparator.comparing(StandSystemDTO::getReleaseDate + , Comparator.nullsLast(Comparator.naturalOrder())); + if (sortField.equals("releaseDate")) { + if (sortMode.equals("desc")) { + resultList.sort(comparatorReleaseDate.reversed()); + } else { + resultList.sort(comparatorReleaseDate); + } + } + Comparator comparatorImplementDate = Comparator.comparing(StandSystemDTO::getImplementDate + , Comparator.nullsLast(Comparator.naturalOrder())); + if (sortField.equals("implementDate")) { + if (sortMode.equals("desc")) { + resultList.sort(comparatorImplementDate.reversed()); + } else { + resultList.sort(comparatorImplementDate); + } + } + } else { + // 根据排序字段对 resultList 进行排序 + // 按照标准体系排序 + // 体系内部按照国内/海外/企业排序 + // 每个类别的标准内部按照类别排序 + resultList.sort(Comparator.comparingInt(StandSystemDTO::getSystemSort) + .thenComparingInt(StandSystemDTO::getStandTypeSort) + .thenComparingInt(StandSystemDTO::getStandCategorySort)); + } + + // 手动分页 + int pageNum = standSystemDTO.getPage(); + int pageSize = standSystemDTO.getPageSize(); + + // 计算总页数 + int total = resultList.size(); + int totalPages = (total + pageSize - 1) / pageSize; + + // 计算当前页应该显示的数据的起始和结束索引 + int start = (pageNum - 1) * pageSize; + int end = Math.min(start + pageSize, total); + + // 获取当前页面的数据 + List pageList = resultList.subList(start, end); + + // 使用MyBatis Plus的Page类来构造分页对象 + Page page = new Page<>(pageNum, pageSize, total); + page.setRecords(pageList); // 设置当前页面的记录 + page.setTotal(total); // 设置总记录数 + page.setPages(totalPages); // 设置总页数 + return page; + } + + private void translateStandardSystemDTO(StandSystemDTO dto, List gbTextStateDictList, List esStateDictList) { + // 翻译数据来源、标准状态 + switch (dto.getDataSource()) { + case "INLAND": + dto.setDataSource("国内标准库"); + dto.setStandState(gbTextStateDictList.stream() + .filter(dict -> dict.getDicTypeCode().equals(dto.getTextStatus())) + .findFirst().orElse(new TsDicType()).getDicTypeName()); + break; + case "FOREIGN": + dto.setDataSource("海外标准库"); + dto.setStandState(gbTextStateDictList.stream() + .filter(dict -> dict.getDicTypeCode().equals(dto.getTextStatus())) + .findFirst().orElse(new TsDicType()).getDicTypeName()); + break; + case "ENTERPRISE": + dto.setDataSource("企业标准库"); + dto.setStandState(esStateDictList.stream() + .filter(dict -> dict.getDicTypeCode().equals(dto.getStandState())) + .findFirst().orElse(new TsDicType()).getDicTypeName()); + break; + } + } + + @Override + public void standardSystemListExport(StandSystemDTO standSystemDTO, HttpServletResponse response, HttpServletRequest request) { + OutputStream os = null; + Workbook workbook; + List dataList; + standSystemDTO.setPage(1); + standSystemDTO.setPageSize(Integer.MAX_VALUE); + try { + response.setHeader("Content-Disposition", + "attachment; filename=" + ReadExcel.encodeFileName(standSystemDTO.getExportName() + ".xlsx", + request)); + // 导出数据,若指定了值则使用ids字段条件导出,否则根据条件导出 + IPage page = this.standardSystemList(standSystemDTO); + dataList = page.getRecords(); + ExportParams exportParams = new ExportParams(); + exportParams.setType(ExcelType.XSSF); + exportParams.setSheetName(standSystemDTO.getExportName()); + workbook = ExcelExportUtil.exportExcel(exportParams, StandSystemDTO.class, dataList); + os = response.getOutputStream(); + workbook.write(os); + os.flush(); + } catch (IOException e) { + log.error(e.getMessage(), e); + throw new AdcDaBaseException("下载文件失败,请重试"); + } finally { + IOUtils.closeQuietly(os); + } + } + @Override public Integer updateMenuStandard(SarMenuStandardNew sarMenuStandardNew) { SarMenuStandard menuStandarddb = dao.selectById(sarMenuStandardNew.getId()); @@ -122,49 +414,68 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl menuUpdateWrapper = new LambdaUpdateWrapper<>(); + menuUpdateWrapper.eq(SarMenuStandard::getId, menuId); + this.dao.delete(menuUpdateWrapper); + log.info("删除主表中的节点成功"); + // 删除国标外标体系关联关系 + LambdaUpdateWrapper gbWrapper = new LambdaUpdateWrapper<>(); + gbWrapper.eq(SarStandMenu::getMenuId, menuId); + sarStandMenuService.remove(gbWrapper); + log.info("删除国标外标主表中的相应字段成功"); + // 删除企标体系关联关系 + // 企标的不用删 删了标准法规库里面就搜不到这条企标了 +// LambdaUpdateWrapper esWrapper = new LambdaUpdateWrapper<>(); +// esWrapper.eq(SarBussStandMenu::getMenuId, menuId); +// sarBussStandMenuService.remove(esWrapper); + log.info("删除企标主表中的相应字段成功"); + // 删除国标外标企标主表中的中文字段 + sarStandardInfoDao.deleteStandSystem(menuName); + sarBussionessStandDao.deleteStandSystem(menuName); } /** * 查询有权限菜单 + * * @param sarMenuStandardNew */ @Override public List getListStandLimit(SarMenuStandardNew sarMenuStandardNew, List access) { List TsResources = new ArrayList<>(); - QueryWrapper queryWrapper =new QueryWrapper<>(); - if(sarMenuStandardNew.getSorDivide()!=null){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (sarMenuStandardNew.getSorDivide() != null) { queryWrapper.eq("sor_divide", sarMenuStandardNew.getSorDivide()); } - if(sarMenuStandardNew.getDicId()!=null){ + if (sarMenuStandardNew.getDicId() != null) { queryWrapper.eq("DIC_ID", sarMenuStandardNew.getDicId()); } - if(access!=null && !access.isEmpty()){ - queryWrapper.in(null!=access && !access.isEmpty(),"ID",access); + if (access != null && !access.isEmpty()) { + queryWrapper.in(null != access && !access.isEmpty(), "ID", access); } - queryWrapper.eq("VALID_FLAG",0); + queryWrapper.eq("VALID_FLAG", 0); queryWrapper.isNull("PARENT_ID"); queryWrapper.orderByAsc("DISPLAY_SEQ"); - TsResources=dao.selectList(queryWrapper); + TsResources = dao.selectList(queryWrapper); - for(SarMenuStandard resource:TsResources){ + for (SarMenuStandard resource : TsResources) { resource.setTreeType("sarMs"); - QueryWrapper TsResourceQueryWrapper=new QueryWrapper<>(); - TsResourceQueryWrapper.like("PARENT_IDS",resource.getId()); - if(access!=null && !access.isEmpty()){ - TsResourceQueryWrapper.in(null!=access && !access.isEmpty(),"ID",access); + QueryWrapper TsResourceQueryWrapper = new QueryWrapper<>(); + TsResourceQueryWrapper.like("PARENT_IDS", resource.getId()); + if (access != null && !access.isEmpty()) { + TsResourceQueryWrapper.in(null != access && !access.isEmpty(), "ID", access); } - TsResourceQueryWrapper.eq("VALID_FLAG",0); + TsResourceQueryWrapper.eq("VALID_FLAG", 0); TsResourceQueryWrapper.orderByAsc("DISPLAY_SEQ"); - List children=dao.selectList(TsResourceQueryWrapper); - resource.setChildren(recursionGetListChildrenStand((resource),(children))); + List children = dao.selectList(TsResourceQueryWrapper); + resource.setChildren(recursionGetListChildrenStand((resource), (children))); } return TsResources; @@ -172,18 +483,23 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl */ - private List recursionGetListChildrenStand(SarMenuStandard resource, List children){ + private List recursionGetListChildrenStand(SarMenuStandard resource, List children) { List tsResources = children.stream() .filter(resource1 -> resource1.getParentId().equals(resource.getId())) .collect(Collectors.toList()); - if(!tsResources.isEmpty()){ - tsResources = tsResources.stream().sorted(Comparator.comparing(resource1 -> resource1.getDisplaySeq())).collect(Collectors.toList()); - tsResources.forEach(resource1 -> { - resource1.setTreeType("sarMs"); - resource1.setChildren(recursionGetListChildrenStand((resource1),(children))); - }); + if (!tsResources.isEmpty()) { + try { + tsResources = tsResources.stream().sorted(Comparator.comparing(resource1 -> resource1.getDisplaySeq())).collect(Collectors.toList()); + tsResources.forEach(resource1 -> { + resource1.setTreeType("sarMs"); + resource1.setChildren(recursionGetListChildrenStand((resource1), (children))); + }); + } catch (Exception e) { + log.error("异常"); + } } return tsResources; } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarPosition/dao/TsPositionDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarPosition/dao/TsPositionDao.java index 2708d80b..d5f74bcd 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarPosition/dao/TsPositionDao.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarPosition/dao/TsPositionDao.java @@ -72,20 +72,20 @@ public interface TsPositionDao extends BaseMapper { Integer countPositionAndRole(TsPosition tsPosition); - /** - * 通过岗位列表查询绑定的角色列表 - * @param positionIds:岗位列表 - * @return List - */ - List getRoleIdsByPositionIds(List positionIds); +// /** +// * 通过岗位列表查询绑定的角色列表 +// * @param positionIds:岗位列表 +// * @return List +// */ +// List getRoleIdsByPositionIds(List positionIds); long pageTotal(); - /** - * 通过roleId查询岗位ID列表 - * @param roleId:角色ID - * @return List - */ - @Select("select position_id from ts_position_role where role_id=#{roleId}") - List getPositionIdsByRoleId(String roleId); +// /** +// * 通过roleId查询岗位ID列表 +// * @param roleId:角色ID +// * @return List +// */ +// @Select("select position_id from ts_position_role where role_id=#{roleId}") +// List getPositionIdsByRoleId(String roleId); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarPosition/service/ITsPositionService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarPosition/service/ITsPositionService.java index 87932f8c..206d50c1 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarPosition/service/ITsPositionService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarPosition/service/ITsPositionService.java @@ -67,17 +67,17 @@ public interface ITsPositionService extends IService { */ ResponseMessage deletePosition(String positionId); - /** - * 通过岗位列表查询绑定的角色列表 - * @param positionIds:岗位列表 - * @return List - */ - List getRoleIdsByPositionIds(List positionIds); - - /** - * 通过roleId查询岗位ID列表 - * @param roleId:角色ID - * @return List - */ - List getPositionIdsByRoleId(String roleId); +// /** +// * 通过岗位列表查询绑定的角色列表 +// * @param positionIds:岗位列表 +// * @return List +// */ +// List getRoleIdsByPositionIds(List positionIds); +// +// /** +// * 通过roleId查询岗位ID列表 +// * @param roleId:角色ID +// * @return List +// */ +// List getPositionIdsByRoleId(String roleId); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarPosition/service/impl/TsPositionServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarPosition/service/impl/TsPositionServiceImpl.java index c67e7c20..0ebb75c4 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarPosition/service/impl/TsPositionServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarPosition/service/impl/TsPositionServiceImpl.java @@ -195,26 +195,26 @@ public class TsPositionServiceImpl extends ServiceImpl - */ - @Override - public List getRoleIdsByPositionIds(List positionIds) { - if(positionIds!=null&&positionIds.size()>0){ - return tsPositionDao.getRoleIdsByPositionIds(positionIds); - } - return null; - } +// /** +// * 通过岗位列表查询绑定的角色列表 +// * @param positionIds:岗位列表 +// * @return List +// */ +// @Override +// public List getRoleIdsByPositionIds(List positionIds) { +// if(positionIds!=null&&positionIds.size()>0){ +// return tsPositionDao.getRoleIdsByPositionIds(positionIds); +// } +// return null; +// } - /** - * 通过roleId查询岗位ID列表 - * @param roleId:角色ID - * @return List - */ - @Override - public List getPositionIdsByRoleId(String roleId) { - return tsPositionDao.getPositionIdsByRoleId(roleId); - } +// /** +// * 通过roleId查询岗位ID列表 +// * @param roleId:角色ID +// * @return List +// */ +// @Override +// public List getPositionIdsByRoleId(String roleId) { +// return tsPositionDao.getPositionIdsByRoleId(roleId); +// } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/controller/TsRoleController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/controller/TsRoleController.java index ad0efc6e..3f9ab09c 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/controller/TsRoleController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/controller/TsRoleController.java @@ -6,14 +6,21 @@ import com.adc.da.http.ResponseMessage; import com.adc.da.http.Result; import com.adc.da.login.util.UserUtils; import com.adc.da.slrs.sarMenu.entity.SarMenu; +import com.adc.da.slrs.sarPosition.entity.TsPosition; import com.adc.da.slrs.sarResource.entity.TsResource; import com.adc.da.slrs.sarResource.service.ITsResourceService; import com.adc.da.slrs.sarRole.dao.TsRoleDao; import com.adc.da.slrs.sarRole.entity.TsRoleMenuVO; import com.adc.da.slrs.sarRole.entity.TsRoleResourceVO; import com.adc.da.slrs.sarRole.service.ITsRoleService; +import com.adc.da.slrs.sarUser.entity.UserPositionBatchVO; +import com.adc.da.slrs.sarUser.entity.UserPositionVO; +import com.adc.da.slrs.sarUser.entity.UserRoleBatchVO; +import com.adc.da.slrs.sarUser.entity.UserRoleVO; +import com.adc.da.slrs.sarUser.service.ITsUserService; import com.adc.da.sys.entity.UserEO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.ObjectUtils; import org.apache.ibatis.annotations.Delete; @@ -24,6 +31,7 @@ import com.adc.da.slrs.sarRole.entity.TsRole; import io.swagger.annotations.Api; import com.adc.da.base.web.BaseController; +import javax.annotation.Resource; import javax.validation.Valid; import java.util.List; @@ -43,6 +51,8 @@ public class TsRoleController extends BaseController { private ITsRoleService tsRoleService; @Autowired private TsRoleDao tsRoleDao; + @Resource + private ITsUserService tsUserService; @ApiOperation("查询所有角色") @GetMapping @@ -51,6 +61,17 @@ public class TsRoleController extends BaseController { return Result.success(tsRoles); } + /** + * 查询角色(可通过name筛选) + * @param tsRole:筛选信息 + */ + @ApiOperation("查询角色") + @GetMapping("/allPage") + public ResponseMessage> getPosition(TsRole tsRole){ + IPage roles = tsRoleService.getRole(tsRole); + return Result.success(roles); + } + @ApiOperation("根据角色名筛选角色") @GetMapping("/name") public ResponseMessage> getByName(String name){ diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/entity/TsRole.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/entity/TsRole.java index cd72e305..558d683e 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/entity/TsRole.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/entity/TsRole.java @@ -123,5 +123,14 @@ public class TsRole extends BaseEntity { @TableField(exist = false) private String parent; + @TableField(exist = false) + private Integer current; + + @TableField(exist = false) + private Integer pageSize; + + @TableField(exist = false) + private Integer total; + } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/service/ITsRoleService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/service/ITsRoleService.java index bf34936c..72698db8 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/service/ITsRoleService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/service/ITsRoleService.java @@ -4,6 +4,7 @@ import com.adc.da.http.ResponseMessage; import com.adc.da.slrs.sarRole.entity.TsRole; import com.adc.da.slrs.sarRole.entity.TsRoleMenuVO; import com.adc.da.slrs.sarRole.entity.TsRoleResourceVO; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.apache.ibatis.annotations.Param; @@ -88,4 +89,12 @@ public interface ITsRoleService extends IService { List getRootMenuIdsByRoleIds(List roleIds); List getRoleDataByUserId(String userId); + + /** + * 分页获取所有角色 + * @param tsRole + * @return + */ + IPage getRole(TsRole tsRole); + } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/service/impl/TsRoleServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/service/impl/TsRoleServiceImpl.java index 36eddc86..597b3ab1 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/service/impl/TsRoleServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarRole/service/impl/TsRoleServiceImpl.java @@ -1,11 +1,13 @@ package com.adc.da.slrs.sarRole.service.impl; +import cn.hutool.core.util.StrUtil; import com.adc.da.http.ResponseMessage; import com.adc.da.http.Result; import com.adc.da.slrs.sarMenu.dao.SarMenuDao; import com.adc.da.slrs.sarMenu.entity.SarMenu; import com.adc.da.slrs.sarMenu.service.ISarMenuService; import com.adc.da.slrs.sarPersonalCenter.service.ISarUserPersonalMenuService; +import com.adc.da.slrs.sarPosition.entity.TsPosition; import com.adc.da.slrs.sarResource.service.ITsResourceService; import com.adc.da.slrs.sarRole.entity.TsRole; import com.adc.da.slrs.sarRole.dao.TsRoleDao; @@ -17,7 +19,10 @@ import com.adc.da.slrs.sarUser.service.ITsUserService; import com.adc.da.slrs.zlTree.dao.ZlTreeDao; import com.adc.da.slrs.zlTree.entity.ZlTree; import com.adc.da.utils.util.ListUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -164,10 +169,10 @@ public class TsRoleServiceImpl extends ServiceImpl implements if(childrenRole!=null&&childrenRole.size()>0){ return Result.error("该角色有下属角色,无法删除"); } - List positionIds=tsRoleDao.getPositionIds(roleId); - if(positionIds!=null&&positionIds.size()>0){ - return Result.error("该角色已绑定岗位,无法删除"); - } +// List positionIds=tsRoleDao.getPositionIds(roleId); +// if(positionIds!=null&&positionIds.size()>0){ +// return Result.error("该角色已绑定岗位,无法删除"); +// } tsRoleDao.deleteById(roleId); return Result.success(); } @@ -299,4 +304,28 @@ public class TsRoleServiceImpl extends ServiceImpl implements } + @Override + public List getRoleDataByUserId(String userId) { + if(StringUtils.isNotBlank(userId)){ + return tsRoleDao.getRoleDataByUserId(userId); + } + return null; + } + + @Override + public IPage getRole(TsRole tsRole) { + IPage page = new Page<>(tsRole.getCurrent(), tsRole.getPageSize()); + LambdaQueryWrapper roleWrapper = new LambdaQueryWrapper<>(); + roleWrapper.like(StrUtil.isNotBlank(tsRole.getName()), TsRole::getName, tsRole.getName()); + IPage tsRoleIPage = baseMapper.selectPage(page, roleWrapper); + List records = tsRoleIPage.getRecords(); + page.setRecords(records); + page.setTotal(page.getTotal()); + page.setCurrent(tsRole.getCurrent()); + page.setSize(tsRole.getPageSize()); + System.out.println(page.getTotal()); + return page; + } + + } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandMenu/dao/SarStandMenuDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandMenu/dao/SarStandMenuDao.java index ccda4edd..2c845073 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandMenu/dao/SarStandMenuDao.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandMenu/dao/SarStandMenuDao.java @@ -1,7 +1,9 @@ package com.adc.da.slrs.sarStandMenu.dao; +import com.adc.da.slrs.sarMenuStandard.entity.StandSystemDTO; import com.adc.da.slrs.sarStandMenu.entity.SarStandMenu; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; import javax.annotation.Resource; import java.util.List; @@ -31,4 +33,9 @@ public interface SarStandMenuDao extends BaseMapper { List getMenuByStandId(SarStandMenu sarStandMenu); + List getGBStandMenu(); + + List getFBStandMenu(); + + List getStandInfoSystemData(@Param("param") StandSystemDTO standSystemDTO, @Param("dataSource") String dataSource); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandMenu/service/ISarStandMenuService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandMenu/service/ISarStandMenuService.java index c96f9818..f163580b 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandMenu/service/ISarStandMenuService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandMenu/service/ISarStandMenuService.java @@ -19,4 +19,7 @@ public interface ISarStandMenuService extends IService { List selectAllMenuByStandId(SarStandMenu sarStandMenuEO); + void deleteStandSystemByStandId(String id); + + void addStandSystemRelation(String standSystem, String id); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandMenu/service/impl/SarStandMenuServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandMenu/service/impl/SarStandMenuServiceImpl.java index 889b796e..845b155e 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandMenu/service/impl/SarStandMenuServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandMenu/service/impl/SarStandMenuServiceImpl.java @@ -1,15 +1,23 @@ package com.adc.da.slrs.sarStandMenu.service.impl; +import com.adc.da.exception.AdcDaBaseException; import com.adc.da.slrs.sarMenu.service.ISarMenuService; import com.adc.da.slrs.sarResource.service.ITsResourceService; import com.adc.da.slrs.sarStandMenu.entity.SarStandMenu; import com.adc.da.slrs.sarStandMenu.dao.SarStandMenuDao; import com.adc.da.slrs.sarStandMenu.service.ISarStandMenuService; +import com.adc.da.sys.sarMenuStandard.entity.SarMenuStandard; +import com.adc.da.sys.sarMenuStandard.service.ISarMenuStandardService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** *

@@ -28,6 +36,9 @@ public class SarStandMenuServiceImpl extends ServiceImpl menuIds = sarMenuEOService.getChildMenuList(sarStandMenuEO.getOldMenuId()); @@ -40,4 +51,39 @@ public class SarStandMenuServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SarStandMenu::getStandId, id); + List list = list(wrapper); + Set collect = list.stream().map(SarStandMenu::getMenuId).collect(Collectors.toSet()); + List menuIds = new ArrayList<>(); + for (String menuId : collect) { + SarMenuStandard menuStand = iSarMenuStandardService.getById(menuId); + if (menuStand != null) { + menuIds.add(menuStand.getId()); + } + } + if (menuIds.size() > 0) { + LambdaUpdateWrapper sarStandMenuWrapper = new LambdaUpdateWrapper<>(); + sarStandMenuWrapper.eq(SarStandMenu::getStandId, id); + sarStandMenuWrapper.in(SarStandMenu::getMenuId,menuIds); + remove(sarStandMenuWrapper); + } + } + + @Override + public void addStandSystemRelation(String standSystem, String id) { + // 校验standSystem是否有效 + SarMenuStandard standMenu = iSarMenuStandardService.getById(standSystem); + if (standMenu == null) { + throw new AdcDaBaseException("无效的标准体系"); + } + SarStandMenu sarStandMenu = new SarStandMenu(); + // 生成不带横杠的UUID + sarStandMenu.setId(java.util.UUID.randomUUID().toString().replaceAll("-", "")); + sarStandMenu.setStandId(id).setMenuId(standSystem).setValidFlag(0); + save(sarStandMenu); + } + } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfo.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfo.java index 2ba4759f..86e8879f 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfo.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfo.java @@ -243,6 +243,8 @@ public class SarStandardsInfo extends BaseEntity { @TableField(exist = false) private String standSystemName; + @TableField(exist = false) + private String standSystemId; public static long getSerialVersionUID() { return serialVersionUID; diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java index 45f945b9..50f1433d 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java @@ -17,7 +17,7 @@ import com.adc.da.slrs.sarBussionessStand.entity.OldSystem; import com.adc.da.slrs.sarLawsAttrDetailedList.dao.SarLawsAttrDetailedListDao; import com.adc.da.slrs.sarLawsAttrDetailedList.entity.SarFindDto; import com.adc.da.slrs.sarPosition.entity.TsPosition; -import com.adc.da.slrs.sarPosition.service.ITsPositionService; +//import com.adc.da.slrs.sarPosition.service.ITsPositionService; import com.adc.da.slrs.sarStandFile.service.ISarStandFileService; import com.adc.da.slrs.sarStandWarning.entity.WarningDate; import com.adc.da.slrs.sarStandWarning.service.Impl.WarningDateServiceImpl; @@ -87,6 +87,7 @@ import com.adc.da.util.UUIDUtils; import com.adc.da.utils.util.*; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.SneakyThrows; @@ -114,6 +115,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; @@ -150,8 +152,8 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl getAttrMap = sarStandAttrInfoEODao.selectStandFieldAndData(fieldInfo, row.getId()); - if(getAttrMap.get("FBGBJBD")!=null){ + if(getAttrMap!= null && getAttrMap.get("FBGBJBD")!=null){ if(StringUtils.isNotBlank(getAttrMap.get("FBGBJBD").toString())){ String[] split = getAttrMap.get("FBGBJBD").toString().split(","); String fileId = ""; @@ -1083,15 +1085,15 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl tsPositionQW = new QueryWrapper<>(); - tsPositionQW.select("name") - .in("id", valArr); - List stringList = iTsPositionService.listObjs(tsPositionQW, o -> o.toString()); - value = String.join(",", stringList.isEmpty() ? valArr : stringList); - break; - } +// //通过id绑定责任部门师名称 +// case "ZRBM": { +// QueryWrapper tsPositionQW = new QueryWrapper<>(); +// tsPositionQW.select("name") +// .in("id", valArr); +// List stringList = iTsPositionService.listObjs(tsPositionQW, o -> o.toString()); +// value = String.join(",", stringList.isEmpty() ? valArr : stringList); +// break; +// } default: value = dicTypeEODao.getDicNamesByCodes(valArr, ""); } @@ -1307,6 +1309,14 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl */ public int updateSarStandardsInfo(SarStandardsInfo sarStandardsInfoEO) throws Exception { + // 标准体系 + sarStandMenuService.deleteStandSystemByStandId(sarStandardsInfoEO.getId()); + if (StringUtils.isNotEmpty(sarStandardsInfoEO.getStandSystemId())) { + sarStandMenuService.addStandSystemRelation(sarStandardsInfoEO.getStandSystemId(), sarStandardsInfoEO.getId()); + } /** * 加入对应"国家/地区"的清单列表 @@ -3233,34 +3248,45 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl wrapper=new QueryWrapper<>(); - wrapper.in("MENU_NAME",sarStandardsInfoEO.getStandSystem()); - wrapper.eq("DIC_ID","9m4qqqaansxmox5e82zm"); - wrapper.orderByDesc("length(PARENT_IDS)"); - List standards=iSarMenuStandardService.list(wrapper); - if (null!=standards && standards.size() == 1) { - List ids=new ArrayList<>(); - if (StringUtils.isNotBlank(standards.get(0).getParentIds())){ - if (standards.get(0).getParentIds().contains(",")){ - ids=new ArrayList<>(Arrays.asList(standards.get(0).getParentIds().split(","))); - }else { - ids.add(standards.get(0).getParentIds()); - } - QueryWrapper wrapper1 = new QueryWrapper<>(); - wrapper1.in("id", ids); - List res = iSarMenuStandardService.list(wrapper1); - if (null!=res && res.size()>0){ - Map map=new HashMap<>(); - res.forEach(sarMenuStandard -> {map.put(sarMenuStandard.getId(),sarMenuStandard.getMenuName());}); - String result=""; - for (String s:ids) { - result +="/"+map.get(s); - } - sarStandardsInfoEO.setStandSystem(result.substring(1,result.length())); - } + // 处理标准体系字段 + String standSystem = sarStandardsInfoEO.getStandSystem(); + if (StringUtils.isNotBlank(standSystem)) { + List list = Arrays.asList(standSystem.split("/")); + standSystem = list.get(list.size() - 1); + // 配置体系类别 + String txlbBussLevel = getParentNodePathRecursive(standSystem); + sarStandardsInfoEO.setStandSystem(txlbBussLevel); } } + // 之前的处理有问题 +// QueryWrapper wrapper=new QueryWrapper<>(); +// wrapper.in("MENU_NAME",sarStandardsInfoEO.getStandSystem()); +// wrapper.eq("DIC_ID","9m4qqqaansxmox5e82zm"); +// wrapper.orderByDesc("length(PARENT_IDS)"); +// List standards=iSarMenuStandardService.list(wrapper); +// if (null!=standards && standards.size() == 1) { +// List ids=new ArrayList<>(); +// if (StringUtils.isNotBlank(standards.get(0).getParentIds())){ +// if (standards.get(0).getParentIds().contains(",")){ +// ids=new ArrayList<>(Arrays.asList(standards.get(0).getParentIds().split(","))); +// }else { +// ids.add(standards.get(0).getParentIds()); +// } +// QueryWrapper wrapper1 = new QueryWrapper<>(); +// wrapper1.in("id", ids); +// List res = iSarMenuStandardService.list(wrapper1); +// if (null!=res && res.size()>0){ +// Map map=new HashMap<>(); +// res.forEach(sarMenuStandard -> {map.put(sarMenuStandard.getId(),sarMenuStandard.getMenuName());}); +// String result=""; +// for (String s:ids) { +// result +="/"+map.get(s); +// } +// sarStandardsInfoEO.setStandSystem(result.substring(1,result.length())); +// } +// } +// } + return sarStandardsInfoEO; @@ -3286,6 +3312,22 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl list = Arrays.asList(standSystem.split("/")); + standSystem = list.get(list.size() - 1); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SarMenuStandard::getMenuName, standSystem); + wrapper.eq(SarMenuStandard::getDicId, "9m4qqqaansxmox5e82zm"); + List list1 = sarMenuStandardService.list(wrapper); + if (list1.size() > 0) { + sarStandardsInfoEO.setStandSystemId(list1.get(0).getId()); + } + // 配置体系类别 + String txlbBussLevel = getParentNodePathRecursive(standSystem); + sarStandardsInfoEO.setStandSystem(txlbBussLevel); + } } return sarStandardsInfoEO; } @@ -3984,5 +4026,29 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SarMenuStandard::getMenuName, nodeName); + SarMenuStandard node = sarMenuStandardService.list(wrapper).get(0); // 根据 txlbBuss 查询节点 + if (node == null) { + return nodeName; // 未找到节点,返回空路径 + } + if (org.apache.commons.lang.StringUtils.isBlank(node.getParentId())) { + return nodeName; + } + SarMenuStandard sarMenuStandard = sarMenuStandardService.selectMenuById(node.getParentId()); + String parentNodePath = getParentNodePathRecursive(sarMenuStandard.getMenuName()); // 递归获取父节点路径 + if (parentNodePath.isEmpty()) { + return nodeName; // 如果父节点路径为空,直接返回当前节点的 txlbBuss + } else { + return parentNodePath + "/" + nodeName; // 否则,拼接当前节点的 txlbBuss 到父节点路径 + } + } + } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/controller/TsUserController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/controller/TsUserController.java index a58e9ba2..9affa8e9 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/controller/TsUserController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/controller/TsUserController.java @@ -71,6 +71,25 @@ public class TsUserController extends BaseController { return tsUserService.setPositionBatchByOrgId(userPositionVO); } + @ApiOperation("配置角色") + @PostMapping("/role") + public ResponseMessage setPosition(@Valid @RequestBody UserRoleVO userRoleVO){ + return tsUserService.setRole(userRoleVO); + } + + + @ApiOperation("配置角色") + @PostMapping("/roleBatch") + public ResponseMessage setPositionBatch(@Valid @RequestBody UserRoleBatchVO userRoleVO){ + return tsUserService.setRoleBatch(userRoleVO); + } + + @ApiOperation("配置角色") + @PostMapping("/roleBatchByOrgId") + public ResponseMessage setPositionBatchByOrgId(@Valid @RequestBody UserRoleBatchVO userRoleVO){ + return tsUserService.setRoleBatchByOrgId(userRoleVO); + } + @ApiOperation("查询当前登录用户权限") @GetMapping("/menu") diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/entity/UserRoleBatchVO.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/entity/UserRoleBatchVO.java new file mode 100644 index 00000000..8353e421 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/entity/UserRoleBatchVO.java @@ -0,0 +1,20 @@ +package com.adc.da.slrs.sarUser.entity; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author: Mzaxd + * @Date: 2023/11/22 22:50 + */ +@Data +public class UserRoleBatchVO { + @NotNull(message = "userId不能为空") + private List userId; + @NotNull(message = "roleIds不能为空") + private List roleIds; + @NotNull(message = "orgId不能为空") + private String orgId; +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/entity/UserRoleVO.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/entity/UserRoleVO.java new file mode 100644 index 00000000..16add0ff --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/entity/UserRoleVO.java @@ -0,0 +1,18 @@ +package com.adc.da.slrs.sarUser.entity; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author: Mzaxd + * @Date: 2023/11/22 22:50 + */ +@Data +public class UserRoleVO { + @NotNull(message = "userId不能为空") + private String userId; + @NotNull(message = "roleIds不能为空") + private List roleIds; +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/service/ITsUserService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/service/ITsUserService.java index fd625467..160c99cf 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/service/ITsUserService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/service/ITsUserService.java @@ -3,10 +3,7 @@ package com.adc.da.slrs.sarUser.service; import com.adc.da.http.ResponseMessage; import com.adc.da.slrs.sarMenu.entity.SarMenu; import com.adc.da.slrs.sarResource.entity.TsResource; -import com.adc.da.slrs.sarUser.entity.TsUser; -import com.adc.da.slrs.sarUser.entity.UpDTO; -import com.adc.da.slrs.sarUser.entity.UserPositionBatchVO; -import com.adc.da.slrs.sarUser.entity.UserPositionVO; +import com.adc.da.slrs.sarUser.entity.*; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; @@ -92,4 +89,10 @@ public interface ITsUserService extends IService { IPage getAllUsers(TsUser tsUser); String userIdByName(String userId); + + ResponseMessage setRole(UserRoleVO userRoleVO); + + ResponseMessage setRoleBatch(UserRoleBatchVO userRoleVO); + + ResponseMessage setRoleBatchByOrgId(UserRoleBatchVO userRoleVO); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/service/impl/TsUserServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/service/impl/TsUserServiceImpl.java index 0d98f305..d1cb40d3 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/service/impl/TsUserServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarUser/service/impl/TsUserServiceImpl.java @@ -7,9 +7,9 @@ import com.adc.da.slrs.sarInstitution.entity.TsInstitution; import com.adc.da.slrs.sarInstitution.service.ITsInstitutionService; import com.adc.da.slrs.sarMenu.entity.SarMenu; import com.adc.da.slrs.sarMenu.service.ISarMenuService; -import com.adc.da.slrs.sarPosition.dao.TsPositionDao; +//import com.adc.da.slrs.sarPosition.dao.TsPositionDao; import com.adc.da.slrs.sarPosition.entity.TsPosition; -import com.adc.da.slrs.sarPosition.service.ITsPositionService; +//import com.adc.da.slrs.sarPosition.service.ITsPositionService; import com.adc.da.slrs.sarResource.entity.TsResource; import com.adc.da.slrs.sarResource.service.ITsResourceService; import com.adc.da.slrs.sarRole.entity.TsRole; @@ -21,10 +21,13 @@ import com.adc.da.slrs.tsRoleMeunData.entity.TsRoleMenuData; import com.adc.da.slrs.tsRoleMeunData.service.ITsRoleMenuDataService; import com.adc.da.sync.service.SyncUserService; import com.adc.da.sys.entity.UserEO; +import com.adc.da.sys.entity.UserRoleEO; +import com.adc.da.sys.service.IUserRoleEOService; import com.adc.da.utils.util.ListUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -35,6 +38,7 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -55,8 +59,8 @@ public class TsUserServiceImpl extends ServiceImpl implements private TsUserDao tsUserDao; @Autowired private ITsUserService tsUserService; - @Autowired - private ITsPositionService tsPositionService; +// @Autowired +// private ITsPositionService tsPositionService; @Autowired @Lazy private ITsRoleService tsRoleService; @@ -66,12 +70,14 @@ public class TsUserServiceImpl extends ServiceImpl implements private ITsResourceService tsResourceService; @Autowired private SyncUserService syncUserService; - @Autowired - private TsPositionDao tsPositionDao; +// @Autowired +// private TsPositionDao tsPositionDao; @Autowired private ITsInstitutionService tsInstitutionService; @Autowired ITsRoleMenuDataService iTsRoleMenuDataService; + @Resource + private IUserRoleEOService userRoleEOService; public void deleteUser(){ @@ -290,16 +296,17 @@ public class TsUserServiceImpl extends ServiceImpl implements public List getMenu() { UserEO userEO=UserUtils.getUser(); String userId= userEO.getUsid(); - List positionIds=tsUserDao.selectPositionIds(userId); +// List positionIds=tsUserDao.selectPositionIds(userId); /** * 当用户没有所属岗位,默认给一个other岗位,适用于特定权限外的其他用户 * 用户同步时需要将用户配置的系统内的岗位保留 */ - if(positionIds == null || positionIds.isEmpty()){ - positionIds = Arrays.asList(new String[]{"other"}); - } - List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); +// if(positionIds == null || positionIds.isEmpty()){ +// positionIds = Arrays.asList(new String[]{"other"}); +// } +// List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); + List roleIds = userRoleEOService.getRoleIdsByUserId(userId); List menuIds=tsRoleService.getMenuIdsByRoleIds(roleIds); return sarMenuService.getMenuByIds(menuIds); } @@ -314,8 +321,9 @@ public class TsUserServiceImpl extends ServiceImpl implements UserEO userEO=UserUtils.getUser(); String userId= userEO.getUsid(); System.out.println(userId); - List positionIds=tsUserDao.selectPositionIds(userId); - List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); +// List positionIds=tsUserDao.selectPositionIds(userId); +// List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); + List roleIds = userRoleEOService.getRoleIdsByUserId(userId); List resourceIds=tsRoleService.getResourceIdsByRoleIds(roleIds); return tsResourceService.getResourceByIds(resourceIds,tsResource.getSorDivide()); } @@ -327,8 +335,16 @@ public class TsUserServiceImpl extends ServiceImpl implements */ @Override public List getUserIdsByRoleId(String roleId) { - List positionIds=tsPositionService.getPositionIdsByRoleId(roleId); - return tsUserDao.getUserIdsByPositionIds(positionIds); + LambdaQueryWrapper userRoleEOLambdaQueryWrapper = new LambdaQueryWrapper<>(); + userRoleEOLambdaQueryWrapper.eq(UserRoleEO::getRoleId,roleId); + // 根据角色ID查询用户ID + List list = userRoleEOService.list(userRoleEOLambdaQueryWrapper); + // 判空 + if (list == null || list.isEmpty()) { + return null; + } + // 获取用户ID + return list.stream().map(UserRoleEO::getUserId).collect(Collectors.toList()); } /** @@ -338,8 +354,9 @@ public class TsUserServiceImpl extends ServiceImpl implements */ @Override public List getMenusByUserId(String userId){ - List positionIds=tsUserDao.selectPositionIds(userId); - List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); +// List positionIds=tsUserDao.selectPositionIds(userId); +// List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); + List roleIds = userRoleEOService.getRoleIdsByUserId(userId); List menuIds=tsRoleService.getMenuIdsByRoleIds(roleIds); return sarMenuService.getMenuByIds(menuIds); } @@ -354,8 +371,9 @@ public class TsUserServiceImpl extends ServiceImpl implements UserEO userEO=UserUtils.getUser(); String userId= userEO.getUsid(); System.out.println(userId); - List positionIds=tsUserDao.selectPositionIds(userId); - List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); +// List positionIds=tsUserDao.selectPositionIds(userId); +// List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); + List roleIds = userRoleEOService.getRoleIdsByUserId(userId); return tsRoleService.getResourceIdsByRoleIds(roleIds); } @@ -366,8 +384,9 @@ public class TsUserServiceImpl extends ServiceImpl implements */ @Override public List getResourceUserId(String userId) { - List positionIds=tsUserDao.selectPositionIds(userId); - List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); +// List positionIds=tsUserDao.selectPositionIds(userId); +// List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); + List roleIds = userRoleEOService.getRoleIdsByUserId(userId); return tsRoleService.getResourceIdsByRoleIds(roleIds); } @@ -377,8 +396,9 @@ public class TsUserServiceImpl extends ServiceImpl implements */ @Override public List getResourceDataUserId(String userId) { - List positionIds=tsUserDao.selectPositionIds(userId); - List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); +// List positionIds=tsUserDao.selectPositionIds(userId); +// List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); + List roleIds = userRoleEOService.getRoleIdsByUserId(userId); QueryWrapper wrapper=new QueryWrapper<>(); wrapper.select("MENU_ID"); wrapper.in("ROLE_ID",roleIds); @@ -421,15 +441,15 @@ public class TsUserServiceImpl extends ServiceImpl implements for(SyncUser syncUser:syncUsers){ QueryWrapper positionQueryWrapper=new QueryWrapper<>(); positionQueryWrapper.eq("name",syncUser.getTitle()); - TsPosition tsPosition=tsPositionDao.selectOne(positionQueryWrapper); - if(tsPosition==null){ - tsPosition=new TsPosition(); - tsPosition.setName(syncUser.getTitle()); - tsPosition.setType("1"); - tsPositionDao.insert(tsPosition); - } +// TsPosition tsPosition=tsPositionDao.selectOne(positionQueryWrapper); +// if(tsPosition==null){ +// tsPosition=new TsPosition(); +// tsPosition.setName(syncUser.getTitle()); +// tsPosition.setType("1"); +// tsPositionDao.insert(tsPosition); +// } TsUser tsUser=SyncUser.toUser(syncUser); - tsUser.setPositionId(tsPosition.getId()); +// tsUser.setPositionId(tsPosition.getId()); tsUserDao.insert(tsUser); } @@ -437,8 +457,9 @@ public class TsUserServiceImpl extends ServiceImpl implements @Override public List getSecondMenusByUserId(String userId) { - List positionIds=tsUserDao.selectPositionIds(userId); - List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); +// List positionIds=tsUserDao.selectPositionIds(userId); +// List roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds); + List roleIds = userRoleEOService.getRoleIdsByUserId(userId); List menuIds=tsRoleService.getMenuIdsByRoleIds(roleIds); return sarMenuService.getSecondMenuByIds(menuIds); } @@ -507,19 +528,19 @@ public class TsUserServiceImpl extends ServiceImpl implements } ids.removeIf(s -> null==s); List tsUsers = tsUserDao.userUnderInstitution((tsUser.getCurrent() - 1) * tsUser.getSize(), tsUser.getSize(), tsUser, ids); - if(tsUsers!=null && !tsUsers.isEmpty()){ - for (TsUser user:tsUsers) { - List positionList = tsPositionService.getPositionDataByUserId(user.getUserId()); - user.setPositions(positionList); - } - } +// if(tsUsers!=null && !tsUsers.isEmpty()){ +// for (TsUser user:tsUsers) { +// List positionList = tsPositionService.getPositionDataByUserId(user.getUserId()); +// user.setPositions(positionList); +// } +// } + if(tsUsers!=null &&!tsUsers.isEmpty()){ for (TsUser user:tsUsers) { List roleList = tsRoleService.getRoleDataByUserId(user.getUserId()); user.setRoles(roleList); } } - Page tsUserPage = new Page<>(); tsUserPage.setCurrent(tsUser.getCurrent()); tsUserPage.setSize(tsUser.getSize()); @@ -535,5 +556,90 @@ public class TsUserServiceImpl extends ServiceImpl implements return userName; } + @Override + public ResponseMessage setRole(UserRoleVO userRoleVO) { + TsUser tsUser=tsUserDao.selectById(userRoleVO.getUserId()); + if(tsUser==null){ + return Result.error("该用户不存在"); + } + // 删除原来的角色关联 + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.eq("USER_ID",userRoleVO.getUserId()); + userRoleEOService.remove(queryWrapper); + // 设置新的角色关联 + List userRoleEOList=new ArrayList<>(); + userRoleVO.getRoleIds().forEach(roleId -> { + UserRoleEO userRoleEO=new UserRoleEO(); + userRoleEO.setUserId(userRoleVO.getUserId()); + userRoleEO.setRoleId(roleId); + userRoleEOList.add(userRoleEO); + }); + userRoleEOService.saveBatch(userRoleEOList); + return Result.success(); + } + + @Override + public ResponseMessage setRoleBatch(UserRoleBatchVO userRoleVO) { + // 删除原来的角色关联 + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.in("USER_ID",userRoleVO.getUserId()); + userRoleEOService.remove(queryWrapper); + // 设置新的角色关联 + List userRoleEOList=new ArrayList<>(); + userRoleVO.getUserId().forEach(userId -> { + userRoleVO.getRoleIds().forEach(roleId -> { + UserRoleEO userRoleEO=new UserRoleEO(); + userRoleEO.setUserId(userId); + userRoleEO.setRoleId(roleId); + userRoleEOList.add(userRoleEO); + }); + }); + userRoleEOService.saveBatch(userRoleEOList); + return Result.success(); + } + + @Override + public ResponseMessage setRoleBatchByOrgId(UserRoleBatchVO userRoleVO) { + //首先将所有用户查出来 + List orgIds=new ArrayList<>(); + orgIds.add(userRoleVO.getOrgId()); + List middle=new ArrayList<>(); + middle.addAll(orgIds); + boolean Orgflag=true; + while (Orgflag){ + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.in("parent_id",middle); + List tsmiddle=tsInstitutionService.list(queryWrapper); + if (tsmiddle.size()>0){ + tsmiddle.forEach(tsInstitution -> { + middle.add(tsInstitution.getId()); + }); + middle.removeAll(orgIds); + orgIds.addAll(middle); + }else { + tsmiddle.forEach(tsInstitution -> { + middle.add(tsInstitution.getId()); + }); + middle.removeAll(orgIds); + orgIds.addAll(middle); + Orgflag=false; + } + } + orgIds.removeIf(s -> null==s); + List userRoleEOList=new ArrayList<>(); + List allUsers = tsUserDao.getUserUnderInstitutionAll(orgIds); + for (TsUser tsUser : allUsers){ + String userId = tsUser.getUserId(); + // 设置新的角色关联 + userRoleVO.getRoleIds().forEach(roleId -> { + UserRoleEO userRoleEO=new UserRoleEO(); + userRoleEO.setUserId(userId); + userRoleEO.setRoleId(roleId); + userRoleEOList.add(userRoleEO); + }); + } + userRoleEOService.saveBatch(userRoleEOList); + return Result.success(); + } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/tsRoleMeunData/dao/TsRoleMenuDataDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/tsRoleMeunData/dao/TsRoleMenuDataDao.java index b7ee9949..46616443 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/tsRoleMeunData/dao/TsRoleMenuDataDao.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/tsRoleMeunData/dao/TsRoleMenuDataDao.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; +import java.util.HashMap; + /** *

* Mapper 接口 @@ -17,4 +19,6 @@ public interface TsRoleMenuDataDao extends BaseMapper { @Insert("insert into ts_role_menu_data (role_id,menu_id) values (#{roleId},#{id})") void save(@Param("roleId") String roleId,@Param("id") String id); + + void insertResourceMenuData(HashMap map); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/annotation/CompareField.java b/adc-da-slrs/src/main/java/com/adc/da/utils/annotation/CompareField.java new file mode 100644 index 00000000..853c8d08 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/annotation/CompareField.java @@ -0,0 +1,13 @@ +package com.adc.da.utils.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface CompareField { + String fieldName() default ""; +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/FieldConvertUtil.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/FieldConvertUtil.java index 1d63b5c6..e019cb92 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/utils/util/FieldConvertUtil.java +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/FieldConvertUtil.java @@ -65,15 +65,15 @@ public class FieldConvertUtil { public static String exportFieldNamesEsRevisePlan = "企标类别,企标编号,企标名称,计划状态,制修订类型,起草人,内部评审责任人,技术委员会评审负责人,计划标准初稿完成时间,计划标准发布时间,起草责任单位,实际标准发布时间,质量评分"; // 内外部会议 表头 - public static String exportFieldNamesInsideOutsideMeeting = "会议名称,课题名称,会议主办单位,会议时间,会议地点,参会人员,会议主要内容,一级会议类别,二级会议类别"; + public static String exportFieldNamesInsideOutsideMeeting = "*会议名称,课题名称,*会议主办单位,*会议时间,*会议地点,*参会人员,会议纪要,*会议主要内容,*一级会议分类,*二级会议分类"; // 内外部会议关联表 表头 - public static String exportFieldNamesMeetingTopic = "议题名称,汇报人,汇报单位,议题主要内容"; + public static String exportFieldNamesMeetingTopic = "*议题名称,议题材料,*汇报人,*汇报单位,*议题主要内容"; // 政策法规资料 表头 - public static String exportFieldLawsInformation = "1级资料分类,2级资料分类,3级资料分类,4级资料分类,资料名称,资料归属部门,作者,资料说明"; + public static String exportFieldLawsInformation = "*1级资料分类,*2级资料分类,*3级资料分类,*4级资料分类,*资料名称,*资料归属部门,作者,资料说明,资料文件"; // 政策课题 表头 - public static String exportFieldLawsTopic = "课题名称,课题承办单位,课题指导单位,课题参与单位,开始时间,结题时间,课题费用(万元),课题组会议列表,课题组联系方式,内部联系方式"; + public static String exportFieldLawsTopic = "*课题名称,*课题承办单位,课题指导单位,课题参与单位,*启动时间,结题时间,课题费用(万元),协议,课题组会议,课题组研究方案,课题组研究成果,课题组其他,课题组会议资料,课题组联系方式,内部立项报告,内部研究方案,内部会议资料,内部研究成果,内部其他,内部联系方式"; // 政策课题关联表 表头 public static String exportFieldLawsTopicRelation = "会议名称,会议时间,会议地点,参会人员(内部),会议主要内容,姓名,单位,电话,邮箱,身份,姓名,单位,电话,邮箱,身份"; @@ -92,7 +92,7 @@ public class FieldConvertUtil { public static String exportName = "填写说明\n" + "1.导入数据从第三行开始,第一行为填写说明,第二行为表头,第三行是正式数据\n" + "2.所有带*号的字段必须填写\n" + - "3.企标类别(例如:Q/FD),文本状态(包含:发布、被代替、参考、即将实施、有效、直接上传、作废、待修订-指的其他企业标准),采用标准(包含:IDT等同采用、NEQ非等效采用、MOD修改采用)字段是单选属性,必须和系统中的对应字段选项相匹配,起草人因为涉及到同名问题只能填写账号例如(zhangsan3),如果有多个起草人需要使用英文逗号进行区分\n" + + "3.企标类别(例如:Q/FD),文本状态(包含:发布、被代替、参考、即将实施、有效、直接上传、作废、待修订-指的其他企业标准),采用标准(包含:IDT等同采用、NEQ非等效采用、MOD修改采用)字段,标准体系(例如:物理集成)是单选属性,必须和系统中的对应字段选项相匹配,起草人因为涉及到同名问题只能填写账号例如(zhangsan3),如果有多个起草人需要使用英文逗号进行区分\n" + "4.适用车型,能源类型,适用产品线字段是多选属性,必须和系统中的对应字段选项相匹配,填写多个时采用英文逗号分割\n" + "5.发布日期,企标实施日期字段为年-月-日格式,必须精确到日,例如(2023-04-01)\n" + "6.企标编号,企标名称,企标英文名称字段为文本,填写文本内容\n" + @@ -101,18 +101,26 @@ public class FieldConvertUtil { public static String exportInsideOutsideMeetingDesc ="填写说明\n" + "1.导入数据从第三行开始,第一行为填写说明,第二行为表头,第三行是正式数据\n" + - "2.会议分类按照系统下拉菜单中的分类填写\n" + - "3.会议议题如果存在多条,则在下面以此填写,新的内外部会议另起一行填写"; + "2.所有带*号的字段必须填写\n" + + "3.会议分类按照系统中的分类填写\n" + + "4.发布日期,企标实施日期字段为年-月-日格式,必须精确到日,例如(2023-04-01)\n" + + "5.会议议题如果存在多条,则在对应列下依次填写,新的内外部会议另起一行填写 \n" + + "6.会议纪要,议题材料为附件文件,需要放在Excel文档同级目录中"; public static String exportLawsInformationDesc = "填写说明\n" + "1.导入数据从第三行开始,第一行为填写说明,第二行为表头,第三行是正式数据\n" + - "2.资料分类按照系统下拉菜单中的分类填写\n"; + "2.所有带*号的字段必须填写\n" + + "3.资料分类按照系统中的分类填写\n" + + "4.资料文件为附件文件,需要放在Excel文档同级目录中"; public static String exportLawsTopicDesc = "填写说明\n" + "1.导入数据从第三行开始,第一行为填写说明,第二行为表头,第三行是正式数据\n" + - "2.课题组会议、课题组联系方式、内部联系方式如果存在多条,则在下面一次填写,新的课题组会议、课题组联系方式、内部联系方式在下面依次填写"; + "2.所有带*号的字段必须填写 \n" + + "3.启动时间,结题时间字段为年-月-日格式,必须精确到日,例如(2023-12-01)\n" + + "4.课题组会议、课题组联系方式、内部联系方式如果存在多条,则在对应列下依次填写,新的课题组会议、课题组联系方式、内部联系方式在下面依次填写 \n" + + "5.协议,研究方案,研究成果,其他,会议资料等为附件文件,需要放在Excel文档同级目录中"; - public static String exportFieldName = "*企标类别,*企标编号,*标准年份,*企标名称,企标英文名称,*文本状态,发布日期,企标实施日期,起草部门,起草人,适用车型,能源类型,适用产品线,体系类别,关联模块-乘用车VPPS编码,关联模块--卡车VPPS编码,发布稿,编制说明,历史版本,其他文件,修改单,代替企标编号,采用标准,采标程度,引用标准,关联文件,"; + public static String exportFieldName = "*企标类别,*企标编号,*标准年份,*企标名称,企标英文名称,*文本状态,发布日期,企标实施日期,起草部门,起草人,适用车型,能源类型,适用产品线,标准体系,关联模块-乘用车VPPS编码,关联模块--卡车VPPS编码,发布稿,编制说明,历史版本,其他文件,修改单,代替企标编号,采用标准,采标程度,引用标准,关联文件,"; /*** * @Description: Clob类型 转String diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/InsideOntSideMeeting/InsideOntSideMeeting.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/InsideOntSideMeeting/InsideOntSideMeeting.xml index eb48940c..5ce6bab1 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/InsideOntSideMeeting/InsideOntSideMeeting.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/InsideOntSideMeeting/InsideOntSideMeeting.xml @@ -10,6 +10,7 @@ + @@ -26,6 +27,8 @@ + + @@ -37,7 +40,8 @@ iom.PARTICIPANTS,iom.MEETING_MINUTES,iom.MEETING_CONTENT,iom.FIRST_MEETING_TYPE,iom.SECOND_MEETING_TYPE, mt.ID as mtId,mt.MEETING_ID,mt.AGENDA_NAME,mt.AGENDA_MATERIALS,mt.REPORTER,mt.REPORTING_UNIT, mt.AGENDA_CONTENT, - iom.VALID_FLAG,iom.CREATE_TIME,iom.MODIFY_TIME + iom.VALID_FLAG,iom.CREATE_TIME,iom.MODIFY_TIME, + iom.AGENDA_NAME_STR @@ -50,17 +54,20 @@ and MEETING_ORGANIZER like concat('%',#{meetingOrganizer},'%') + + and MEETING_TIME >= DATE_FORMAT(#{meetingTimeBegin}, '%Y-%m-%d') + + + and MEETING_TIME <= DATE_FORMAT(#{meetingTimeEnd}, '%Y-%m-%d') + - and MEETING_TIME between #{meetingTimeBegin} and #{meetingTimeEnd} + and MEETING_TIME between DATE_FORMAT(#{meetingTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(#{meetingTimeEnd}, '%Y-%m-%d') and MEETING_ADDRESS like concat('%',#{meetingAddress},'%') - - and PARTICIPANTS in - - #{participant} - + + and PARTICIPANTS like concat('%',#{participants},'%') and MEETING_CONTENT like concat('%',#{meetingContent},'%') @@ -88,44 +95,63 @@ \ No newline at end of file diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandMenu/SarStandMenuMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandMenu/SarStandMenuMapper.xml index 5197d677..bc301c9c 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandMenu/SarStandMenuMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandMenu/SarStandMenuMapper.xml @@ -144,5 +144,135 @@ + + + + + diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/positionRole/PositionRoleMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/positionRole/PositionRoleMapper.xml new file mode 100644 index 00000000..2e0d18c7 --- /dev/null +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/positionRole/PositionRoleMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + role_id,position_id + + diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussStandMenu/SarBussStandMenuMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussStandMenu/SarBussStandMenuMapper.xml index 2d1f6a2b..9852e679 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussStandMenu/SarBussStandMenuMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussStandMenu/SarBussStandMenuMapper.xml @@ -203,6 +203,23 @@ where buss_stand_id = #{bussStandId} and valid_flag=0 + + delete from SAR_BUSS_STAND_MENU where buss_stand_id = #{bussStandId, jdbcType=VARCHAR} and MENU_ID = #{menuId, jdbcType=VARCHAR} diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussionessStand/SarBussionessStandMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussionessStand/SarBussionessStandMapper.xml index 2846dfb0..836ed914 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussionessStand/SarBussionessStandMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussionessStand/SarBussionessStandMapper.xml @@ -362,6 +362,11 @@ where id = #{value} + + update sar_buss_stand_attr_info + set TXLBBUSS = null + where TXLBBUSS like #{menuName} + + SELECT + DISTINCT + es.ID AS standId, + es.STAND_CODE AS standNo, + es.STAND_NAME AS standName, + es.TEXT_STATUS_BUSS AS standState, + es.ISSUE_TIME AS releaseDate, + es.PUT_TIME AS implementDate, + es.REPLACE_STAND_NUM AS replaceStandardNo, + esa.QCDW AS dept, + esa.QCRBUSS AS draftUserName, + 'ENTERPRISE' AS dataSource, + sms.ID AS menuId, + 3 AS standTypeSort, + CASE + when es.stand_code like concat('%', 'Q/FT A', '%') THEN 0 + when es.stand_code like concat('%', 'Q/FT B', '%') THEN 1 + when es.stand_code like concat('%', 'Q/FT E', '%') THEN 2 + when es.stand_code like concat('%', 'Q/FT F', '%') THEN 3 + when es.stand_code like concat('%', 'Q/FT G', '%') THEN 4 + when es.stand_code like concat('%', 'Q/FT M', '%') THEN 5 + when es.stand_code like concat('%', 'Q/FT Q', '%') THEN 6 + when es.stand_code like concat('%', 'Q/FT R', '%') THEN 7 + when es.stand_code like concat('%', 'Q/FT S', '%') THEN 8 + when es.stand_code like concat('%', 'Q/FT T', '%') THEN 9 + when es.stand_code like concat('%', 'Q/FT V', '%') THEN 10 + when es.stand_code like concat('%', 'Q/FT X', '%') THEN 11 + when es.stand_code like concat('%', 'Q/FT Y', '%') THEN 12 + when es.stand_code like concat('%', 'Q/FT Z', '%') THEN 13 + when es.stand_code like concat('%', 'Q/QCBFC', '%') THEN 14 + when es.stand_code like concat('%', '雷萨企标Q/FL', '%') THEN 15 + when es.stand_code like concat('%', 'Q/QCFLC', '%') THEN 16 + ELSE 17 + END AS standCategorySort + FROM + `sar_bussioness_stand` AS es + LEFT JOIN `sar_buss_stand_attr_info` AS esa ON es.ID = esa.STAND_ID + LEFT JOIN `sar_buss_stand_menu` AS m ON es.ID = m.BUSS_STAND_ID + AND LENGTH(m.MENU_ID) > 30 + AND m.TREE_TYPE is null + AND m.VALID_FLAG = 0 + LEFT JOIN sar_menu_standard sms on m.MENU_ID = sms.ID + WHERE 1 = 1 + AND sms.id in (select id from sar_menu_standard where valid_flag = 0) + + + AND es.STAND_CODE LIKE CONCAT('%',#{param.standNo},'%') + + + + AND m.MENU_ID IN + + #{item} + + + + + AND es.STAND_NAME LIKE CONCAT('%',#{param.standName},'%') + + + + AND es.ISSUE_TIME >= #{param.startReleaseDateString} + + + AND es.ISSUE_TIME <= CONCAT(#{param.endReleaseDateString}, ' 23:59:59') + + + + AND es.PUT_TIME >= #{param.startImplementDate} + + + AND es.PUT_TIME <= CONCAT(#{param.endImplementDate}, ' 23:59:59') + + + + AND es.REPLACE_STAND_NUM LIKE CONCAT('%',#{param.replaceStandardNo},'%') + + + + AND esa.QCDW LIKE CONCAT('%',#{param.dept},'%') + + + + AND esa.QCRBUSS LIKE CONCAT('%',#{param.draftUserName},'%') + + + + AND 'ENTERPRISE' = #{param.dataSource} + + + + AND m.MENU_ID IN + + #{item} + + + + AND es.ID IN + + #{item} + + + diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsInformation/SarLawsInformationMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsInformation/SarLawsInformationMapper.xml index 6457df92..eaf9a5a0 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsInformation/SarLawsInformationMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsInformation/SarLawsInformationMapper.xml @@ -52,8 +52,14 @@ and `NAME` like concat('%',#{name},'%') + + and UPLOAD_TIME >= DATE_FORMAT(#{uploadTimeBegin}, '%Y-%m-%d') + + + and UPLOAD_TIME <= DATE_FORMAT(#{uploadTimeEnd}, '%Y-%m-%d') + - and UPLOAD_TIME between DATE_FORMAT(#{uploadTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(${uploadTimeEnd}, '%Y-%m-%d') + and UPLOAD_TIME between DATE_FORMAT(#{uploadTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(#{uploadTimeEnd}, '%Y-%m-%d') and TREE_NODE_ID in @@ -88,6 +94,6 @@ from sar_laws_information where VALID_FLAG = 0 - order by ID asc + order by UPLOAD_TIME desc diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsStandInfo/SarLawsStandInfoMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsStandInfo/SarLawsStandInfoMapper.xml index 51c316a5..b0c199f0 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsStandInfo/SarLawsStandInfoMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsStandInfo/SarLawsStandInfoMapper.xml @@ -466,7 +466,7 @@ - ${orderByA} ${order1}, + ${orderByA} is null desc, ${orderByA} ${order1}, diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsTopic/SarLawsTopicMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsTopic/SarLawsTopicMapper.xml index 6980ed91..a486a128 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsTopic/SarLawsTopicMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsTopic/SarLawsTopicMapper.xml @@ -114,8 +114,14 @@ and PARTICIPATING_UNIT like concat('%',#{participatingUnit},'%') + + and START_TIME >= DATE_FORMAT(#{startTimeBegin}, '%Y-%m-%d') + + + and START_TIME <= DATE_FORMAT(#{startTimeEnd}, '%Y-%m-%d') + - and START_TIME between #{startTimeBegin} and ${startTimeEnd} + and START_TIME between DATE_FORMAT(#{startTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(#{startTimeEnd}, '%Y-%m-%d') and TOPIC_STATUS = #{topicStatus} @@ -135,12 +141,6 @@ and sltm.MEETING_ADDRESS like concat('%',#{meetingAddress},'%') - - - - - - and sltm.PARTICIPANTS like concat('%',#{participants},'%') @@ -182,26 +182,28 @@ diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarRole/TsRoleMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarRole/TsRoleMapper.xml index 513a09d3..6e24eb85 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarRole/TsRoleMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarRole/TsRoleMapper.xml @@ -35,4 +35,8 @@ select * from ts_role where ID in ( SELECT ROLE_ID FROM `ts_user_role` where USER_ID = #{userId}) + + diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarStandWarning/SarStandardInfo.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarStandWarning/SarStandardInfo.xml index 44bd0401..ab488682 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarStandWarning/SarStandardInfo.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarStandWarning/SarStandardInfo.xml @@ -48,5 +48,11 @@ where ID=#{id} + + update sar_standards_info + set STAND_SYSTEM = null + where STAND_SYSTEM like #{menuName} + + diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarUser/TsUserMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarUser/TsUserMapper.xml index bb1bae1c..a55a085b 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarUser/TsUserMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarUser/TsUserMapper.xml @@ -152,10 +152,10 @@ SELECT ts_user.UNAME,ts_user.USID,ts_user.INSTITUTION_ID , ts_institution.name as institution_name from ts_user left join ts_institution on ts_institution.id=ts_user.INSTITUTION_ID - LEFT JOIN ts_user_position on ts_user.USID = ts_user_position.user_id - WHERE ts_user_position.position_id in ( - SELECT ts_position_role.position_id from ts_position_role - WHERE ts_position_role.role_id = #{role.roleId} ) and ts_user.DISABLE_FLAG = '0' + LEFT JOIN ts_user_role on ts_user.USID = ts_user_role.user_id + WHERE ts_user_role.role_id in ( + SELECT ts_user_role.role_id from ts_user_role + WHERE ts_user_role.role_id = #{role.roleId} ) and ts_user.DISABLE_FLAG = '0' and ts_user.USID like concat(concat('%',#{role.userId}),'%') diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/tsRoleMeunData/TsRoleMenuDataMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/tsRoleMeunData/TsRoleMenuDataMapper.xml index dacec7b5..c448940f 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/tsRoleMeunData/TsRoleMenuDataMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/tsRoleMeunData/TsRoleMenuDataMapper.xml @@ -2,4 +2,8 @@ + + INSERT INTO ts_role_menu_data + VALUES(#{roleId},#{menuId} ) + diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/userPosition/UserPositionMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/userPosition/UserPositionMapper.xml new file mode 100644 index 00000000..810a941d --- /dev/null +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/userPosition/UserPositionMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + user_id,position_id + + diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/entity/UserRoleEO.java b/adc-da-sys/src/main/java/com/adc/da/sys/entity/UserRoleEO.java index ff52a4f5..e858e5a9 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/entity/UserRoleEO.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/entity/UserRoleEO.java @@ -1,6 +1,10 @@ package com.adc.da.sys.entity; import com.adc.da.base.entity.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; /** @@ -9,9 +13,17 @@ import com.adc.da.base.entity.BaseEntity; * 日期: 2018-09-03
* 版权所有:版权归北京卡达克数据技术中心所有。
*/ +@EqualsAndHashCode(callSuper = true) +@Getter +@TableName("TS_USER_ROLE") +@Data public class UserRoleEO extends BaseEntity { + /** + */ private String roleId; + /** + */ private String userId; /** @@ -43,22 +55,12 @@ public class UserRoleEO extends BaseEntity { default: return null; } } - - /** **/ - public String getRoleId() { - return this.roleId; - } /** **/ public void setRoleId(String roleId) { this.roleId = roleId; } - /** **/ - public String getUserId() { - return this.userId; - } - /** **/ public void setUserId(String userId) { this.userId = userId; diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/SarMenuStandard.java b/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/SarMenuStandard.java index 7cea639d..412d5d92 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/SarMenuStandard.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/SarMenuStandard.java @@ -15,8 +15,11 @@ import lombok.experimental.Accessors; import org.springframework.format.annotation.DateTimeFormat; import javax.validation.constraints.NotNull; +import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; /** *

@@ -60,10 +63,18 @@ public class SarMenuStandard extends BaseEntity { @TableField("PARENT_IDS") private String parentIds; + @TableField(exist = false) + @ApiModelProperty(value = "级联菜单显示") + private String menuNames; + @ApiModelProperty(value = "排序序号") @TableField("DISPLAY_SEQ") private Integer displaySeq; + @ApiModelProperty(value = "排序") + @TableField(exist = false) + private Integer systemSort; + @ApiModelProperty(value = "路径") @TableField("HREF") private String href; @@ -107,4 +118,122 @@ public class SarMenuStandard extends BaseEntity { @TableField(exist = false) private String treeType; + @ApiModelProperty(value = "树层级") + @TableField(exist = false) + private Integer level; + @TableField(exist = false) + + private Integer gbStandCount; + + @TableField(exist = false) + private Integer fbStandCount; + + @TableField(exist = false) + private Integer esStandCount; + + @TableField(exist = false) + private List gbStandIdList; + + @TableField(exist = false) + private List fbStandIdList; + + @TableField(exist = false) + private List esStandIdList; + + // 添加用于计算和设置关联关系数量的方法 + // 添加用于计算和设置关联关系数量的方法 + public void calculateAndSetCounts(List gbStandMenu, List fbStandMenu, List esStandMenu, Integer curLevel) { + this.gbStandIdList = new ArrayList<>(); + this.fbStandIdList = new ArrayList<>(); + this.esStandIdList = new ArrayList<>(); + this.level = curLevel; + this.gbStandCount = countMatches(gbStandMenu, this.id, gbStandIdList); + this.fbStandCount = countMatches(fbStandMenu, this.id, fbStandIdList); + this.esStandCount = countMatches(esStandMenu, this.id, esStandIdList); + + if (children != null && !children.isEmpty()) { + for (SarMenuStandard child : children) { + child.calculateAndSetCounts(gbStandMenu, fbStandMenu, esStandMenu, curLevel + 1); + this.gbStandCount += child.gbStandCount; + this.gbStandIdList.addAll(child.gbStandIdList); + this.fbStandCount += child.fbStandCount; + this.fbStandIdList.addAll(child.fbStandIdList); + this.esStandCount += child.esStandCount; + this.esStandIdList.addAll(child.esStandIdList); + } + } + } + + private int countMatches(List standMenuList, String menuId, List standIdList) { + int count = 0; + // 计算与menuId匹配的项的数量 + for (StandMenuRelation standMenu : standMenuList) { + if (standMenu.getMenuId().equals(menuId)) { + count++; + standIdList.add(standMenu.getStandId()); + } + } + return count; + } + + // 添加用于构建映射的方法 + public void buildPathMap(Map pathMap, String parentPath) { + String currentPath = parentPath.isEmpty() ? this.menuName : parentPath + "/" + this.menuName; + pathMap.put(this.id, currentPath); + for (SarMenuStandard child : children) { + child.buildPathMap(pathMap, currentPath); + } + } + + // 添加用于收集子节点ID的方法 + public void collectChildIds(List childIds) { + childIds.add(this.id); + for (SarMenuStandard child : children) { + child.collectChildIds(childIds); + } + } + + public static SarMenuStandard findNodeById(SarMenuStandard node, String menuId) { + if (node == null) { + return null; + } + // 检查当前节点的ID是否匹配 + if (menuId.equals(node.getId())) { + return node; + } + // 在子节点中递归搜索 + for (SarMenuStandard child : node.getChildren()) { + SarMenuStandard found = findNodeById(child, menuId); + if (found != null) { + return found; + } + } + // 如果在当前节点及其子节点中都没有找到,返回null + return null; + } + + // 递归方法来设置每个节点的 systemSort + public static void setSystemSort(SarMenuStandard node, String parentSort) { + // 计算当前节点的 systemSort + String currentSort = parentSort.isEmpty() ? String.valueOf(node.getDisplaySeq()) : parentSort + node.getDisplaySeq(); + + // 设置当前节点的 systemSort + node.setSystemSort(Integer.parseInt(currentSort)); + + // 递归设置子节点的 systemSort + for (SarMenuStandard child : node.getChildren()) { + setSystemSort(child, currentSort); + } + } + + // 新增的深度优先遍历方法 + public static void setSystemSortDFS(SarMenuStandard node, AtomicInteger currentNumber) { + if (node == null) { + return; + } + node.setSystemSort(currentNumber.getAndIncrement()); + for (SarMenuStandard child : node.getChildren()) { + setSystemSortDFS(child, currentNumber); + } + } } diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/StandMenuRelation.java b/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/StandMenuRelation.java new file mode 100644 index 00000000..6b1b24b2 --- /dev/null +++ b/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/StandMenuRelation.java @@ -0,0 +1,20 @@ +package com.adc.da.sys.sarMenuStandard.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author: Mzaxd + * @Date: 2023/11/14 16:31 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class StandMenuRelation { + + private String standId; + + private String menuId; + +} diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/service/impl/SarMenuStandardServiceImpl.java b/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/service/impl/SarMenuStandardServiceImpl.java index b0039b7b..779a05f8 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/service/impl/SarMenuStandardServiceImpl.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/service/impl/SarMenuStandardServiceImpl.java @@ -119,6 +119,7 @@ public class SarMenuStandardServiceImpl extends ServiceImpl remove=new ArrayList<>(); for (SarMenuStandard sarMenuStandard:sarMenus) { if (null==sarMenuStandard.getParentId() ){ + sarMenuStandard.setMenuNames(sarMenuStandard.getMenuName()); dtas.add(sarMenuStandard); remove.add(sarMenuStandard); } @@ -135,6 +136,7 @@ public class SarMenuStandardServiceImpl extends ServiceImpl children=new ArrayList<>(); sarMenuStandards.forEach(sarMenuStandard -> { if (Menu.getId().equals(sarMenuStandard.getParentId())){ + sarMenuStandard.setMenuNames(Menu.getMenuNames()+"/"+sarMenuStandard.getMenuName()); children.add(sarMenuStandard); } }); diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/service/IUserRoleEOService.java b/adc-da-sys/src/main/java/com/adc/da/sys/service/IUserRoleEOService.java index f9e2efac..56cfd7ff 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/service/IUserRoleEOService.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/service/IUserRoleEOService.java @@ -3,5 +3,9 @@ package com.adc.da.sys.service; import com.adc.da.sys.entity.UserRoleEO; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + public interface IUserRoleEOService extends IService { + + List getRoleIdsByUserId(String userId); } diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/service/impl/UserRoleEOServiceImpl.java b/adc-da-sys/src/main/java/com/adc/da/sys/service/impl/UserRoleEOServiceImpl.java index 7830cb0a..90096546 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/service/impl/UserRoleEOServiceImpl.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/service/impl/UserRoleEOServiceImpl.java @@ -3,11 +3,16 @@ package com.adc.da.sys.service.impl; import com.adc.da.sys.dao.UserRoleEODao; import com.adc.da.sys.entity.UserRoleEO; import com.adc.da.sys.service.IUserRoleEOService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + /** * @@ -21,4 +26,10 @@ import org.springframework.transaction.annotation.Transactional; @Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class) public class UserRoleEOServiceImpl extends ServiceImpl implements IUserRoleEOService { + @Override + public List getRoleIdsByUserId(String userId) { + return this.list(new LambdaQueryWrapper() + .eq(UserRoleEO::getUserId, userId)) + .stream().map(UserRoleEO::getRoleId).distinct().collect(Collectors.toList()); + } } diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/util/BeanCopyUtils.java b/adc-da-sys/src/main/java/com/adc/da/sys/util/BeanCopyUtils.java new file mode 100644 index 00000000..a0018525 --- /dev/null +++ b/adc-da-sys/src/main/java/com/adc/da/sys/util/BeanCopyUtils.java @@ -0,0 +1,36 @@ +package com.adc.da.sys.util; + +import org.springframework.beans.BeanUtils; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author Mzaxd + * @since 2022-11-22 15:36 + */ +public class BeanCopyUtils { + + private BeanCopyUtils() { + } + + public static V copyBean(Object source, Class clazz){ + V result = null; + //创建目标对象 + try { + result = clazz.newInstance(); + //实现属性copy + BeanUtils.copyProperties(source, result); + } catch (Exception e) { + e.printStackTrace(); + } + //返回结果 + return result; + } + + public static List copyBeanList(List list, Class clazz) { + return list.stream() + .map(o -> copyBean(o, clazz)) + .collect(Collectors.toList()); + } +}