优化采购统计和销售统计的查询逻辑
This commit is contained in:
parent
336d818eca
commit
bf8d660367
@ -478,22 +478,23 @@ public class DepotItemController {
|
||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||
try {
|
||||
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
|
||||
List<Long> depotList = depotService.parseDepotList(null);
|
||||
Boolean amountApprovalFlag = systemConfigService.getAmountApprovalFlag();
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.getListWithBugOrSale(StringUtil.toNull(materialParam),
|
||||
"buy", beginTime, endTime, creatorArray, amountApprovalFlag, (currentPage-1)*pageSize, pageSize);
|
||||
"buy", beginTime, endTime, creatorArray, depotList, amountApprovalFlag, (currentPage-1)*pageSize, pageSize);
|
||||
String[] mpArr = mpList.split(",");
|
||||
int total = depotItemService.getListWithBugOrSaleCount(StringUtil.toNull(materialParam),
|
||||
"buy", beginTime, endTime, creatorArray, amountApprovalFlag);
|
||||
"buy", beginTime, endTime, creatorArray, 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, "number");
|
||||
BigDecimal OutSum = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), beginTime, endTime, creatorArray, "number");
|
||||
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), beginTime, endTime, creatorArray, "price");
|
||||
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), beginTime, endTime, creatorArray, "price");
|
||||
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 InOutSumPrice = InSumPrice.subtract(OutSumPrice);
|
||||
item.put("barCode", diEx.getBarCode());
|
||||
item.put("materialName", diEx.getMName());
|
||||
@ -551,26 +552,27 @@ public class DepotItemController {
|
||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||
try {
|
||||
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
|
||||
List<Long> depotList = depotService.parseDepotList(null);
|
||||
Boolean amountApprovalFlag = systemConfigService.getAmountApprovalFlag();
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.getListWithBugOrSale(StringUtil.toNull(materialParam),
|
||||
"sale", beginTime, endTime, creatorArray, amountApprovalFlag, (currentPage-1)*pageSize, pageSize);
|
||||
"sale", beginTime, endTime, creatorArray, depotList, amountApprovalFlag, (currentPage-1)*pageSize, pageSize);
|
||||
String[] mpArr = mpList.split(",");
|
||||
int total = depotItemService.getListWithBugOrSaleCount(StringUtil.toNull(materialParam),
|
||||
"sale", beginTime, endTime, creatorArray, amountApprovalFlag);
|
||||
"sale", beginTime, endTime, creatorArray, 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,"number");
|
||||
BigDecimal OutSum = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), beginTime, endTime, creatorArray,"number");
|
||||
BigDecimal InSumRetail = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), beginTime, endTime, creatorArray,"number");
|
||||
BigDecimal InSum = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), beginTime, endTime, creatorArray,"number");
|
||||
BigDecimal OutSumRetailPrice = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), beginTime, endTime, creatorArray,"price");
|
||||
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), beginTime, endTime, creatorArray,"price");
|
||||
BigDecimal InSumRetailPrice = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), beginTime, endTime, creatorArray,"price");
|
||||
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), beginTime, endTime, creatorArray,"price");
|
||||
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 OutInSumPrice = (OutSumRetailPrice.add(OutSumPrice)).subtract(InSumRetailPrice.add(InSumPrice));
|
||||
item.put("barCode", diEx.getBarCode());
|
||||
item.put("materialName", diEx.getMName());
|
||||
|
||||
@ -30,7 +30,7 @@ public interface DepotItemMapperEx {
|
||||
@Param("remark") String remark);
|
||||
|
||||
List<DepotItemVo4DetailByTypeAndMId> findDetailByDepotIdsAndMaterialIdList(
|
||||
@Param("depotIdArray") String[] depotIdArray,
|
||||
@Param("depotIdArray") Long[] depotIdArray,
|
||||
@Param("sku") String sku,
|
||||
@Param("batchNumber") String batchNumber,
|
||||
@Param("number") String number,
|
||||
@ -41,7 +41,7 @@ public interface DepotItemMapperEx {
|
||||
@Param("rows") Integer rows);
|
||||
|
||||
Long findDetailByDepotIdsAndMaterialIdCount(
|
||||
@Param("depotIdArray") String[] depotIdArray,
|
||||
@Param("depotIdArray") Long[] depotIdArray,
|
||||
@Param("sku") String sku,
|
||||
@Param("batchNumber") String batchNumber,
|
||||
@Param("number") String number,
|
||||
@ -68,6 +68,7 @@ public interface DepotItemMapperEx {
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime,
|
||||
@Param("creatorArray") String[] creatorArray,
|
||||
@Param("depotList") List<Long> depotList,
|
||||
@Param("amountApprovalFlag") Boolean amountApprovalFlag,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("rows") Integer rows);
|
||||
@ -78,6 +79,7 @@ public interface DepotItemMapperEx {
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime,
|
||||
@Param("creatorArray") String[] creatorArray,
|
||||
@Param("depotList") List<Long> depotList,
|
||||
@Param("amountApprovalFlag") Boolean amountApprovalFlag);
|
||||
|
||||
BigDecimal buyOrSaleNumber(
|
||||
@ -87,6 +89,7 @@ public interface DepotItemMapperEx {
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime,
|
||||
@Param("creatorArray") String[] creatorArray,
|
||||
@Param("depotList") List<Long> depotList,
|
||||
@Param("sumType") String sumType);
|
||||
|
||||
BigDecimal buyOrSalePrice(
|
||||
@ -96,6 +99,7 @@ public interface DepotItemMapperEx {
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime,
|
||||
@Param("creatorArray") String[] creatorArray,
|
||||
@Param("depotList") List<Long> depotList,
|
||||
@Param("sumType") String sumType);
|
||||
|
||||
BigDecimal inOrOutPrice(
|
||||
|
||||
@ -176,10 +176,12 @@ public class DepotItemService {
|
||||
|
||||
public List<DepotItemVo4DetailByTypeAndMId> findDetailByDepotIdsAndMaterialIdList(String depotIds, String sku, String batchNumber,
|
||||
String number, String beginTime, String endTime, Long mId, int offset, int rows)throws Exception {
|
||||
String [] depotIdArray = null;
|
||||
Long depotId = null;
|
||||
if(StringUtil.isNotEmpty(depotIds)) {
|
||||
depotIdArray = depotIds.split(",");
|
||||
depotId = Long.parseLong(depotIds);
|
||||
}
|
||||
List<Long> depotList = depotService.parseDepotList(depotId);
|
||||
Long[] depotIdArray = StringUtil.listToLongArray(depotList);
|
||||
List<DepotItemVo4DetailByTypeAndMId> list =null;
|
||||
try{
|
||||
list = depotItemMapperEx.findDetailByDepotIdsAndMaterialIdList(depotIdArray, sku, batchNumber, number, beginTime, endTime, mId, offset, rows);
|
||||
@ -191,10 +193,12 @@ public class DepotItemService {
|
||||
|
||||
public Long findDetailByDepotIdsAndMaterialIdCount(String depotIds, String sku, String batchNumber,
|
||||
String number, String beginTime, String endTime, Long mId)throws Exception {
|
||||
String [] depotIdArray = null;
|
||||
Long depotId = null;
|
||||
if(StringUtil.isNotEmpty(depotIds)) {
|
||||
depotIdArray = depotIds.split(",");
|
||||
depotId = Long.parseLong(depotIds);
|
||||
}
|
||||
List<Long> depotList = depotService.parseDepotList(depotId);
|
||||
Long[] depotIdArray = StringUtil.listToLongArray(depotList);
|
||||
Long result =null;
|
||||
try{
|
||||
result = depotItemMapperEx.findDetailByDepotIdsAndMaterialIdCount(depotIdArray, sku, batchNumber, number, beginTime, endTime, mId);
|
||||
@ -314,10 +318,10 @@ public class DepotItemService {
|
||||
}
|
||||
|
||||
public List<DepotItemVo4WithInfoEx> getListWithBugOrSale(String materialParam, String billType,
|
||||
String beginTime, String endTime, String[] creatorArray, Boolean amountApprovalFlag, Integer offset, Integer rows)throws Exception {
|
||||
String beginTime, String endTime, String[] creatorArray, List<Long> depotList, Boolean amountApprovalFlag, Integer offset, Integer rows)throws Exception {
|
||||
List<DepotItemVo4WithInfoEx> list =null;
|
||||
try{
|
||||
list = depotItemMapperEx.getListWithBugOrSale(materialParam, billType, beginTime, endTime, creatorArray, amountApprovalFlag, offset, rows);
|
||||
list = depotItemMapperEx.getListWithBugOrSale(materialParam, billType, beginTime, endTime, creatorArray, depotList, amountApprovalFlag, offset, rows);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@ -325,10 +329,10 @@ public class DepotItemService {
|
||||
}
|
||||
|
||||
public int getListWithBugOrSaleCount(String materialParam, String billType,
|
||||
String beginTime, String endTime, String[] creatorArray, Boolean amountApprovalFlag)throws Exception {
|
||||
String beginTime, String endTime, String[] creatorArray, List<Long> depotList, Boolean amountApprovalFlag)throws Exception {
|
||||
int result=0;
|
||||
try{
|
||||
result = depotItemMapperEx.getListWithBugOrSaleCount(materialParam, billType, beginTime, endTime, creatorArray, amountApprovalFlag);
|
||||
result = depotItemMapperEx.getListWithBugOrSaleCount(materialParam, billType, beginTime, endTime, creatorArray, depotList, amountApprovalFlag);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@ -336,13 +340,13 @@ public class DepotItemService {
|
||||
}
|
||||
|
||||
public BigDecimal buyOrSale(String type, String subType, Long MId, String beginTime, String endTime,
|
||||
String[] creatorArray, String sumType) throws Exception{
|
||||
String[] creatorArray, 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, sumType);
|
||||
result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, beginTime, endTime, creatorArray, depotList, sumType);
|
||||
} else {
|
||||
result= depotItemMapperEx.buyOrSalePrice(type, subType, MId, beginTime, endTime, creatorArray, sumType);
|
||||
result= depotItemMapperEx.buyOrSalePrice(type, subType, MId, beginTime, endTime, creatorArray, depotList, sumType);
|
||||
}
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
|
||||
@ -376,6 +376,12 @@
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="depotList.size()>0">
|
||||
and di.depot_id in
|
||||
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="amountApprovalFlag">
|
||||
and dh.status = '1'
|
||||
</if>
|
||||
@ -417,6 +423,12 @@
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="depotList.size()>0">
|
||||
and di.depot_id in
|
||||
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="amountApprovalFlag">
|
||||
and dh.status = '1'
|
||||
</if>
|
||||
@ -438,6 +450,12 @@
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="depotList.size()>0">
|
||||
and di.depot_id in
|
||||
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
and ifnull(dh.delete_flag,'0') !='1'
|
||||
and ifnull(di.delete_flag,'0') !='1'
|
||||
</select>
|
||||
@ -456,6 +474,12 @@
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="depotList.size()>0">
|
||||
and di.depot_id in
|
||||
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
and ifnull(dh.delete_flag,'0') !='1'
|
||||
and ifnull(di.delete_flag,'0') !='1'
|
||||
</select>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user