From 380d62d79719303f4bde99adf57009369c06ca8a Mon Sep 17 00:00:00 2001 From: zhn <947514737@qq.com> Date: Thu, 23 Jun 2022 19:18:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=95=E8=A7=84=E9=A2=84=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BussDocumentLibraryEOServiceImpl.java | 25 ++++- .../warn/controller/LawsWarnController.java | 49 ++++++++++ .../modules/warn/service/LawsWarnService.java | 95 +++++++++++++++++++ 3 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 jero-boot/jero-boot-modules/src/main/java/com/jero/modules/warn/controller/LawsWarnController.java create mode 100644 jero-boot/jero-boot-modules/src/main/java/com/jero/modules/warn/service/LawsWarnService.java diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java index fe6c9e3f8..2a201f721 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java @@ -3574,8 +3574,9 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl parameter) { + public String getConditionStr(Map parameter) { String cut = (String) parameter.get("cut"); + String flag = String.valueOf(parameter.get("flag")); //查询条件 StringBuilder conditionSb = new StringBuilder("where 1 = 1"); @@ -3640,6 +3641,28 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl= '" + warnTime.split(",")[0] + "'" + + " and " + "date_format(" + "xin1_che1_xing2_shi2_shi1_ri4_qi1" + ",'%Y-%m-%d') <= '" + warnTime.split(",")[1] + "'"); + } else { + conditionSb.append(" and " + "date_format(" + "xin1_che1_xing2_shi2_shi1_ri4_qi1" + ",'%Y-%m-%d') = '" + warnTime + "'"); + } + }else{ + //日期(区分单日期还时间范围) + if (warnTime.contains(",")) { + conditionSb.append(" and " + "date_format(" + "implement_time" + ",'%Y-%m-%d') >= '" + warnTime.split(",")[0] + "'" + + " and " + "date_format(" + "implement_time" + ",'%Y-%m-%d') <= '" + warnTime.split(",")[1] + "'"); + } else { + conditionSb.append(" and " + "date_format(" + "implement_time" + ",'%Y-%m-%d') = '" + warnTime + "'"); + } + } + } + //高级搜索 queryConditionVOList List if(ObjectUtils.isNotEmpty(parameter.get("queryConditionVOList"))){ String queryConditionVOListStr = (String) parameter.get("queryConditionVOList"); diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/warn/controller/LawsWarnController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/warn/controller/LawsWarnController.java new file mode 100644 index 000000000..90f86844f --- /dev/null +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/warn/controller/LawsWarnController.java @@ -0,0 +1,49 @@ +package com.jero.modules.warn.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.jero.common.api.vo.Result; +import com.jero.modules.warn.service.LawsWarnService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import net.sf.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** + * @description + * @date 2022/6/20 11:54 + * @auth zhn + */ +@Api(tags="法规预警") +@RestController +@RequestMapping("/LawsWarn") +@Slf4j +public class LawsWarnController { + + @Autowired + private LawsWarnService lawsWarnService; + + + /** + * 分页列表查询 + * @param parameter + * @return + */ + @ApiOperation(value="分页查询", notes="分页查询") + @PostMapping(value = "/queryPageInfo") + @ResponseBody +// @RequiresPermissions("document:queryPageInfo") + public JSONObject queryPageInfo(@RequestBody Map parameter) { + IPage infoPage = lawsWarnService.getInfoPage(parameter); + Result ok = Result.OK(infoPage); + JSONObject jsonResult = JSONObject.fromObject(ok); + return jsonResult; + } +} diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/warn/service/LawsWarnService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/warn/service/LawsWarnService.java new file mode 100644 index 000000000..fabab41bc --- /dev/null +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/warn/service/LawsWarnService.java @@ -0,0 +1,95 @@ +package com.jero.modules.warn.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.jero.common.constant.enums.CutEnum; +import com.jero.common.constant.enums.ModuleEnum; +import com.jero.generater.modules.online.cgform.entity.OnlCgformField; +import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl; +import com.jero.modules.document.mapper.BussDocumentLibraryEOMapper; +import com.jero.modules.document.service.impl.BussDocumentLibraryEOServiceImpl; +import com.jero.modules.system.entity.SysCategory; +import com.jero.modules.system.entity.SysDictItem; +import com.jero.modules.system.service.impl.SysCategoryServiceImpl; +import com.jero.modules.system.service.impl.SysDictItemServiceImpl; +import com.jero.modules.system.util.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @description + * @date 2022/6/20 11:55 + * @auth zhn + */ +@Service +public class LawsWarnService { + @Autowired + private BussDocumentLibraryEOServiceImpl bussDocumentLibraryEOService; + @Autowired + private BussDocumentLibraryEOMapper bussDocumentLibraryEOMapper; + @Autowired + private SysCategoryServiceImpl sysCategoryService; + @Autowired + private SysDictItemServiceImpl sysDictItemServiceImpl; + @Autowired + private OnlCgformFieldServiceImpl onlCgformFieldService; + + public IPage getInfoPage(Map parameter) { + String cut = (String) parameter.get("cut");//中英文切换标识 + List onlCgformFieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue()); + //查询的字段 + String fieldQuery = "id,serial_number,title,title_en,state,region,technology_territory,xin1_che1_xing2_shi2_shi1_ri4_qi1,implement_time"; + List fieldList = Arrays.asList(fieldQuery.split(",")); + + List fieldListNew = new ArrayList<>(); + for (String field : fieldList) { + String fieldTemp = null; + if ("xin1_che1_xing2_shi2_shi1_ri4_qi1".equals(field) || "implement_time".equals(field)) { + String fieldNew = "date_format(" + field + ", '%Y-%m-%d')"; + fieldTemp = "case when " + fieldNew + " is null then \"\" else " + fieldNew + " end " + field; + fieldListNew.add(fieldTemp); + } else { + fieldTemp = "case when " + field + " is null then \"\" else " + field + " end " + field; + fieldListNew.add(fieldTemp); + } + } + parameter.remove("warnTime"); + //封装查询条件(包含高级搜索) + String condition = bussDocumentLibraryEOService.getConditionStr(parameter); + int pageNo = Integer.parseInt(parameter.get("pageNo").toString()); + int pageSize = Integer.parseInt(parameter.get("pageSize").toString()); + IPage page = new Page(pageNo, pageSize); + IPage infoPage = bussDocumentLibraryEOMapper.getInfoPage(page, " " + StringUtils.join(fieldListNew, ","), condition); + + + //树形数据字典 + List categoryList = sysCategoryService.list(); + //数据字典 + List sysDictItems = sysDictItemServiceImpl.selectItemsAll(); + List onlCgformFieldListTemp = onlCgformFieldList.stream().filter(e -> fieldList.contains(e.getDbFieldName())).collect(Collectors.toList()); + List records = infoPage.getRecords(); + for (Map record : records) { + //处理标题 + if(CutEnum.EN.getValue().equals(cut)){ + record.put("title",record.get("title_en")); + } + Map record1 = (Map) record; + List treeFieldList = new ArrayList<>(); + OnlCgformField onlCgformField = new OnlCgformField(); + onlCgformField.setDbFieldName("technology_territory"); + treeFieldList.add(onlCgformField); + for (Map.Entry entry : record1.entrySet()) { + //下拉选处理数据字典 + bussDocumentLibraryEOService.dictItem(sysDictItems, entry, cut, onlCgformFieldListTemp,null); + bussDocumentLibraryEOService.treeDictItem(categoryList, entry, treeFieldList, cut,null); + } + } + return infoPage; + } +}