优化客户对账和供应商对账
This commit is contained in:
@@ -280,44 +280,54 @@ public class DepotHeadController {
|
||||
* @param beginTime
|
||||
* @param endTime
|
||||
* @param organId
|
||||
* @param supType
|
||||
* @param supplierType
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findStatementAccount")
|
||||
@GetMapping(value = "/getStatementAccount")
|
||||
@ApiOperation(value = "对账单接口")
|
||||
public BaseResponseInfo findStatementAccount(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("beginTime") String beginTime,
|
||||
@RequestParam("endTime") String endTime,
|
||||
@RequestParam(value = "organId", required = false) Integer organId,
|
||||
@RequestParam("supType") String supType,
|
||||
HttpServletRequest request) throws Exception{
|
||||
public BaseResponseInfo getStatementAccount(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("beginTime") String beginTime,
|
||||
@RequestParam("endTime") String endTime,
|
||||
@RequestParam(value = "organId", required = false) Integer organId,
|
||||
@RequestParam("supplierType") String supplierType,
|
||||
HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
String type = "";
|
||||
String subType = "";
|
||||
if (("供应商").equals(supplierType)) {
|
||||
type = "入库";
|
||||
subType = "采购";
|
||||
} else if (("客户").equals(supplierType)) {
|
||||
type = "出库";
|
||||
subType = "销售";
|
||||
}
|
||||
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
|
||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||
List<DepotHeadVo4StatementAccount> list = depotHeadService.findStatementAccount(beginTime, endTime, organId, supType, (currentPage-1)*pageSize, pageSize);
|
||||
int total = depotHeadService.findStatementAccountCount(beginTime, endTime, organId, supType);
|
||||
List<DepotHeadVo4StatementAccount> list = depotHeadService.getStatementAccount(beginTime, endTime, organId,
|
||||
supplierType, type, subType, (currentPage-1)*pageSize, pageSize);
|
||||
int total = depotHeadService.getStatementAccountCount(beginTime, endTime, organId,
|
||||
supplierType, type, subType);
|
||||
for(DepotHeadVo4StatementAccount item: list) {
|
||||
BigDecimal preNeed = item.getBeginNeed().add(item.getPreDebtMoney()).subtract(item.getPreBackMoney());
|
||||
item.setPreNeed(preNeed);
|
||||
BigDecimal allNeedGet = preNeed.add(item.getDebtMoney()).subtract(item.getBackMoney());
|
||||
item.setAllNeed(allNeedGet);
|
||||
}
|
||||
map.put("rows", list);
|
||||
map.put("total", total);
|
||||
if(null!=organId) {
|
||||
Supplier supplier = supplierService.getSupplier(organId);
|
||||
BigDecimal beginNeed = BigDecimal.ZERO;
|
||||
if (("客户").equals(supType)) {
|
||||
if(supplier.getBeginNeedGet()!=null) {
|
||||
beginNeed = supplier.getBeginNeedGet();
|
||||
}
|
||||
} else if (("供应商").equals(supType)) {
|
||||
if(supplier.getBeginNeedPay()!=null) {
|
||||
beginNeed = supplier.getBeginNeedPay();
|
||||
}
|
||||
List<DepotHeadVo4StatementAccount> totalPayList = depotHeadService.getStatementAccountTotalPay(beginTime, endTime, organId, supplierType, type, subType);
|
||||
if(totalPayList.size()>0) {
|
||||
DepotHeadVo4StatementAccount totalPayItem = totalPayList.get(0);
|
||||
BigDecimal firstMoney = BigDecimal.ZERO;
|
||||
BigDecimal lastMoney = BigDecimal.ZERO;
|
||||
if(totalPayItem!=null) {
|
||||
firstMoney = totalPayItem.getBeginNeed().add(totalPayItem.getPreDebtMoney()).subtract(totalPayItem.getPreBackMoney());
|
||||
lastMoney = firstMoney.add(totalPayItem.getDebtMoney()).subtract(totalPayItem.getBackMoney());
|
||||
}
|
||||
BigDecimal firstMoney = depotHeadService.findTotalPay(organId, beginTime, supType)
|
||||
.subtract(accountHeadService.findTotalPay(organId, beginTime, supType)).add(beginNeed);
|
||||
BigDecimal lastMoney = depotHeadService.findTotalPay(organId, endTime, supType)
|
||||
.subtract(accountHeadService.findTotalPay(organId, endTime, supType)).add(beginNeed);
|
||||
map.put("firstMoney", firstMoney); //期初
|
||||
map.put("lastMoney", lastMoney); //期末
|
||||
}
|
||||
|
||||
@@ -121,19 +121,31 @@ public interface DepotHeadMapperEx {
|
||||
@Param("depotFList") List<Long> depotFList,
|
||||
@Param("remark") String remark);
|
||||
|
||||
List<DepotHeadVo4StatementAccount> findStatementAccount(
|
||||
List<DepotHeadVo4StatementAccount> getStatementAccount(
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime,
|
||||
@Param("organId") Integer organId,
|
||||
@Param("supType") String supType,
|
||||
@Param("supplierType") String supplierType,
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("rows") Integer rows);
|
||||
|
||||
int findStatementAccountCount(
|
||||
int getStatementAccountCount(
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime,
|
||||
@Param("organId") Integer organId,
|
||||
@Param("supType") String supType);
|
||||
@Param("supplierType") String supplierType,
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType);
|
||||
|
||||
List<DepotHeadVo4StatementAccount> getStatementAccountTotalPay(
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime,
|
||||
@Param("organId") Integer organId,
|
||||
@Param("supplierType") String supplierType,
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType);
|
||||
|
||||
BigDecimal findAllMoney(
|
||||
@Param("supplierId") Integer supplierId,
|
||||
|
||||
@@ -5,103 +5,133 @@ import java.math.BigDecimal;
|
||||
|
||||
public class DepotHeadVo4StatementAccount {
|
||||
|
||||
private String number;
|
||||
private Long id;
|
||||
|
||||
private String type;
|
||||
private String supplier;
|
||||
|
||||
private BigDecimal discountLastMoney;
|
||||
private String contacts;
|
||||
|
||||
private BigDecimal otherMoney;
|
||||
private String telephone;
|
||||
|
||||
private BigDecimal billMoney;
|
||||
private String phoneNum;
|
||||
|
||||
private BigDecimal changeAmount;
|
||||
private String email;
|
||||
|
||||
private BigDecimal allPrice;
|
||||
private BigDecimal beginNeed;
|
||||
|
||||
private String supplierName;
|
||||
private BigDecimal preDebtMoney;
|
||||
|
||||
private String oTime;
|
||||
private BigDecimal preBackMoney;
|
||||
|
||||
private Long tenantId;
|
||||
private BigDecimal preNeed;
|
||||
|
||||
public String getNumber() {
|
||||
return number;
|
||||
private BigDecimal debtMoney;
|
||||
|
||||
private BigDecimal backMoney;
|
||||
|
||||
private BigDecimal allNeed;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setNumber(String number) {
|
||||
this.number = number;
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
public String getSupplier() {
|
||||
return supplier;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
public void setSupplier(String supplier) {
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
public BigDecimal getDiscountLastMoney() {
|
||||
return discountLastMoney;
|
||||
public String getContacts() {
|
||||
return contacts;
|
||||
}
|
||||
|
||||
public void setDiscountLastMoney(BigDecimal discountLastMoney) {
|
||||
this.discountLastMoney = discountLastMoney;
|
||||
public void setContacts(String contacts) {
|
||||
this.contacts = contacts;
|
||||
}
|
||||
|
||||
public BigDecimal getOtherMoney() {
|
||||
return otherMoney;
|
||||
public String getTelephone() {
|
||||
return telephone;
|
||||
}
|
||||
|
||||
public void setOtherMoney(BigDecimal otherMoney) {
|
||||
this.otherMoney = otherMoney;
|
||||
public void setTelephone(String telephone) {
|
||||
this.telephone = telephone;
|
||||
}
|
||||
|
||||
public BigDecimal getBillMoney() {
|
||||
return billMoney;
|
||||
public String getPhoneNum() {
|
||||
return phoneNum;
|
||||
}
|
||||
|
||||
public void setBillMoney(BigDecimal billMoney) {
|
||||
this.billMoney = billMoney;
|
||||
public void setPhoneNum(String phoneNum) {
|
||||
this.phoneNum = phoneNum;
|
||||
}
|
||||
|
||||
public BigDecimal getChangeAmount() {
|
||||
return changeAmount;
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setChangeAmount(BigDecimal changeAmount) {
|
||||
this.changeAmount = changeAmount;
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public BigDecimal getAllPrice() {
|
||||
return allPrice;
|
||||
public BigDecimal getBeginNeed() {
|
||||
return beginNeed;
|
||||
}
|
||||
|
||||
public void setAllPrice(BigDecimal allPrice) {
|
||||
this.allPrice = allPrice;
|
||||
public void setBeginNeed(BigDecimal beginNeed) {
|
||||
this.beginNeed = beginNeed;
|
||||
}
|
||||
|
||||
public String getSupplierName() {
|
||||
return supplierName;
|
||||
public BigDecimal getPreDebtMoney() {
|
||||
return preDebtMoney;
|
||||
}
|
||||
|
||||
public void setSupplierName(String supplierName) {
|
||||
this.supplierName = supplierName;
|
||||
public void setPreDebtMoney(BigDecimal preDebtMoney) {
|
||||
this.preDebtMoney = preDebtMoney;
|
||||
}
|
||||
|
||||
public String getoTime() {
|
||||
return oTime;
|
||||
public BigDecimal getPreBackMoney() {
|
||||
return preBackMoney;
|
||||
}
|
||||
|
||||
public void setoTime(String oTime) {
|
||||
this.oTime = oTime;
|
||||
public void setPreBackMoney(BigDecimal preBackMoney) {
|
||||
this.preBackMoney = preBackMoney;
|
||||
}
|
||||
|
||||
public Long getTenantId() {
|
||||
return tenantId;
|
||||
public BigDecimal getPreNeed() {
|
||||
return preNeed;
|
||||
}
|
||||
|
||||
public void setTenantId(Long tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
public void setPreNeed(BigDecimal preNeed) {
|
||||
this.preNeed = preNeed;
|
||||
}
|
||||
|
||||
public BigDecimal getDebtMoney() {
|
||||
return debtMoney;
|
||||
}
|
||||
|
||||
public void setDebtMoney(BigDecimal debtMoney) {
|
||||
this.debtMoney = debtMoney;
|
||||
}
|
||||
|
||||
public BigDecimal getBackMoney() {
|
||||
return backMoney;
|
||||
}
|
||||
|
||||
public void setBackMoney(BigDecimal backMoney) {
|
||||
this.backMoney = backMoney;
|
||||
}
|
||||
|
||||
public BigDecimal getAllNeed() {
|
||||
return allNeed;
|
||||
}
|
||||
|
||||
public void setAllNeed(BigDecimal allNeed) {
|
||||
this.allNeed = allNeed;
|
||||
}
|
||||
}
|
||||
@@ -511,72 +511,39 @@ public class DepotHeadService {
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DepotHeadVo4StatementAccount> findStatementAccount(String beginTime, String endTime, Integer organId, String supType, Integer offset, Integer rows)throws Exception {
|
||||
public List<DepotHeadVo4StatementAccount> getStatementAccount(String beginTime, String endTime, Integer organId, String supplierType,
|
||||
String type, String subType, Integer offset, Integer rows) {
|
||||
List<DepotHeadVo4StatementAccount> list = null;
|
||||
try{
|
||||
int j = 1;
|
||||
if (supType.equals("客户")) { //客户
|
||||
j = 1;
|
||||
} else if (supType.equals("供应商")) { //供应商
|
||||
j = -1;
|
||||
}
|
||||
list =depotHeadMapperEx.findStatementAccount(beginTime, endTime, organId, supType, offset, rows);
|
||||
if (null != list) {
|
||||
for (DepotHeadVo4StatementAccount dha : list) {
|
||||
dha.setNumber(dha.getNumber()); //单据编号
|
||||
dha.setType(dha.getType()); //类型
|
||||
String type = dha.getType();
|
||||
BigDecimal p1 = BigDecimal.ZERO ;
|
||||
BigDecimal p2 = BigDecimal.ZERO;
|
||||
if (dha.getDiscountLastMoney() != null) {
|
||||
p1 = dha.getDiscountLastMoney();
|
||||
}
|
||||
if (dha.getChangeAmount() != null) {
|
||||
p2 = dha.getChangeAmount();
|
||||
}
|
||||
BigDecimal allPrice = BigDecimal.ZERO;
|
||||
if ((p1.compareTo(BigDecimal.ZERO))==-1) {
|
||||
p1 = p1.abs();
|
||||
}
|
||||
if(dha.getOtherMoney()!=null) {
|
||||
p1 = p1.add(dha.getOtherMoney()); //与其它费用相加
|
||||
}
|
||||
if ((p2 .compareTo(BigDecimal.ZERO))==-1) {
|
||||
p2 = p2.abs();
|
||||
}
|
||||
if (type.equals("采购入库")) {
|
||||
allPrice = p2.subtract(p1);
|
||||
} else if (type.equals("销售出库")) {
|
||||
allPrice = p1.subtract(p2);
|
||||
} else if (type.equals("收款")) {
|
||||
allPrice = BigDecimal.ZERO.subtract(p1);
|
||||
} else if (type.equals("付款")) {
|
||||
allPrice = p1;
|
||||
}
|
||||
dha.setBillMoney(p1); //单据金额
|
||||
dha.setChangeAmount(p2); //实际支付
|
||||
DecimalFormat df = new DecimalFormat(".##");
|
||||
dha.setAllPrice(new BigDecimal(df.format(allPrice.multiply(new BigDecimal(j))))); //本期变化
|
||||
dha.setSupplierName(dha.getSupplierName()); //单位名称
|
||||
dha.setoTime(dha.getoTime()); //单据日期
|
||||
}
|
||||
}
|
||||
list = depotHeadMapperEx.getStatementAccount(beginTime, endTime, organId, supplierType, type, subType, offset, rows);
|
||||
} catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) throws Exception{
|
||||
public int getStatementAccountCount(String beginTime, String endTime, Integer organId, String supplierType,
|
||||
String type, String subType) {
|
||||
int result = 0;
|
||||
try{
|
||||
result =depotHeadMapperEx.findStatementAccountCount(beginTime, endTime, organId, supType);
|
||||
}catch(Exception e){
|
||||
result = depotHeadMapperEx.getStatementAccountCount(beginTime, endTime, organId, supplierType, type, subType);
|
||||
} catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DepotHeadVo4StatementAccount> getStatementAccountTotalPay(String beginTime, String endTime, Integer organId, String supplierType,
|
||||
String type, String subType) {
|
||||
List<DepotHeadVo4StatementAccount> list = null;
|
||||
try{
|
||||
list = depotHeadMapperEx.getStatementAccountTotalPay(beginTime, endTime, organId, supplierType, type, subType);
|
||||
} catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public BigDecimal findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime)throws Exception {
|
||||
String modeName = "";
|
||||
BigDecimal allOtherMoney = BigDecimal.ZERO;
|
||||
|
||||
Reference in New Issue
Block a user