Skip to content

Commit

Permalink
优化销售统计接口
Browse files Browse the repository at this point in the history
  • Loading branch information
jishenghua committed Mar 9, 2023
1 parent ca1c6e1 commit 5f0f72b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -478,23 +478,24 @@ public BaseResponseInfo buyIn(@RequestParam("currentPage") Integer currentPage,
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
try {
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
String [] organArray = null;
List<Long> depotList = depotService.parseDepotList(null);
Boolean amountApprovalFlag = systemConfigService.getAmountApprovalFlag();
List<DepotItemVo4WithInfoEx> dataList = depotItemService.getListWithBugOrSale(StringUtil.toNull(materialParam),
"buy", beginTime, endTime, creatorArray, depotList, amountApprovalFlag, (currentPage-1)*pageSize, pageSize);
"buy", beginTime, endTime, creatorArray, organArray, depotList, amountApprovalFlag, (currentPage-1)*pageSize, pageSize);
String[] mpArr = mpList.split(",");
int total = depotItemService.getListWithBugOrSaleCount(StringUtil.toNull(materialParam),
"buy", beginTime, endTime, creatorArray, depotList, amountApprovalFlag);
"buy", beginTime, endTime, creatorArray, organArray, depotList, amountApprovalFlag);
map.put("total", total);
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) {
JSONObject item = new JSONObject();
BigDecimal InSum = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), beginTime, endTime, creatorArray, depotList, "number");
BigDecimal OutSum = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), beginTime, endTime, creatorArray, depotList, "number");
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), beginTime, endTime, creatorArray, depotList, "price");
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), beginTime, endTime, creatorArray, depotList, "price");
BigDecimal InSum = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), beginTime, endTime, creatorArray, organArray, depotList, "number");
BigDecimal OutSum = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), beginTime, endTime, creatorArray, organArray, depotList, "number");
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), beginTime, endTime, creatorArray, organArray, depotList, "price");
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), beginTime, endTime, creatorArray, organArray, depotList, "price");
BigDecimal InOutSumPrice = InSumPrice.subtract(OutSumPrice);
item.put("barCode", diEx.getBarCode());
item.put("materialName", diEx.getMName());
Expand Down Expand Up @@ -552,27 +553,28 @@ public BaseResponseInfo saleOut(@RequestParam("currentPage") Integer currentPage
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
try {
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
String [] organArray = depotHeadService.getOrganArray("销售", "");
List<Long> depotList = depotService.parseDepotList(null);
Boolean amountApprovalFlag = systemConfigService.getAmountApprovalFlag();
List<DepotItemVo4WithInfoEx> dataList = depotItemService.getListWithBugOrSale(StringUtil.toNull(materialParam),
"sale", beginTime, endTime, creatorArray, depotList, amountApprovalFlag, (currentPage-1)*pageSize, pageSize);
"sale", beginTime, endTime, creatorArray, organArray, depotList, amountApprovalFlag, (currentPage-1)*pageSize, pageSize);
String[] mpArr = mpList.split(",");
int total = depotItemService.getListWithBugOrSaleCount(StringUtil.toNull(materialParam),
"sale", beginTime, endTime, creatorArray, depotList, amountApprovalFlag);
"sale", beginTime, endTime, creatorArray, organArray, depotList, amountApprovalFlag);
map.put("total", total);
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) {
JSONObject item = new JSONObject();
BigDecimal OutSumRetail = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), beginTime, endTime, creatorArray, depotList,"number");
BigDecimal OutSum = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), beginTime, endTime, creatorArray, depotList,"number");
BigDecimal InSumRetail = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), beginTime, endTime, creatorArray, depotList,"number");
BigDecimal InSum = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), beginTime, endTime, creatorArray, depotList,"number");
BigDecimal OutSumRetailPrice = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), beginTime, endTime, creatorArray, depotList,"price");
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), beginTime, endTime, creatorArray, depotList,"price");
BigDecimal InSumRetailPrice = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), beginTime, endTime, creatorArray, depotList,"price");
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), beginTime, endTime, creatorArray, depotList,"price");
BigDecimal OutSumRetail = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), beginTime, endTime, creatorArray, organArray, depotList,"number");
BigDecimal OutSum = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), beginTime, endTime, creatorArray, organArray, depotList,"number");
BigDecimal InSumRetail = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), beginTime, endTime, creatorArray, organArray, depotList,"number");
BigDecimal InSum = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), beginTime, endTime, creatorArray, organArray, depotList,"number");
BigDecimal OutSumRetailPrice = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), beginTime, endTime, creatorArray, organArray, depotList,"price");
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), beginTime, endTime, creatorArray, organArray, depotList,"price");
BigDecimal InSumRetailPrice = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), beginTime, endTime, creatorArray, organArray, depotList,"price");
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), beginTime, endTime, creatorArray, organArray, depotList,"price");
BigDecimal OutInSumPrice = (OutSumRetailPrice.add(OutSumPrice)).subtract(InSumRetailPrice.add(InSumPrice));
item.put("barCode", diEx.getBarCode());
item.put("materialName", diEx.getMName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ List<DepotItemVo4WithInfoEx> getListWithBugOrSale(
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray,
@Param("organArray") String [] organArray,
@Param("depotList") List<Long> depotList,
@Param("amountApprovalFlag") Boolean amountApprovalFlag,
@Param("offset") Integer offset,
Expand All @@ -79,6 +80,7 @@ int getListWithBugOrSaleCount(
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray,
@Param("organArray") String [] organArray,
@Param("depotList") List<Long> depotList,
@Param("amountApprovalFlag") Boolean amountApprovalFlag);

Expand All @@ -89,6 +91,7 @@ BigDecimal buyOrSaleNumber(
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray,
@Param("organArray") String [] organArray,
@Param("depotList") List<Long> depotList,
@Param("sumType") String sumType);

Expand All @@ -99,6 +102,7 @@ BigDecimal buyOrSalePrice(
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray,
@Param("organArray") String [] organArray,
@Param("depotList") List<Long> depotList,
@Param("sumType") String sumType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,35 +318,35 @@ public int findByAllCount(String materialParam, String endTime)throws Exception
}

public List<DepotItemVo4WithInfoEx> getListWithBugOrSale(String materialParam, String billType,
String beginTime, String endTime, String[] creatorArray, List<Long> depotList, Boolean amountApprovalFlag, Integer offset, Integer rows)throws Exception {
String beginTime, String endTime, String[] creatorArray, String [] organArray, List<Long> depotList, Boolean amountApprovalFlag, Integer offset, Integer rows)throws Exception {
List<DepotItemVo4WithInfoEx> list =null;
try{
list = depotItemMapperEx.getListWithBugOrSale(materialParam, billType, beginTime, endTime, creatorArray, depotList, amountApprovalFlag, offset, rows);
list = depotItemMapperEx.getListWithBugOrSale(materialParam, billType, beginTime, endTime, creatorArray, organArray, depotList, amountApprovalFlag, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}

public int getListWithBugOrSaleCount(String materialParam, String billType,
String beginTime, String endTime, String[] creatorArray, List<Long> depotList, Boolean amountApprovalFlag)throws Exception {
String beginTime, String endTime, String[] creatorArray, String [] organArray, List<Long> depotList, Boolean amountApprovalFlag)throws Exception {
int result=0;
try{
result = depotItemMapperEx.getListWithBugOrSaleCount(materialParam, billType, beginTime, endTime, creatorArray, depotList, amountApprovalFlag);
result = depotItemMapperEx.getListWithBugOrSaleCount(materialParam, billType, beginTime, endTime, creatorArray, organArray, depotList, amountApprovalFlag);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}

public BigDecimal buyOrSale(String type, String subType, Long MId, String beginTime, String endTime,
String[] creatorArray, List<Long> depotList, String sumType) throws Exception{
String[] creatorArray, String [] organArray, List<Long> depotList, String sumType) throws Exception{
BigDecimal result= BigDecimal.ZERO;
try{
if (SUM_TYPE.equals(sumType)) {
result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, beginTime, endTime, creatorArray, depotList, sumType);
result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, beginTime, endTime, creatorArray, organArray, depotList, sumType);
} else {
result= depotItemMapperEx.buyOrSalePrice(type, subType, MId, beginTime, endTime, creatorArray, depotList, sumType);
result= depotItemMapperEx.buyOrSalePrice(type, subType, MId, beginTime, endTime, creatorArray, organArray, depotList, sumType);
}
}catch(Exception e){
JshException.readFail(logger, e);
Expand Down
28 changes: 28 additions & 0 deletions jshERP-boot/src/main/resources/mapper_xml/DepotItemMapperEx.xml
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,13 @@
</foreach>
)
</if>
<if test="organArray != null and organArray !=''">
and dh.organ_id in (
<foreach collection="organArray" item="organId" separator=",">
#{organId}
</foreach>
)
</if>
<if test="depotList.size()>0">
and di.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
Expand Down Expand Up @@ -423,6 +430,13 @@
</foreach>
)
</if>
<if test="organArray != null and organArray !=''">
and dh.organ_id in (
<foreach collection="organArray" item="organId" separator=",">
#{organId}
</foreach>
)
</if>
<if test="depotList.size()>0">
and di.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
Expand Down Expand Up @@ -450,6 +464,13 @@
</foreach>
)
</if>
<if test="organArray != null and organArray !=''">
and dh.organ_id in (
<foreach collection="organArray" item="organId" separator=",">
#{organId}
</foreach>
)
</if>
<if test="depotList.size()>0">
and di.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
Expand All @@ -474,6 +495,13 @@
</foreach>
)
</if>
<if test="organArray != null and organArray !=''">
and dh.organ_id in (
<foreach collection="organArray" item="organId" separator=",">
#{organId}
</foreach>
)
</if>
<if test="depotList.size()>0">
and di.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
Expand Down

0 comments on commit 5f0f72b

Please sign in to comment.