Commit 394b4ee990728664596ff4d49eed663eec1541b2

Authored by yeqianyong
1 parent 20c27e8e

楚江erp:1、业务员可以对本区域的发货计划进行操作;2、自动生成发货单时经营办发货员数据剔除

... ... @@ -13,6 +13,7 @@ import com.lframework.starter.web.inner.dto.message.SysSiteMessageDto;
13 13 import com.lframework.starter.web.inner.entity.SysDept;
14 14 import com.lframework.starter.web.inner.service.DicCityService;
15 15 import com.lframework.starter.web.inner.service.system.SysDeptService;
  16 +import com.lframework.starter.web.inner.service.system.SysUserRoleService;
16 17 import com.lframework.xingyun.basedata.entity.Customer;
17 18 import com.lframework.xingyun.basedata.entity.Workshop;
18 19 import com.lframework.xingyun.basedata.service.customer.CustomerService;
... ... @@ -87,6 +88,8 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr
87 88 private MqProducerService mqProducerService;
88 89 @Resource
89 90 private PurchaseOrderLineService purchaseOrderLineService;
  91 + @Resource
  92 + private SysUserRoleService sysUserRoleService;
90 93
91 94
92 95 @Override
... ... @@ -304,6 +307,8 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr
304 307 if (CollectionUtils.isEmpty(detailList)) {
305 308 throw new DefaultClientException("发货明细数据不存在!");
306 309 }
  310 + // 剔除经营办发货员添加的计划
  311 + dataFilter(detailList);
307 312 // 根据客户分组
308 313 Map<String, List<ShipmentsPlanDetail>> detailMap = new HashMap<>();
309 314 for (ShipmentsPlanDetail detail : detailList) {
... ... @@ -751,4 +756,35 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr
751 756 ticketVo.setLoadingTime(loadingTime);
752 757 return ticketVo;
753 758 }
  759 +
  760 +
  761 + /**
  762 + * 数据过滤
  763 + *
  764 + * @param dataList 源数据
  765 + */
  766 + private void dataFilter(List<ShipmentsPlanDetail> dataList) {
  767 + if (CollectionUtils.isEmpty(dataList)) {
  768 + return;
  769 + }
  770 + // 获取所有经营办发货员
  771 + List<String> roleCodeList = new ArrayList<>();
  772 + roleCodeList.add("yfcjybfhy");
  773 + roleCodeList.add("efcjybfhy");
  774 + roleCodeList.add("sfcjybfhy");
  775 + roleCodeList.add("ztfcjybfhy");
  776 + List<String> deliveryUserIds = sysUserRoleService.listUserIdByRoleCodes(roleCodeList);
  777 + if (CollectionUtils.isEmpty(deliveryUserIds)) {
  778 + return;
  779 + }
  780 + Iterator<ShipmentsPlanDetail> iterator = dataList.iterator();
  781 + while (iterator.hasNext()) {
  782 + ShipmentsPlanDetail next = iterator.next();
  783 + String createById = next.getCreateById();
  784 + if (deliveryUserIds.contains(createById)) {
  785 + // 剔除经营办发货员添加的计划
  786 + iterator.remove();
  787 + }
  788 + }
  789 + }
754 790 }
... ...
... ... @@ -6,6 +6,11 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
6 6 import com.github.pagehelper.PageInfo;
7 7 import com.lframework.starter.web.core.components.security.SecurityUtil;
8 8 import com.lframework.starter.web.core.utils.*;
  9 +import com.lframework.starter.web.inner.entity.SysRole;
  10 +import com.lframework.starter.web.inner.entity.SysUserRole;
  11 +import com.lframework.starter.web.inner.service.system.SysRoleService;
  12 +import com.lframework.starter.web.inner.service.system.SysUserDeptService;
  13 +import com.lframework.starter.web.inner.service.system.SysUserRoleService;
9 14 import com.lframework.xingyun.basedata.entity.Workshop;
10 15 import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
11 16 import com.lframework.xingyun.basedata.vo.workshop.QueryWorkshopVo;
... ... @@ -49,6 +54,12 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP
49 54 private WorkshopService workshopService;
50 55 @Resource
51 56 private PurchaseOrderInfoService purchaseOrderInfoService;
  57 + @Resource
  58 + private SysUserRoleService sysUserRoleService;
  59 + @Resource
  60 + private SysRoleService sysRoleService;
  61 + @Resource
  62 + private SysUserDeptService sysUserDeptService;
52 63
53 64
54 65 @Override
... ... @@ -187,6 +198,20 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP
187 198 existOrderSpecIds.addAll(orderSpecIds);
188 199 }
189 200 vo.setOrderSpecIds(existOrderSpecIds);
  201 + // 业务员做权限控制
  202 + List<String> userIds = new ArrayList<>();
  203 + String currentUserId = SecurityUtil.getCurrentUser().getId();
  204 + List<SysUserRole> userRoles = sysUserRoleService.getByUserId(currentUserId);
  205 + List<String> roleIds = userRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList());
  206 + List<SysRole> roleList = sysRoleService.listByIds(roleIds);
  207 + for (SysRole role : roleList) {
  208 + String code = role.getCode();
  209 + if ("ywy".equals(code)) {
  210 + userIds = sysUserDeptService.listAllUserByUserId(Collections.singletonList(currentUserId), false);
  211 + break;
  212 + }
  213 + }
  214 + vo.setCreateByIds(userIds);
190 215 // 开启分页
191 216 PageHelperUtil.startPage(pageIndex, pageSize);
192 217 List<ShipmentsPlanDetail> dataList = getBaseMapper().queryCanShipmentsData(vo);
... ... @@ -433,16 +458,11 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP
433 458 LocalTime shipmentsTime = detail.getShipmentsTime();
434 459 Boolean canShipments = detail.getCanShipments();
435 460 Boolean preShipments = detail.getPreShipments();
436   - if ("CHECKING".equals(status)) {
437   - // 提交计划
  461 + if ("IN_PROGRESS".equals(status)) {
  462 + // 核对计划
438 463 if (!preShipments && shipmentsTime == null) {
439 464 throw new DefaultClientException("发货时点不能为空!");
440 465 }
441   - if (preShipments && canShipments == null) {
442   - throw new DefaultClientException("是否可发货不能为空!");
443   - }
444   - } else if ("IN_PROGRESS".equals(status)) {
445   - // 核对计划
446 466 if (!preShipments && canShipments == null) {
447 467 throw new DefaultClientException("是否可发货不能为空!");
448 468 }
... ...
... ... @@ -75,4 +75,10 @@ public class QueryShipmentsPlanDetailVo extends PageVo implements BaseVo, Serial
75 75 */
76 76 @ApiModelProperty("客户名称")
77 77 private Boolean completed;
  78 +
  79 + /**
  80 + * 创建人ID集合
  81 + */
  82 + @ApiModelProperty("创建人ID集合")
  83 + private List<String> createByIds;
78 84 }
... ...
... ... @@ -203,6 +203,12 @@
203 203 #{item}
204 204 </foreach>
205 205 </if>
  206 + <if test="vo.createByIds != null and vo.createByIds.size() > 0">
  207 + and o.contract_create_by_id in
  208 + <foreach collection="vo.createByIds" open="(" separator="," close=")" item="item">
  209 + #{item}
  210 + </foreach>
  211 + </if>
206 212 <if test="vo.orderNo != null and vo.orderNo != ''">
207 213 AND o.order_no like concat('%', #{vo.orderNo}, '%')
208 214 </if>
... ...