客户对账单优化
This commit is contained in:
@@ -292,11 +292,19 @@ public class AccountHeadAction extends BaseAction<AccountHeadModel>
|
||||
JSONObject outer = new JSONObject();
|
||||
Double sum = 0.0;
|
||||
String getS = model.getSupplierId();
|
||||
String supType = model.getSupType(); //单位类型:客户、供应商
|
||||
int i = 1;
|
||||
if(supType.equals("customer")){ //客户
|
||||
i = 1;
|
||||
}
|
||||
else if(supType.equals("vendor")){ //供应商
|
||||
i = -1;
|
||||
}
|
||||
//收付款部分
|
||||
sum = sum - (allMoney(getS, "付款", "合计") + allMoney(getS, "付款", "实际"));
|
||||
sum = sum + (allMoney(getS, "收款", "合计") + allMoney(getS, "收款", "实际"));
|
||||
sum = sum - (allMoney(getS, "收入", "合计") - allMoney(getS, "收入", "实际"));
|
||||
sum = sum + (allMoney(getS, "支出", "合计") - allMoney(getS, "支出", "实际"));
|
||||
sum = sum + (allMoney(getS, "付款", "合计") + allMoney(getS, "付款", "实际"))*i;
|
||||
sum = sum - (allMoney(getS, "收款", "合计") + allMoney(getS, "收款", "实际"))*i;
|
||||
sum = sum + (allMoney(getS, "收入", "合计") - allMoney(getS, "收入", "实际"))*i;
|
||||
sum = sum - (allMoney(getS, "支出", "合计") - allMoney(getS, "支出", "实际"))*i;
|
||||
outer.put("getAllMoney", sum);
|
||||
toClient(outer.toString());
|
||||
}
|
||||
@@ -321,9 +329,10 @@ public class AccountHeadAction extends BaseAction<AccountHeadModel>
|
||||
Log.infoFileSync("getS:" + getS);
|
||||
Double allMoney = 0.0;
|
||||
String allReturn = "";
|
||||
PageUtil pageUtil = new PageUtil();
|
||||
PageUtil<AccountHead> pageUtil = new PageUtil<AccountHead>();
|
||||
pageUtil.setPageSize(0);
|
||||
pageUtil.setCurPage(0);
|
||||
pageUtil.setAdvSearch(getConditionHead_byEndTime());
|
||||
try {
|
||||
Integer supplierId = Integer.valueOf(getS);
|
||||
accountHeadService.findAllMoney(pageUtil, supplierId, type, mode);
|
||||
@@ -362,6 +371,13 @@ public class AccountHeadAction extends BaseAction<AccountHeadModel>
|
||||
return condition;
|
||||
}
|
||||
|
||||
private Map<String,Object> getConditionHead_byEndTime()
|
||||
{
|
||||
Map<String,Object> condition = new HashMap<String,Object>();
|
||||
condition.put("BillTime_s_lteq", model.getEndTime());
|
||||
return condition;
|
||||
}
|
||||
|
||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
||||
public AccountHeadModel getModel()
|
||||
{
|
||||
|
||||
@@ -565,13 +565,21 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
JSONObject outer = new JSONObject();
|
||||
Double sum = 0.0;
|
||||
String getS = model.getSupplierId();
|
||||
String supType = model.getSupType(); //单位类型:客户、供应商
|
||||
int i = 1;
|
||||
if(supType.equals("customer")){ //客户
|
||||
i = 1;
|
||||
}
|
||||
else if(supType.equals("vendor")){ //供应商
|
||||
i = -1;
|
||||
}
|
||||
//进销部分
|
||||
sum = sum + (allMoney(getS, "入库", "采购", "合计") - allMoney(getS, "入库", "采购", "实际"));
|
||||
sum = sum + (allMoney(getS, "入库", "销售退货", "合计") - allMoney(getS, "入库", "销售退货", "实际"));
|
||||
sum = sum + (allMoney(getS, "入库", "其他", "合计") - allMoney(getS, "入库", "其他", "实际"));
|
||||
sum = sum - (allMoney(getS, "出库", "销售", "合计") - allMoney(getS, "出库", "销售", "实际"));
|
||||
sum = sum - (allMoney(getS, "出库", "采购退货", "合计") - allMoney(getS, "出库", "采购退货", "实际"));
|
||||
sum = sum - (allMoney(getS, "出库", "其他", "合计") - allMoney(getS, "出库", "其他", "实际"));
|
||||
sum = sum - (allMoney(getS, "入库", "采购", "合计") - allMoney(getS, "入库", "采购", "实际"))*i;
|
||||
sum = sum - (allMoney(getS, "入库", "销售退货", "合计") - allMoney(getS, "入库", "销售退货", "实际"))*i;
|
||||
sum = sum - (allMoney(getS, "入库", "其他", "合计") - allMoney(getS, "入库", "其他", "实际"))*i;
|
||||
sum = sum + (allMoney(getS, "出库", "销售", "合计") - allMoney(getS, "出库", "销售", "实际"))*i;
|
||||
sum = sum + (allMoney(getS, "出库", "采购退货", "合计") - allMoney(getS, "出库", "采购退货", "实际"))*i;
|
||||
sum = sum + (allMoney(getS, "出库", "其他", "合计") - allMoney(getS, "出库", "其他", "实际"))*i;
|
||||
outer.put("getAllMoney", sum);
|
||||
toClient(outer.toString());
|
||||
}
|
||||
@@ -598,9 +606,10 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
Log.infoFileSync("getS:" + getS);
|
||||
Double allMoney = 0.0;
|
||||
String allReturn = "";
|
||||
PageUtil pageUtil = new PageUtil();
|
||||
PageUtil<DepotHead> pageUtil = new PageUtil<DepotHead>();
|
||||
pageUtil.setPageSize(0);
|
||||
pageUtil.setCurPage(0);
|
||||
pageUtil.setAdvSearch(getConditionHead_byEndTime());
|
||||
try {
|
||||
Integer supplierId = Integer.valueOf(getS);
|
||||
depotHeadService.findAllMoney(pageUtil, supplierId, type, subType, mode);
|
||||
@@ -755,10 +764,58 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
Object dl = dataList.get(i); //获取对象
|
||||
Object[] arr = (Object[]) dl; //转为数组
|
||||
item.put("number", arr[0]); //单据编号
|
||||
item.put("changeAmount", arr[1]); //金额
|
||||
item.put("totalPrice", arr[2]); //金额
|
||||
item.put("supplierName", arr[3]); //供应商
|
||||
item.put("operTime", arr[4]); //入库出库日期
|
||||
item.put("type", arr[1]); //类型
|
||||
item.put("changeAmount", arr[2]); //金额
|
||||
item.put("totalPrice", arr[3]); //金额
|
||||
String type = arr[1].toString();
|
||||
Double p1 = 0.0;
|
||||
Double p2 = 0.0;
|
||||
if(arr[3]!=null){
|
||||
p1 = Double.parseDouble(arr[3].toString());
|
||||
}
|
||||
if(arr[2]!=null){
|
||||
p2 = Double.parseDouble(arr[2].toString());
|
||||
}
|
||||
Double allPrice = 0.0;
|
||||
if(p1<0) {
|
||||
p1 = -p1;
|
||||
}
|
||||
if(p2<0) {
|
||||
p2 = -p2;
|
||||
}
|
||||
if(type.equals("采购入库")) {
|
||||
allPrice = -(p1-p2);
|
||||
}
|
||||
else if(type.equals("销售退货入库")) {
|
||||
allPrice = -(p1-p2);
|
||||
}
|
||||
else if(type.equals("其他入库")) {
|
||||
allPrice = -(p1-p2);
|
||||
}
|
||||
else if(type.equals("销售出库")) {
|
||||
allPrice = p1-p2;
|
||||
}
|
||||
else if(type.equals("采购退货出库")) {
|
||||
allPrice = p1-p2;
|
||||
}
|
||||
else if(type.equals("其他出库")) {
|
||||
allPrice = p1-p2;
|
||||
}
|
||||
else if(type.equals("付款")) {
|
||||
allPrice = p1+p2;
|
||||
}
|
||||
else if(type.equals("收款")) {
|
||||
allPrice = -(p1+p2);
|
||||
}
|
||||
else if(type.equals("收入")) {
|
||||
allPrice = p1-p2;
|
||||
}
|
||||
else if(type.equals("支出")) {
|
||||
allPrice = -(p1-p2);
|
||||
}
|
||||
item.put("allPrice", String .format("%.2f",allPrice)); //计算后的金额
|
||||
item.put("supplierName", arr[4]); //供应商
|
||||
item.put("operTime", arr[5]); //入库出库日期
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
@@ -823,6 +880,13 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
}
|
||||
return condition;
|
||||
}
|
||||
|
||||
private Map<String,Object> getConditionHead_byEndTime()
|
||||
{
|
||||
Map<String,Object> condition = new HashMap<String,Object>();
|
||||
condition.put("OperTime_s_lteq", model.getEndTime());
|
||||
return condition;
|
||||
}
|
||||
|
||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
||||
public DepotHeadModel getModel()
|
||||
|
||||
@@ -131,14 +131,14 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findStatementAccount(PageUtil pageUtil,String beginTime,String endTime,Long organId) throws JshException {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("select dh.Number,dh.ChangeAmount,dh.TotalPrice,s.supplier,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_depothead dh " +
|
||||
queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType,dh.ChangeAmount,dh.TotalPrice,s.supplier,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_depothead dh " +
|
||||
"inner join jsh_supplier s on s.id=dh.OrganId where s.type!='会员' " +
|
||||
"and dh.OperTime >='"+ beginTime +"' and dh.OperTime<='"+ endTime +"' ");
|
||||
if(organId!=null && !organId.equals("")) {
|
||||
queryString.append(" and dh.OrganId='"+ organId +"' ");
|
||||
}
|
||||
queryString.append("UNION ALL " +
|
||||
"select ah.BillNo,ah.ChangeAmount,ah.TotalPrice,s.supplier,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_accounthead ah " +
|
||||
"select ah.BillNo,ah.Type as newType,ah.ChangeAmount,ah.TotalPrice,s.supplier,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_accounthead ah " +
|
||||
"inner join jsh_supplier s on s.id=ah.OrganId where s.type!='会员' " +
|
||||
"and ah.BillTime >='"+ beginTime +"' and ah.BillTime<='"+ endTime +"' ");
|
||||
if(organId!=null && !organId.equals("")) {
|
||||
|
||||
@@ -22,6 +22,8 @@ public class AccountHeadModel implements Serializable
|
||||
private String MonthTime; //查询月份
|
||||
|
||||
private String supplierId; //单位Id,用于查询单位的收付款
|
||||
|
||||
private String supType; //单位类型,客户、供应商
|
||||
/**
|
||||
* 分类ID
|
||||
*/
|
||||
@@ -233,5 +235,12 @@ public class AccountHeadModel implements Serializable
|
||||
public void setSupplierId(String supplierId) {
|
||||
this.supplierId = supplierId;
|
||||
}
|
||||
|
||||
|
||||
public String getSupType() {
|
||||
return supType;
|
||||
}
|
||||
|
||||
public void setSupType(String supType) {
|
||||
this.supType = supType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class DepotHeadModel implements Serializable
|
||||
private String supplierId; //单位Id,用于查询单位的应收应付
|
||||
private String MaterialParam; //商品参数
|
||||
private String dhIds; //单据id列表
|
||||
private String supType; //单位类型,客户、供应商
|
||||
|
||||
/**
|
||||
* 分类ID
|
||||
@@ -381,4 +382,12 @@ public class DepotHeadModel implements Serializable
|
||||
public void setDhIds(String dhIds) {
|
||||
this.dhIds = dhIds;
|
||||
}
|
||||
|
||||
public String getSupType() {
|
||||
return supType;
|
||||
}
|
||||
|
||||
public void setSupType(String supType) {
|
||||
this.supType = supType;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user