Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
d4a5fa79
Commit
d4a5fa79
authored
Nov 23, 2022
by
季圣华
Browse files
优化单据的额查询列表的逻辑,提高查询速度
parent
0c213747
Changes
3
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotHeadMapperEx.java
View file @
d4a5fa79
package
com.jsh.erp.datasource.mappers
;
package
com.jsh.erp.datasource.mappers
;
import
com.jsh.erp.datasource.entities.DepotHead
;
import
com.jsh.erp.datasource.entities.DepotHead
;
import
com.jsh.erp.datasource.vo.DepotHeadVo4InDetail
;
import
com.jsh.erp.datasource.vo.*
;
import
com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount
;
import
com.jsh.erp.datasource.vo.DepotHeadVo4List
;
import
com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
...
@@ -230,8 +227,8 @@ public interface DepotHeadMapperEx {
...
@@ -230,8 +227,8 @@ public interface DepotHeadMapperEx {
@Param
(
"materialParam"
)
String
materialParam
,
@Param
(
"materialParam"
)
String
materialParam
,
@Param
(
"depotArray"
)
String
[]
depotArray
);
@Param
(
"depotArray"
)
String
[]
depotArray
);
BigDecimal
getFinishDepositByNumber
(
List
<
FinishDepositVo
>
getFinishDepositByNumber
List
(
@Param
(
"number
"
)
String
number
);
@Param
(
"number
List"
)
List
<
String
>
number
List
);
BigDecimal
getFinishDepositByNumberExceptCurrent
(
BigDecimal
getFinishDepositByNumberExceptCurrent
(
@Param
(
"linkNumber"
)
String
linkNumber
,
@Param
(
"linkNumber"
)
String
linkNumber
,
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java
View file @
d4a5fa79
...
@@ -7,10 +7,7 @@ import com.jsh.erp.datasource.entities.*;
...
@@ -7,10 +7,7 @@ import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.DepotHeadMapper;
import com.jsh.erp.datasource.mappers.DepotHeadMapper;
import com.jsh.erp.datasource.mappers.DepotHeadMapperEx;
import com.jsh.erp.datasource.mappers.DepotHeadMapperEx;
import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
import
com.jsh.erp.datasource.vo.DepotHeadVo4InDetail
;
import com.jsh.erp.datasource.vo.*;
import
com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount
;
import
com.jsh.erp.datasource.vo.DepotHeadVo4List
;
import
com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount
;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.account.AccountService;
import com.jsh.erp.service.account.AccountService;
...
@@ -125,6 +122,15 @@ public class DepotHeadService {
...
@@ -125,6 +122,15 @@ public class DepotHeadService {
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, creatorArray, hasDebt, statusArray, purchaseStatusArray, number, linkNumber, beginTime, endTime,
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, creatorArray, hasDebt, statusArray, purchaseStatusArray, number, linkNumber, beginTime, endTime,
materialParam, organId, organArray, creator, depotId, depotArray, accountId, remark, offset, rows);
materialParam, organId, organArray, creator, depotId, depotArray, accountId, remark, offset, rows);
if (null != list) {
if (null != list) {
List<Long> idList = new ArrayList<>();
List<String> numberList = new ArrayList<>();
for (DepotHeadVo4List dh : list) {
idList.add(dh.getId());
numberList.add(dh.getNumber());
}
//通过批量查询去构造map
Map<String,BigDecimal> finishDepositMap = getFinishDepositMapByNumberList(numberList);
Map<String,Integer> billSizeMap = getBillSizeMapByLinkNumberList(numberList);
for (DepotHeadVo4List dh : list) {
for (DepotHeadVo4List dh : list) {
if(accountMap!=null && StringUtil.isNotEmpty(dh.getAccountIdList()) && StringUtil.isNotEmpty(dh.getAccountMoneyList())) {
if(accountMap!=null && StringUtil.isNotEmpty(dh.getAccountIdList()) && StringUtil.isNotEmpty(dh.getAccountMoneyList())) {
String accountStr = accountService.getAccountStrByIdAndMoney(accountMap, dh.getAccountIdList(), dh.getAccountMoneyList());
String accountStr = accountService.getAccountStrByIdAndMoney(accountMap, dh.getAccountIdList(), dh.getAccountMoneyList());
...
@@ -147,7 +153,7 @@ public class DepotHeadService {
...
@@ -147,7 +153,7 @@ public class DepotHeadService {
if(dh.getDeposit() == null) {
if(dh.getDeposit() == null) {
dh.setDeposit(BigDecimal.ZERO);
dh.setDeposit(BigDecimal.ZERO);
}
}
dh
.
setFinishDeposit
(
depotHeadMapperEx
.
getF
inishDeposit
ByNumber
(
dh
.
getNumber
()));
dh.setFinishDeposit(
f
inishDeposit
Map.get
(dh.getNumber()));
//欠款计算
//欠款计算
BigDecimal discountLastMoney = dh.getDiscountLastMoney()!=null?dh.getDiscountLastMoney():BigDecimal.ZERO;
BigDecimal discountLastMoney = dh.getDiscountLastMoney()!=null?dh.getDiscountLastMoney():BigDecimal.ZERO;
BigDecimal otherMoney = dh.getOtherMoney()!=null?dh.getOtherMoney():BigDecimal.ZERO;
BigDecimal otherMoney = dh.getOtherMoney()!=null?dh.getOtherMoney():BigDecimal.ZERO;
...
@@ -157,8 +163,10 @@ public class DepotHeadService {
...
@@ -157,8 +163,10 @@ public class DepotHeadService {
int financialBillNoSize = accountHeadService.getFinancialBillNoByBillId(dh.getId()).size();
int financialBillNoSize = accountHeadService.getFinancialBillNoByBillId(dh.getId()).size();
dh.setHasFinancialFlag(financialBillNoSize>0);
dh.setHasFinancialFlag(financialBillNoSize>0);
//是否有退款单
//是否有退款单
int
billListSize
=
getBillListByLinkNumber
(
dh
.
getNumber
()).
size
();
if(billSizeMap!=null) {
dh
.
setHasBackFlag
(
billListSize
>
0
);
Integer billListSize = billSizeMap.get(dh.getNumber());
dh.setHasBackFlag(billListSize!=null && billListSize>0);
}
if(StringUtil.isNotEmpty(dh.getSalesMan())) {
if(StringUtil.isNotEmpty(dh.getSalesMan())) {
dh.setSalesManStr(personService.getPersonByMapAndIds(personMap,dh.getSalesMan()));
dh.setSalesManStr(personService.getPersonByMapAndIds(personMap,dh.getSalesMan()));
}
}
...
@@ -283,6 +291,24 @@ public class DepotHeadService {
...
@@ -283,6 +291,24 @@ public class DepotHeadService {
return creator;
return creator;
}
}
public Map<String, BigDecimal> getFinishDepositMapByNumberList(List<String> numberList) {
List<FinishDepositVo> list = depotHeadMapperEx.getFinishDepositByNumberList(numberList);
Map<String,BigDecimal> finishDepositMap = new HashMap<>();
for(FinishDepositVo finishDepositVo : list){
finishDepositMap.put(finishDepositVo.getNumber(), finishDepositVo.getFinishDeposit());
}
return finishDepositMap;
}
public Map<String, Integer> getBillSizeMapByLinkNumberList(List<String> numberList) throws Exception {
List<DepotHead> list = getBillListByLinkNumberList(numberList);
Map<String, Integer> billListMap = new HashMap<>();
for(DepotHead depotHead : list){
billListMap.put(depotHead.getLinkNumber(), list.size());
}
return billListMap;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotHead(JSONObject obj, HttpServletRequest request)throws Exception {
public int insertDepotHead(JSONObject obj, HttpServletRequest request)throws Exception {
DepotHead depotHead = JSONObject.parseObject(obj.toJSONString(), DepotHead.class);
DepotHead depotHead = JSONObject.parseObject(obj.toJSONString(), DepotHead.class);
...
@@ -768,6 +794,18 @@ public class DepotHeadService {
...
@@ -768,6 +794,18 @@ public class DepotHeadService {
return depotHeadMapper.selectByExample(example);
return depotHeadMapper.selectByExample(example);
}
}
/**
* 根据原单号查询关联的单据列表(批量)
* @param linkNumberList
* @return
* @throws Exception
*/
public List<DepotHead> getBillListByLinkNumberList(List<String> linkNumberList)throws Exception {
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andLinkNumberIn(linkNumberList).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return depotHeadMapper.selectByExample(example);
}
/**
/**
* 根据原单号查询关联的单据列表
* 根据原单号查询关联的单据列表
* @param linkNumber
* @param linkNumber
...
...
jshERP-boot/src/main/resources/mapper_xml/DepotHeadMapperEx.xml
View file @
d4a5fa79
...
@@ -954,10 +954,16 @@
...
@@ -954,10 +954,16 @@
order by dh.oper_time desc
order by dh.oper_time desc
</select>
</select>
<select
id=
"getFinishDepositByNumber"
resultType=
"
java.math.BigDecimal
"
>
<select
id=
"getFinishDepositByNumber
List
"
resultType=
"
com.jsh.erp.datasource.vo.FinishDepositVo
"
>
select ifnull(sum(dh.deposit),0)
select
dh.link_number number,
ifnull(sum(dh.deposit),0)
finishDeposit
from jsh_depot_head dh
from jsh_depot_head dh
where dh.link_number=#{number}
where 1=1
<if
test=
"numberList.size()>0"
>
and dh.link_number in
<foreach
collection=
"numberList"
item=
"item"
index=
"index"
separator=
","
open=
"("
close=
")"
>
#{item}
</foreach>
</if>
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(dh.delete_flag,'0') !='1'
</select>
</select>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment