Browse Source

权限过滤调整

yzc 1 year ago
parent
commit
76a80fc097

+ 5 - 0
hx-mes/src/main/java/com/fjhx/mes/entity/material/dto/MaterialPreparationSelectDto.java

@@ -19,4 +19,9 @@ public class MaterialPreparationSelectDto extends BaseSelectDto {
      */
     private Integer status;
 
+    /**
+     * 归属公司
+     */
+    private Long companyId;
+
 }

+ 5 - 0
hx-mes/src/main/java/com/fjhx/mes/entity/material/po/MaterialPreparation.java

@@ -66,4 +66,9 @@ public class MaterialPreparation extends BasePo {
      */
     private Integer status;
 
+    /**
+     * 归属公司
+     */
+    private Long companyId;
+
 }

+ 5 - 0
hx-mes/src/main/java/com/fjhx/mes/entity/production/dto/ProduceOrderDetailSelectDto.java

@@ -31,4 +31,9 @@ public class ProduceOrderDetailSelectDto extends BaseSelectDto {
      */
     private Date endDeliveryPeriod;
 
+    /**
+     * 归属公司Id
+     */
+    private Long companyId;
+
 }

+ 13 - 8
hx-mes/src/main/java/com/fjhx/mes/entity/production/po/ProductionOrder.java

@@ -39,14 +39,19 @@ public class ProductionOrder extends BasePo {
 	 */
 	private Long produceCompanyId;
 
-	/**
-	 * 生产状态 0未开始 1进行中 2已完成
-	 */
-	private Integer produceStatus;
+    /**
+     * 生产状态 0未开始 1进行中 2已完成
+     */
+    private Integer produceStatus;
 
-	/**
-	 * 租户id
-	 */
-	private String tenantId;
+    /**
+     * 租户id
+     */
+    private String tenantId;
+
+    /**
+     * 归属公司
+     */
+    private Long companyId;
 
 }

+ 5 - 0
hx-mes/src/main/java/com/fjhx/mes/entity/production/po/ProductionOrderDetail.java

@@ -68,4 +68,9 @@ public class ProductionOrderDetail extends BasePo {
 
     private Date finishTime;
 
+    /**
+     * 归属公司Id
+     */
+    private Long companyId;
+
 }

+ 6 - 1
hx-mes/src/main/java/com/fjhx/mes/entity/work/dto/WorkOrderSelectDto.java

@@ -7,7 +7,7 @@ import lombok.Setter;
 /**
  * 工单列表查询入参实体
  *
- * @author 
+ * @author
  * @since 2023-03-29
  */
 @Getter
@@ -19,4 +19,9 @@ public class WorkOrderSelectDto extends BaseSelectDto {
      */
     private String source;
 
+    /**
+     * 归属公司Id
+     */
+    private Long companyId;
+
 }

+ 5 - 0
hx-mes/src/main/java/com/fjhx/mes/entity/work/po/WorkOrder.java

@@ -70,4 +70,9 @@ public class WorkOrder extends BasePo {
      */
     private Long contractDetailsId;
 
+    /**
+     * 归属公司Id
+     */
+    private Long companyId;
+
 }

+ 11 - 0
hx-mes/src/main/java/com/fjhx/mes/service/material/impl/MaterialPreparationServiceImpl.java

@@ -8,11 +8,14 @@ import com.fjhx.mes.entity.material.po.MaterialPreparation;
 import com.fjhx.mes.entity.material.vo.MaterialPreparationVo;
 import com.fjhx.mes.mapper.material.MaterialPreparationMapper;
 import com.fjhx.mes.service.material.MaterialPreparationService;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.ruoyi.common.utils.wrapper.SqlField;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Objects;
+
 
 /**
  * <p>
@@ -41,6 +44,14 @@ public class MaterialPreparationServiceImpl extends ServiceImpl<MaterialPreparat
         //关键字过滤
         wrapper.keyword(dto.getKeyword(), new SqlField("pi.code"));
 
+        //权限过滤:生产备料-子公司看自己的,总公司看全部
+        Long companyId = SecurityUtils.getCompanyId();
+        if (!Objects.equals(companyId, 100L)) {
+            wrapper.eq(MaterialPreparation::getCompanyId, companyId);
+        } else {
+            wrapper.eq(MaterialPreparation::getCompanyId, dto.getCompanyId());
+        }
+
         wrapper.orderByDesc("mp", MaterialPreparation::getCreateTime);
         wrapper.orderByDesc("mp", MaterialPreparation::getId);
 

+ 10 - 0
hx-mes/src/main/java/com/fjhx/mes/service/production/impl/ProduceOrderDetailServiceImpl.java

@@ -12,6 +12,7 @@ import com.fjhx.mes.entity.production.vo.ProductionProcessesVo;
 import com.fjhx.mes.mapper.production.ProduceOrderDetailMapper;
 import com.fjhx.mes.mapper.production.ProductionProcessesMapper;
 import com.fjhx.mes.service.production.ProduceOrderDetailService;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.ruoyi.common.utils.wrapper.SqlField;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +21,7 @@ import org.springframework.stereotype.Service;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 
@@ -57,6 +59,14 @@ public class ProduceOrderDetailServiceImpl extends ServiceImpl<ProduceOrderDetai
         wrapper.orderByDesc("po", ProductionOrder::getCreateTime);
         wrapper.orderByDesc("pod", ProductionOrderDetail::getId);
 
+        //权限过滤:生产订单-子公司看自己的,总公司看全部
+        Long companyId = SecurityUtils.getCompanyId();
+        if (!Objects.equals(companyId, 100L)) {
+            wrapper.eq("po", ProductionOrder::getCompanyId, companyId);
+        } else {
+            wrapper.eq("po", ProductionOrder::getCompanyId, dto.getCompanyId());
+        }
+
         Page<ProductionOrderDetailVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         List<ProductionOrderDetailVo> records = page.getRecords();
         if (ObjectUtil.isEmpty(records)) {

+ 13 - 3
hx-mes/src/main/java/com/fjhx/mes/service/production/impl/ProduceOrderServiceImpl.java

@@ -92,6 +92,14 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
         //关键字
         wrapper.keyword(dto.getKeyword(), new SqlField(ProductionOrder::getCode));
 
+        //权限过滤:生产订单-子公司看自己的,总公司看全部
+        Long companyId = SecurityUtils.getCompanyId();
+        if (!Objects.equals(companyId, 100L)) {
+            wrapper.eq(ProductionOrder::getCompanyId, companyId);
+        } else {
+            wrapper.eq(ProductionOrder::getCompanyId, dto.getCompanyId());
+        }
+
         Page<ProductionOrderVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         List<ProductionOrderVo> records = page.getRecords();
         if (ObjectUtil.isEmpty(records)) {
@@ -167,8 +175,8 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
         //将数据移到归属公司下
         SysDept produceCompany = sysDeptService.getById(produceOrderDto.getProduceCompanyId());
         Assert.notEmpty(produceCompany, "查询不到生产公司信息");
-        String tenantId = produceCompany.getTenantId();
-        produceOrderDto.setTenantId(tenantId);
+        Long companyId = produceCompany.getDeptId();
+        produceOrderDto.setCompanyId(companyId);
 
         //获取合同信息
         Contract contract = contractService.getById(contractId);
@@ -197,7 +205,7 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
             productionOrderDetail.setQuantity(contractProduct.getQuantity());
             productionOrderDetail.setFinishQuantity(BigDecimal.ZERO);
             productionOrderDetail.setProduceStatus(0);
-            productionOrderDetail.setTenantId(tenantId);
+            productionOrderDetail.setCompanyId(companyId);
             productionOrderDetailList.add(productionOrderDetail);
 
             //创建备料
@@ -218,6 +226,7 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
                 materialPreparation.setMaterialId(bomDetail.getMaterialId());
                 materialPreparation.setQuantity(multiply);
                 materialPreparation.setStatus(0);
+                materialPreparation.setCompanyId(companyId);
                 materialPreparationList.add(materialPreparation);
             }
             materialPreparationService.saveBatch(materialPreparationList);
@@ -238,6 +247,7 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
                 workOrder.setStatus(0);
                 workOrder.setContractId(contractId);
                 workOrder.setContractDetailsId(contractProduct.getId());
+                workOrder.setCompanyId(companyId);
                 workOrderList.add(workOrder);
             }
         }

+ 14 - 3
hx-mes/src/main/java/com/fjhx/mes/service/work/impl/WorkOrderServiceImpl.java

@@ -32,6 +32,7 @@ import com.fjhx.wms.entity.stock.po.StockFrozen;
 import com.fjhx.wms.service.stock.StockFrozenService;
 import com.fjhx.wms.service.stock.StockService;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -41,6 +42,7 @@ import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 
@@ -78,13 +80,22 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
     @Override
     public Page<WorkOrderVo> getPage(WorkOrderSelectDto dto) {
         IWrapper<WorkOrder> wrapper = getWrapper();
-        if(ObjectUtil.isNotEmpty(dto.getKeyword())){
-            wrapper.and(q->q.like("wo", WorkOrder::getCode, dto.getKeyword())
+        if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
+            wrapper.and(q -> q.like("wo", WorkOrder::getCode, dto.getKeyword())
                     .or()
                     .like("wo", WorkOrder::getQuantity, dto.getKeyword()));
         }
-        wrapper.eq("wo",WorkOrder::getSource,dto.getSource());
+        wrapper.eq("wo", WorkOrder::getSource, dto.getSource());
         wrapper.orderByDesc("wo", WorkOrder::getId);
+
+        //权限过滤:生产工单-子公司看自己的,总公司看全部
+        Long companyId = SecurityUtils.getCompanyId();
+        if (!Objects.equals(companyId, 100L)) {
+            wrapper.eq("wo", WorkOrder::getCompanyId, companyId);
+        } else {
+            wrapper.eq("wo", WorkOrder::getCompanyId, dto.getCompanyId());
+        }
+
         Page<WorkOrderVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         List<WorkOrderVo> records = page.getRecords();
         //赋值产品名