Commit b05e88251211b2899058e82aafaaa95eb3fbce81

Authored by 杨鸣坤
1 parent abfe9061

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

... ... @@ -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 176 PageResult<ContractDistributorStandard> pageResult = contractDistributorStandardService.query(getPageIndex(vo), getPageSize(vo), vo);
181 177
182 178 List<ContractDistributorStandard> datas = pageResult.getDatas();
... ...
... ... @@ -13,7 +13,10 @@ import com.lframework.starter.mq.core.service.MqProducerService;
13 13 import com.lframework.starter.web.core.components.security.SecurityUtil;
14 14 import com.lframework.starter.web.inner.dto.message.SysSiteMessageDto;
15 15 import com.lframework.starter.web.inner.entity.SysDataDicItem;
  16 +import com.lframework.starter.web.inner.entity.SysRole;
16 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 20 import com.lframework.starter.web.inner.service.system.SysUserRoleService;
18 21 import com.lframework.xingyun.basedata.entity.Workshop;
19 22 import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
... ... @@ -72,6 +75,9 @@ public class ContractDistributorStandardServiceImpl extends
72 75 private static final String FORMAL_FLAG = "FORMAL_CONTRACT"; // 正式合同审批
73 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 81 @Autowired
76 82 private ContractDistributorLineService contractDistributorLineService;
77 83 @Autowired
... ... @@ -92,6 +98,10 @@ public class ContractDistributorStandardServiceImpl extends
92 98 private WorkshopService workshopService;
93 99 @Autowired
94 100 private MqProducerService mqProducerService;
  101 + @Resource
  102 + private SysRoleService sysRoleService;
  103 + @Resource
  104 + private SysUserDeptService sysUserDeptService;
95 105
96 106 @Override
97 107 public PageResult<ContractDistributorStandard> query(Integer pageIndex, Integer pageSize, QueryContractDistributorStandardVo vo) {
... ... @@ -99,14 +109,30 @@ public class ContractDistributorStandardServiceImpl extends
99 109 Assert.greaterThanZero(pageIndex);
100 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 130 PageHelperUtil.startPage(pageIndex, pageSize);
103 131 List<ContractDistributorStandard> datas = this.query(vo);
104 132 if (CollectionUtils.isEmpty(datas)) {
105 133 return PageResultUtil.convert(new PageInfo<>(datas));
106 134 }
107 135
108   - // 获取当前人员的待办任务数据
109   - List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId());
110 136 if (CollectionUtils.isEmpty(flowTaskList)) {
111 137 return PageResultUtil.convert(new PageInfo<>(datas));
112 138 }
... ...
... ... @@ -83,7 +83,13 @@ public class QueryContractDistributorStandardVo extends PageVo implements BaseVo
83 83 @ApiModelProperty("创建人ID")
84 84 private String createById;
85 85
  86 + @ApiModelProperty("创建人ID集合")
  87 + private List<String> createByIdList;
  88 +
86 89 @ApiModelProperty("关键字搜索(办事处、客户、编号)")
87 90 private String keyword;
  91 +
  92 + @ApiModelProperty("有审核权限的合同ID集合")
  93 + private List<String> contractIdList;
88 94 }
89 95
... ...
... ... @@ -163,9 +163,6 @@
163 163 </if>
164 164 </otherwise>
165 165 </choose>
166   - <if test="vo.orderDate != null">
167   - AND tb.order_date IN (#{vo.orderDate})
168   - </if>
169 166 <if test="vo.orderDateStart != null">
170 167 AND tb.order_date &gt;= #{vo.orderDateStart}
171 168 </if>
... ... @@ -175,9 +172,6 @@
175 172 <if test="vo.status != null">
176 173 AND tb.status LIKE CONCAT(#{vo.status}, '%')
177 174 </if>
178   - <if test="vo.createById != null and vo.createById != ''">
179   - AND tb.create_by_id = #{vo.createById}
180   - </if>
181 175 <if test="vo.type != null">
182 176 AND tb.type = #{vo.type}
183 177 </if>
... ... @@ -187,6 +181,36 @@
187 181 <if test="vo.standardApproved != null">
188 182 AND tb.standard_approved = #{vo.standardApproved}
189 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 214 </where>
191 215 order by tb.create_time desc
192 216 </select>
... ...