feat(system):库区管理新增库区面积合计查询接口
新增 GET /storageSectionApi/sumStorageRegion,与库区列表 /list 相同筛选条件及组织数据权限, SQL 端 IFNULL(SUM(storage_region),0) 返回面积合计(平方米),无数据返回0; 抽取 queryList 数据权限为 applyQueryDataPermission 供列表与合计共用,/list 行为不变。
This commit is contained in:
+22
-1
@@ -21,6 +21,7 @@ import com.mhd.system.service.ISysDictTypeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 库区ApplicationService
|
||||
@@ -42,6 +43,27 @@ public class StorageSectionApplicationService {
|
||||
*/
|
||||
|
||||
public List<StorageSectionPO> queryList(StorageSectionDO storageSectionDO) {
|
||||
//设置查询数据权限
|
||||
applyQueryDataPermission(storageSectionDO);
|
||||
return storageSectionDomainService.queryList(storageSectionDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 库区面积合计:与 /list 相同的数据权限和筛选条件,SQL 直接 SUM(库区面积),
|
||||
* 保证合计数与列表中各行库区面积之和一致
|
||||
*/
|
||||
public BigDecimal sumStorageRegion(StorageSectionDO storageSectionDO) {
|
||||
//与 /list 共用同一数据权限,保证合计与列表口径一致
|
||||
applyQueryDataPermission(storageSectionDO);
|
||||
return storageSectionDomainService.sumStorageRegion(storageSectionDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 设置查询数据权限(queryList 与 sumStorageRegion 共用)
|
||||
* @author ZhouGY
|
||||
* @param storageSectionDO
|
||||
*/
|
||||
private void applyQueryDataPermission(StorageSectionDO storageSectionDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
@@ -91,7 +113,6 @@ public class StorageSectionApplicationService {
|
||||
}
|
||||
}
|
||||
}
|
||||
return storageSectionDomainService.queryList(storageSectionDO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
@@ -5,6 +5,7 @@ import com.mhd.basic.domain.storageSection.entity.StorageSection;
|
||||
import com.mhd.basic.domain.storageSection.repository.po.StorageSectionPO;
|
||||
import com.mhd.basic.domain.storageSection.repository.todo.StorageSectionDO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -20,6 +21,11 @@ public interface IStorageSectionService extends IService<StorageSection>
|
||||
*/
|
||||
public List<StorageSectionPO> queryList(StorageSectionDO storageSectionDO);
|
||||
|
||||
/**
|
||||
* 库区面积合计(与 queryList 相同筛选条件)
|
||||
*/
|
||||
public BigDecimal sumStorageRegion(StorageSectionDO storageSectionDO);
|
||||
|
||||
/**
|
||||
* 新增库区
|
||||
*/
|
||||
|
||||
+6
@@ -1,5 +1,6 @@
|
||||
package com.mhd.basic.domain.storageSection.repository.mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhd.basic.domain.storageSection.entity.StorageSection;
|
||||
@@ -19,4 +20,9 @@ public interface StorageSectionMapper extends BaseMapper<StorageSection>
|
||||
*/
|
||||
public List<StorageSectionPO> queryList(StorageSectionDO storageSectionDO);
|
||||
|
||||
/**
|
||||
* 库区面积合计(与 queryList 相同筛选条件)
|
||||
*/
|
||||
public BigDecimal sumStorageRegion(StorageSectionDO storageSectionDO);
|
||||
|
||||
}
|
||||
|
||||
+10
@@ -10,6 +10,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,6 +34,15 @@ public class StorageSectionImpl extends ServiceImpl<StorageSectionMapper, Storag
|
||||
return storageSectionMapper.queryList(storageSectionDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 库区面积合计(与 queryList 相同筛选条件)
|
||||
*/
|
||||
@Override
|
||||
public BigDecimal sumStorageRegion(StorageSectionDO storageSectionDO)
|
||||
{
|
||||
return storageSectionMapper.sumStorageRegion(storageSectionDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增库区
|
||||
*/
|
||||
|
||||
+8
@@ -21,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -53,6 +54,13 @@ public class StorageSectionDomainService {
|
||||
return storageSectionService.queryList(storageSectionDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 库区面积合计(与 queryList 相同筛选条件)
|
||||
*/
|
||||
public BigDecimal sumStorageRegion(StorageSectionDO storageSectionDO) {
|
||||
return storageSectionService.sumStorageRegion(storageSectionDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增库区
|
||||
|
||||
+12
@@ -55,6 +55,18 @@ public class StorageSectionApi extends BaseController{
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 库区面积合计:与 /list 相同的筛选条件,返回库区面积总和
|
||||
*/
|
||||
@ApiOperation("查询库区面积合计(与库区列表相同筛选条件,SUM(库区面积))")
|
||||
@GetMapping("/sumStorageRegion")
|
||||
public AjaxResult sumStorageRegion(StorageSectionDTO storageSectionDTO)
|
||||
{
|
||||
//转换实体
|
||||
StorageSectionDO storageSectionDO = storageSectionAssembler.toDO(storageSectionDTO);
|
||||
return AjaxResult.success(storageSectionApplicationService.sumStorageRegion(storageSectionDO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询库区列表
|
||||
*/
|
||||
|
||||
+8
@@ -102,4 +102,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectStorageSectionPo1"/>
|
||||
order by a.storage_name asc, a.create_time desc
|
||||
</select>
|
||||
|
||||
<!-- 库区面积合计:与 queryList 相同筛选条件,SUM(库区面积),无数据时返回 0 -->
|
||||
<select id="sumStorageRegion" parameterType="com.mhd.basic.domain.storageSection.repository.todo.StorageSectionDO" resultType="java.math.BigDecimal">
|
||||
select IFNULL(SUM(a.storage_region), 0)
|
||||
from storage_section a
|
||||
LEFT JOIN warehouse w ON a.warehouse_id = w.warehouse_id AND w.del_flag = 1
|
||||
<include refid="selectStorageSectionPo1"/>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user