ComplainServiceImpl.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package cn.com.lzt.complain.service.impl;
  2. import cn.com.lzt.common.util.StringUtil;
  3. import cn.com.lzt.complain.service.ComplainService;
  4. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5. import com.baomidou.mybatisplus.core.metadata.IPage;
  6. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  7. import com.daju.common.util.DataPage;
  8. import com.daju.mix.dao.entity.TBComplaint;
  9. import com.daju.mix.dao.mapper.TBComplaintMapper;
  10. import com.daju.mix.dao.service.impl.BaseServiceImpl;
  11. import org.apache.commons.lang3.StringUtils;
  12. import org.jeecgframework.core.util.JeecgDataAutorUtils;
  13. import org.jeecgframework.core.util.ResourceUtil;
  14. import org.jeecgframework.web.system.pojo.base.TSUser;
  15. import org.springframework.stereotype.Service;
  16. import javax.servlet.http.HttpServletRequest;
  17. import java.util.Map;
  18. /**
  19. * @author :sahib.kio.m
  20. * @date :Created in 2021/8/13 下午3:48
  21. */
  22. @Service
  23. public class ComplainServiceImpl extends BaseServiceImpl<TBComplaintMapper, TBComplaint> implements ComplainService {
  24. public DataPage list(Map<String, String> param) {
  25. DataPage result = new DataPage();
  26. int page = 1;
  27. if(param.containsKey("page")){
  28. page = Integer.valueOf(param.get("page"));
  29. }
  30. int rows = 999;
  31. if(param.containsKey("rows")){
  32. rows = Integer.valueOf(param.get("rows"));
  33. }
  34. TSUser user = ResourceUtil.getSessionUser();
  35. String userId = user.getId();
  36. String code = param.get("code");
  37. String departId = param.get("depart.id");
  38. String backStatus = param.get("back.status");
  39. String complainDate = param.get("complaint.date");
  40. String responsible = param.get("responsible.user.str");
  41. String leader = param.get("leader.user.str");
  42. String from = param.get("complaint.from");
  43. String type = param.get("type");
  44. String area = param.get("area");
  45. String status = param.get("status");
  46. String rate = param.get("rate");
  47. QueryWrapper<?> queryWrapper = new QueryWrapper<>();
  48. String selectSql = " SELECT TBC.* " +
  49. "FROM T_B_COMPLAINT TBC WHERE 1 = 1\n";
  50. if(!StringUtil.isEmpty(code)){
  51. selectSql += "and TBC.code like '%" + code + "%' ";
  52. }
  53. if(!StringUtil.isEmpty(complainDate)){
  54. selectSql += "and TBC.complaint_date LIKE '%" + complainDate + "%' ";
  55. }
  56. if(!StringUtil.isEmpty(departId)){
  57. selectSql += "and TBC.depart_id LIKE '%" + departId + "%' ";
  58. }
  59. boolean queryUserState = false;
  60. if(!StringUtil.isEmpty(responsible)){
  61. queryUserState = true;
  62. selectSql += "and TBC.responsible_user_id in (select id from t_s_base_user where realname like '%" + responsible + "%')";
  63. }
  64. if(!StringUtil.isEmpty(leader)){
  65. queryUserState = true;
  66. selectSql += "and TBC.leader_user_id in (select id from t_s_base_user where realname like '%" + leader + "%')";
  67. }
  68. if(!StringUtil.isEmpty(backStatus)){
  69. selectSql += "and TBC.back_status = '" + backStatus + "' ";
  70. }
  71. if(!StringUtil.isEmpty(from)){
  72. selectSql += "and TBC.complaint_from = '" + from + "' ";
  73. }
  74. String MENU_DATA_AUTHOR_RULE_SQL = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  75. if(StringUtils.isNotEmpty(MENU_DATA_AUTHOR_RULE_SQL)){
  76. selectSql += MENU_DATA_AUTHOR_RULE_SQL;
  77. }
  78. if(!StringUtil.isEmpty(type)){
  79. selectSql += "and TBC.type = '" + type + "' ";
  80. }
  81. if(!StringUtil.isEmpty(area)){
  82. selectSql += "and TBC.area = '" + area + "' ";
  83. }
  84. if(!StringUtil.isEmpty(status)){
  85. selectSql += "and TBC.status = '" + status + "' ";
  86. }
  87. if(!StringUtil.isEmpty(rate)){
  88. selectSql += "and TBC.rate = '" + rate + "' ";
  89. }
  90. if(!queryUserState){
  91. selectSql += " or TBC.responsible_user_id like '%"+userId+"%' or TBC.leader_user_id like '%"+userId+"%' or TBC.create_by like '%"+userId+"%' ";
  92. }
  93. selectSql += "\t order by TBC.complaint_date desc ";
  94. IPage<Map<String, Object>> mapPage = getBaseMapper().queryMapPageBySql(new Page<>(page, rows), queryWrapper, selectSql);
  95. result.setList(mapPage.getRecords());
  96. result.setTotalCount((int) mapPage.getTotal());
  97. return result;
  98. }
  99. }