diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/AccountHeadController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/AccountHeadController.java index 5c2d97b1..a1023eca 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/AccountHeadController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/AccountHeadController.java @@ -60,37 +60,6 @@ public class AccountHeadController { return result; } - /** - * 查询单位的累计应收和累计应付,收预付款不计入此处 - * @param supplierId - * @param endTime - * @param supType - * @param request - * @return - */ - @GetMapping(value = "/findTotalPay") - public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId, - @RequestParam("endTime") String endTime, - @RequestParam("supType") String supType, - HttpServletRequest request)throws Exception { - BaseResponseInfo res = new BaseResponseInfo(); - Map map = new HashMap(); - try { - JSONObject outer = new JSONObject(); - endTime = endTime + BusinessConstants.DAY_LAST_TIME; - BigDecimal sum = accountHeadService.findTotalPay(supplierId, endTime, supType); - outer.put("getAllMoney", sum); - map.put("rows", outer); - res.code = 200; - res.data = map; - } catch (Exception e) { - e.printStackTrace(); - res.code = 500; - res.data = "获取数据失败"; - } - return res; - } - /** * 根据编号查询单据信息 * @param billNo diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java index 5b93f0b8..eaf66e81 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java @@ -6,14 +6,17 @@ import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.datasource.entities.DepotHead; import com.jsh.erp.datasource.entities.DepotHeadVo4Body; +import com.jsh.erp.datasource.entities.Supplier; import com.jsh.erp.datasource.vo.DepotHeadVo4InDetail; 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.BusinessParamCheckingException; +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.redis.RedisService; +import com.jsh.erp.service.supplier.SupplierService; import com.jsh.erp.utils.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,6 +47,12 @@ public class DepotHeadController { @Resource private DepotHeadService depotHeadService; + @Resource + private AccountHeadService accountHeadService; + + @Resource + private SupplierService supplierService; + @Resource private RedisService redisService; @@ -187,69 +196,27 @@ public class DepotHeadController { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { - int j = 1; - if (supType.equals("客户")) { //客户 - j = 1; - } else if (supType.equals("供应商")) { //供应商 - j = -1; - } beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME); endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME); - List resList = new ArrayList(); List list = depotHeadService.findStatementAccount(beginTime, endTime, organId, supType, (currentPage-1)*pageSize, pageSize); int total = depotHeadService.findStatementAccountCount(beginTime, endTime, organId, supType); + map.put("rows", list); map.put("total", total); - //存放数据json数组 - 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 = p2.subtract(p1); - } else if (type.equals("销售出库")) { - allPrice = p1.subtract(p2); - } else if (type.equals("采购退货出库")) { - allPrice = p1.subtract(p2); - } else if (type.equals("收款")) { - allPrice = BigDecimal.ZERO.subtract(p1); - } else if (type.equals("付款")) { - allPrice = p1; - } else if (type.equals("收入")) { - allPrice = p1.subtract(p2); - } else if (type.equals("支出")) { - allPrice = p2.subtract(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()); //单据日期 - resList.add(dha); + if(null!=organId) { + Supplier supplier = supplierService.getSupplier(organId); + BigDecimal beginNeed = BigDecimal.ZERO; + if (("客户").equals(supType)) { + beginNeed = supplier.getBeginNeedGet(); + } else if (("供应商").equals(supType)) { + beginNeed = supplier.getBeginNeedPay(); } + BigDecimal firstMoney = depotHeadService.findTotalPay(organId, beginTime, supType) + .add(accountHeadService.findTotalPay(organId, beginTime, supType)).add(beginNeed); + BigDecimal lastMoney = depotHeadService.findTotalPay(organId, endTime, supType) + .add(accountHeadService.findTotalPay(organId, endTime, supType)).add(beginNeed); + map.put("firstMoney", firstMoney); //期初 + map.put("lastMoney", lastMoney); //期末 } - map.put("rows", resList); res.code = 200; res.data = map; } catch(Exception e){ @@ -260,37 +227,6 @@ public class DepotHeadController { return res; } - /** - * 查询单位的累计应收和累计应付,零售不能计入 - * @param supplierId - * @param endTime - * @param supType - * @param request - * @return - */ - @GetMapping(value = "/findTotalPay") - public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId, - @RequestParam("endTime") String endTime, - @RequestParam("supType") String supType, - HttpServletRequest request)throws Exception { - BaseResponseInfo res = new BaseResponseInfo(); - Map map = new HashMap(); - try { - JSONObject outer = new JSONObject(); - endTime = endTime + BusinessConstants.DAY_LAST_TIME; - BigDecimal sum = depotHeadService.findTotalPay(supplierId, endTime, supType); - outer.put("getAllMoney", sum); - map.put("rows", outer); - res.code = 200; - res.data = map; - } catch (Exception e) { - e.printStackTrace(); - res.code = 500; - res.data = "获取数据失败"; - } - return res; - } - /** * 根据编号查询单据信息 * @param number diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/SupplierController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/SupplierController.java index 598dba7b..65e95216 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/SupplierController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/SupplierController.java @@ -165,60 +165,6 @@ public class SupplierController { return arr; } - /** - * 根据id查找信息 - * @param supplierId - * @param request - * @return - */ - @GetMapping(value = "/findById") - public BaseResponseInfo findById(@RequestParam("supplierId") Long supplierId, - HttpServletRequest request)throws Exception { - BaseResponseInfo res = new BaseResponseInfo(); - try { - JSONArray dataArray = new JSONArray(); - List dataList = supplierService.findById(supplierId); - if (null != dataList) { - for (Supplier supplier : dataList) { - JSONObject item = new JSONObject(); - item.put("id", supplier.getId()); - //名称 - item.put("supplier", supplier.getSupplier()); - item.put("type", supplier.getType()); - item.put("contacts", supplier.getContacts()); - item.put("phonenum", supplier.getPhoneNum()); - item.put("email", supplier.getEmail()); - item.put("AdvanceIn", supplier.getAdvanceIn()); - item.put("BeginNeedGet", supplier.getBeginNeedGet()); - item.put("BeginNeedPay", supplier.getBeginNeedPay()); - /** - * 2018-01-28这里会有空指针异常 - * */ - if(supplier.getIsystem()!=null){ - item.put("isystem", supplier.getIsystem() == (short) 0 ? "是" : "否"); - } - item.put("description", supplier.getDescription()); - item.put("fax", supplier.getFax()); - item.put("telephone", supplier.getTelephone()); - item.put("address", supplier.getAddress()); - item.put("taxNum", supplier.getTaxNum()); - item.put("bankName", supplier.getBankName()); - item.put("accountNumber", supplier.getAccountNumber()); - item.put("taxRate", supplier.getTaxRate()); - item.put("enabled", supplier.getEnabled()); - dataArray.add(item); - } - res.code = 200; - res.data = dataArray; - } - } catch (Exception e) { - e.printStackTrace(); - res.code = 500; - res.data = "获取数据失败"; - } - return res; - } - /** * 批量设置状态-启用或者禁用 * @param jsonObject diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java index f8fcb2d1..d7f06713 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java @@ -99,7 +99,9 @@ public class AccountHeadService { if(ah.getTotalPrice() != null) { ah.setTotalPrice(ah.getTotalPrice().abs()); } - ah.setBillTimeStr(getCenternTime(ah.getBillTime())); + if(ah.getBillTime() !=null) { + ah.setBillTimeStr(getCenternTime(ah.getBillTime())); + } resList.add(ah); } } @@ -308,9 +310,9 @@ public class AccountHeadService { BigDecimal sum = BigDecimal.ZERO; String getS = supplierId.toString(); int i = 1; - if (("customer").equals(supType)) { //客户 + if (("客户").equals(supType)) { //客户 i = 1; - } else if (("vendor").equals(supType)) { //供应商 + } else if (("供应商").equals(supType)) { //供应商 i = -1; } //收付款部分 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java index 2debf9b8..befd4280 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java @@ -40,6 +40,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.sql.Timestamp; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -422,8 +423,62 @@ public class DepotHeadService { public List findStatementAccount(String beginTime, String endTime, Integer organId, String supType, Integer offset, Integer rows)throws Exception { List 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); - }catch(Exception e){ + 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 = p2.subtract(p1); + } else if (type.equals("销售出库")) { + allPrice = p1.subtract(p2); + } else if (type.equals("采购退货出库")) { + allPrice = p1.subtract(p2); + } else if (type.equals("收款")) { + allPrice = BigDecimal.ZERO.subtract(p1); + } else if (type.equals("付款")) { + allPrice = p1; + } else if (type.equals("收入")) { + allPrice = p1.subtract(p2); + } else if (type.equals("支出")) { + allPrice = p2.subtract(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()); //单据日期 + } + } + } catch(Exception e){ JshException.readFail(logger, e); } return list; @@ -497,9 +552,9 @@ public class DepotHeadService { BigDecimal sum = BigDecimal.ZERO; String getS = supplierId.toString(); int i = 1; - if (("customer").equals(supType)) { //客户 + if (("客户").equals(supType)) { //客户 i = 1; - } else if (("vendor").equals(supType)) { //供应商 + } else if (("供应商").equals(supType)) { //供应商 i = -1; } //进销部分 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java index 9784b8cf..63f9c79f 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java @@ -462,7 +462,9 @@ public class MaterialService { m.setModel(model); m.setColor(color); Long categoryId = materialCategoryService.getCategoryIdByName(categoryName); - m.setCategoryId(categoryId); + if(null!=categoryId){ + m.setCategoryId(categoryId); + } m.setSafetyStock(parseBigDecimalEx(safetyStock)); String manyUnit = ExcelUtils.getContent(src, i, 7); //副单位 String barCode = ExcelUtils.getContent(src, i, 8); //基础条码 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java index 570c297a..24917428 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java @@ -362,7 +362,7 @@ public class MaterialCategoryService { * @param name */ public Long getCategoryIdByName(String name){ - Long categoryId = 0L; + Long categoryId = null; MaterialCategoryExample example = new MaterialCategoryExample(); example.createCriteria().andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); List list = materialCategoryMapper.selectByExample(example); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/supplier/SupplierService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/supplier/SupplierService.java index aff8681d..16343dd6 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/supplier/SupplierService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/supplier/SupplierService.java @@ -95,12 +95,7 @@ public class SupplierService { 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"; - } + String supType = s.getType(); BigDecimal sum = BigDecimal.ZERO; BigDecimal beginNeedGet = s.getBeginNeedGet(); if(beginNeedGet==null) {