优化采购统计和销售统计报表的查询条件
This commit is contained in:
@@ -265,7 +265,7 @@ public class DepotItemController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找所有的明细
|
* 进销存统计
|
||||||
* @param currentPage
|
* @param currentPage
|
||||||
* @param pageSize
|
* @param pageSize
|
||||||
* @param depotIds
|
* @param depotIds
|
||||||
@@ -351,7 +351,7 @@ public class DepotItemController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计总计金额
|
* 进销存统计总计金额
|
||||||
* @param depotIds
|
* @param depotIds
|
||||||
* @param monthTime
|
* @param monthTime
|
||||||
* @param materialParam
|
* @param materialParam
|
||||||
@@ -421,7 +421,8 @@ public class DepotItemController {
|
|||||||
* 进货统计
|
* 进货统计
|
||||||
* @param currentPage
|
* @param currentPage
|
||||||
* @param pageSize
|
* @param pageSize
|
||||||
* @param monthTime
|
* @param beginTime
|
||||||
|
* @param endTime
|
||||||
* @param materialParam
|
* @param materialParam
|
||||||
* @param mpList
|
* @param mpList
|
||||||
* @param request
|
* @param request
|
||||||
@@ -431,28 +432,30 @@ public class DepotItemController {
|
|||||||
@ApiOperation(value = "进货统计")
|
@ApiOperation(value = "进货统计")
|
||||||
public BaseResponseInfo buyIn(@RequestParam("currentPage") Integer currentPage,
|
public BaseResponseInfo buyIn(@RequestParam("currentPage") Integer currentPage,
|
||||||
@RequestParam("pageSize") Integer pageSize,
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
@RequestParam("monthTime") String monthTime,
|
@RequestParam("beginTime") String beginTime,
|
||||||
|
@RequestParam("endTime") String endTime,
|
||||||
@RequestParam("materialParam") String materialParam,
|
@RequestParam("materialParam") String materialParam,
|
||||||
@RequestParam("mpList") String mpList,
|
@RequestParam("mpList") String mpList,
|
||||||
HttpServletRequest request)throws Exception {
|
HttpServletRequest request)throws Exception {
|
||||||
BaseResponseInfo res = new BaseResponseInfo();
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
String endTime = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME;
|
beginTime = Tools.parseDayToTime(beginTime, BusinessConstants.DAY_FIRST_TIME);
|
||||||
|
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||||
try {
|
try {
|
||||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
|
List<DepotItemVo4WithInfoEx> dataList = depotItemService.getListWithBugOrSale(StringUtil.toNull(materialParam),
|
||||||
endTime, (currentPage-1)*pageSize, pageSize);
|
"buy", beginTime, endTime, (currentPage-1)*pageSize, pageSize);
|
||||||
String[] mpArr = mpList.split(",");
|
String[] mpArr = mpList.split(",");
|
||||||
int total = depotItemService.findByAllCount(StringUtil.toNull(materialParam), endTime);
|
int total = depotItemService.getListWithBugOrSaleCount(StringUtil.toNull(materialParam), "buy", beginTime, endTime);
|
||||||
map.put("total", total);
|
map.put("total", total);
|
||||||
//存放数据json数组
|
//存放数据json数组
|
||||||
JSONArray dataArray = new JSONArray();
|
JSONArray dataArray = new JSONArray();
|
||||||
if (null != dataList) {
|
if (null != dataList) {
|
||||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||||
JSONObject item = new JSONObject();
|
JSONObject item = new JSONObject();
|
||||||
BigDecimal InSum = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), monthTime, "number");
|
BigDecimal InSum = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), beginTime, endTime, "number");
|
||||||
BigDecimal OutSum = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), monthTime, "number");
|
BigDecimal OutSum = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), beginTime, endTime, "number");
|
||||||
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), monthTime, "price");
|
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), beginTime, endTime, "price");
|
||||||
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), monthTime, "price");
|
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), beginTime, endTime, "price");
|
||||||
BigDecimal InOutSumPrice = InSumPrice.subtract(OutSumPrice);
|
BigDecimal InOutSumPrice = InSumPrice.subtract(OutSumPrice);
|
||||||
item.put("barCode", diEx.getBarCode());
|
item.put("barCode", diEx.getBarCode());
|
||||||
item.put("materialName", diEx.getMName());
|
item.put("materialName", diEx.getMName());
|
||||||
@@ -487,7 +490,8 @@ public class DepotItemController {
|
|||||||
* 销售统计
|
* 销售统计
|
||||||
* @param currentPage
|
* @param currentPage
|
||||||
* @param pageSize
|
* @param pageSize
|
||||||
* @param monthTime
|
* @param beginTime
|
||||||
|
* @param endTime
|
||||||
* @param materialParam
|
* @param materialParam
|
||||||
* @param mpList
|
* @param mpList
|
||||||
* @param request
|
* @param request
|
||||||
@@ -497,32 +501,34 @@ public class DepotItemController {
|
|||||||
@ApiOperation(value = "销售统计")
|
@ApiOperation(value = "销售统计")
|
||||||
public BaseResponseInfo saleOut(@RequestParam("currentPage") Integer currentPage,
|
public BaseResponseInfo saleOut(@RequestParam("currentPage") Integer currentPage,
|
||||||
@RequestParam("pageSize") Integer pageSize,
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
@RequestParam("monthTime") String monthTime,
|
@RequestParam("beginTime") String beginTime,
|
||||||
|
@RequestParam("endTime") String endTime,
|
||||||
@RequestParam("materialParam") String materialParam,
|
@RequestParam("materialParam") String materialParam,
|
||||||
@RequestParam("mpList") String mpList,
|
@RequestParam("mpList") String mpList,
|
||||||
HttpServletRequest request)throws Exception {
|
HttpServletRequest request)throws Exception {
|
||||||
BaseResponseInfo res = new BaseResponseInfo();
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
String endTime = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME;
|
beginTime = Tools.parseDayToTime(beginTime, BusinessConstants.DAY_FIRST_TIME);
|
||||||
|
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||||
try {
|
try {
|
||||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
|
List<DepotItemVo4WithInfoEx> dataList = depotItemService.getListWithBugOrSale(StringUtil.toNull(materialParam),
|
||||||
endTime,(currentPage-1)*pageSize, pageSize);
|
"sale", beginTime, endTime,(currentPage-1)*pageSize, pageSize);
|
||||||
String[] mpArr = mpList.split(",");
|
String[] mpArr = mpList.split(",");
|
||||||
int total = depotItemService.findByAllCount(StringUtil.toNull(materialParam), endTime);
|
int total = depotItemService.getListWithBugOrSaleCount(StringUtil.toNull(materialParam), "sale", beginTime, endTime);
|
||||||
map.put("total", total);
|
map.put("total", total);
|
||||||
//存放数据json数组
|
//存放数据json数组
|
||||||
JSONArray dataArray = new JSONArray();
|
JSONArray dataArray = new JSONArray();
|
||||||
if (null != dataList) {
|
if (null != dataList) {
|
||||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||||
JSONObject item = new JSONObject();
|
JSONObject item = new JSONObject();
|
||||||
BigDecimal OutSumRetail = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), monthTime,"number");
|
BigDecimal OutSumRetail = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), beginTime, endTime,"number");
|
||||||
BigDecimal OutSum = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), monthTime,"number");
|
BigDecimal OutSum = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), beginTime, endTime,"number");
|
||||||
BigDecimal InSumRetail = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), monthTime,"number");
|
BigDecimal InSumRetail = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), beginTime, endTime,"number");
|
||||||
BigDecimal InSum = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), monthTime,"number");
|
BigDecimal InSum = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), beginTime, endTime,"number");
|
||||||
BigDecimal OutSumRetailPrice = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), monthTime,"price");
|
BigDecimal OutSumRetailPrice = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), beginTime, endTime,"price");
|
||||||
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), monthTime,"price");
|
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), beginTime, endTime,"price");
|
||||||
BigDecimal InSumRetailPrice = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), monthTime,"price");
|
BigDecimal InSumRetailPrice = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), beginTime, endTime,"price");
|
||||||
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), monthTime,"price");
|
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), beginTime, endTime,"price");
|
||||||
BigDecimal OutInSumPrice = (OutSumRetailPrice.add(OutSumPrice)).subtract(InSumRetailPrice.add(InSumPrice));
|
BigDecimal OutInSumPrice = (OutSumRetailPrice.add(OutSumPrice)).subtract(InSumRetailPrice.add(InSumPrice));
|
||||||
item.put("barCode", diEx.getBarCode());
|
item.put("barCode", diEx.getBarCode());
|
||||||
item.put("materialName", diEx.getMName());
|
item.put("materialName", diEx.getMName());
|
||||||
|
|||||||
@@ -50,6 +50,20 @@ public interface DepotItemMapperEx {
|
|||||||
@Param("materialParam") String materialParam,
|
@Param("materialParam") String materialParam,
|
||||||
@Param("endTime") String endTime);
|
@Param("endTime") String endTime);
|
||||||
|
|
||||||
|
List<DepotItemVo4WithInfoEx> getListWithBugOrSale(
|
||||||
|
@Param("materialParam") String materialParam,
|
||||||
|
@Param("billType") String billType,
|
||||||
|
@Param("beginTime") String beginTime,
|
||||||
|
@Param("endTime") String endTime,
|
||||||
|
@Param("offset") Integer offset,
|
||||||
|
@Param("rows") Integer rows);
|
||||||
|
|
||||||
|
int getListWithBugOrSaleCount(
|
||||||
|
@Param("materialParam") String materialParam,
|
||||||
|
@Param("billType") String billType,
|
||||||
|
@Param("beginTime") String beginTime,
|
||||||
|
@Param("endTime") String endTime);
|
||||||
|
|
||||||
BigDecimal buyOrSaleNumber(
|
BigDecimal buyOrSaleNumber(
|
||||||
@Param("type") String type,
|
@Param("type") String type,
|
||||||
@Param("subType") String subType,
|
@Param("subType") String subType,
|
||||||
|
|||||||
@@ -259,11 +259,29 @@ public class DepotItemService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal buyOrSale(String type, String subType, Long MId, String monthTime, String sumType) throws Exception{
|
public List<DepotItemVo4WithInfoEx> getListWithBugOrSale(String materialParam, String billType, String beginTime, String endTime, Integer offset, Integer rows)throws Exception {
|
||||||
|
List<DepotItemVo4WithInfoEx> list =null;
|
||||||
|
try{
|
||||||
|
list = depotItemMapperEx.getListWithBugOrSale(materialParam, billType, beginTime, endTime, offset, rows);
|
||||||
|
}catch(Exception e){
|
||||||
|
JshException.readFail(logger, e);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getListWithBugOrSaleCount(String materialParam, String billType, String beginTime, String endTime)throws Exception {
|
||||||
|
int result=0;
|
||||||
|
try{
|
||||||
|
result = depotItemMapperEx.getListWithBugOrSaleCount(materialParam, billType, beginTime, endTime);
|
||||||
|
}catch(Exception e){
|
||||||
|
JshException.readFail(logger, e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal buyOrSale(String type, String subType, Long MId, String beginTime, String endTime, String sumType) throws Exception{
|
||||||
BigDecimal result= BigDecimal.ZERO;
|
BigDecimal result= BigDecimal.ZERO;
|
||||||
try{
|
try{
|
||||||
String beginTime = Tools.firstDayOfMonth(monthTime) + BusinessConstants.DAY_FIRST_TIME;
|
|
||||||
String endTime = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME;
|
|
||||||
if (SUM_TYPE.equals(sumType)) {
|
if (SUM_TYPE.equals(sumType)) {
|
||||||
result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, beginTime, endTime, sumType);
|
result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, beginTime, endTime, sumType);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -233,6 +233,67 @@
|
|||||||
group by m.id) cc
|
group by m.id) cc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getListWithBugOrSale" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultByMaterial">
|
||||||
|
select m.id MId, me.bar_code, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard,
|
||||||
|
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
|
||||||
|
concat_ws('', m.unit, u.basic_unit) MaterialUnit, m.color MColor, u.name unit_name
|
||||||
|
from jsh_material m
|
||||||
|
left join jsh_depot_item di on di.material_id=m.id and ifnull(di.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
|
||||||
|
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
|
||||||
|
where 1=1
|
||||||
|
<if test="materialParam != null and materialParam !=''">
|
||||||
|
<bind name="bindKey" value="'%'+materialParam+'%'"/>
|
||||||
|
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
|
||||||
|
</if>
|
||||||
|
<if test="billType =='buy'">
|
||||||
|
and (dh.sub_type = '采购' or dh.sub_type = '采购退货')
|
||||||
|
</if>
|
||||||
|
<if test="billType =='sale'">
|
||||||
|
and (dh.sub_type = '销售' or dh.sub_type = '销售退货' or dh.sub_type = '零售' or dh.sub_type = '零售退货')
|
||||||
|
</if>
|
||||||
|
<if test="beginTime != null">
|
||||||
|
and dh.oper_time >= #{beginTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null">
|
||||||
|
and dh.oper_time <= #{endTime}
|
||||||
|
</if>
|
||||||
|
and ifnull(m.delete_flag,'0') !='1'
|
||||||
|
group by m.id
|
||||||
|
order by m.id desc
|
||||||
|
<if test="offset != null and rows != null">
|
||||||
|
limit #{offset},#{rows}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getListWithBugOrSaleCount" resultType="java.lang.Integer">
|
||||||
|
select count(1) from (select m.id
|
||||||
|
from jsh_material m
|
||||||
|
left join jsh_depot_item di on di.material_id=m.id and ifnull(m.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
|
||||||
|
where 1=1
|
||||||
|
<if test="materialParam != null and materialParam !=''">
|
||||||
|
<bind name="bindKey" value="'%'+materialParam+'%'"/>
|
||||||
|
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
|
||||||
|
</if>
|
||||||
|
<if test="billType =='buy'">
|
||||||
|
and (dh.sub_type = '采购' or dh.sub_type = '采购退货')
|
||||||
|
</if>
|
||||||
|
<if test="billType =='sale'">
|
||||||
|
and (dh.sub_type = '销售' or dh.sub_type = '销售退货' or dh.sub_type = '零售' or dh.sub_type = '零售退货')
|
||||||
|
</if>
|
||||||
|
<if test="beginTime != null">
|
||||||
|
and dh.oper_time >= #{beginTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null">
|
||||||
|
and dh.oper_time <= #{endTime}
|
||||||
|
</if>
|
||||||
|
and ifnull(di.delete_flag,'0') !='1'
|
||||||
|
group by m.id) cc
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="buyOrSaleNumber" resultType="java.math.BigDecimal">
|
<select id="buyOrSaleNumber" resultType="java.math.BigDecimal">
|
||||||
select ifnull(sum(basic_number),0) as BasicNumber from jsh_depot_item di,jsh_depot_head dh
|
select ifnull(sum(basic_number),0) as BasicNumber from jsh_depot_item di,jsh_depot_head dh
|
||||||
where di.header_id = dh.id
|
where di.header_id = dh.id
|
||||||
|
|||||||
Reference in New Issue
Block a user