From 986fbaf438f54824d73a80950dfd2642507c0012 Mon Sep 17 00:00:00 2001 From: caihaohan Date: Thu, 18 Apr 2024 15:27:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=91=E5=AE=9A=E9=9B=B6=E9=83=A8?= =?UTF-8?q?=E4=BB=B6=E5=85=B6=E4=BD=99=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LawsBindPartController.java | 71 ++++++++++-- .../bindPart/entity/BindPartStandardVO.java | 61 ++++++++++ .../laws/bindPart/entity/LawsBindPart.java | 13 +-- .../laws/bindPart/entity/LawsBindPartDoc.java | 2 +- .../bindPart/mapper/LawsBindPartMapper.java | 3 + .../mapper/xml/LawsBindPartMapper.xml | 47 +++++++- .../service/ILawsBindPartService.java | 18 +-- .../service/impl/LawsBindPartServiceImpl.java | 105 ++++++++++++++++-- 8 files changed, 279 insertions(+), 41 deletions(-) create mode 100644 laws-modules/src/main/java/com/jero/modules/laws/bindPart/entity/BindPartStandardVO.java diff --git a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/controller/LawsBindPartController.java b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/controller/LawsBindPartController.java index 464dd2ed..6d403bb7 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/controller/LawsBindPartController.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/controller/LawsBindPartController.java @@ -4,19 +4,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.jero.common.api.vo.Result; import com.jero.common.api.vo.ResultCommon; import com.jero.common.aspect.annotation.AutoLog; -import com.jero.common.aspect.annotation.DictPoint; import com.jero.common.exception.JeroBootException; import com.jero.common.util.MessageUtils; +import com.jero.modules.laws.bindPart.entity.BindPartStandardVO; import com.jero.modules.laws.bindPart.entity.LawsBindPart; import com.jero.modules.laws.bindPart.service.ILawsBindPartService; -import com.jero.modules.laws.common.service.ILawsCommonService; -import com.jero.modules.laws.common.vo.LawsDictModel; -import com.jero.modules.laws.common.vo.ManyStandardSelectionBox; -import com.jero.modules.laws.common.vo.ManyStandardSelectionBoxVO; -import com.jero.modules.laws.enterprise.entity.EnterpriseStandardInspectContent; -import com.jero.modules.laws.enterprise.entity.dto.ESQueryCommonDTO; -import com.jero.modules.laws.enterprise.entity.vo.EnterpriseStandardDeclareVo; -import com.jero.modules.split.entity.SarFileSplitInfoEO; +import com.jero.modules.laws.documenttool.service.IDocumentSplitService; +import com.jero.modules.split.entity.SarFileSplitMenuEO; +import com.jero.modules.split.page.SarFileSplitMenuEOPage; +import com.jero.modules.split.service.ISarFileSplitMenuEOService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -28,9 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; @@ -43,6 +39,12 @@ public class LawsBindPartController { @Autowired private ILawsBindPartService lawsBindPartService; + @Resource + private IDocumentSplitService documentSplitService; + + @Resource + private ISarFileSplitMenuEOService sarFileSplitMenuEOService; + /** * 分页列表查询 * @@ -123,4 +125,53 @@ public class LawsBindPartController { return Result.OK("批量删除成功!"); } + /** + * 选择标准 + * + * @return + */ + @AutoLog(value = "绑定零部件-选择标准") + @ApiOperation(value="绑定零部件-选择标准", notes="绑定零部件-选择标准") + @GetMapping(value = "/selectStandard") + public Result> selectStandard(BindPartStandardVO bindPartStandardVO, + @RequestParam(name="pageNo", defaultValue="1") @ApiParam("页码") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") @ApiParam("页面显示数量") Integer pageSize) { + IPage pageList= lawsBindPartService.selectStandard(bindPartStandardVO, pageNo, pageSize); + return Result.OK(pageList); + } + + /** + * 选择条款 + * + * @return + */ + @AutoLog(value = "绑定零部件-条款列表") + @ApiOperation(value="绑定零部件-条款列表", notes="绑定零部件-条款列表") + @PostMapping(value = "/selectClause") + public Result>> selectClause(@RequestBody Map parameter) { + try { + IPage> data = documentSplitService.queryDocumentSplitDetail(parameter); + return Result.OK(data); + } catch (JeroBootException e){ + return Result.error(e.getMessage()); + } catch (Exception e){ + return Result.error(MessageUtils.getMessage(ResultCommon.ERROR)); + } + } + + /** + * 选择条款 + * + * @return + */ + @AutoLog(value = "绑定零部件-条款目录树") + @ApiOperation(value="绑定零部件-条款目录树", notes="绑定零部件-条款目录树") + @GetMapping(value = "/selectClause") + public Result> clauseTree(SarFileSplitMenuEOPage page) { + page.setValidFlag("0"); + page.setOrderBy("display_seq asc"); + List getList = sarFileSplitMenuEOService.queryByList(page); + return Result.OK(getList); + } + } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/entity/BindPartStandardVO.java b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/entity/BindPartStandardVO.java new file mode 100644 index 00000000..ff00aed8 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/entity/BindPartStandardVO.java @@ -0,0 +1,61 @@ +package com.jero.modules.laws.bindPart.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.jero.common.aspect.annotation.Dict; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author: Mzaxd + * @Date: 2024/4/18 10:09 + */ +@Data +public class BindPartStandardVO { + /** + * id + */ + @ApiModelProperty(value = "id") + private String id; + /** + * 标准号 + */ + @ApiModelProperty(value = "标准号") + private String standardNumber; + /** + * 标准名称 + */ + @ApiModelProperty(value = "标准名称") + private String standardName; + /** + * 标准状态 + */ + @ApiModelProperty(value = "标准状态") + @Dict(dicCode = "standard_state") + private String standardState; + /** + * 标准状态 + */ + @ApiModelProperty(value = "企标标准状态") + @Dict(dicCode = "es_standard_state") + private String esStandardState; + /** + * 发布日期 + */ + @ApiModelProperty(value = "发布日期") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + private Date releaseDate; + /** + * 标准类型(1:国内,2:海外,3:企业) + */ + @ApiModelProperty(value = "标准类型(1:国内,2:海外,3:企业)") + @Dict(dicCode = "standard_source") + private String standardType; + + /** + * 拆分条款记录Id(选择条款用) + */ + @ApiModelProperty(value = "拆分条款记录Id(选择条款用)") + private String infoId; +} \ No newline at end of file diff --git a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/entity/LawsBindPart.java b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/entity/LawsBindPart.java index 28165e2e..b201465d 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/entity/LawsBindPart.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/entity/LawsBindPart.java @@ -70,10 +70,10 @@ public class LawsBindPart implements Serializable { private String partName; /** - * 零部件标准绑定关系表id + * 文档拆分Id */ - @ApiModelProperty(value = "零部件标准绑定关系表id") - private String sarFileSplitInfoId; + @ApiModelProperty(value = "文档拆分Id") + private String docSplitId; /** * 绑定人员 @@ -90,13 +90,6 @@ public class LawsBindPart implements Serializable { @ApiModelProperty(value = "绑定时间") private Date bindTime; - /** - * 文档拆分Id - */ - @ApiModelProperty(value = "文档拆分Id") - @TableField(exist = false) - private String docSplitId; - /** * 条款Id */ diff --git a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/entity/LawsBindPartDoc.java b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/entity/LawsBindPartDoc.java index f94fb872..d2c474ec 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/entity/LawsBindPartDoc.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/entity/LawsBindPartDoc.java @@ -63,7 +63,7 @@ public class LawsBindPartDoc implements Serializable { * 条款id */ @ApiModelProperty(value = "条款id") - private String docId; + private String clauseId; @TableField(exist = false) private static final long serialVersionUID = 1L; diff --git a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/mapper/LawsBindPartMapper.java b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/mapper/LawsBindPartMapper.java index 5879f7a7..09b1496f 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/mapper/LawsBindPartMapper.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/mapper/LawsBindPartMapper.java @@ -1,6 +1,7 @@ package com.jero.modules.laws.bindPart.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.jero.modules.laws.bindPart.entity.BindPartStandardVO; import com.jero.modules.laws.bindPart.entity.LawsBindPart; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.jero.modules.laws.enterprise.entity.vo.EnterpriseStandardPlanVo; @@ -15,6 +16,8 @@ import org.apache.ibatis.annotations.Param; public interface LawsBindPartMapper extends BaseMapper { IPage page(IPage page, @Param("param") LawsBindPart lawsBindPart); + + IPage selectStandard(IPage page, @Param("param") BindPartStandardVO bindPartStandardVO); } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/mapper/xml/LawsBindPartMapper.xml b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/mapper/xml/LawsBindPartMapper.xml index 55a63a8f..2c559f7c 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/mapper/xml/LawsBindPartMapper.xml +++ b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/mapper/xml/LawsBindPartMapper.xml @@ -13,7 +13,7 @@ - + @@ -30,7 +30,7 @@ bp.id, bp.part_no, bp.part_name, - bp.sar_file_split_info_id, + bp.doc_split_id, standard.standard_number, standard.standard_name, GROUP_CONCAT(lbpd.clause_id ORDER BY split.item_num SEPARATOR ', ') AS clauseIds, @@ -39,7 +39,7 @@ bp.bind_time FROM `laws_bind_part` AS bp - LEFT JOIN sar_file_split_info AS sfsi ON bp.sar_file_split_info_id = sfsi.id + LEFT JOIN sar_file_split_info AS sfsi ON bp.doc_split_id = sfsi.id LEFT JOIN ( select id, standard_number, standard_name from laws_enterprise_standard where del_flag = 0 UNION ALL @@ -71,4 +71,45 @@ + + diff --git a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/service/ILawsBindPartService.java b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/service/ILawsBindPartService.java index 8b765886..44945f87 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/service/ILawsBindPartService.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/service/ILawsBindPartService.java @@ -1,6 +1,7 @@ package com.jero.modules.laws.bindPart.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.jero.modules.laws.bindPart.entity.BindPartStandardVO; import com.jero.modules.laws.bindPart.entity.LawsBindPart; import com.baomidou.mybatisplus.extension.service.IService; import com.jero.modules.laws.system.entity.LawsContactManage; @@ -26,15 +27,6 @@ public interface ILawsBindPartService extends IService { */ IPage queryPage(LawsBindPart lawsBindPart, Integer pageNo, Integer pageSize, HttpServletRequest req); - /** - * 列表查询 - * - * @param lawsBindPart - * @param req - * @return - */ - List queryList(LawsBindPart lawsBindPart, HttpServletRequest req); - /** * 保存 * @@ -75,4 +67,12 @@ public interface ILawsBindPartService extends IService { */ LawsBindPart queryById(String id); + /** + * 选择标准 + * @param bindPartStandardVO + * @param pageNo + * @param pageSize + * @return + */ + IPage selectStandard(BindPartStandardVO bindPartStandardVO, Integer pageNo, Integer pageSize); } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/service/impl/LawsBindPartServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/service/impl/LawsBindPartServiceImpl.java index b07db727..7a8e1b51 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/bindPart/service/impl/LawsBindPartServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/bindPart/service/impl/LawsBindPartServiceImpl.java @@ -1,19 +1,31 @@ package com.jero.modules.laws.bindPart.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.jero.common.system.query.QueryGenerator; +import com.jero.common.exception.JeroBootException; +import com.jero.modules.laws.bindPart.entity.BindPartStandardVO; import com.jero.modules.laws.bindPart.entity.LawsBindPart; +import com.jero.modules.laws.bindPart.entity.LawsBindPartDoc; +import com.jero.modules.laws.bindPart.service.ILawsBindPartDocService; import com.jero.modules.laws.bindPart.service.ILawsBindPartService; import com.jero.modules.laws.bindPart.mapper.LawsBindPartMapper; -import com.jero.modules.laws.enterprise.entity.vo.EnterpriseStandardPlanVo; +import com.jero.modules.onlyoffice.entity.StandardFileType; +import com.jero.modules.split.entity.SarFileSplitInfoEO; +import com.jero.modules.split.service.ISarFileSplitInfoService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static com.jero.common.constant.CommonConstant.HAS_SEND; /** * @author ThinkBook @@ -27,6 +39,12 @@ public class LawsBindPartServiceImpl extends ServiceImpl queryPage(LawsBindPart lawsBindPart, Integer pageNo, Integer pageSize, HttpServletRequest req) { IPage page = new Page<>(pageNo, pageSize); @@ -34,29 +52,61 @@ public class LawsBindPartServiceImpl extends ServiceImpl queryList(LawsBindPart lawsBindPart, HttpServletRequest req) { - return null; - } - @Override public void add(LawsBindPart lawsBindPart) { save(lawsBindPart); + String clauseIds = lawsBindPart.getClauseIds(); + this.saveBindPartDoc(clauseIds, lawsBindPart.getId()); + } + + private void saveBindPartDoc(String clauseIds, String bindId) { + if (StrUtil.isBlank(clauseIds)) { + return; + } + String[] clauseIdList = clauseIds.split(","); + List lawsBindPartDocList = new ArrayList<>(); + for (String clause : clauseIdList) { + LawsBindPartDoc lawsBindPartDoc = new LawsBindPartDoc(); + lawsBindPartDoc.setBindId(bindId); + lawsBindPartDoc.setClauseId(clause); + lawsBindPartDocList.add(lawsBindPartDoc); + } + lawsBindPartDocService.saveBatch(lawsBindPartDocList); } @Override public void editById(LawsBindPart lawsBindPart) { + if (StrUtil.isBlank(lawsBindPart.getId())) { + throw new JeroBootException("id不能为空"); + } updateById(lawsBindPart); + // 清空关联关系 + removeBindPartDoc(lawsBindPart.getId()); + // 保存新关系 + String clauseIds = lawsBindPart.getClauseIds(); + this.saveBindPartDoc(clauseIds, lawsBindPart.getId()); + } + + private void removeBindPartDoc(String bindIds) { + if (StrUtil.isBlank(bindIds)) { + return; + } + List bindIdList = Arrays.asList(bindIds.split(",")); + LambdaQueryWrapper lawsBindPartDocLambdaQueryWrapper = new LambdaQueryWrapper<>(); + lawsBindPartDocLambdaQueryWrapper.in(LawsBindPartDoc::getBindId, bindIdList); + lawsBindPartDocService.remove(lawsBindPartDocLambdaQueryWrapper); } @Override public void deleteById(String id) { removeById(id); + removeBindPartDoc(id); } @Override public void deleteByIds(List ids) { removeByIds(ids); + removeBindPartDoc(ids.stream().map(String::valueOf).collect(Collectors.joining(","))); } @Override @@ -64,6 +114,45 @@ public class LawsBindPartServiceImpl extends ServiceImpl selectStandard(BindPartStandardVO bindPartStandardVO, Integer pageNo, Integer pageSize) { + IPage page = new Page<>(pageNo, pageSize); + lawsBindPartMapper.selectStandard(page, bindPartStandardVO); + List records = page.getRecords(); + // 获取所有标准Id + List standardIdList = records.stream().map(BindPartStandardVO::getId).collect(Collectors.toList()); + LambdaQueryWrapper sarFileSplitInfoEOLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sarFileSplitInfoEOLambdaQueryWrapper.isNotNull(SarFileSplitInfoEO::getStandardId); + sarFileSplitInfoEOLambdaQueryWrapper.in(!standardIdList.isEmpty(), SarFileSplitInfoEO::getStandardId, standardIdList); + sarFileSplitInfoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getSplitStatus, HAS_SEND); + // 设置拆分信息id + List splitInfoEOList = fileSplitInfoService.list(sarFileSplitInfoEOLambdaQueryWrapper); + Map> map = splitInfoEOList.stream().collect(Collectors.groupingBy(SarFileSplitInfoEO::getStandardId)); + // 创建映射:枚举的value到order的映射 + Map orderMap = java.util.Arrays.stream(StandardFileType.values()) + .collect(Collectors.toMap(StandardFileType::getValue, StandardFileType::getOrder)); + records.forEach(standard -> { + List sarFileSplitInfoEOS = map.get(standard.getId()); + if (sarFileSplitInfoEOS == null || sarFileSplitInfoEOS.isEmpty()) { + return; + } + if (sarFileSplitInfoEOS.size() == 1) { + standard.setInfoId(sarFileSplitInfoEOS.get(0).getId()); + } + // 需要对所有拆分信息按照文件类型排序 + sarFileSplitInfoEOS.sort((file1, file2) -> { + Integer order1 = orderMap.get(file1.getFileType()); + Integer order2 = orderMap.get(file2.getFileType()); + return Integer.compare(order1, order2); + }); + standard.setInfoId(sarFileSplitInfoEOS.get(0).getId()); + }); + // 设置编辑Id + return page; + } + + + }