领导人员功能开发

This commit is contained in:
lizhenhua 2026-01-30 11:29:15 +08:00
parent 6fd11a195e
commit d9eb7a0193
11 changed files with 494 additions and 46 deletions

View File

@ -18,6 +18,13 @@ import java.util.Date;
@Data @Data
public class DrpInventoryoutDetailVO { public class DrpInventoryoutDetailVO {
/**
* 记录类型标识
* 0: 正常入库记录
* 1: 退款记录数量金额为负
*/
private Integer recordTypeFlag;
/** 仓库ID */ /** 仓库ID */
private Long warehouseId; private Long warehouseId;

View File

@ -67,4 +67,7 @@ public class InventoryGoodsSummaryVO {
@Excel(name = "仓库名称") @Excel(name = "仓库名称")
private String warehouseName; private String warehouseName;
private String supplierName;
private Long supplierId;
} }

View File

@ -9,6 +9,7 @@ import com.bonus.canteen.core.reportforms.service.DrpInventoryService;
import com.bonus.common.core.utils.poi.ExcelUtil; import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -75,5 +76,14 @@ public class DrpInventoryController extends BaseController{
ajax.put("summary", summary); ajax.put("summary", summary);
return ajax; return ajax;
} }
/**
* 供应商汇总
*/
@GetMapping("/summarylist")
public TableDataInfo summarylist(DrpInventoryIntoDetailQueryDTO inventoryInOutSummaryVO)
{
startPage();
List<InventoryGoodsSummaryVO> list = drpInventoryService.selectInventoryInOutSummaryList(inventoryInOutSummaryVO);
return getDataTable(list);
}
} }

View File

@ -146,4 +146,5 @@ public class DrpInventoryIntoDetailController extends BaseController
List<DrpDictVO> list = drpInventoryIntoDetailService.getGoodsCategoryDict(); List<DrpDictVO> list = drpInventoryIntoDetailService.getGoodsCategoryDict();
return AjaxResult.success(list); return AjaxResult.success(list);
} }
} }

View File

@ -3,6 +3,7 @@ package com.bonus.canteen.core.reportforms.mapper;
import com.bonus.canteen.core.reportforms.beans.*; import com.bonus.canteen.core.reportforms.beans.*;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface DrpInventoryhzMapper { public interface DrpInventoryhzMapper {
@ -13,4 +14,9 @@ public interface DrpInventoryhzMapper {
List<ReportDrpInventoryWarehouseSummaryVO> queryInventoryWarehouseSummaryList(DrpInventoryIntoDetailWrapper wrapper); List<ReportDrpInventoryWarehouseSummaryVO> queryInventoryWarehouseSummaryList(DrpInventoryIntoDetailWrapper wrapper);
InventoryIntoSummaryVO queryInventoryWarehouseSummarySum(DrpInventoryIntoDetailWrapper wrapper); InventoryIntoSummaryVO queryInventoryWarehouseSummarySum(DrpInventoryIntoDetailWrapper wrapper);
List<InventoryGoodsSummaryVO> queryInventorySupplierSummaryList(DrpInventoryIntoDetailWrapper wrapper);
List<InventoryGoodsSummaryVO> queryWarehouseInventorySupplierSummaryList(@Param("idList") List<Long> idList,
@Param("wrapper") DrpInventoryIntoDetailWrapper wrapper);
} }

View File

@ -3,6 +3,7 @@ package com.bonus.canteen.core.reportforms.service;
import com.bonus.canteen.core.reportforms.beans.DrpInventoryIntoDetailQueryDTO; import com.bonus.canteen.core.reportforms.beans.DrpInventoryIntoDetailQueryDTO;
import com.bonus.canteen.core.reportforms.beans.DrpInventoryIntoDetailVO; import com.bonus.canteen.core.reportforms.beans.DrpInventoryIntoDetailVO;
import com.bonus.canteen.core.reportforms.beans.InventoryGoodsSummaryVO; import com.bonus.canteen.core.reportforms.beans.InventoryGoodsSummaryVO;
import com.bonus.canteen.core.reportforms.beans.InventoryIntoSummaryVO;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -16,4 +17,6 @@ public interface DrpInventoryService {
List<InventoryGoodsSummaryVO> pageInventoryIntoDetailExport(DrpInventoryIntoDetailQueryDTO queryDTO); List<InventoryGoodsSummaryVO> pageInventoryIntoDetailExport(DrpInventoryIntoDetailQueryDTO queryDTO);
Map<String, Object> pageInventoryWarehouseSummary(DrpInventoryIntoDetailQueryDTO queryDTO); Map<String, Object> pageInventoryWarehouseSummary(DrpInventoryIntoDetailQueryDTO queryDTO);
List<InventoryGoodsSummaryVO> selectInventoryInOutSummaryList(DrpInventoryIntoDetailQueryDTO inventoryInOutSummaryVO);
} }

View File

@ -94,7 +94,7 @@ public class DrpInventoryIntoDetailServiceImpl implements IDrpInventoryIntoDetai
wrapper.setWarehouseAuthority(warehouseAuthority); wrapper.setWarehouseAuthority(warehouseAuthority);
wrapper.setAreaAuth(areaAuth); wrapper.setAreaAuth(areaAuth);
List<DrpInventoryoutDetailVO> drpInventoryoutDetailVOS = drpInventoryIntoDetailMapper.queryInventoryOutDetail(wrapper); List<DrpInventoryoutDetailVO> drpInventoryoutDetailVOS = drpInventoryIntoDetailMapper.queryInventoryOutDetail(wrapper);
for ( DrpInventoryoutDetailVO c : drpInventoryoutDetailVOS) { /* for ( DrpInventoryoutDetailVO c : drpInventoryoutDetailVOS) {
try { try {
// 姓名解密 // 姓名解密
if (c.getOperatorName() != null && !c.getOperatorName().isEmpty()) { if (c.getOperatorName() != null && !c.getOperatorName().isEmpty()) {
@ -103,9 +103,11 @@ public class DrpInventoryIntoDetailServiceImpl implements IDrpInventoryIntoDetai
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }*/
// 查询合计数据 - 这里应该返回 InventoryIntoSummaryVO // 查询合计数据 - 这里应该返回 InventoryIntoSummaryVO
InventoryIntoSummaryVO sumRow = drpInventoryIntoDetailMapper.queryInventoryIntoDocDetailoutSum(wrapper); InventoryIntoSummaryVO sumRow = drpInventoryIntoDetailMapper.queryInventoryIntoDocDetailoutSum(wrapper);
//有关退款问题进行处理
// 创建一个Map来返回明细和合计数据 // 创建一个Map来返回明细和合计数据
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("list", drpInventoryoutDetailVOS); result.put("list", drpInventoryoutDetailVOS);

View File

@ -4,17 +4,18 @@ import com.bonus.canteen.core.reportforms.beans.*;
import com.bonus.canteen.core.reportforms.mapper.DrpInventoryIntoDetailMapper; import com.bonus.canteen.core.reportforms.mapper.DrpInventoryIntoDetailMapper;
import com.bonus.canteen.core.reportforms.mapper.DrpInventoryhzMapper; import com.bonus.canteen.core.reportforms.mapper.DrpInventoryhzMapper;
import com.bonus.canteen.core.reportforms.service.DrpInventoryService; import com.bonus.canteen.core.reportforms.service.DrpInventoryService;
import com.bonus.common.houqin.utils.SM4EncryptUtils;
import com.bonus.common.security.utils.SecurityUtils; import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.domain.SysUser; import com.bonus.system.api.domain.SysUser;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collections; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Collectors;
@Service @Service
public class DrpInventoryServiceImpl implements DrpInventoryService { public class DrpInventoryServiceImpl implements DrpInventoryService {
@ -76,4 +77,25 @@ public class DrpInventoryServiceImpl implements DrpInventoryService {
result.put("summary", sumRow); // 这里直接放入 sumRow 对象 result.put("summary", sumRow); // 这里直接放入 sumRow 对象
return result; return result;
} }
@Override
public List<InventoryGoodsSummaryVO> selectInventoryInOutSummaryList(DrpInventoryIntoDetailQueryDTO queryDTO) {
SysUser currentUser = SecurityUtils.getLoginUser().getSysUser();
List<Long> areaAuth = drpInventoryIntoDetailMapper.getTenantAreaIds(currentUser.getUserId());
PageHelper.startPage(queryDTO);
DrpInventoryIntoDetailWrapper wrapper = new DrpInventoryIntoDetailWrapper();
wrapper.setParam(queryDTO);
wrapper.setAreaAuth(areaAuth);
List<InventoryGoodsSummaryVO> list = this.drpInventoryMapper.queryInventorySupplierSummaryList(wrapper);
List<Long> idList = new ArrayList<Long>();
for (InventoryGoodsSummaryVO vo : list) {
Long supplierId = vo.getSupplierId();
if (supplierId != null) {
idList.add(supplierId);
}
}
List<InventoryGoodsSummaryVO> warhouseVOList = this.drpInventoryMapper.queryWarehouseInventorySupplierSummaryList(idList, wrapper);
return warhouseVOList;
}
} }

View File

@ -288,6 +288,136 @@
</if> </if>
</where> </where>
</select> </select>
<select id="queryInventorySupplierSummaryList"
resultType="com.bonus.canteen.core.reportforms.beans.InventoryGoodsSummaryVO">
select t.supplier_id,
t.supplier_name as supplierName,
sum(t.into_num) as intoNum,
sum(t.into_amount) as intoAmount,
sum(t.out_num) as outNum,
sum(t.out_amount) as outAmount
from (select ifnull(dsl.supplier_id, ds.supplier_id) supplier_id,
ifnull(dsl.supplier_name, '透支出库') supplier_name,
dw.warehouse_id,
dw.warehouse_name as warehouseName,
sum(ds.into_num) into_num,
sum(ds.into_amount) into_amount,
sum(ds.out_num) out_num,
sum(ds.out_amount) out_amount
from report_drp_inventory_summary ds
LEFT JOIN drp_supplier dsl ON ds.supplier_id = dsl.supplier_id
LEFT JOIN drp_warehouse dw ON dw.warehouse_id = ds.warehouse_id
<where>
<if test="param.startDate != null">
and ds.statistic_date <![CDATA[ >= ]]> #{param.startDate}
</if>
<if test="param.endDate != null">
and ds.statistic_date <![CDATA[ <= ]]> #{param.endDate}
</if>
<if test="param.supplierIdList != null and param.supplierIdList.size() > 0">
AND dsl.supplier_id in
<foreach collection="param.supplierIdList" item="supplierId" separator="," open="("
close=")">
#{supplierId}
</foreach>
</if>
<if test="param.areaIdList != null and param.areaIdList.size() > 0">
AND dw.area_id in
<foreach collection="param.areaIdList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="param.warehouseIdList != null and param.warehouseIdList.size() > 0">
AND dw.warehouse_id in
<foreach collection="param.warehouseIdList" item="warehouseId" separator="," open="("
close=")">
#{warehouseId}
</foreach>
</if>
<if test="warehouseAuthority != null and warehouseAuthority.size() > 0">
and dw.warehouse_id in
<foreach collection="warehouseAuthority" item="warehouseId" separator="," open="(" close=")">
#{warehouseId}
</foreach>
</if>
<if test="areaAuth != null and areaAuth.size() > 0">
and dw.area_id in
<foreach collection="areaAuth" item="areaId" separator="," open="(" close=")">
#{areaId}
</foreach>
</if>
</where>
GROUP BY supplier_id, supplier_name, dw.warehouse_id,
dw.warehouse_name) t
GROUP BY t.supplier_id, t.supplier_name
</select>
<select id="queryWarehouseInventorySupplierSummaryList"
resultType="com.bonus.canteen.core.reportforms.beans.InventoryGoodsSummaryVO">
select
ds.supplier_id,
dsl.supplier_name as supplierName,
aa.area_name,
dw.warehouse_id,
dw.warehouse_name,
sum(ds.into_num) as intoNum,
sum(ds.into_amount) as intoAmount,
sum(ds.out_num) as outNum,
sum(ds.out_amount) as outAmount
from report_drp_inventory_summary ds
LEFT JOIN drp_supplier dsl ON ds.supplier_id = dsl.supplier_id
LEFT JOIN drp_warehouse dw ON dw.warehouse_id = ds.warehouse_id
LEFT JOIN alloc_area aa ON aa.area_id = dw.area_id
<where>
<if test="wrapper.param.startDate != null">
and ds.statistic_date <![CDATA[ >= ]]> #{wrapper.param.startDate}
</if>
<if test="wrapper.param.endDate != null">
and ds.statistic_date <![CDATA[ <= ]]> #{wrapper.param.endDate}
</if>
<if test="idList != null and idList.size() > 0">
and ds.supplier_id in
<foreach collection="idList" item="supplierId" open="(" close=")" separator=",">
#{supplierId}
</foreach>
</if>
<if test="wrapper.param.areaIdList != null and wrapper.param.areaIdList.size() > 0">
and dw.area_id in
<foreach collection="wrapper.param.areaIdList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="wrapper.param.warehouseIdList != null and wrapper.param.warehouseIdList.size() > 0">
and dw.warehouse_id in
<foreach collection="wrapper.param.warehouseIdList" item="warehouseId" open="(" close=")" separator=",">
#{warehouseId}
</foreach>
</if>
<if test="wrapper.warehouseAuthority != null and wrapper.warehouseAuthority.size() > 0">
and dw.warehouse_id in
<foreach collection="wrapper.warehouseAuthority" item="warehouseId" open="(" close=")" separator=",">
#{warehouseId}
</foreach>
</if>
<if test="wrapper.areaAuth != null and wrapper.areaAuth.size() > 0">
and dw.area_id in
<foreach collection="wrapper.areaAuth" item="areaId" open="(" close=")" separator=",">
#{areaId}
</foreach>
</if>
</where>
GROUP BY ds.supplier_id, aa.area_name, dw.warehouse_id,
dw.warehouse_name
</select>
</mapper> </mapper>

View File

@ -220,7 +220,8 @@
resultType="com.bonus.canteen.core.reportforms.beans.DrpInventoryoutDetailVO" resultType="com.bonus.canteen.core.reportforms.beans.DrpInventoryoutDetailVO"
parameterType="com.bonus.canteen.core.reportforms.beans.DrpInventoryIntoDetailWrapper"> parameterType="com.bonus.canteen.core.reportforms.beans.DrpInventoryIntoDetailWrapper">
select de.material_id, SELECT
de.material_id,
mm.material_name as goods_name, mm.material_name as goods_name,
mm.material_code as goods_code, mm.material_code as goods_code,
mmc.category_id, mmc.category_id,
@ -244,7 +245,8 @@
de.product_date as production_date, de.product_date as production_date,
de.expire_time as expiry_date, de.expire_time as expiry_date,
de.record_id, de.record_id,
mm.size as specification mm.size as specification,
0 as record_type_flag -- 0表示正常入库记录
from report_drp_inventory_base de from report_drp_inventory_base de
LEFT JOIN menu_material mm ON de.material_id = mm.material_id LEFT JOIN menu_material mm ON de.material_id = mm.material_id
LEFT JOIN drp_unit du ON de.unit_id = du.unit_id LEFT JOIN drp_unit du ON de.unit_id = du.unit_id
@ -252,13 +254,7 @@
left join drp_warehouse dw on dw.warehouse_id = de.warehouse_id left join drp_warehouse dw on dw.warehouse_id = de.warehouse_id
left join alloc_area aa on aa.area_id = dw.area_id left join alloc_area aa on aa.area_id = dw.area_id
LEFT JOIN mgr_user mu ON de.fetch_user_id = mu.user_id LEFT JOIN mgr_user mu ON de.fetch_user_id = mu.user_id
left join order_info oi on oi.order_time = de.record_time
where de.record_type = 2 and de.out_into_type in (1,3,5,6) where de.record_type = 2 and de.out_into_type in (1,3,5,6)
and not exists (
select 1 from order_info oi
where oi.order_time = de.record_time
and oi.order_state = 3
)
<if test="param.startDate != null"> <if test="param.startDate != null">
and de.record_date >= #{param.startDate} and de.record_date >= #{param.startDate}
@ -325,6 +321,111 @@
</foreach> </foreach>
</if> </if>
UNION ALL
-- 退款记录(负数)
SELECT
de.material_id,
mm.material_name as goods_name,
mm.material_code as goods_code,
mmc.category_id,
mmc.category_name as goods_category_name,
de.unit_id,
du.unit_name,
de.unit_price as price,
aa.area_name,
dw.warehouse_id,
dw.warehouse_name,
de.out_into_type intoType,
de.fetch_user_id as supplier_id,
null as supplier_name,
de.record_time intoDate,
de.out_into_num intoNum, -- 负值表示退款
de.inventory_num balance_num,
-de.out_into_amount intoAmount, -- 负值表示退款
de.total_amount balance_amount,
de.fetch_user_id as operator_id,
IF(mu.real_name IS NULL OR mu.real_name = '', mu.username, mu.real_name) operatorName,
de.product_date as production_date,
de.expire_time as expiry_date,
de.record_id,
mm.size as specification,
1 as record_type_flag -- 1表示退款记录
from report_drp_inventory_base de
LEFT JOIN menu_material mm ON de.material_id = mm.material_id
LEFT JOIN drp_unit du ON de.unit_id = du.unit_id
LEFT JOIN menu_material_category mmc ON mmc.category_id = mm.category_id
left join drp_warehouse dw on dw.warehouse_id = de.warehouse_id
left join alloc_area aa on aa.area_id = dw.area_id
LEFT JOIN mgr_user mu ON de.fetch_user_id = mu.user_id
INNER JOIN order_info oi ON oi.inventory_out_id = de.record_id -- 关联order_info
INNER JOIN order_refund rr ON rr.order_id = oi.order_id AND rr.check_state = 2 -- 关联order_refund只查询已审核的退款
where de.record_type = 2 and de.out_into_type in (1,3,5,6)
<if test="param.startDate != null">
and rr.apply_time >= #{param.startDate} -- 退款申请时间条件
</if>
<if test="param.endDate != null">
and rr.apply_time &lt;= #{param.endDate} -- 退款申请时间条件
</if>
<if test="param.supplierIdList != null and param.supplierIdList.size() > 0">
and de.fetch_user_id in
<foreach collection="param.supplierIdList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="param.materialName != null and param.materialName != ''">
and (mm.material_name like concat('%', #{param.materialName}, '%')
or mm.material_code like concat('%', #{param.materialName}, '%'))
</if>
<if test="param.categoryIdList != null and param.categoryIdList.size() > 0">
and mmc.category_id in
<foreach collection="param.categoryIdList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="param.intoTypeList != null and param.intoTypeList.size() > 0">
and de.out_into_type in
<foreach collection="param.intoTypeList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="param.recordId != null and param.recordId != ''">
and de.record_id like concat('%', #{param.recordId}, '%')
</if>
<if test="param.areaIdList != null and param.areaIdList.size() > 0">
and dw.area_id in
<foreach collection="param.areaIdList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="param.warehouseIdList != null and param.warehouseIdList.size() > 0">
and dw.warehouse_id in
<foreach collection="param.warehouseIdList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="warehouseAuthority != null and warehouseAuthority.size() > 0">
and dw.warehouse_id in
<foreach collection="warehouseAuthority" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="areaAuth != null and areaAuth.size() > 0">
and dw.area_id in
<foreach collection="areaAuth" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
</select> </select>
<!-- 获取租户仓库列表(带权限控制) --> <!-- 获取租户仓库列表(带权限控制) -->
@ -426,93 +527,256 @@
<select id="queryInventoryIntoDocDetailoutSum" <select id="queryInventoryIntoDocDetailoutSum"
resultType="com.bonus.canteen.core.reportforms.beans.InventoryIntoSummaryVO"> resultType="com.bonus.canteen.core.reportforms.beans.InventoryIntoSummaryVO">
SELECT SELECT
SUM(de.out_into_num) as totalInQty, SUM(intoNum) as totalInQty,
SUM(de.out_into_amount) as totalInAmount, SUM(intoAmount) as totalInAmount,
SUM(de.inventory_num) as totalStockQty, -- 库存总计(直接从主表查询,不包含退款记录)
SUM(de.total_amount) as totalStockAmount (SELECT SUM(de2.inventory_num)
from report_drp_inventory_base de FROM report_drp_inventory_base de2
LEFT JOIN menu_material mm2 ON de2.material_id = mm2.material_id
LEFT JOIN drp_warehouse dw2 ON de2.warehouse_id = dw2.warehouse_id
LEFT JOIN alloc_area aa2 ON aa2.area_id = dw2.area_id
WHERE de2.record_type = 2
AND de2.out_into_type IN (1,3,5,6)
<if test="param.startDate != null">
AND de2.record_date >= #{param.startDate}
</if>
<if test="param.endDate != null">
AND de2.record_date &lt;= #{param.endDate}
</if>
<if test="param.materialName != null and param.materialName != ''">
AND (mm2.material_name like concat('%', #{param.materialName}, '%')
OR mm2.material_code like concat('%', #{param.materialName}, '%'))
</if>
<if test="param.areaIdList != null and param.areaIdList.size() > 0">
AND dw2.area_id in
<foreach collection="param.areaIdList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="param.warehouseIdList != null and param.warehouseIdList.size() > 0">
AND dw2.warehouse_id in
<foreach collection="param.warehouseIdList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="warehouseAuthority != null and warehouseAuthority.size() > 0">
AND dw2.warehouse_id in
<foreach collection="warehouseAuthority" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="areaAuth != null and areaAuth.size() > 0">
AND dw2.area_id in
<foreach collection="areaAuth" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
) as totalStockQty,
(SELECT SUM(de2.total_amount)
FROM report_drp_inventory_base de2
LEFT JOIN menu_material mm2 ON de2.material_id = mm2.material_id
LEFT JOIN drp_warehouse dw2 ON de2.warehouse_id = dw2.warehouse_id
LEFT JOIN alloc_area aa2 ON aa2.area_id = dw2.area_id
WHERE de2.record_type = 2
AND de2.out_into_type IN (1,3,5,6)
<if test="param.startDate != null">
AND de2.record_date >= #{param.startDate}
</if>
<if test="param.endDate != null">
AND de2.record_date &lt;= #{param.endDate}
</if>
<if test="param.materialName != null and param.materialName != ''">
AND (mm2.material_name like concat('%', #{param.materialName}, '%')
OR mm2.material_code like concat('%', #{param.materialName}, '%'))
</if>
<if test="param.areaIdList != null and param.areaIdList.size() > 0">
AND dw2.area_id in
<foreach collection="param.areaIdList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="param.warehouseIdList != null and param.warehouseIdList.size() > 0">
AND dw2.warehouse_id in
<foreach collection="param.warehouseIdList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="warehouseAuthority != null and warehouseAuthority.size() > 0">
AND dw2.warehouse_id in
<foreach collection="warehouseAuthority" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="areaAuth != null and areaAuth.size() > 0">
AND dw2.area_id in
<foreach collection="areaAuth" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
) as totalStockAmount
FROM (
-- 正常入库记录
SELECT
de.out_into_num as intoNum,
de.out_into_amount as intoAmount
FROM report_drp_inventory_base de
LEFT JOIN menu_material mm ON de.material_id = mm.material_id LEFT JOIN menu_material mm ON de.material_id = mm.material_id
LEFT JOIN drp_unit du ON de.unit_id = du.unit_id LEFT JOIN drp_unit du ON de.unit_id = du.unit_id
LEFT JOIN menu_material_category mmc ON mmc.category_id = mm.category_id LEFT JOIN menu_material_category mmc ON mmc.category_id = mm.category_id
left join drp_warehouse dw on dw.warehouse_id = de.warehouse_id LEFT JOIN drp_warehouse dw ON dw.warehouse_id = de.warehouse_id
left join alloc_area aa on aa.area_id = dw.area_id LEFT JOIN alloc_area aa ON aa.area_id = dw.area_id
LEFT JOIN drp_supplier ds ON de.supplier_id = ds.supplier_id LEFT JOIN mgr_user mu ON de.fetch_user_id = mu.user_id
LEFT JOIN mgr_user mu ON de.operator_id = mu.username WHERE de.record_type = 2
left join order_info oi on oi.order_time = de.record_time AND de.out_into_type IN (1,3,5,6)
where de.record_type=2 and de.out_into_type in (1,3,5,6)
and not exists (
select 1 from order_info oi
where oi.order_time = de.record_time
and oi.order_state = 3
)
<if test="param.startDate != null"> <if test="param.startDate != null">
and de.record_date >= #{param.startDate} AND de.record_date >= #{param.startDate}
</if> </if>
<if test="param.endDate != null"> <if test="param.endDate != null">
and de.record_date &lt;= #{param.endDate} AND de.record_date &lt;= #{param.endDate}
</if> </if>
<if test="param.supplierIdList != null and param.supplierIdList.size() > 0"> <if test="param.supplierIdList != null and param.supplierIdList.size() > 0">
and de.supplier_id in AND de.fetch_user_id in
<foreach collection="param.supplierIdList" item="id" open="(" close=")" separator=","> <foreach collection="param.supplierIdList" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</if> </if>
<if test="param.materialName != null and param.materialName != ''"> <if test="param.materialName != null and param.materialName != ''">
and (mm.material_name like concat('%', #{param.materialName}, '%') AND (mm.material_name like concat('%', #{param.materialName}, '%')
or mm.material_code like concat('%', #{param.materialName}, '%')) OR mm.material_code like concat('%', #{param.materialName}, '%'))
</if> </if>
<if test="param.categoryIdList != null and param.categoryIdList.size() > 0"> <if test="param.categoryIdList != null and param.categoryIdList.size() > 0">
and mmc.category_id in AND mmc.category_id in
<foreach collection="param.categoryIdList" item="id" open="(" close=")" separator=","> <foreach collection="param.categoryIdList" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</if> </if>
<if test="param.intoTypeList != null and param.intoTypeList.size() > 0"> <if test="param.intoTypeList != null and param.intoTypeList.size() > 0">
and de.out_into_type in AND de.out_into_type in
<foreach collection="param.intoTypeList" item="id" open="(" close=")" separator=","> <foreach collection="param.intoTypeList" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</if> </if>
<if test="param.recordId != null and param.recordId != ''"> <if test="param.recordId != null and param.recordId != ''">
and de.record_id like concat('%', #{param.recordId}, '%') AND de.record_id like concat('%', #{param.recordId}, '%')
</if> </if>
<if test="param.areaIdList != null and param.areaIdList.size() > 0"> <if test="param.areaIdList != null and param.areaIdList.size() > 0">
and dw.area_id in AND dw.area_id in
<foreach collection="param.areaIdList" item="id" open="(" close=")" separator=","> <foreach collection="param.areaIdList" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</if> </if>
<if test="param.warehouseIdList != null and param.warehouseIdList.size() > 0"> <if test="param.warehouseIdList != null and param.warehouseIdList.size() > 0">
and dw.warehouse_id in AND dw.warehouse_id in
<foreach collection="param.warehouseIdList" item="id" open="(" close=")" separator=","> <foreach collection="param.warehouseIdList" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</if> </if>
<if test="warehouseAuthority != null and warehouseAuthority.size() > 0"> <if test="warehouseAuthority != null and warehouseAuthority.size() > 0">
and dw.warehouse_id in AND dw.warehouse_id in
<foreach collection="warehouseAuthority" item="id" open="(" close=")" separator=","> <foreach collection="warehouseAuthority" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</if> </if>
<if test="areaAuth != null and areaAuth.size() > 0"> <if test="areaAuth != null and areaAuth.size() > 0">
and dw.area_id in AND dw.area_id in
<foreach collection="areaAuth" item="id" open="(" close=")" separator=","> <foreach collection="areaAuth" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</if> </if>
UNION ALL
-- 退款记录(负数)
SELECT
de.out_into_num as intoNum, -- 注意:这里需要改成负数,或者保持正数在外部处理
-de.out_into_amount as intoAmount -- 金额为负数
FROM report_drp_inventory_base de
LEFT JOIN menu_material mm ON de.material_id = mm.material_id
LEFT JOIN drp_unit du ON de.unit_id = du.unit_id
LEFT JOIN menu_material_category mmc ON mmc.category_id = mm.category_id
LEFT JOIN drp_warehouse dw ON dw.warehouse_id = de.warehouse_id
LEFT JOIN alloc_area aa ON aa.area_id = dw.area_id
LEFT JOIN mgr_user mu ON de.fetch_user_id = mu.user_id
INNER JOIN order_info oi ON oi.inventory_out_id = de.record_id
INNER JOIN order_refund rr ON rr.order_id = oi.order_id AND rr.check_state = 2
WHERE de.record_type = 2
AND de.out_into_type IN (1,3,5,6)
<if test="param.startDate != null">
AND rr.apply_time >= #{param.startDate}
</if>
<if test="param.endDate != null">
AND rr.apply_time &lt;= #{param.endDate}
</if>
<if test="param.supplierIdList != null and param.supplierIdList.size() > 0">
AND de.fetch_user_id in
<foreach collection="param.supplierIdList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="param.materialName != null and param.materialName != ''">
AND (mm.material_name like concat('%', #{param.materialName}, '%')
OR mm.material_code like concat('%', #{param.materialName}, '%'))
</if>
<if test="param.categoryIdList != null and param.categoryIdList.size() > 0">
AND mmc.category_id in
<foreach collection="param.categoryIdList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="param.intoTypeList != null and param.intoTypeList.size() > 0">
AND de.out_into_type in
<foreach collection="param.intoTypeList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="param.recordId != null and param.recordId != ''">
AND de.record_id like concat('%', #{param.recordId}, '%')
</if>
<if test="param.areaIdList != null and param.areaIdList.size() > 0">
AND dw.area_id in
<foreach collection="param.areaIdList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="param.warehouseIdList != null and param.warehouseIdList.size() > 0">
AND dw.warehouse_id in
<foreach collection="param.warehouseIdList" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="warehouseAuthority != null and warehouseAuthority.size() > 0">
AND dw.warehouse_id in
<foreach collection="warehouseAuthority" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="areaAuth != null and areaAuth.size() > 0">
AND dw.area_id in
<foreach collection="areaAuth" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
) AS combined_data
</select> </select>
</mapper> </mapper>

View File

@ -623,7 +623,7 @@
<select id="getPeoplelist" resultType="com.bonus.canteen.core.reportforms.beans.CanteenRecord"> <select id="getPeoplelist" resultType="com.bonus.canteen.core.reportforms.beans.CanteenRecord">
SELECT SELECT
rf.flow_id AS flowId, rf.flow_id AS flowId,
ci.cust_id AS custId, ci.cust_num AS custId,
ci.cust_name AS custName, ci.cust_name AS custName,
ci.mobile AS phone, ci.mobile AS phone,
co.org_id AS orgId, co.org_id AS orgId,