Commit b05e88251211b2899058e82aafaaa95eb3fbce81

Authored by 杨鸣坤
1 parent abfe9061

楚江ERP:合同列表查询接口逻辑调整

@@ -173,10 +173,6 @@ public class ContractDistributorStandardController extends DefaultBaseController @@ -173,10 +173,6 @@ public class ContractDistributorStandardController extends DefaultBaseController
173 } 173 }
174 } 174 }
175 175
176 - if (!"DELETED".equals(vo.getStatus())) {  
177 - vo.setCreateById(SecurityUtil.getCurrentUser().getId());  
178 - }  
179 -  
180 PageResult<ContractDistributorStandard> pageResult = contractDistributorStandardService.query(getPageIndex(vo), getPageSize(vo), vo); 176 PageResult<ContractDistributorStandard> pageResult = contractDistributorStandardService.query(getPageIndex(vo), getPageSize(vo), vo);
181 177
182 List<ContractDistributorStandard> datas = pageResult.getDatas(); 178 List<ContractDistributorStandard> datas = pageResult.getDatas();
@@ -13,7 +13,10 @@ import com.lframework.starter.mq.core.service.MqProducerService; @@ -13,7 +13,10 @@ import com.lframework.starter.mq.core.service.MqProducerService;
13 import com.lframework.starter.web.core.components.security.SecurityUtil; 13 import com.lframework.starter.web.core.components.security.SecurityUtil;
14 import com.lframework.starter.web.inner.dto.message.SysSiteMessageDto; 14 import com.lframework.starter.web.inner.dto.message.SysSiteMessageDto;
15 import com.lframework.starter.web.inner.entity.SysDataDicItem; 15 import com.lframework.starter.web.inner.entity.SysDataDicItem;
  16 +import com.lframework.starter.web.inner.entity.SysRole;
16 import com.lframework.starter.web.inner.service.system.SysDataDicItemService; 17 import com.lframework.starter.web.inner.service.system.SysDataDicItemService;
  18 +import com.lframework.starter.web.inner.service.system.SysRoleService;
  19 +import com.lframework.starter.web.inner.service.system.SysUserDeptService;
17 import com.lframework.starter.web.inner.service.system.SysUserRoleService; 20 import com.lframework.starter.web.inner.service.system.SysUserRoleService;
18 import com.lframework.xingyun.basedata.entity.Workshop; 21 import com.lframework.xingyun.basedata.entity.Workshop;
19 import com.lframework.xingyun.basedata.service.workshop.WorkshopService; 22 import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
@@ -72,6 +75,9 @@ public class ContractDistributorStandardServiceImpl extends @@ -72,6 +75,9 @@ public class ContractDistributorStandardServiceImpl extends
72 private static final String FORMAL_FLAG = "FORMAL_CONTRACT"; // 正式合同审批 75 private static final String FORMAL_FLAG = "FORMAL_CONTRACT"; // 正式合同审批
73 private static final String STANDARD_FLAG = "STANDARD_CONTRACT"; // 标准合同审批 76 private static final String STANDARD_FLAG = "STANDARD_CONTRACT"; // 标准合同审批
74 77
  78 + private static final String YWY_ROLE_CODE = "ywy"; // 业务员角色
  79 + private static final String QYFZR_ROLE_CODE = "qyfzr"; // 区域负责人角色
  80 +
75 @Autowired 81 @Autowired
76 private ContractDistributorLineService contractDistributorLineService; 82 private ContractDistributorLineService contractDistributorLineService;
77 @Autowired 83 @Autowired
@@ -92,6 +98,10 @@ public class ContractDistributorStandardServiceImpl extends @@ -92,6 +98,10 @@ public class ContractDistributorStandardServiceImpl extends
92 private WorkshopService workshopService; 98 private WorkshopService workshopService;
93 @Autowired 99 @Autowired
94 private MqProducerService mqProducerService; 100 private MqProducerService mqProducerService;
  101 + @Resource
  102 + private SysRoleService sysRoleService;
  103 + @Resource
  104 + private SysUserDeptService sysUserDeptService;
95 105
96 @Override 106 @Override
97 public PageResult<ContractDistributorStandard> query(Integer pageIndex, Integer pageSize, QueryContractDistributorStandardVo vo) { 107 public PageResult<ContractDistributorStandard> query(Integer pageIndex, Integer pageSize, QueryContractDistributorStandardVo vo) {
@@ -99,14 +109,30 @@ public class ContractDistributorStandardServiceImpl extends @@ -99,14 +109,30 @@ public class ContractDistributorStandardServiceImpl extends
99 Assert.greaterThanZero(pageIndex); 109 Assert.greaterThanZero(pageIndex);
100 Assert.greaterThanZero(pageSize); 110 Assert.greaterThanZero(pageSize);
101 111
  112 + // 获取当前人员的待办任务数据
  113 + List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId());
  114 + if (!"DELETED".equals(vo.getStatus())) { // 不为删除状态,则根据角色查询不同的数据
  115 + String userId = SecurityUtil.getCurrentUser().getId();
  116 + List<SysRole> sysRoleList = sysRoleService.getByUserId(userId);
  117 + String roleCodeStr = CollectionUtils.emptyIfNull(sysRoleList).stream().map(SysRole::getCode).collect(Collectors.joining(","));
  118 + if (StringUtils.isNotBlank(roleCodeStr) && roleCodeStr.equals(YWY_ROLE_CODE)) { // 业务员只查询自己的数据
  119 + vo.setCreateById(userId);
  120 + } else {
  121 + Map<String, List<String>> userIdMap = sysUserDeptService.mapAllUserByUserId(Collections.singletonList(userId), true);
  122 + vo.setCreateByIdList(userIdMap.get(userId));
  123 + vo.getCreateByIdList().add(userId);
  124 + }
  125 +
  126 + List<String> contractIdList = CollectionUtils.emptyIfNull(flowTaskList).stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toList());
  127 + vo.setContractIdList(contractIdList);
  128 + }
  129 +
102 PageHelperUtil.startPage(pageIndex, pageSize); 130 PageHelperUtil.startPage(pageIndex, pageSize);
103 List<ContractDistributorStandard> datas = this.query(vo); 131 List<ContractDistributorStandard> datas = this.query(vo);
104 if (CollectionUtils.isEmpty(datas)) { 132 if (CollectionUtils.isEmpty(datas)) {
105 return PageResultUtil.convert(new PageInfo<>(datas)); 133 return PageResultUtil.convert(new PageInfo<>(datas));
106 } 134 }
107 135
108 - // 获取当前人员的待办任务数据  
109 - List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId());  
110 if (CollectionUtils.isEmpty(flowTaskList)) { 136 if (CollectionUtils.isEmpty(flowTaskList)) {
111 return PageResultUtil.convert(new PageInfo<>(datas)); 137 return PageResultUtil.convert(new PageInfo<>(datas));
112 } 138 }
@@ -83,7 +83,13 @@ public class QueryContractDistributorStandardVo extends PageVo implements BaseVo @@ -83,7 +83,13 @@ public class QueryContractDistributorStandardVo extends PageVo implements BaseVo
83 @ApiModelProperty("创建人ID") 83 @ApiModelProperty("创建人ID")
84 private String createById; 84 private String createById;
85 85
  86 + @ApiModelProperty("创建人ID集合")
  87 + private List<String> createByIdList;
  88 +
86 @ApiModelProperty("关键字搜索(办事处、客户、编号)") 89 @ApiModelProperty("关键字搜索(办事处、客户、编号)")
87 private String keyword; 90 private String keyword;
  91 +
  92 + @ApiModelProperty("有审核权限的合同ID集合")
  93 + private List<String> contractIdList;
88 } 94 }
89 95
@@ -163,9 +163,6 @@ @@ -163,9 +163,6 @@
163 </if> 163 </if>
164 </otherwise> 164 </otherwise>
165 </choose> 165 </choose>
166 - <if test="vo.orderDate != null">  
167 - AND tb.order_date IN (#{vo.orderDate})  
168 - </if>  
169 <if test="vo.orderDateStart != null"> 166 <if test="vo.orderDateStart != null">
170 AND tb.order_date &gt;= #{vo.orderDateStart} 167 AND tb.order_date &gt;= #{vo.orderDateStart}
171 </if> 168 </if>
@@ -175,9 +172,6 @@ @@ -175,9 +172,6 @@
175 <if test="vo.status != null"> 172 <if test="vo.status != null">
176 AND tb.status LIKE CONCAT(#{vo.status}, '%') 173 AND tb.status LIKE CONCAT(#{vo.status}, '%')
177 </if> 174 </if>
178 - <if test="vo.createById != null and vo.createById != ''">  
179 - AND tb.create_by_id = #{vo.createById}  
180 - </if>  
181 <if test="vo.type != null"> 175 <if test="vo.type != null">
182 AND tb.type = #{vo.type} 176 AND tb.type = #{vo.type}
183 </if> 177 </if>
@@ -187,6 +181,36 @@ @@ -187,6 +181,36 @@
187 <if test="vo.standardApproved != null"> 181 <if test="vo.standardApproved != null">
188 AND tb.standard_approved = #{vo.standardApproved} 182 AND tb.standard_approved = #{vo.standardApproved}
189 </if> 183 </if>
  184 +
  185 + <choose>
  186 + <when test="vo.contractIdList != null and vo.contractIdList.size() > 0">
  187 + AND (tb.id IN
  188 + <foreach collection="vo.contractIdList" open="(" separator="," close=")" item="item">
  189 + #{item}
  190 + </foreach>
  191 + <if test="vo.createById != null and vo.createById != ''">
  192 + OR tb.create_by_id = #{vo.createById}
  193 + </if>
  194 + <if test="vo.createByIdList != null and vo.createByIdList.size() > 0">
  195 + OR tb.create_by_id IN
  196 + <foreach collection="vo.createByIdList" open="(" separator="," close=")" item="item">
  197 + #{item}
  198 + </foreach>
  199 + </if>
  200 + )
  201 + </when>
  202 + <otherwise>
  203 + <if test="vo.createById != null and vo.createById != ''">
  204 + AND tb.create_by_id = #{vo.createById}
  205 + </if>
  206 + <if test="vo.createByIdList != null and vo.createByIdList.size() > 0">
  207 + AND tb.create_by_id IN
  208 + <foreach collection="vo.createByIdList" open="(" separator="," close=")" item="item">
  209 + #{item}
  210 + </foreach>
  211 + </if>
  212 + </otherwise>
  213 + </choose>
190 </where> 214 </where>
191 order by tb.create_time desc 215 order by tb.create_time desc
192 </select> 216 </select>