From 0d1deaa197f4ea7ac4b4b44ddacd9ad364018a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sun, 16 Jun 2019 22:04:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E4=BE=9B=E5=BA=94=E5=95=86=E5=92=8C?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=88=97=E8=A1=A8=E5=A2=9E=E5=8A=A0=E6=9C=9F?= =?UTF-8?q?=E6=9C=AB=E5=BA=94=E6=94=B6=E5=92=8C=E6=9C=9F=E6=9C=AB=E5=BA=94?= =?UTF-8?q?=E4=BB=98=E7=9A=84=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/js/pages/manage/supplier.js | 2 + .../erp/controller/AccountHeadController.java | 39 +-------------- .../erp/controller/DepotHeadController.java | 40 +-------------- .../accountHead/AccountHeadService.java | 50 +++++++++++++++++++ .../service/depotHead/DepotHeadService.java | 50 +++++++++++++++++++ .../erp/service/supplier/SupplierService.java | 50 ++++++++++++++++--- 6 files changed, 147 insertions(+), 84 deletions(-) diff --git a/erp_web/js/pages/manage/supplier.js b/erp_web/js/pages/manage/supplier.js index 8ef1b329..e4812a17 100644 --- a/erp_web/js/pages/manage/supplier.js +++ b/erp_web/js/pages/manage/supplier.js @@ -76,6 +76,8 @@ { title: '预付款',field: 'advancein',width:70,align:"center"}, { title: '期初应收',field: 'beginneedget',width:70,align:"center"}, { title: '期初应付',field: 'beginneedpay',width:70,align:"center"}, + { title: '期末应收',field: 'allneedget',width:70,align:"center"}, + { title: '期末应付',field: 'allneedpay',width:70,align:"center"}, { title: '税率(%)', field: 'taxrate',width:50,align:"center"}, { title: '状态',field: 'enabled',width:70,align:"center",formatter:function(value){ return value? "启用":"禁用"; diff --git a/src/main/java/com/jsh/erp/controller/AccountHeadController.java b/src/main/java/com/jsh/erp/controller/AccountHeadController.java index ae350955..e82ad8c1 100644 --- a/src/main/java/com/jsh/erp/controller/AccountHeadController.java +++ b/src/main/java/com/jsh/erp/controller/AccountHeadController.java @@ -73,19 +73,7 @@ public class AccountHeadController { Map map = new HashMap(); try { JSONObject outer = new JSONObject(); - BigDecimal sum = BigDecimal.ZERO; - String getS = supplierId.toString(); - int i = 1; - if (supType.equals("customer")) { //客户 - i = 1; - } else if (supType.equals("vendor")) { //供应商 - i = -1; - } - //收付款部分 - sum = sum.add((allMoney(getS, "付款", "合计",endTime).add(allMoney(getS, "付款", "实际",endTime))).multiply(new BigDecimal(i))); - sum = sum.subtract((allMoney(getS, "收款", "合计",endTime).add(allMoney(getS, "收款", "实际",endTime))).multiply(new BigDecimal(i))); - sum = sum.add((allMoney(getS, "收入", "合计",endTime).subtract(allMoney(getS, "收入", "实际",endTime))).multiply(new BigDecimal(i))); - sum = sum.subtract((allMoney(getS, "支出", "合计",endTime).subtract(allMoney(getS, "支出", "实际",endTime))).multiply(new BigDecimal(i))); + BigDecimal sum = accountHeadService.findTotalPay(supplierId, endTime, supType); outer.put("getAllMoney", sum); map.put("rows", outer); res.code = 200; @@ -124,31 +112,6 @@ public class AccountHeadController { return res; } - /** - * 统计总金额 - * @param getS - * @param type - * @param mode 合计或者金额 - * @param endTime - * @return - */ - public BigDecimal allMoney(String getS, String type, String mode, String endTime)throws Exception { - BigDecimal allMoney = BigDecimal.ZERO; - try { - Integer supplierId = Integer.valueOf(getS); - BigDecimal sum = accountHeadService.findAllMoney(supplierId, type, mode, endTime); - if(sum != null) { - allMoney = sum; - } - } catch (Exception e) { - e.printStackTrace(); - } - //返回正数,如果负数也转为正数 - if ((allMoney.compareTo(BigDecimal.ZERO))==-1) { - allMoney = allMoney.abs(); - } - return allMoney; - } /** * create by: qiankunpingtai * website:https://qiankunpingtai.cn diff --git a/src/main/java/com/jsh/erp/controller/DepotHeadController.java b/src/main/java/com/jsh/erp/controller/DepotHeadController.java index 2e497446..34156a14 100644 --- a/src/main/java/com/jsh/erp/controller/DepotHeadController.java +++ b/src/main/java/com/jsh/erp/controller/DepotHeadController.java @@ -343,19 +343,7 @@ public class DepotHeadController { Map map = new HashMap(); try { JSONObject outer = new JSONObject(); - BigDecimal sum = BigDecimal.ZERO; - String getS = supplierId.toString(); - int i = 1; - if (supType.equals("customer")) { //客户 - i = 1; - } else if (supType.equals("vendor")) { //供应商 - i = -1; - } - //进销部分 - sum = sum.subtract((allMoney(getS, "入库", "采购", "合计",endTime).subtract(allMoney(getS, "入库", "采购", "实际",endTime))).multiply(new BigDecimal(i))); - sum = sum.subtract((allMoney(getS, "入库", "销售退货", "合计",endTime).subtract(allMoney(getS, "入库", "销售退货", "实际",endTime))).multiply(new BigDecimal(i))); - sum = sum.add((allMoney(getS, "出库", "销售", "合计",endTime).subtract(allMoney(getS, "出库", "销售", "实际",endTime))).multiply(new BigDecimal(i))); - sum = sum.add((allMoney(getS, "出库", "采购退货", "合计",endTime).subtract(allMoney(getS, "出库", "采购退货", "实际",endTime))).multiply(new BigDecimal(i))); + BigDecimal sum = depotHeadService.findTotalPay(supplierId, endTime, supType); outer.put("getAllMoney", sum); map.put("rows", outer); res.code = 200; @@ -394,32 +382,6 @@ public class DepotHeadController { return res; } - - /** - * 统计总金额 - * @param getS - * @param type - * @param subType - * @param mode 合计或者金额 - * @return - */ - public BigDecimal allMoney(String getS, String type, String subType, String mode, String endTime)throws Exception { - BigDecimal allMoney = BigDecimal.ZERO; - try { - Integer supplierId = Integer.valueOf(getS); - BigDecimal sum = depotHeadService.findAllMoney(supplierId, type, subType, mode, endTime); - if(sum != null) { - allMoney = sum; - } - } catch (Exception e) { - e.printStackTrace(); - } - //返回正数,如果负数也转为正数 - if ((allMoney.compareTo(BigDecimal.ZERO))==-1) { - allMoney = allMoney.abs(); - } - return allMoney; - } /** * create by: cjl * description: diff --git a/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java b/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java index 45cd02a7..77b529a1 100644 --- a/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java +++ b/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java @@ -216,6 +216,56 @@ public class AccountHeadService { return result; } + /** + * 统计总金额 + * @param getS + * @param type + * @param mode 合计或者金额 + * @param endTime + * @return + */ + public BigDecimal allMoney(String getS, String type, String mode, String endTime) { + BigDecimal allMoney = BigDecimal.ZERO; + try { + Integer supplierId = Integer.valueOf(getS); + BigDecimal sum = findAllMoney(supplierId, type, mode, endTime); + if(sum != null) { + allMoney = sum; + } + } catch (Exception e) { + e.printStackTrace(); + } + //返回正数,如果负数也转为正数 + if ((allMoney.compareTo(BigDecimal.ZERO))==-1) { + allMoney = allMoney.abs(); + } + return allMoney; + } + + /** + * 查询单位的累计应收和累计应付,收预付款不计入此处 + * @param supplierId + * @param endTime + * @param supType + * @return + */ + public BigDecimal findTotalPay(Integer supplierId, String endTime, String supType) { + BigDecimal sum = BigDecimal.ZERO; + String getS = supplierId.toString(); + int i = 1; + if (("customer").equals(supType)) { //客户 + i = 1; + } else if (("vendor").equals(supType)) { //供应商 + i = -1; + } + //收付款部分 + sum = sum.add((allMoney(getS, "付款", "合计",endTime).add(allMoney(getS, "付款", "实际",endTime))).multiply(new BigDecimal(i))); + sum = sum.subtract((allMoney(getS, "收款", "合计",endTime).add(allMoney(getS, "收款", "实际",endTime))).multiply(new BigDecimal(i))); + sum = sum.add((allMoney(getS, "收入", "合计",endTime).subtract(allMoney(getS, "收入", "实际",endTime))).multiply(new BigDecimal(i))); + sum = sum.subtract((allMoney(getS, "支出", "合计",endTime).subtract(allMoney(getS, "支出", "实际",endTime))).multiply(new BigDecimal(i))); + return sum; + } + public List getDetailByNumber(String billNo)throws Exception { List resList = new ArrayList(); List list = null; diff --git a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java index d9bf7380..1167252b 100644 --- a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java +++ b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java @@ -446,6 +446,56 @@ public class DepotHeadService { return result; } + /** + * 统计总金额 + * @param getS + * @param type + * @param subType + * @param mode 合计或者金额 + * @return + */ + public BigDecimal allMoney(String getS, String type, String subType, String mode, String endTime) { + BigDecimal allMoney = BigDecimal.ZERO; + try { + Integer supplierId = Integer.valueOf(getS); + BigDecimal sum = findAllMoney(supplierId, type, subType, mode, endTime); + if(sum != null) { + allMoney = sum; + } + } catch (Exception e) { + e.printStackTrace(); + } + //返回正数,如果负数也转为正数 + if ((allMoney.compareTo(BigDecimal.ZERO))==-1) { + allMoney = allMoney.abs(); + } + return allMoney; + } + + /** + * 查询单位的累计应收和累计应付,零售不能计入 + * @param supplierId + * @param endTime + * @param supType + * @return + */ + public BigDecimal findTotalPay(Integer supplierId, String endTime, String supType) { + BigDecimal sum = BigDecimal.ZERO; + String getS = supplierId.toString(); + int i = 1; + if (("customer").equals(supType)) { //客户 + i = 1; + } else if (("vendor").equals(supType)) { //供应商 + i = -1; + } + //进销部分 + sum = sum.subtract((allMoney(getS, "入库", "采购", "合计",endTime).subtract(allMoney(getS, "入库", "采购", "实际",endTime))).multiply(new BigDecimal(i))); + sum = sum.subtract((allMoney(getS, "入库", "销售退货", "合计",endTime).subtract(allMoney(getS, "入库", "销售退货", "实际",endTime))).multiply(new BigDecimal(i))); + sum = sum.add((allMoney(getS, "出库", "销售", "合计",endTime).subtract(allMoney(getS, "出库", "销售", "实际",endTime))).multiply(new BigDecimal(i))); + sum = sum.add((allMoney(getS, "出库", "采购退货", "合计",endTime).subtract(allMoney(getS, "出库", "采购退货", "实际",endTime))).multiply(new BigDecimal(i))); + return sum; + } + public List getDetailByNumber(String number)throws Exception { List resList = new ArrayList(); List list = null; diff --git a/src/main/java/com/jsh/erp/service/supplier/SupplierService.java b/src/main/java/com/jsh/erp/service/supplier/SupplierService.java index ae2695d2..93ce849e 100644 --- a/src/main/java/com/jsh/erp/service/supplier/SupplierService.java +++ b/src/main/java/com/jsh/erp/service/supplier/SupplierService.java @@ -10,6 +10,8 @@ import com.jsh.erp.datasource.mappers.DepotHeadMapperEx; import com.jsh.erp.datasource.mappers.SupplierMapper; import com.jsh.erp.datasource.mappers.SupplierMapperEx; import com.jsh.erp.exception.BusinessRunTimeException; +import com.jsh.erp.service.accountHead.AccountHeadService; +import com.jsh.erp.service.depotHead.DepotHeadService; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.user.UserService; import com.jsh.erp.utils.BaseResponseInfo; @@ -24,10 +26,9 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; + +import static com.jsh.erp.utils.Tools.getNow3; @Service public class SupplierService { @@ -46,6 +47,10 @@ public class SupplierService { private AccountHeadMapperEx accountHeadMapperEx; @Resource private DepotHeadMapperEx depotHeadMapperEx; + @Resource + private DepotHeadService depotHeadService; + @Resource + private AccountHeadService accountHeadService; public Supplier getSupplier(long id)throws Exception { Supplier result=null; @@ -77,16 +82,47 @@ public class SupplierService { public List select(String supplier, String type, String phonenum, String telephone, String description, int offset, int rows) throws Exception{ - List list=null; + List resList = new ArrayList(); try{ - list=supplierMapperEx.selectByConditionSupplier(supplier, type, phonenum, telephone, description, offset, rows); + List list = supplierMapperEx.selectByConditionSupplier(supplier, type, phonenum, telephone, description, offset, rows); + for(Supplier s : list) { + Integer supplierId = s.getId().intValue(); + String endTime = getNow3(); + String supType = null; + if(("客户").equals(s.getType())) { + supType = "customer"; + } else if(("供应商").equals(s.getType())) { + supType = "vendor"; + } + BigDecimal sum = BigDecimal.ZERO; + BigDecimal beginNeedGet = s.getBeginneedget(); + if(beginNeedGet==null) { + beginNeedGet = BigDecimal.ZERO; + } + BigDecimal beginNeedPay = s.getBeginneedpay(); + if(beginNeedPay==null) { + beginNeedPay = BigDecimal.ZERO; + } + sum = sum.add(depotHeadService.findTotalPay(supplierId, endTime, supType)); + sum = sum.add(accountHeadService.findTotalPay(supplierId, endTime, supType)); + if(("客户").equals(s.getType())) { + sum = sum.add(beginNeedGet).subtract(beginNeedPay); + s.setAllneedget(sum); + s.setAllneedpay(BigDecimal.ZERO); + } else if(("供应商").equals(s.getType())) { + sum = sum.add(beginNeedPay).subtract(beginNeedGet); + s.setAllneedget(BigDecimal.ZERO); + s.setAllneedpay(sum); + } + resList.add(s); + } }catch(Exception e){ logger.error("异常码[{}],异常提示[{}],异常[{}]", ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, ExceptionConstants.DATA_READ_FAIL_MSG); } - return list; + return resList; } public Long countSupplier(String supplier, String type, String phonenum, String telephone, String description) throws Exception{