Browse Source

问题处理

yzc 1 year ago
parent
commit
091b18cef8

+ 48 - 6
hx-jushuitan/src/main/java/com/fjhx/jushuitan/service/shop/impl/ShopInfoServiceImpl.java

@@ -1,6 +1,8 @@
 package com.fjhx.jushuitan.service.shop.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.jushuitan.entity.shop.dto.ShopInfoDto;
@@ -9,10 +11,18 @@ import com.fjhx.jushuitan.entity.shop.po.ShopInfo;
 import com.fjhx.jushuitan.entity.shop.vo.ShopInfoVo;
 import com.fjhx.jushuitan.mapper.shop.ShopInfoMapper;
 import com.fjhx.jushuitan.service.shop.ShopInfoService;
+import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.utils.wrapper.IWrapper;
-import com.ruoyi.common.utils.wrapper.SqlField;
+import com.ruoyi.framework.mybatis.holder.TenantHolder;
+import com.ruoyi.system.service.ISysDeptService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 
 /**
  * <p>
@@ -25,19 +35,51 @@ import org.springframework.stereotype.Service;
 @Service
 public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> implements ShopInfoService {
 
+    @Autowired
+    private ISysDeptService deptService;
+
     @Override
     public Page<ShopInfoVo> getPage(ShopInfoSelectDto dto) {
         IWrapper<ShopInfo> wrapper = getWrapper();
 
         //关键字检索
-        wrapper.keyword(dto.getKeyword(),
-                new SqlField(ShopInfo::getCode),
-                new SqlField(ShopInfo::getCode),
-                new SqlField("de", ShopInfoVo::getDeptName)
-        );
+        if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
+            TenantHolder.setIgnore(true);
+            List<SysDept> deptList = deptService.list(Wrappers.<SysDept>query()
+                    .like("dept_name", dto.getKeyword())
+            );
+            TenantHolder.clear();
+            List<Long> deptIds = deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList());
+            wrapper.and(q -> q
+                    .like(ShopInfo::getCode, dto.getKeyword())
+                    .or().like(ShopInfo::getName, dto.getKeyword())
+                    .or().in(ShopInfo::getDeptId, deptIds)
+            );
+        }
 
         wrapper.orderByDesc("si", ShopInfo::getId);
         Page<ShopInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+
+        if (ObjectUtil.isEmpty(page)) {
+            return page;
+        }
+        List<ShopInfoVo> records = page.getRecords();
+
+        List<Long> deptIds = records.stream().map(ShopInfo::getDeptId).collect(Collectors.toList());
+
+        TenantHolder.setIgnore(true);
+        Map<Long, String> deptMap = new HashMap<>();
+        if (ObjectUtil.isNotEmpty(deptIds)) {
+            List<SysDept> deptList = deptService.list(Wrappers.<SysDept>query().in("dept_id", deptIds));
+            deptMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
+        }
+        TenantHolder.clear();
+
+        for (ShopInfoVo record : records) {
+            //赋值部门id
+            record.setDeptName(deptMap.get(record.getDeptId()));
+        }
+
         return page;
     }
 

+ 1 - 3
hx-jushuitan/src/main/resources/mapper/shop/ShopInfoMapper.xml

@@ -9,10 +9,8 @@
                si.create_user,
                si.create_time,
                si.update_user,
-               si.update_time,
-               de.dept_name
+               si.update_time
         from shop_info si
-                 LEFT JOIN sys_dept de ON si.dept_id = de.dept_id
             ${ew.customSqlSegment}
     </select>
 

+ 16 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/contract/po/ContractProduct.java

@@ -125,4 +125,20 @@ public class ContractProduct extends BasePo {
     @TableField(exist = false)
     private String productUnit;
 
+    /**
+     * 产品长
+     */
+    @TableField(exist = false)
+    private BigDecimal productLength;
+    /**
+     * 产品宽
+     */
+    @TableField(exist = false)
+    private BigDecimal productWidth;
+    /**
+     * 产品高
+     */
+    @TableField(exist = false)
+    private BigDecimal productHeight;
+
 }

+ 5 - 1
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -1097,8 +1097,12 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         List<ContractProduct> contractProductList = contractProductService.list(q -> q.eq(ContractProduct::getContractId, id));
         productInfoService.attributeAssign(contractProductList, ContractProduct::getProductId, (item, product) -> {
             item.setProductCnName(product.getName());
-            item.setProductCode(product.getCode());
+            item.setProductCode(product.getCustomCode());
             item.setProductUnit(product.getUnit());
+
+            item.setProductLength(product.getLength());
+            item.setProductWidth(product.getWidth());
+            item.setProductHeight(product.getHeight());
         });
         //重新赋值待采购数量
         List<Long> contractProductIds = contractProductList.stream().map(ContractProduct::getId).collect(Collectors.toList());