Commit 846fd5d58117201da98ee7d27f0cb587609a7363

Authored by yeqianyong
1 parent 1988335b

楚江erp:1、发货计划列表增加权限控制(经营办发货员、精轧车间计划员);2、发货计划、发货单列表排序调整(按创建时间倒序);3、生成发货单逻辑调整(过滤掉已发货的数据)

... ... @@ -38,6 +38,7 @@ import com.lframework.xingyun.sc.vo.shipments.order.*;
38 38 import com.lframework.xingyun.sc.vo.shipments.plan.QueryShipmentsPlanDetailVo;
39 39 import lombok.extern.slf4j.Slf4j;
40 40 import org.apache.commons.collections4.CollectionUtils;
  41 +import org.apache.commons.collections4.MapUtils;
41 42 import org.apache.commons.lang3.StringUtils;
42 43 import org.springframework.transaction.annotation.Transactional;
43 44 import com.lframework.xingyun.sc.mappers.ShipmentsOrderInfoMapper;
... ... @@ -249,14 +250,21 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr
249 250 // 根据客户批量生成
250 251 List<ShipmentsPlanDetail> detailList = shipmentsPlanDetailService.listByPlanId(planId);
251 252 if (CollectionUtils.isEmpty(detailList)) {
252   - return;
  253 + throw new DefaultClientException("发货明细数据不存在!");
253 254 }
254 255 // 根据客户分组
255 256 Map<String, List<ShipmentsPlanDetail>> detailMap = new HashMap<>();
256 257 for (ShipmentsPlanDetail detail : detailList) {
  258 + // 已发货的直接过滤
  259 + if (StringUtils.isNotBlank(detail.getShipmentOrderId())) {
  260 + continue;
  261 + }
257 262 List<ShipmentsPlanDetail> list = detailMap.computeIfAbsent(detail.getCustomerId(), k -> new ArrayList<>());
258 263 list.add(detail);
259 264 }
  265 + if (MapUtils.isEmpty(detailMap)) {
  266 + throw new DefaultClientException("发货明细数据不存在!");
  267 + }
260 268 // todo 如果客户很多,则此处需要优化
261 269 for (Map.Entry<String, List<ShipmentsPlanDetail>> entry : detailMap.entrySet()) {
262 270 List<ShipmentsPlanDetail> value = entry.getValue();
... ...
... ... @@ -3,6 +3,9 @@ package com.lframework.xingyun.sc.impl.shipments;
3 3 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
4 4 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5 5 import com.github.pagehelper.PageInfo;
  6 +import com.lframework.starter.web.core.components.security.SecurityUtil;
  7 +import com.lframework.starter.web.inner.entity.SysRole;
  8 +import com.lframework.starter.web.inner.service.system.SysRoleService;
6 9 import com.lframework.xingyun.sc.entity.ShipmentsPlan;
7 10 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
8 11 import com.lframework.starter.web.core.utils.PageResultUtil;
... ... @@ -15,7 +18,7 @@ import com.lframework.starter.web.core.annotations.oplog.OpLog;
15 18 import com.lframework.starter.web.core.utils.PageHelperUtil;
16 19 import com.lframework.starter.common.utils.Assert;
17 20 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
18   -import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
  21 +import org.apache.commons.lang3.StringUtils;
19 22 import org.springframework.transaction.annotation.Transactional;
20 23 import com.lframework.xingyun.sc.mappers.ShipmentsPlanMapper;
21 24 import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanService;
... ... @@ -25,6 +28,7 @@ import com.lframework.xingyun.sc.vo.shipments.plan.UpdateShipmentsPlanVo;
25 28 import org.springframework.stereotype.Service;
26 29
27 30 import javax.annotation.Resource;
  31 +import java.util.ArrayList;
28 32 import java.util.List;
29 33
30 34 @Service
... ... @@ -33,12 +37,34 @@ public class ShipmentsPlanServiceImpl extends BaseMpServiceImpl<ShipmentsPlanMap
33 37
34 38
35 39 @Resource
36   - private PurchaseOrderLineService orderLineService;
  40 + private SysRoleService sysRoleService;
37 41
38 42 @Override
39 43 public PageResult<ShipmentsPlan> query(Integer pageIndex, Integer pageSize, QueryShipmentsPlanVo vo) {
40 44 Assert.greaterThanZero(pageIndex);
41 45 Assert.greaterThanZero(pageSize);
  46 + List<String> workshopCodeList = new ArrayList<>();
  47 + // 数据权限控制
  48 + String currentUserId = SecurityUtil.getCurrentUser().getId();
  49 + // 获取当前人所属角色
  50 + List<SysRole> roleList = sysRoleService.getByUserId(currentUserId);
  51 + for (SysRole role : roleList) {
  52 + String roleCode = role.getCode();
  53 + String workshopCode = "";
  54 + if ("yfcjybfhy".equals(roleCode) || "yfcjzcjjhy".equals(roleCode)) {
  55 + workshopCode = "yfc";
  56 + } else if ("efcjybfhy".equals(roleCode) || "efcjzcjjhy".equals(roleCode)) {
  57 + workshopCode = "efc";
  58 + } else if ("sfcjybfhy".equals(roleCode) || "sfcjzcjjhy".equals(roleCode)) {
  59 + workshopCode = "sfc";
  60 + } else if ("ztfcjybfhy".equals(roleCode) || "ztfcjzcjjhy".equals(roleCode)) {
  61 + workshopCode = "ztfc";
  62 + }
  63 + if (StringUtils.isNotBlank(workshopCode)) {
  64 + workshopCodeList.add(workshopCode);
  65 + }
  66 + }
  67 + vo.setWorkshopCodeList(workshopCodeList);
42 68 // 开启分页
43 69 PageHelperUtil.startPage(pageIndex, pageSize);
44 70 List<ShipmentsPlan> dataList = this.query(vo);
... ...
... ... @@ -6,6 +6,7 @@ import com.lframework.starter.web.core.vo.BaseVo;
6 6 import io.swagger.annotations.ApiModelProperty;
7 7 import java.io.Serializable;
8 8 import java.time.LocalDateTime;
  9 +import java.util.List;
9 10
10 11 @Data
11 12 public class QueryShipmentsPlanVo extends PageVo implements BaseVo, Serializable {
... ... @@ -19,6 +20,12 @@ public class QueryShipmentsPlanVo extends PageVo implements BaseVo, Serializable
19 20 private String workshopId;
20 21
21 22 /**
  23 + * 生产厂编号
  24 + */
  25 + @ApiModelProperty("生产厂编号")
  26 + private List<String> workshopCodeList;
  27 +
  28 + /**
22 29 * 状态
23 30 */
24 31 @ApiModelProperty("状态")
... ...
... ... @@ -70,6 +70,7 @@
70 70 AND c.name like concat('%', #{vo.customerName}, '%')
71 71 </if>
72 72 </where>
  73 + ORDER BY tb.create_time DESC
73 74 </select>
74 75
75 76 <insert id="batchAdd">
... ...
... ... @@ -37,6 +37,12 @@
37 37 <if test="vo.workshopId != null and vo.workshopId != ''">
38 38 AND tb.workshop_id = #{vo.workshopId}
39 39 </if>
  40 + <if test="vo.workshopCodeList != null and vo.workshopCodeList.size() > 0">
  41 + AND w.code IN
  42 + <foreach collection="vo.workshopCodeList" open="(" separator="," close=")" item="item">
  43 + #{item}
  44 + </foreach>
  45 + </if>
40 46 <if test="vo.status != null and vo.status != ''">
41 47 AND tb.status = #{vo.status}
42 48 </if>
... ... @@ -47,6 +53,7 @@
47 53 AND tb.create_time &lt;= #{vo.createEndTime}
48 54 </if>
49 55 </where>
  56 + ORDER BY tb.create_time DESC
50 57 </select>
51 58
52 59 <select id="getById" resultType="com.lframework.xingyun.sc.entity.ShipmentsPlan">
... ...