1、修改double类型为BigDecimal

2、修复sql中大于小于少&出错的问题
This commit is contained in:
cjl
2019-01-17 15:56:25 +08:00
61 changed files with 24893 additions and 24820 deletions

View File

@@ -1,6 +1,5 @@
package com.jsh.erp.service.account;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.AccountHeadMapper;
@@ -19,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -56,13 +56,13 @@ public class AccountService {
if (null != list && null !=timeStr) {
for (AccountVo4List al : list) {
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";
if (thisMonthAmount != 0) {
if ((thisMonthAmount.compareTo(BigDecimal.ZERO))!=0) {
thisMonthAmountFmt = df.format(thisMonthAmount);
}
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);
resList.add(al);
}
@@ -78,7 +78,7 @@ public class AccountService {
public int insertAccount(String beanJson, HttpServletRequest request) {
Account account = JSONObject.parseObject(beanJson, Account.class);
if(account.getInitialamount() == null) {
account.setInitialamount(0d);
account.setInitialamount(BigDecimal.ZERO);
}
account.setIsdefault(false);
return accountMapper.insertSelective(account);
@@ -123,8 +123,8 @@ public class AccountService {
* @param id
* @return
*/
public Double getAccountSum(Long id, String timeStr, String type) {
Double accountSum = 0.0;
public BigDecimal getAccountSum(Long id, String timeStr, String type) {
BigDecimal accountSum = BigDecimal.ZERO;
try {
DepotHeadExample example = new DepotHeadExample();
if (!timeStr.equals("")) {
@@ -145,7 +145,7 @@ public class AccountService {
if (dataList != null) {
for (DepotHead depotHead : dataList) {
if(depotHead.getChangeamount()!=null) {
accountSum = accountSum + depotHead.getChangeamount();
accountSum = accountSum .add(depotHead.getChangeamount()) ;
}
}
}
@@ -161,8 +161,8 @@ public class AccountService {
* @param id
* @return
*/
public Double getAccountSumByHead(Long id, String timeStr, String type) {
Double accountSum = 0.0;
public BigDecimal getAccountSumByHead(Long id, String timeStr, String type) {
BigDecimal accountSum = BigDecimal.ZERO;
try {
AccountHeadExample example = new AccountHeadExample();
if (!timeStr.equals("")) {
@@ -183,7 +183,7 @@ public class AccountService {
if (dataList != null) {
for (AccountHead accountHead : dataList) {
if(accountHead.getChangeamount()!=null) {
accountSum = accountSum + accountHead.getChangeamount();
accountSum = accountSum.add(accountHead.getChangeamount());
}
}
}
@@ -199,8 +199,8 @@ public class AccountService {
* @param id
* @return
*/
public Double getAccountSumByDetail(Long id, String timeStr, String type) {
Double accountSum = 0.0;
public BigDecimal getAccountSumByDetail(Long id, String timeStr, String type) {
BigDecimal accountSum =BigDecimal.ZERO ;
try {
AccountHeadExample example = new AccountHeadExample();
if (!timeStr.equals("")) {
@@ -234,7 +234,7 @@ public class AccountService {
if (dataListOne != null) {
for (AccountItem accountItem : dataListOne) {
if(accountItem.getEachamount()!=null) {
accountSum = accountSum + accountItem.getEachamount();
accountSum = accountSum.add(accountItem.getEachamount());
}
}
}
@@ -253,8 +253,8 @@ public class AccountService {
* @param id
* @return
*/
public Double getManyAccountSum(Long id, String timeStr, String type) {
Double accountSum = 0.0;
public BigDecimal getManyAccountSum(Long id, String timeStr, String type) {
BigDecimal accountSum = BigDecimal.ZERO;
try {
DepotHeadExample example = new DepotHeadExample();
if (!timeStr.equals("")) {
@@ -282,7 +282,7 @@ public class AccountService {
String[] amList = accountMoneyList.split(",");
for (int i = 0; i < aList.length; i++) {
if (aList[i].toString().equals(id.toString())) {
accountSum = accountSum + Double.parseDouble(amList[i].toString());
accountSum = accountSum .add(new BigDecimal(amList[i]));
}
}
}

View File

@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@@ -39,10 +40,10 @@ public class AccountHeadService {
if (null != list) {
for (AccountHeadVo4ListEx ah : list) {
if(ah.getChangeamount() != null) {
ah.setChangeamount(Math.abs(ah.getChangeamount()));
ah.setChangeamount(ah.getChangeamount().abs());
}
if(ah.getTotalprice() != null) {
ah.setTotalprice(Math.abs(ah.getTotalprice()));
ah.setTotalprice(ah.getTotalprice().abs());
}
resList.add(ah);
}
@@ -91,7 +92,7 @@ public class AccountHeadService {
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 = "";
if (mode.equals("实际")) {
modeName = "ChangeAmount";
@@ -107,10 +108,10 @@ public class AccountHeadService {
if (null != list) {
for (AccountHeadVo4ListEx ah : list) {
if(ah.getChangeamount() != null) {
ah.setChangeamount(Math.abs(ah.getChangeamount()));
ah.setChangeamount(ah.getChangeamount().abs());
}
if(ah.getTotalprice() != null) {
ah.setTotalprice(Math.abs(ah.getTotalprice()));
ah.setTotalprice(ah.getTotalprice().abs());
}
resList.add(ah);
}

View File

@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
@@ -108,13 +109,13 @@ public class AccountItemService {
accountItem.setInoutitemid(tempInsertedJson.getLong("InOutItemId"));
}
if (tempInsertedJson.get("EachAmount") != null && !tempInsertedJson.get("EachAmount").equals("")) {
Double eachAmount = tempInsertedJson.getDouble("EachAmount");
BigDecimal eachAmount = tempInsertedJson.getBigDecimal("EachAmount");
if (listType.equals("付款")) {
eachAmount = 0 - eachAmount;
eachAmount = BigDecimal.ZERO.subtract(eachAmount);
}
accountItem.setEachamount(eachAmount);
} else {
accountItem.setEachamount(0.0);
accountItem.setEachamount(BigDecimal.ZERO);
}
accountItem.setRemark(tempInsertedJson.getString("Remark"));
this.insertAccountItemWithObj(accountItem);
@@ -139,13 +140,13 @@ public class AccountItemService {
accountItem.setInoutitemid(tempUpdatedJson.getLong("InOutItemId"));
}
if (tempUpdatedJson.get("EachAmount") != null && !tempUpdatedJson.get("EachAmount").equals("")) {
Double eachAmount = tempUpdatedJson.getDouble("EachAmount");
BigDecimal eachAmount = tempUpdatedJson.getBigDecimal("EachAmount");
if (listType.equals("付款")) {
eachAmount = 0 - eachAmount;
eachAmount = BigDecimal.ZERO.subtract(eachAmount);
}
accountItem.setEachamount(eachAmount);
} else {
accountItem.setEachamount(0.0);
accountItem.setEachamount(BigDecimal.ZERO);
}
accountItem.setRemark(tempUpdatedJson.getString("Remark"));
this.updateAccountItemWithObj(accountItem);

View File

@@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
@@ -54,10 +55,10 @@ public class DepotHeadService {
dh.setOthermoneyitem(otherMoneyItemStr);
}
if(dh.getChangeamount() != null) {
dh.setChangeamount(Math.abs(dh.getChangeamount()));
dh.setChangeamount(dh.getChangeamount().abs());
}
if(dh.getTotalprice() != null) {
dh.setTotalprice(Math.abs(dh.getTotalprice()));
dh.setTotalprice(dh.getTotalprice().abs());
}
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
resList.add(dh);
@@ -213,7 +214,7 @@ public class DepotHeadService {
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 = "";
if (mode.equals("实际")) {
modeName = "ChangeAmount";
@@ -237,10 +238,10 @@ public class DepotHeadService {
dh.setOthermoneyitem(otherMoneyItemStr);
}
if(dh.getChangeamount() != null) {
dh.setChangeamount(Math.abs(dh.getChangeamount()));
dh.setChangeamount(dh.getChangeamount().abs());
}
if(dh.getTotalprice() != null) {
dh.setTotalprice(Math.abs(dh.getTotalprice()));
dh.setTotalprice(dh.getTotalprice().abs());
}
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
resList.add(dh);

View File

@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@@ -157,7 +158,7 @@ public class DepotItemService {
return depotItemMapper.findByAllCount(headIds, materialIds);
}
public Double findByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
public BigDecimal findByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
if (TYPE.equals(type)) {
if (isPrev) {
return depotItemMapper.findByTypeInIsPrev(ProjectId, MId, MonthTime);
@@ -173,7 +174,7 @@ public class DepotItemService {
}
}
public Double findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
public BigDecimal findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
if (TYPE.equals(type)) {
if (isPrev) {
return depotItemMapper.findPriceByTypeInIsPrev(ProjectId, MId, MonthTime);
@@ -189,7 +190,7 @@ public class DepotItemService {
}
}
public Double buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) {
public BigDecimal buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) {
if (SUM_TYPE.equals(sumType)) {
return depotItemMapper.buyOrSaleNumber(type, subType, MId, MonthTime, sumType);
} else {
@@ -197,7 +198,7 @@ public class DepotItemService {
}
}
public Double findGiftByType(String subType, Integer ProjectId, Long MId, String type) {
public BigDecimal findGiftByType(String subType, Integer ProjectId, Long MId, String type) {
if (IN.equals(type)) {
return depotItemMapper.findGiftByTypeIn(subType, ProjectId, MId);
} else {
@@ -219,10 +220,10 @@ public class DepotItemService {
depotItem.setMaterialid(tempInsertedJson.getLong("MaterialId"));
depotItem.setMunit(tempInsertedJson.getString("Unit"));
if (!StringUtil.isEmpty(tempInsertedJson.get("OperNumber").toString())) {
depotItem.setOpernumber(tempInsertedJson.getDouble("OperNumber"));
depotItem.setOpernumber(tempInsertedJson.getBigDecimal("OperNumber"));
try {
String Unit = tempInsertedJson.get("Unit").toString();
Double oNumber = tempInsertedJson.getDouble("OperNumber");
BigDecimal oNumber = tempInsertedJson.getBigDecimal("OperNumber");
Long mId = Long.parseLong(tempInsertedJson.get("MaterialId").toString());
//以下进行单位换算
String UnitName = findUnitName(mId); //查询计量单位名称
@@ -235,7 +236,7 @@ public class DepotItemService {
if (Unit.equals(basicUnit)) { //如果等于基础单位
depotItem.setBasicnumber(oNumber); //数量一致
} else if (Unit.equals(otherUnit)) { //如果等于副单位
depotItem.setBasicnumber(oNumber * ratio); //数量乘以比例
depotItem.setBasicnumber(oNumber.multiply(new BigDecimal(ratio)) ); //数量乘以比例
}
} else {
depotItem.setBasicnumber(oNumber); //其他情况
@@ -245,13 +246,13 @@ public class DepotItemService {
}
}
if (!StringUtil.isEmpty(tempInsertedJson.get("UnitPrice").toString())) {
depotItem.setUnitprice(tempInsertedJson.getDouble("UnitPrice"));
depotItem.setUnitprice(tempInsertedJson.getBigDecimal("UnitPrice"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxUnitPrice").toString())) {
depotItem.setTaxunitprice(tempInsertedJson.getDouble("TaxUnitPrice"));
depotItem.setTaxunitprice(tempInsertedJson.getBigDecimal("TaxUnitPrice"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("AllPrice").toString())) {
depotItem.setAllprice(tempInsertedJson.getDouble("AllPrice"));
depotItem.setAllprice(tempInsertedJson.getBigDecimal("AllPrice"));
}
depotItem.setRemark(tempInsertedJson.getString("Remark"));
if (tempInsertedJson.get("DepotId") != null && !StringUtil.isEmpty(tempInsertedJson.get("DepotId").toString())) {
@@ -261,13 +262,13 @@ public class DepotItemService {
depotItem.setAnotherdepotid(tempInsertedJson.getLong("AnotherDepotId"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxRate").toString())) {
depotItem.setTaxrate(tempInsertedJson.getDouble("TaxRate"));
depotItem.setTaxrate(tempInsertedJson.getBigDecimal("TaxRate"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxMoney").toString())) {
depotItem.setTaxmoney(tempInsertedJson.getDouble("TaxMoney"));
depotItem.setTaxmoney(tempInsertedJson.getBigDecimal("TaxMoney"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxLastMoney").toString())) {
depotItem.setTaxlastmoney(tempInsertedJson.getDouble("TaxLastMoney"));
depotItem.setTaxlastmoney(tempInsertedJson.getBigDecimal("TaxLastMoney"));
}
if (tempInsertedJson.get("OtherField1") != null) {
depotItem.setOtherfield1(tempInsertedJson.getString("OtherField1"));
@@ -304,10 +305,10 @@ public class DepotItemService {
depotItem.setMaterialid(tempUpdatedJson.getLong("MaterialId"));
depotItem.setMunit(tempUpdatedJson.getString("Unit"));
if (!StringUtil.isEmpty(tempUpdatedJson.get("OperNumber").toString())) {
depotItem.setOpernumber(tempUpdatedJson.getDouble("OperNumber"));
depotItem.setOpernumber(tempUpdatedJson.getBigDecimal("OperNumber"));
try {
String Unit = tempUpdatedJson.get("Unit").toString();
Double oNumber = tempUpdatedJson.getDouble("OperNumber");
BigDecimal oNumber = tempUpdatedJson.getBigDecimal("OperNumber");
Long mId = Long.parseLong(tempUpdatedJson.get("MaterialId").toString());
//以下进行单位换算
String UnitName = findUnitName(mId); //查询计量单位名称
@@ -320,7 +321,7 @@ public class DepotItemService {
if (Unit.equals(basicUnit)) { //如果等于基础单位
depotItem.setBasicnumber(oNumber); //数量一致
} else if (Unit.equals(otherUnit)) { //如果等于副单位
depotItem.setBasicnumber(oNumber * ratio); //数量乘以比例
depotItem.setBasicnumber(oNumber.multiply(new BigDecimal(ratio))); //数量乘以比例
}
} else {
depotItem.setBasicnumber(oNumber); //其他情况
@@ -330,13 +331,13 @@ public class DepotItemService {
}
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("UnitPrice").toString())) {
depotItem.setUnitprice(tempUpdatedJson.getDouble("UnitPrice"));
depotItem.setUnitprice(tempUpdatedJson.getBigDecimal("UnitPrice"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxUnitPrice").toString())) {
depotItem.setTaxunitprice(tempUpdatedJson.getDouble("TaxUnitPrice"));
depotItem.setTaxunitprice(tempUpdatedJson.getBigDecimal("TaxUnitPrice"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("AllPrice").toString())) {
depotItem.setAllprice(tempUpdatedJson.getDouble("AllPrice"));
depotItem.setAllprice(tempUpdatedJson.getBigDecimal("AllPrice"));
}
depotItem.setRemark(tempUpdatedJson.getString("Remark"));
if (tempUpdatedJson.get("DepotId") != null && !StringUtil.isEmpty(tempUpdatedJson.get("DepotId").toString())) {
@@ -346,13 +347,13 @@ public class DepotItemService {
depotItem.setAnotherdepotid(tempUpdatedJson.getLong("AnotherDepotId"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxRate").toString())) {
depotItem.setTaxrate(tempUpdatedJson.getDouble("TaxRate"));
depotItem.setTaxrate(tempUpdatedJson.getBigDecimal("TaxRate"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxMoney").toString())) {
depotItem.setTaxmoney(tempUpdatedJson.getDouble("TaxMoney"));
depotItem.setTaxmoney(tempUpdatedJson.getBigDecimal("TaxMoney"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxLastMoney").toString())) {
depotItem.setTaxlastmoney(tempUpdatedJson.getDouble("TaxLastMoney"));
depotItem.setTaxlastmoney(tempUpdatedJson.getBigDecimal("TaxLastMoney"));
}
depotItem.setOtherfield1(tempUpdatedJson.getString("OtherField1"));
depotItem.setOtherfield2(tempUpdatedJson.getString("OtherField2"));

View File

@@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -75,9 +76,9 @@ public class SupplierService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAdvanceIn(Long supplierId, Double advanceIn){
public int updateAdvanceIn(Long supplierId, BigDecimal advanceIn){
Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId);
supplier.setAdvancein(supplier.getAdvancein() + advanceIn); //增加预收款的金额,可能增加的是负值
supplier.setAdvancein(supplier.getAdvancein().add(advanceIn)); //增加预收款的金额,可能增加的是负值
return supplierMapper.updateByPrimaryKeySelective(supplier);
}