更新供应商和客户的累计应收应付的算法

This commit is contained in:
季圣华
2017-04-09 16:52:02 +08:00
parent bd5deee8ba
commit 33bb4e06ef
29 changed files with 293 additions and 25 deletions

View File

@@ -7,9 +7,12 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.model.po.Account;
@@ -20,8 +23,11 @@ import com.jsh.model.po.Person;
import com.jsh.model.po.Supplier;
import com.jsh.model.vo.materials.DepotHeadModel;
import com.jsh.service.materials.DepotHeadIService;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
import com.jsh.util.Tools;
/*
* 单据表头管理
* @author jishenghua qq:752718920
@@ -331,6 +337,72 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
}
}
/**
* 查询单位的累计应收和累计应付
* @return
*/
public void findTotalPay() {
try
{
JSONObject outer = new JSONObject();
Double sum = 0.0;
String getS = model.getSupplierId();
//进销部分
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, "出库", "其他", "实际"));
outer.put("getAllMoney", sum);
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询结果异常", e);
}
}
/**
* 统计总金额
* @param type
* @param subType
* @param mode 合计或者金额
* @return
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public Double allMoney(String getS, String type, String subType, String mode) {
Log.infoFileSync("getS:" + getS);
Double allMoney = 0.0;
String allReturn = "";
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
try {
Integer supplierId = Integer.valueOf(getS);
depotHeadService.findAllMoney(pageUtil, supplierId, type, subType, mode);
allReturn = pageUtil.getPageList().toString();
allReturn = allReturn.substring(1,allReturn.length()-1);
if(allReturn.equals("null")){
allReturn = "0";
}
} catch (JshException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
allMoney = Double.parseDouble(allReturn);
//返回正数,如果负数也转为正数
if(allMoney<0){
allMoney = -allMoney;
}
return allMoney;
}
/**
* 拼接搜索条件
* @return
@@ -362,7 +434,6 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
@Override
public DepotHeadModel getModel()
{
return model;