Commit 1dc95653 authored by cjl's avatar cjl
Browse files

1、修改double类型为BigDecimal

2、修复sql中大于小于少&出错的问题
parents 6abe4bc8 4afc188b
package com.jsh.erp.datasource.vo; package com.jsh.erp.datasource.vo;
import java.math.BigDecimal;
public class DepotHeadVo4StatementAccount { public class DepotHeadVo4StatementAccount {
private String number; private String number;
private String type; private String type;
private Double discountLastMoney; private BigDecimal discountLastMoney;
private Double changeAmount; private BigDecimal changeAmount;
private Double allPrice; private BigDecimal allPrice;
private String supplierName; private String supplierName;
...@@ -33,27 +35,27 @@ public class DepotHeadVo4StatementAccount { ...@@ -33,27 +35,27 @@ public class DepotHeadVo4StatementAccount {
this.type = type; this.type = type;
} }
public Double getDiscountLastMoney() { public BigDecimal getDiscountLastMoney() {
return discountLastMoney; return discountLastMoney;
} }
public void setDiscountLastMoney(Double discountLastMoney) { public void setDiscountLastMoney(BigDecimal discountLastMoney) {
this.discountLastMoney = discountLastMoney; this.discountLastMoney = discountLastMoney;
} }
public Double getChangeAmount() { public BigDecimal getChangeAmount() {
return changeAmount; return changeAmount;
} }
public void setChangeAmount(Double changeAmount) { public void setChangeAmount(BigDecimal changeAmount) {
this.changeAmount = changeAmount; this.changeAmount = changeAmount;
} }
public Double getAllPrice() { public BigDecimal getAllPrice() {
return allPrice; return allPrice;
} }
public void setAllPrice(Double allPrice) { public void setAllPrice(BigDecimal allPrice) {
this.allPrice = allPrice; this.allPrice = allPrice;
} }
......
package com.jsh.erp.service.account; package com.jsh.erp.service.account;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.AccountHeadMapper; import com.jsh.erp.datasource.mappers.AccountHeadMapper;
...@@ -19,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -19,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -56,13 +56,13 @@ public class AccountService { ...@@ -56,13 +56,13 @@ public class AccountService {
if (null != list && null !=timeStr) { if (null != list && null !=timeStr) {
for (AccountVo4List al : list) { for (AccountVo4List al : list) {
DecimalFormat df = new DecimalFormat(".##"); DecimalFormat df = new DecimalFormat(".##");
Double thisMonthAmount = getAccountSum(al.getId(), timeStr, "month") + getAccountSumByHead(al.getId(), timeStr, "month") + getAccountSumByDetail(al.getId(), timeStr, "month") + getManyAccountSum(al.getId(), timeStr, "month"); BigDecimal thisMonthAmount = getAccountSum(al.getId(), timeStr, "month").add(getAccountSumByHead(al.getId(), timeStr, "month")).add(getAccountSumByDetail(al.getId(), timeStr, "month")).add(getManyAccountSum(al.getId(), timeStr, "month"));
String thisMonthAmountFmt = "0"; String thisMonthAmountFmt = "0";
if (thisMonthAmount != 0) { if ((thisMonthAmount.compareTo(BigDecimal.ZERO))!=0) {
thisMonthAmountFmt = df.format(thisMonthAmount); thisMonthAmountFmt = df.format(thisMonthAmount);
} }
al.setThismonthamount(thisMonthAmountFmt); //本月发生额 al.setThismonthamount(thisMonthAmountFmt); //本月发生额
Double currentAmount = getAccountSum(al.getId(), "", "month") + getAccountSumByHead(al.getId(), "", "month") + getAccountSumByDetail(al.getId(), "", "month") + getManyAccountSum(al.getId(), "", "month") + al.getInitialamount(); BigDecimal currentAmount = getAccountSum(al.getId(), "", "month").add(getAccountSumByHead(al.getId(), "", "month")).add(getAccountSumByDetail(al.getId(), "", "month")).add(getManyAccountSum(al.getId(), "", "month")) .add(al.getInitialamount()) ;
al.setCurrentamount(currentAmount); al.setCurrentamount(currentAmount);
resList.add(al); resList.add(al);
} }
...@@ -78,7 +78,7 @@ public class AccountService { ...@@ -78,7 +78,7 @@ public class AccountService {
public int insertAccount(String beanJson, HttpServletRequest request) { public int insertAccount(String beanJson, HttpServletRequest request) {
Account account = JSONObject.parseObject(beanJson, Account.class); Account account = JSONObject.parseObject(beanJson, Account.class);
if(account.getInitialamount() == null) { if(account.getInitialamount() == null) {
account.setInitialamount(0d); account.setInitialamount(BigDecimal.ZERO);
} }
account.setIsdefault(false); account.setIsdefault(false);
return accountMapper.insertSelective(account); return accountMapper.insertSelective(account);
...@@ -123,8 +123,8 @@ public class AccountService { ...@@ -123,8 +123,8 @@ public class AccountService {
* @param id * @param id
* @return * @return
*/ */
public Double getAccountSum(Long id, String timeStr, String type) { public BigDecimal getAccountSum(Long id, String timeStr, String type) {
Double accountSum = 0.0; BigDecimal accountSum = BigDecimal.ZERO;
try { try {
DepotHeadExample example = new DepotHeadExample(); DepotHeadExample example = new DepotHeadExample();
if (!timeStr.equals("")) { if (!timeStr.equals("")) {
...@@ -145,7 +145,7 @@ public class AccountService { ...@@ -145,7 +145,7 @@ public class AccountService {
if (dataList != null) { if (dataList != null) {
for (DepotHead depotHead : dataList) { for (DepotHead depotHead : dataList) {
if(depotHead.getChangeamount()!=null) { if(depotHead.getChangeamount()!=null) {
accountSum = accountSum + depotHead.getChangeamount(); accountSum = accountSum .add(depotHead.getChangeamount()) ;
} }
} }
} }
...@@ -161,8 +161,8 @@ public class AccountService { ...@@ -161,8 +161,8 @@ public class AccountService {
* @param id * @param id
* @return * @return
*/ */
public Double getAccountSumByHead(Long id, String timeStr, String type) { public BigDecimal getAccountSumByHead(Long id, String timeStr, String type) {
Double accountSum = 0.0; BigDecimal accountSum = BigDecimal.ZERO;
try { try {
AccountHeadExample example = new AccountHeadExample(); AccountHeadExample example = new AccountHeadExample();
if (!timeStr.equals("")) { if (!timeStr.equals("")) {
...@@ -183,7 +183,7 @@ public class AccountService { ...@@ -183,7 +183,7 @@ public class AccountService {
if (dataList != null) { if (dataList != null) {
for (AccountHead accountHead : dataList) { for (AccountHead accountHead : dataList) {
if(accountHead.getChangeamount()!=null) { if(accountHead.getChangeamount()!=null) {
accountSum = accountSum + accountHead.getChangeamount(); accountSum = accountSum.add(accountHead.getChangeamount());
} }
} }
} }
...@@ -199,8 +199,8 @@ public class AccountService { ...@@ -199,8 +199,8 @@ public class AccountService {
* @param id * @param id
* @return * @return
*/ */
public Double getAccountSumByDetail(Long id, String timeStr, String type) { public BigDecimal getAccountSumByDetail(Long id, String timeStr, String type) {
Double accountSum = 0.0; BigDecimal accountSum =BigDecimal.ZERO ;
try { try {
AccountHeadExample example = new AccountHeadExample(); AccountHeadExample example = new AccountHeadExample();
if (!timeStr.equals("")) { if (!timeStr.equals("")) {
...@@ -234,7 +234,7 @@ public class AccountService { ...@@ -234,7 +234,7 @@ public class AccountService {
if (dataListOne != null) { if (dataListOne != null) {
for (AccountItem accountItem : dataListOne) { for (AccountItem accountItem : dataListOne) {
if(accountItem.getEachamount()!=null) { if(accountItem.getEachamount()!=null) {
accountSum = accountSum + accountItem.getEachamount(); accountSum = accountSum.add(accountItem.getEachamount());
} }
} }
} }
...@@ -253,8 +253,8 @@ public class AccountService { ...@@ -253,8 +253,8 @@ public class AccountService {
* @param id * @param id
* @return * @return
*/ */
public Double getManyAccountSum(Long id, String timeStr, String type) { public BigDecimal getManyAccountSum(Long id, String timeStr, String type) {
Double accountSum = 0.0; BigDecimal accountSum = BigDecimal.ZERO;
try { try {
DepotHeadExample example = new DepotHeadExample(); DepotHeadExample example = new DepotHeadExample();
if (!timeStr.equals("")) { if (!timeStr.equals("")) {
...@@ -282,7 +282,7 @@ public class AccountService { ...@@ -282,7 +282,7 @@ public class AccountService {
String[] amList = accountMoneyList.split(","); String[] amList = accountMoneyList.split(",");
for (int i = 0; i < aList.length; i++) { for (int i = 0; i < aList.length; i++) {
if (aList[i].toString().equals(id.toString())) { if (aList[i].toString().equals(id.toString())) {
accountSum = accountSum + Double.parseDouble(amList[i].toString()); accountSum = accountSum .add(new BigDecimal(amList[i]));
} }
} }
} }
......
...@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -39,10 +40,10 @@ public class AccountHeadService { ...@@ -39,10 +40,10 @@ public class AccountHeadService {
if (null != list) { if (null != list) {
for (AccountHeadVo4ListEx ah : list) { for (AccountHeadVo4ListEx ah : list) {
if(ah.getChangeamount() != null) { if(ah.getChangeamount() != null) {
ah.setChangeamount(Math.abs(ah.getChangeamount())); ah.setChangeamount(ah.getChangeamount().abs());
} }
if(ah.getTotalprice() != null) { if(ah.getTotalprice() != null) {
ah.setTotalprice(Math.abs(ah.getTotalprice())); ah.setTotalprice(ah.getTotalprice().abs());
} }
resList.add(ah); resList.add(ah);
} }
...@@ -91,7 +92,7 @@ public class AccountHeadService { ...@@ -91,7 +92,7 @@ public class AccountHeadService {
return accountHeadMapper.getMaxId(); return accountHeadMapper.getMaxId();
} }
public Double findAllMoney(Integer supplierId, String type, String mode, String endTime) { public BigDecimal findAllMoney(Integer supplierId, String type, String mode, String endTime) {
String modeName = ""; String modeName = "";
if (mode.equals("实际")) { if (mode.equals("实际")) {
modeName = "ChangeAmount"; modeName = "ChangeAmount";
...@@ -107,10 +108,10 @@ public class AccountHeadService { ...@@ -107,10 +108,10 @@ public class AccountHeadService {
if (null != list) { if (null != list) {
for (AccountHeadVo4ListEx ah : list) { for (AccountHeadVo4ListEx ah : list) {
if(ah.getChangeamount() != null) { if(ah.getChangeamount() != null) {
ah.setChangeamount(Math.abs(ah.getChangeamount())); ah.setChangeamount(ah.getChangeamount().abs());
} }
if(ah.getTotalprice() != null) { if(ah.getTotalprice() != null) {
ah.setTotalprice(Math.abs(ah.getTotalprice())); ah.setTotalprice(ah.getTotalprice().abs());
} }
resList.add(ah); resList.add(ah);
} }
......
...@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson; import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
...@@ -108,13 +109,13 @@ public class AccountItemService { ...@@ -108,13 +109,13 @@ public class AccountItemService {
accountItem.setInoutitemid(tempInsertedJson.getLong("InOutItemId")); accountItem.setInoutitemid(tempInsertedJson.getLong("InOutItemId"));
} }
if (tempInsertedJson.get("EachAmount") != null && !tempInsertedJson.get("EachAmount").equals("")) { if (tempInsertedJson.get("EachAmount") != null && !tempInsertedJson.get("EachAmount").equals("")) {
Double eachAmount = tempInsertedJson.getDouble("EachAmount"); BigDecimal eachAmount = tempInsertedJson.getBigDecimal("EachAmount");
if (listType.equals("付款")) { if (listType.equals("付款")) {
eachAmount = 0 - eachAmount; eachAmount = BigDecimal.ZERO.subtract(eachAmount);
} }
accountItem.setEachamount(eachAmount); accountItem.setEachamount(eachAmount);
} else { } else {
accountItem.setEachamount(0.0); accountItem.setEachamount(BigDecimal.ZERO);
} }
accountItem.setRemark(tempInsertedJson.getString("Remark")); accountItem.setRemark(tempInsertedJson.getString("Remark"));
this.insertAccountItemWithObj(accountItem); this.insertAccountItemWithObj(accountItem);
...@@ -139,13 +140,13 @@ public class AccountItemService { ...@@ -139,13 +140,13 @@ public class AccountItemService {
accountItem.setInoutitemid(tempUpdatedJson.getLong("InOutItemId")); accountItem.setInoutitemid(tempUpdatedJson.getLong("InOutItemId"));
} }
if (tempUpdatedJson.get("EachAmount") != null && !tempUpdatedJson.get("EachAmount").equals("")) { if (tempUpdatedJson.get("EachAmount") != null && !tempUpdatedJson.get("EachAmount").equals("")) {
Double eachAmount = tempUpdatedJson.getDouble("EachAmount"); BigDecimal eachAmount = tempUpdatedJson.getBigDecimal("EachAmount");
if (listType.equals("付款")) { if (listType.equals("付款")) {
eachAmount = 0 - eachAmount; eachAmount = BigDecimal.ZERO.subtract(eachAmount);
} }
accountItem.setEachamount(eachAmount); accountItem.setEachamount(eachAmount);
} else { } else {
accountItem.setEachamount(0.0); accountItem.setEachamount(BigDecimal.ZERO);
} }
accountItem.setRemark(tempUpdatedJson.getString("Remark")); accountItem.setRemark(tempUpdatedJson.getString("Remark"));
this.updateAccountItemWithObj(accountItem); this.updateAccountItemWithObj(accountItem);
......
...@@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -54,10 +55,10 @@ public class DepotHeadService { ...@@ -54,10 +55,10 @@ public class DepotHeadService {
dh.setOthermoneyitem(otherMoneyItemStr); dh.setOthermoneyitem(otherMoneyItemStr);
} }
if(dh.getChangeamount() != null) { if(dh.getChangeamount() != null) {
dh.setChangeamount(Math.abs(dh.getChangeamount())); dh.setChangeamount(dh.getChangeamount().abs());
} }
if(dh.getTotalprice() != null) { if(dh.getTotalprice() != null) {
dh.setTotalprice(Math.abs(dh.getTotalprice())); dh.setTotalprice(dh.getTotalprice().abs());
} }
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId())); dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
resList.add(dh); resList.add(dh);
...@@ -213,7 +214,7 @@ public class DepotHeadService { ...@@ -213,7 +214,7 @@ public class DepotHeadService {
return depotHeadMapper.findStatementAccountCount(beginTime, endTime, organId, supType); return depotHeadMapper.findStatementAccountCount(beginTime, endTime, organId, supType);
} }
public Double findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime) { public BigDecimal findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime) {
String modeName = ""; String modeName = "";
if (mode.equals("实际")) { if (mode.equals("实际")) {
modeName = "ChangeAmount"; modeName = "ChangeAmount";
...@@ -237,10 +238,10 @@ public class DepotHeadService { ...@@ -237,10 +238,10 @@ public class DepotHeadService {
dh.setOthermoneyitem(otherMoneyItemStr); dh.setOthermoneyitem(otherMoneyItemStr);
} }
if(dh.getChangeamount() != null) { if(dh.getChangeamount() != null) {
dh.setChangeamount(Math.abs(dh.getChangeamount())); dh.setChangeamount(dh.getChangeamount().abs());
} }
if(dh.getTotalprice() != null) { if(dh.getTotalprice() != null) {
dh.setTotalprice(Math.abs(dh.getTotalprice())); dh.setTotalprice(dh.getTotalprice().abs());
} }
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId())); dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
resList.add(dh); resList.add(dh);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<result column="Number" jdbcType="VARCHAR" property="number" /> <result column="Number" jdbcType="VARCHAR" property="number" />
<result column="newType" jdbcType="VARCHAR" property="type" /> <result column="newType" jdbcType="VARCHAR" property="type" />
<result column="supplier" jdbcType="VARCHAR" property="supplierName" /> <result column="supplier" jdbcType="VARCHAR" property="supplierName" />
<result column="ChangeAmount" jdbcType="DOUBLE" property="changeAmount" /> <result column="ChangeAmount" jdbcType="DECIMAL" property="changeAmount" />
<result column="oTime" jdbcType="VARCHAR" property="operTime" /> <result column="oTime" jdbcType="VARCHAR" property="operTime" />
<result column="AList" jdbcType="VARCHAR" property="aList" /> <result column="AList" jdbcType="VARCHAR" property="aList" />
<result column="AMList" jdbcType="VARCHAR" property="amList" /> <result column="AMList" jdbcType="VARCHAR" property="amList" />
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment