From 3a61407d9b86b5ef9eb622ef009abd5ed3e777dd Mon Sep 17 00:00:00 2001 From: zhaowenxuan <chacca165@163.com> Date: 星期五, 13 十二月 2024 17:38:58 +0800 Subject: [PATCH] 20241213 --- ltkj-hosp/src/main/java/com/ltkj/hosp/domain/TjAdvice.java | 6 + ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java | 129 ++++++++++++++++++------------- ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjAdviceService.java | 3 ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjAdviceServiceImpl.java | 11 ++ ltkj-hosp/src/main/resources/mapper/hosp/TjAdviceMapper.xml | 29 +++++++ ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjAdviceMapper.java | 3 6 files changed, 124 insertions(+), 57 deletions(-) diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java index 517cf9f..493fd23 100644 --- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java +++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java @@ -6,10 +6,12 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +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.ltkj.common.annotation.Excel; +import com.ltkj.common.core.domain.entity.SysDept; import com.ltkj.common.utils.StringUtils; import com.ltkj.common.utils.poi.ExcelUtil; import com.ltkj.framework.config.UserHoder; @@ -21,6 +23,7 @@ import com.ltkj.hosp.service.ITjProjectService; import com.ltkj.hosp.service.TjAdviceKjbqService; import com.ltkj.hosp.service.TjUserAdviceService; +import com.ltkj.system.service.ISysDeptService; import com.ltkj.system.service.ISysUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -53,6 +56,8 @@ private TjUserAdviceService userAdviceService; @Autowired private ISysUserService userService; + @Autowired + private ISysDeptService sysDeptService; @PostMapping("/addTjAdviceKjbq") @ApiOperation(value = "鏂板浣撴寤鸿蹇嵎鏍囩鎺ュ彛") @@ -198,60 +203,76 @@ @ApiParam(value = "鏍囬") @RequestParam(required = false) String bt, @ApiParam(value = "寤鸿") @RequestParam(required = false) String nr, @ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer page, - @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize) { - Page<TjAdvice> page1 = new Page<>(page, pageSize); - Map<String, Object> map = new HashMap<>(); - List<TjAdvice> list = null; - long total = 0; - if (null != proName) { - LambdaQueryWrapper<TjProject> wq = new LambdaQueryWrapper<>(); - list = new ArrayList<>(); - wq.like(TjProject::getProName, proName); - List<TjProject> projectList = tjProjectService.list(wq); - if (null != projectList && !projectList.isEmpty()) { - for (TjProject project : projectList) { - LambdaQueryWrapper<TjAdvice> wqq = new LambdaQueryWrapper<>(); - wqq.eq(TjAdvice::getProId, project.getProId()); - IPage<TjAdvice> adviceList = tjAdviceService.page(page1, wqq); - if (null != adviceList.getRecords() && !adviceList.getRecords().isEmpty()) { - for (TjAdvice record : adviceList.getRecords()) { - record.setProName(project.getProName()); - String kjbq = record.getKjbq(); - if(null !=kjbq && !kjbq.isEmpty()){ - String[] split = kjbq.split(","); - record.setKjbqz(Arrays.asList(split)); - } - } - list.addAll(adviceList.getRecords()); - } - total = adviceList.getTotal(); - } - } - map.put("list", list); - map.put("total", total); - return AjaxResult.success(map); - } - LambdaQueryWrapper<TjAdvice> wq=new LambdaQueryWrapper<>(); - if(!StringUtil.isBlank(bt)) wq.like(TjAdvice::getTitle,bt); - if(!StringUtil.isBlank(nr)) wq.like(TjAdvice::getAdvice,nr); - Page<TjAdvice> page2 = tjAdviceService.page(page1,wq); - list = page2.getRecords(); - if (null != list && !list.isEmpty()) { - for (TjAdvice advice : list) { - TjProject tjProject = tjProjectService.getById(advice.getProId()); - if (null != tjProject) { - advice.setProName(tjProject.getProName()); - } - String kjbq = advice.getKjbq(); - if(null !=kjbq && !kjbq.equals("")){ - String[] split = kjbq.split(","); - advice.setKjbqz(Arrays.asList(split)); - } - } - } - map.put("list", list); - map.put("total", page2.getTotal()); - return AjaxResult.success(map); + @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(value = "deptId")String deptId) { +// LambdaQueryWrapper<SysDept> wrapper = new LambdaQueryWrapper<>(); +// wrapper.eq(SysDept::getParentId, 0); +// SysDept sysDept = sysDeptService.getOne(wrapper); +// Page<TjAdvice> page1 = new Page<>(page, pageSize); +// Map<String, Object> map = new HashMap<>(); +// List<TjAdvice> list = null; +// long total = 0; +// if (null != proName) { +// LambdaQueryWrapper<TjProject> wq = new LambdaQueryWrapper<>(); +// list = new ArrayList<>(); +// wq.like(TjProject::getProName, proName); +// List<TjProject> projectList = tjProjectService.list(wq); +// if (null != projectList && !projectList.isEmpty()) { +// for (TjProject project : projectList) { +// LambdaQueryWrapper<TjAdvice> wqq = new LambdaQueryWrapper<>(); +// wqq.eq(TjAdvice::getProId, project.getProId()); +// if (!deptId.equals(String.valueOf(sysDept.getDeptId()))) { +// wqq.eq(TjAdvice::getDept_id, deptId); +// } +// IPage<TjAdvice> adviceList = tjAdviceService.page(page1, wqq); +// if (null != adviceList.getRecords() && !adviceList.getRecords().isEmpty()) { +// for (TjAdvice record : adviceList.getRecords()) { +// record.setProName(project.getProName()); +// String kjbq = record.getKjbq(); +// if(null !=kjbq && !kjbq.isEmpty()){ +// String[] split = kjbq.split(","); +// record.setKjbqz(Arrays.asList(split)); +// } +// } +// list.addAll(adviceList.getRecords()); +// } +// total = adviceList.getTotal(); +// } +// } +// map.put("list", list); +// map.put("total", total); +// List<TjAdvice> list1 = tjAdviceService.selectList(proName,deptId,(page -1) * pageSize,pageSize); +// return AjaxResult.success(map); +// } +// LambdaQueryWrapper<TjAdvice> wq=new LambdaQueryWrapper<>(); +// if(!StringUtil.isBlank(bt)) wq.like(TjAdvice::getTitle,bt); +// if(!StringUtil.isBlank(nr)) wq.like(TjAdvice::getAdvice,nr); +// if (!deptId.equals(String.valueOf(sysDept.getDeptId()))) { +// wq.eq(TjAdvice::getDept_id, deptId); +// } +// Page<TjAdvice> page2 = tjAdviceService.page(page1,wq); +// list = page2.getRecords(); +// if (null != list && !list.isEmpty()) { +// for (TjAdvice advice : list) { +// TjProject tjProject = tjProjectService.getById(advice.getProId()); +// if (null != tjProject) { +// advice.setProName(tjProject.getProName()); +// } +// String kjbq = advice.getKjbq(); +// if(null !=kjbq && !kjbq.equals("")){ +// String[] split = kjbq.split(","); +// advice.setKjbqz(Arrays.asList(split)); +// } +// } +// } +// map.put("list", list); +// map.put("total", page2.getTotal()); + List<TjAdvice> tjAdvices = tjAdviceService.selectList(proName, deptId, (page - 1) * pageSize, pageSize); + Integer count = tjAdviceService.selectListCount(proName, deptId); + HashMap<String, Object> hashMap = new HashMap<>(); + hashMap.put("list",tjAdvices); + hashMap.put("total",count); + return AjaxResult.success(hashMap); } /** diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/domain/TjAdvice.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/domain/TjAdvice.java index c3f832e..5af3765 100644 --- a/ltkj-hosp/src/main/java/com/ltkj/hosp/domain/TjAdvice.java +++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/domain/TjAdvice.java @@ -60,7 +60,7 @@ @Excel(name = "鎵�灞炵瀹d") @ApiModelProperty(value = "鎵�灞炵瀹d") - private String dept_id; + private String deptId; @Excel(name = "蹇嵎鏍囩") @ApiModelProperty(value = "蹇嵎鏍囩") @@ -84,6 +84,9 @@ @ApiModelProperty(value = "蹇嵎鏍囩") private List<String> kjbqz; + @TableField(exist = false) + private String deptName; + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) @@ -96,6 +99,7 @@ .append("updateTime", getUpdateTime()) .append("updateBy", getUpdateBy()) .append("deleted", getDeleted()) + .append("deptName", getDeptName()) .toString(); } } diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjAdviceMapper.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjAdviceMapper.java index 8f942e5..b998966 100644 --- a/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjAdviceMapper.java +++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjAdviceMapper.java @@ -82,4 +82,7 @@ "</foreach>", "</script>" }) List<TjAdvice> getAdviceStringByIds(@Param("aList") String[] aList); + + List<TjAdvice> selectList(@Param("proName") String proName,@Param("deptId") String deptId,@Param("page") int i,@Param("pageSize") Integer pageSize); + Integer selectListCount(@Param("proName") String proName,@Param("deptId") String deptId); } diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjAdviceService.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjAdviceService.java index bba3d7b..252bab5 100644 --- a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjAdviceService.java +++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjAdviceService.java @@ -68,5 +68,6 @@ List<TjAdvice> getAdviceStringByIds(String[] aList); - + List<TjAdvice> selectList(String proName, String deptId, int i, Integer pageSize); + Integer selectListCount(String proName, String deptId); } diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjAdviceServiceImpl.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjAdviceServiceImpl.java index b4a5d85..9f3cabf 100644 --- a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjAdviceServiceImpl.java +++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjAdviceServiceImpl.java @@ -1,5 +1,6 @@ package com.ltkj.hosp.service.impl; +import java.util.Collections; import java.util.List; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -99,4 +100,14 @@ public List<TjAdvice> getAdviceStringByIds(String[] aList) { return tjAdviceMapper.getAdviceStringByIds(aList); } + + @Override + public Integer selectListCount(String proName, String deptId) { + return tjAdviceMapper.selectListCount(proName,deptId); + } + + @Override + public List<TjAdvice> selectList(String proName, String deptId, int i, Integer pageSize) { + return tjAdviceMapper.selectList(proName,deptId,i,pageSize); + } } diff --git a/ltkj-hosp/src/main/resources/mapper/hosp/TjAdviceMapper.xml b/ltkj-hosp/src/main/resources/mapper/hosp/TjAdviceMapper.xml index 66f9aaf..edf22c3 100644 --- a/ltkj-hosp/src/main/resources/mapper/hosp/TjAdviceMapper.xml +++ b/ltkj-hosp/src/main/resources/mapper/hosp/TjAdviceMapper.xml @@ -40,6 +40,33 @@ <include refid="selectTjAdviceVo"/> where id = #{id} </select> + <select id="selectList" resultType="com.ltkj.hosp.domain.TjAdvice"> + SELECT a.*,p.pro_name as proName,d.dept_name as deptName FROM `tj_advice` a + LEFT JOIN tj_project p ON a.pro_id = p.pro_id + LEFT JOIN sys_dept d ON a.dept_id = d.dept_id + <where> + <if test="deptId != null and deptId != ''"> + and a.dept_id = #{deptId} + </if> + <if test="proName != null and proName != ''"> + and p.pro_name like concat('%',#{proName},'%') + </if> + </where> + LIMIT #{page},#{pageSize} + </select> + + <select id="selectListCount" resultType="int"> + SELECT count(*) FROM `tj_advice` a + LEFT JOIN tj_project p ON a.pro_id = p.pro_id + <where> + <if test="deptId != null"> + and a.dept_id = #{deptId} + </if> + <if test="proName != null"> + and p.pro_name like concat('%',#{proName},'%') + </if> + </where> + </select> <insert id="insertTjAdvice" parameterType="TjAdvice" useGeneratedKeys="true" keyProperty="id"> insert into tj_advice @@ -92,4 +119,4 @@ #{id} </foreach> </delete> -</mapper> \ No newline at end of file +</mapper> -- Gitblit v1.8.0