优化销售统计接口

This commit is contained in:
季圣华
2023-03-09 22:53:56 +08:00
parent ca1c6e13ef
commit 5f0f72b06c
4 changed files with 57 additions and 23 deletions

View File

@@ -478,23 +478,24 @@ public class DepotItemController {
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());
@@ -552,27 +553,28 @@ public class DepotItemController {
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());

View File

@@ -68,6 +68,7 @@ public interface DepotItemMapperEx {
@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,
@@ -79,6 +80,7 @@ public interface DepotItemMapperEx {
@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);
@@ -89,6 +91,7 @@ public interface DepotItemMapperEx {
@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);
@@ -99,6 +102,7 @@ public interface DepotItemMapperEx {
@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);

View File

@@ -318,10 +318,10 @@ public class DepotItemService {
}
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);
}
@@ -329,10 +329,10 @@ public class DepotItemService {
}
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);
}
@@ -340,13 +340,13 @@ public class DepotItemService {
}
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);