给计量单位表修改比例的字段类型,给系统参数表增加金额审核启用标记,给单据增加来源字段

This commit is contained in:
季圣华
2023-03-09 00:01:50 +08:00
parent 00cabc2612
commit 61d9d8704f
28 changed files with 608 additions and 193 deletions

View File

@@ -10,6 +10,7 @@ import com.jsh.erp.datasource.vo.AccountVo4List;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.systemConfig.SystemConfigService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools;
@@ -55,6 +56,8 @@ public class AccountService {
private LogService logService;
@Resource
private UserService userService;
@Resource
private SystemConfigService systemConfigService;
public Account getAccount(long id) throws Exception{
return accountMapper.selectByPrimaryKey(id);
@@ -105,16 +108,19 @@ public class AccountService {
JshException.readFail(logger, e);
}
String timeStr = Tools.getCurrentMonth();
Boolean apprFlag = systemConfigService.getAmountApprovalFlag();
if (null != list && null !=timeStr) {
for (AccountVo4List al : list) {
DecimalFormat df = new DecimalFormat(".##");
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"));
BigDecimal thisMonthAmount = getAccountSum(al.getId(), timeStr, "month", apprFlag).add(getAccountSumByHead(al.getId(), timeStr, "month", apprFlag))
.add(getAccountSumByDetail(al.getId(), timeStr, "month", apprFlag)).add(getManyAccountSum(al.getId(), timeStr, "month", apprFlag));
String thisMonthAmountFmt = "0";
if ((thisMonthAmount.compareTo(BigDecimal.ZERO))!=0) {
thisMonthAmountFmt = df.format(thisMonthAmount);
}
al.setThisMonthAmount(thisMonthAmountFmt); //本月发生额
BigDecimal currentAmount = getAccountSum(al.getId(), "", "month").add(getAccountSumByHead(al.getId(), "", "month")).add(getAccountSumByDetail(al.getId(), "", "month")).add(getManyAccountSum(al.getId(), "", "month")) .add(al.getInitialAmount()) ;
BigDecimal currentAmount = getAccountSum(al.getId(), "", "month", apprFlag).add(getAccountSumByHead(al.getId(), "", "month", apprFlag))
.add(getAccountSumByDetail(al.getId(), "", "month", apprFlag)).add(getManyAccountSum(al.getId(), "", "month", apprFlag)) .add(al.getInitialAmount()) ;
al.setCurrentAmount(currentAmount);
resList.add(al);
}
@@ -273,28 +279,32 @@ public class AccountService {
* @param id
* @return
*/
public BigDecimal getAccountSum(Long id, String timeStr, String type) throws Exception{
public BigDecimal getAccountSum(Long id, String timeStr, String type, Boolean apprFlag) throws Exception{
BigDecimal accountSum = BigDecimal.ZERO;
try {
DepotHeadExample example = new DepotHeadExample();
DepotHeadExample.Criteria criteria = example.createCriteria();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null);
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
if (type.equals("month")) {
example.createCriteria().andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款")
criteria.andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款")
.andOperTimeGreaterThanOrEqualTo(bTime).andOperTimeLessThanOrEqualTo(eTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else if (type.equals("date")) {
example.createCriteria().andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款")
criteria.andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款")
.andOperTimeLessThanOrEqualTo(mTime).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
} else {
example.createCriteria().andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款")
criteria.andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款")
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
List<DepotHead> dataList=null;
try{
if(apprFlag) {
criteria.andStatusEqualTo("1");
}
dataList = depotHeadMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
@@ -318,29 +328,33 @@ public class AccountService {
* @param id
* @return
*/
public BigDecimal getAccountSumByHead(Long id, String timeStr, String type) throws Exception{
public BigDecimal getAccountSumByHead(Long id, String timeStr, String type, Boolean apprFlag) throws Exception{
BigDecimal accountSum = BigDecimal.ZERO;
try {
AccountHeadExample example = new AccountHeadExample();
AccountHeadExample.Criteria criteria = example.createCriteria();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null);
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
if (type.equals("month")) {
example.createCriteria().andAccountIdEqualTo(id)
criteria.andAccountIdEqualTo(id)
.andBillTimeGreaterThanOrEqualTo(bTime).andBillTimeLessThanOrEqualTo(eTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else if (type.equals("date")) {
example.createCriteria().andAccountIdEqualTo(id)
criteria.andAccountIdEqualTo(id)
.andBillTimeLessThanOrEqualTo(mTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
} else {
example.createCriteria().andAccountIdEqualTo(id)
criteria.andAccountIdEqualTo(id)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
List<AccountHead> dataList=null;
try{
if(apprFlag) {
criteria.andStatusEqualTo("1");
}
dataList = accountHeadMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
@@ -364,24 +378,28 @@ public class AccountService {
* @param id
* @return
*/
public BigDecimal getAccountSumByDetail(Long id, String timeStr, String type)throws Exception {
public BigDecimal getAccountSumByDetail(Long id, String timeStr, String type, Boolean apprFlag)throws Exception {
BigDecimal accountSum =BigDecimal.ZERO ;
try {
AccountHeadExample example = new AccountHeadExample();
AccountHeadExample.Criteria criteria = example.createCriteria();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null);
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
if (type.equals("month")) {
example.createCriteria().andBillTimeGreaterThanOrEqualTo(bTime).andBillTimeLessThanOrEqualTo(eTime)
criteria.andBillTimeGreaterThanOrEqualTo(bTime).andBillTimeLessThanOrEqualTo(eTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else if (type.equals("date")) {
example.createCriteria().andBillTimeLessThanOrEqualTo(mTime)
criteria.andBillTimeLessThanOrEqualTo(mTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
}
List<AccountHead> dataList=null;
try{
if(apprFlag) {
criteria.andStatusEqualTo("1");
}
dataList = accountHeadMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
@@ -423,20 +441,21 @@ public class AccountService {
* @param id
* @return
*/
public BigDecimal getManyAccountSum(Long id, String timeStr, String type)throws Exception {
public BigDecimal getManyAccountSum(Long id, String timeStr, String type, Boolean apprFlag)throws Exception {
BigDecimal accountSum = BigDecimal.ZERO;
try {
DepotHeadExample example = new DepotHeadExample();
DepotHeadExample.Criteria criteria = example.createCriteria();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null);
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
if (type.equals("month")) {
example.createCriteria().andAccountIdListLike("%" +id.toString() + "%")
criteria.andAccountIdListLike("%" +id.toString() + "%")
.andOperTimeGreaterThanOrEqualTo(bTime).andOperTimeLessThanOrEqualTo(eTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else if (type.equals("date")) {
example.createCriteria().andAccountIdListLike("%" +id.toString() + "%")
criteria.andAccountIdListLike("%" +id.toString() + "%")
.andOperTimeLessThanOrEqualTo(mTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
@@ -446,6 +465,9 @@ public class AccountService {
}
List<DepotHead> dataList=null;
try{
if(apprFlag) {
criteria.andStatusEqualTo("1");
}
dataList = depotHeadMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
@@ -548,12 +570,13 @@ public class AccountService {
String timeStr = Tools.getCurrentMonth();
BigDecimal allMonthAmount = BigDecimal.ZERO;
BigDecimal allCurrentAmount = BigDecimal.ZERO;
Boolean apprFlag = systemConfigService.getAmountApprovalFlag();
if (null != list && null !=timeStr) {
for (Account a : list) {
BigDecimal monthAmount = getAccountSum(a.getId(), timeStr, "month").add(getAccountSumByHead(a.getId(), timeStr, "month"))
.add(getAccountSumByDetail(a.getId(), timeStr, "month")).add(getManyAccountSum(a.getId(), timeStr, "month"));
BigDecimal currentAmount = getAccountSum(a.getId(), "", "month").add(getAccountSumByHead(a.getId(), "", "month"))
.add(getAccountSumByDetail(a.getId(), "", "month")).add(getManyAccountSum(a.getId(), "", "month")).add(a.getInitialAmount());
BigDecimal monthAmount = getAccountSum(a.getId(), timeStr, "month", apprFlag).add(getAccountSumByHead(a.getId(), timeStr, "month", apprFlag))
.add(getAccountSumByDetail(a.getId(), timeStr, "month", apprFlag)).add(getManyAccountSum(a.getId(), timeStr, "month", apprFlag));
BigDecimal currentAmount = getAccountSum(a.getId(), "", "month", apprFlag).add(getAccountSumByHead(a.getId(), "", "month", apprFlag))
.add(getAccountSumByDetail(a.getId(), "", "month", apprFlag)).add(getManyAccountSum(a.getId(), "", "month", apprFlag)).add(a.getInitialAmount());
allMonthAmount = allMonthAmount.add(monthAmount);
allCurrentAmount = allCurrentAmount.add(currentAmount);
}

View File

@@ -18,7 +18,6 @@ import com.jsh.erp.service.depotItem.DepotItemService;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
import com.jsh.erp.service.person.PersonService;
import com.jsh.erp.service.redis.RedisService;
import com.jsh.erp.service.role.RoleService;
import com.jsh.erp.service.serialNumber.SerialNumberService;
import com.jsh.erp.service.supplier.SupplierService;
@@ -38,7 +37,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.util.*;
import static com.jsh.erp.utils.Tools.getCenternTime;
@@ -586,11 +584,11 @@ public class DepotHeadService {
}
public List<DepotHeadVo4InDetail> findInOutDetail(String beginTime, String endTime, String type, String [] creatorArray,
String [] organArray, String materialParam, List<Long> depotList, Integer oId, String number,
String [] organArray, Boolean amountApprovalFlag, String materialParam, List<Long> depotList, Integer oId, String number,
String remark, Integer offset, Integer rows) throws Exception{
List<DepotHeadVo4InDetail> list = null;
try{
list =depotHeadMapperEx.findInOutDetail(beginTime, endTime, type, creatorArray, organArray, materialParam, depotList, oId, number, remark, offset, rows);
list =depotHeadMapperEx.findInOutDetail(beginTime, endTime, type, creatorArray, organArray, amountApprovalFlag, materialParam, depotList, oId, number, remark, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
@@ -598,25 +596,25 @@ public class DepotHeadService {
}
public int findInOutDetailCount(String beginTime, String endTime, String type, String [] creatorArray,
String [] organArray, String materialParam, List<Long> depotList, Integer oId, String number,
String [] organArray, Boolean amountApprovalFlag, String materialParam, List<Long> depotList, Integer oId, String number,
String remark) throws Exception{
int result = 0;
try{
result =depotHeadMapperEx.findInOutDetailCount(beginTime, endTime, type, creatorArray, organArray, materialParam, depotList, oId, number, remark);
result =depotHeadMapperEx.findInOutDetailCount(beginTime, endTime, type, creatorArray, organArray, amountApprovalFlag, materialParam, depotList, oId, number, remark);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public List<DepotHeadVo4InOutMCount> findInOutMaterialCount(String beginTime, String endTime, String type, String materialParam,
public List<DepotHeadVo4InOutMCount> findInOutMaterialCount(String beginTime, String endTime, String type, Boolean amountApprovalFlag, String materialParam,
List<Long> depotList, Integer oId, String roleType, Integer offset, Integer rows)throws Exception {
List<DepotHeadVo4InOutMCount> list = null;
try{
String [] creatorArray = getCreatorArray(roleType);
String subType = "出库".equals(type)? "销售" : "";
String [] organArray = getOrganArray(subType, "");
list =depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, materialParam, depotList, oId,
list =depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, amountApprovalFlag, materialParam, depotList, oId,
creatorArray, organArray, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
@@ -624,14 +622,14 @@ public class DepotHeadService {
return list;
}
public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, String materialParam,
public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, Boolean amountApprovalFlag, String materialParam,
List<Long> depotList, Integer oId, String roleType)throws Exception {
int result = 0;
try{
String [] creatorArray = getCreatorArray(roleType);
String subType = "出库".equals(type)? "销售" : "";
String [] organArray = getOrganArray(subType, "");
result =depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, materialParam, depotList, oId,
result =depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, amountApprovalFlag, materialParam, depotList, oId,
creatorArray, organArray);
}catch(Exception e){
JshException.readFail(logger, e);
@@ -640,11 +638,11 @@ public class DepotHeadService {
}
public List<DepotHeadVo4InDetail> findAllocationDetail(String beginTime, String endTime, String subType, String number,
String [] creatorArray, String materialParam, List<Long> depotList, List<Long> depotFList,
String [] creatorArray, Boolean amountApprovalFlag, String materialParam, List<Long> depotList, List<Long> depotFList,
String remark, Integer offset, Integer rows) throws Exception{
List<DepotHeadVo4InDetail> list = null;
try{
list =depotHeadMapperEx.findAllocationDetail(beginTime, endTime, subType, number, creatorArray,
list =depotHeadMapperEx.findAllocationDetail(beginTime, endTime, subType, number, creatorArray, amountApprovalFlag,
materialParam, depotList, depotFList, remark, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
@@ -653,11 +651,11 @@ public class DepotHeadService {
}
public int findAllocationDetailCount(String beginTime, String endTime, String subType, String number,
String [] creatorArray, String materialParam, List<Long> depotList, List<Long> depotFList,
String [] creatorArray, Boolean amountApprovalFlag, String materialParam, List<Long> depotList, List<Long> depotFList,
String remark) throws Exception{
int result = 0;
try{
result =depotHeadMapperEx.findAllocationDetailCount(beginTime, endTime, subType, number, creatorArray,
result =depotHeadMapperEx.findAllocationDetailCount(beginTime, endTime, subType, number, creatorArray, amountApprovalFlag,
materialParam, depotList, depotFList, remark);
}catch(Exception e){
JshException.readFail(logger, e);
@@ -1198,13 +1196,15 @@ public class DepotHeadService {
}
public BigDecimal getBuyAndSaleBasicStatistics(String type, String subType, Integer hasSupplier,
String beginTime, String endTime, String[] creatorArray) {
return depotHeadMapperEx.getBuyAndSaleBasicStatistics(type, subType, hasSupplier, beginTime, endTime, creatorArray);
String beginTime, String endTime, String[] creatorArray) throws Exception {
Boolean amountApprovalFlag = systemConfigService.getAmountApprovalFlag();
return depotHeadMapperEx.getBuyAndSaleBasicStatistics(type, subType, hasSupplier, beginTime, endTime, creatorArray, amountApprovalFlag);
}
public BigDecimal getBuyAndSaleRetailStatistics(String type, String subType,
String beginTime, String endTime, String[] creatorArray) {
return depotHeadMapperEx.getBuyAndSaleRetailStatistics(type, subType, beginTime, endTime, creatorArray).abs();
String beginTime, String endTime, String[] creatorArray) throws Exception {
Boolean amountApprovalFlag = systemConfigService.getAmountApprovalFlag();
return depotHeadMapperEx.getBuyAndSaleRetailStatistics(type, subType, beginTime, endTime, creatorArray, amountApprovalFlag).abs();
}
public DepotHead getDepotHead(String number)throws Exception {

View File

@@ -314,10 +314,10 @@ public class DepotItemService {
}
public List<DepotItemVo4WithInfoEx> getListWithBugOrSale(String materialParam, String billType,
String beginTime, String endTime, String[] creatorArray, Integer offset, Integer rows)throws Exception {
String beginTime, String endTime, String[] creatorArray, Boolean amountApprovalFlag, Integer offset, Integer rows)throws Exception {
List<DepotItemVo4WithInfoEx> list =null;
try{
list = depotItemMapperEx.getListWithBugOrSale(materialParam, billType, beginTime, endTime, creatorArray, offset, rows);
list = depotItemMapperEx.getListWithBugOrSale(materialParam, billType, beginTime, endTime, creatorArray, amountApprovalFlag, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
@@ -325,10 +325,10 @@ public class DepotItemService {
}
public int getListWithBugOrSaleCount(String materialParam, String billType,
String beginTime, String endTime, String[] creatorArray)throws Exception {
String beginTime, String endTime, String[] creatorArray, Boolean amountApprovalFlag)throws Exception {
int result=0;
try{
result = depotItemMapperEx.getListWithBugOrSaleCount(materialParam, billType, beginTime, endTime, creatorArray);
result = depotItemMapperEx.getListWithBugOrSaleCount(materialParam, billType, beginTime, endTime, creatorArray, amountApprovalFlag);
}catch(Exception e){
JshException.readFail(logger, e);
}
@@ -363,9 +363,10 @@ public class DepotItemService {
BigDecimal result= BigDecimal.ZERO;
try{
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
Boolean amountApprovalFlag = systemConfigService.getAmountApprovalFlag();
String beginTime = Tools.firstDayOfMonth(month) + BusinessConstants.DAY_FIRST_TIME;
String endTime = Tools.lastDayOfMonth(month) + BusinessConstants.DAY_LAST_TIME;
result = depotItemMapperEx.inOrOutPrice(type, subType, beginTime, endTime, creatorArray);
result = depotItemMapperEx.inOrOutPrice(type, subType, beginTime, endTime, creatorArray, amountApprovalFlag);
}catch(Exception e){
JshException.readFail(logger, e);
}
@@ -384,9 +385,10 @@ public class DepotItemService {
BigDecimal result= BigDecimal.ZERO;
try{
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
Boolean amountApprovalFlag = systemConfigService.getAmountApprovalFlag();
String beginTime = Tools.firstDayOfMonth(month) + BusinessConstants.DAY_FIRST_TIME;
String endTime = Tools.lastDayOfMonth(month) + BusinessConstants.DAY_LAST_TIME;
result = depotItemMapperEx.inOrOutRetailPrice(type, subType, beginTime, endTime, creatorArray);
result = depotItemMapperEx.inOrOutRetailPrice(type, subType, beginTime, endTime, creatorArray, amountApprovalFlag);
result = result.abs();
}catch(Exception e){
JshException.readFail(logger, e);
@@ -494,11 +496,11 @@ public class DepotItemService {
if (unit.equals(basicUnit)) { //如果等于基本单位
depotItem.setBasicNumber(oNumber); //数量一致
} else if (unit.equals(unitInfo.getOtherUnit())) { //如果等于副单位
depotItem.setBasicNumber(oNumber.multiply(new BigDecimal(unitInfo.getRatio())) ); //数量乘以比例
depotItem.setBasicNumber(oNumber.multiply(unitInfo.getRatio())); //数量乘以比例
} else if (unit.equals(unitInfo.getOtherUnitTwo())) { //如果等于副单位2
depotItem.setBasicNumber(oNumber.multiply(new BigDecimal(unitInfo.getRatioTwo())) ); //数量乘以比例
depotItem.setBasicNumber(oNumber.multiply(unitInfo.getRatioTwo())); //数量乘以比例
} else if (unit.equals(unitInfo.getOtherUnitThree())) { //如果等于副单位3
depotItem.setBasicNumber(oNumber.multiply(new BigDecimal(unitInfo.getRatioThree())) ); //数量乘以比例
depotItem.setBasicNumber(oNumber.multiply(unitInfo.getRatioThree())); //数量乘以比例
}
} else {
depotItem.setBasicNumber(oNumber); //其他情况
@@ -1034,14 +1036,14 @@ public class DepotItemService {
}
BigDecimal count = depotItemMapperEx.getFinishNumber(meId, linkId, linkNumber, goToType);
//根据多单位情况进行数量的转换
if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != 0) {
count = count.divide(BigDecimal.valueOf(unitInfo.getRatio()),2,BigDecimal.ROUND_HALF_UP);
if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio()!=null && unitInfo.getRatio().compareTo(BigDecimal.ZERO)!=0) {
count = count.divide(unitInfo.getRatio(),2,BigDecimal.ROUND_HALF_UP);
}
if(materialUnit.equals(unitInfo.getOtherUnitTwo()) && unitInfo.getRatioTwo() != 0) {
count = count.divide(BigDecimal.valueOf(unitInfo.getRatioTwo()),2,BigDecimal.ROUND_HALF_UP);
if(materialUnit.equals(unitInfo.getOtherUnitTwo()) && unitInfo.getRatioTwo()!=null && unitInfo.getRatioTwo().compareTo(BigDecimal.ZERO)!=0) {
count = count.divide(unitInfo.getRatioTwo(),2,BigDecimal.ROUND_HALF_UP);
}
if(materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree() != 0) {
count = count.divide(BigDecimal.valueOf(unitInfo.getRatioThree()),2,BigDecimal.ROUND_HALF_UP);
if(materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree()!=null && unitInfo.getRatioThree().compareTo(BigDecimal.ZERO)!=0) {
count = count.divide(unitInfo.getRatioThree(),2,BigDecimal.ROUND_HALF_UP);
}
return count;
}
@@ -1064,14 +1066,14 @@ public class DepotItemService {
String linkNumber = depotHead.getNumber(); //订单号
BigDecimal count = depotItemMapperEx.getRealFinishNumber(meId, linkId, linkNumber, currentHeaderId, goToType);
//根据多单位情况进行数量的转换
if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != 0) {
count = count.divide(BigDecimal.valueOf(unitInfo.getRatio()),2,BigDecimal.ROUND_HALF_UP);
if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio()!=null && unitInfo.getRatio().compareTo(BigDecimal.ZERO)!=0) {
count = count.divide(unitInfo.getRatio(),2,BigDecimal.ROUND_HALF_UP);
}
if(materialUnit.equals(unitInfo.getOtherUnitTwo()) && unitInfo.getRatioTwo() != 0) {
count = count.divide(BigDecimal.valueOf(unitInfo.getRatioTwo()),2,BigDecimal.ROUND_HALF_UP);
if(materialUnit.equals(unitInfo.getOtherUnitTwo()) && unitInfo.getRatioTwo()!=null && unitInfo.getRatioTwo().compareTo(BigDecimal.ZERO)!=0) {
count = count.divide(unitInfo.getRatioTwo(),2,BigDecimal.ROUND_HALF_UP);
}
if(materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree() != 0) {
count = count.divide(BigDecimal.valueOf(unitInfo.getRatioThree()),2,BigDecimal.ROUND_HALF_UP);
if(materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree()!=null && unitInfo.getRatioThree().compareTo(BigDecimal.ZERO)!=0) {
count = count.divide(unitInfo.getRatioThree(),2,BigDecimal.ROUND_HALF_UP);
}
return count;
}

View File

@@ -567,12 +567,12 @@ public class MaterialService {
basicObj.put("lowDecimal", lowDecimal);
materialExObj.put("basic", basicObj);
if(StringUtil.isNotEmpty(manyUnit) && StringUtil.isNotEmpty(ratio)){ //多单位
//校验比例是否是正整
if(!StringUtil.isPositiveLong(ratio.trim())) {
//校验比例是否是数字(含小数)
if(!StringUtil.isPositiveBigDecimal(ratio.trim())) {
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_RATIO_NOT_INTEGER_CODE,
String.format(ExceptionConstants.MATERIAL_RATIO_NOT_INTEGER_MSG, i+1));
}
Long unitId = unitService.getUnitIdByParam(unit, manyUnit, Integer.parseInt(ratio.trim()));
Long unitId = unitService.getUnitIdByParam(unit, manyUnit, new BigDecimal(ratio.trim()));
if(unitId != null) {
m.setUnitId(unitId);
} else {
@@ -1140,8 +1140,8 @@ public class MaterialService {
String bigUnitStock = "";
if(null!= unitId) {
Unit unit = unitService.getUnit(unitId);
if(unit.getRatio()!=0 && stock!=null) {
bigUnitStock = stock.divide(BigDecimal.valueOf(unit.getRatio()),2,BigDecimal.ROUND_HALF_UP) + unit.getOtherUnit();
if(unit.getRatio()!=null && unit.getRatio().compareTo(BigDecimal.ZERO)!=0 && stock!=null) {
bigUnitStock = stock.divide(unit.getRatio(),2,BigDecimal.ROUND_HALF_UP) + unit.getOtherUnit();
}
}
return bigUnitStock;

View File

@@ -199,4 +199,21 @@ public class SystemConfigService {
}
return minusStockFlag;
}
/**
* 获取金额审核开关
* @return
* @throws Exception
*/
public boolean getAmountApprovalFlag() throws Exception {
boolean amountApprovalFlag = false;
List<SystemConfig> list = getSystemConfig();
if(list.size()>0) {
String flag = list.get(0).getAmountApprovalFlag();
if(("1").equals(flag)) {
amountApprovalFlag = true;
}
}
return amountApprovalFlag;
}
}

View File

@@ -217,7 +217,7 @@ public class UnitService {
* @param ratio
* @return
*/
public Long getUnitIdByParam(String basicUnit, String otherUnit, Integer ratio){
public Long getUnitIdByParam(String basicUnit, String otherUnit, BigDecimal ratio){
Long unitId = null;
UnitExample example = new UnitExample();
example.createCriteria().andBasicUnitEqualTo(basicUnit).andOtherUnitEqualTo(otherUnit).andRatioEqualTo(ratio)
@@ -237,14 +237,14 @@ public class UnitService {
* @return
*/
public BigDecimal parseStockByUnit(BigDecimal stock, Unit unitInfo, String materialUnit) {
if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != 0) {
stock = stock.divide(BigDecimal.valueOf(unitInfo.getRatio()),2,BigDecimal.ROUND_HALF_UP);
if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio()!=null && unitInfo.getRatio().compareTo(BigDecimal.ZERO)!=0) {
stock = stock.divide(unitInfo.getRatio(),2,BigDecimal.ROUND_HALF_UP);
}
if(materialUnit.equals(unitInfo.getOtherUnitTwo()) && unitInfo.getRatioTwo() != 0) {
stock = stock.divide(BigDecimal.valueOf(unitInfo.getRatioTwo()),2,BigDecimal.ROUND_HALF_UP);
if(materialUnit.equals(unitInfo.getOtherUnitTwo()) && unitInfo.getRatioTwo()!=null && unitInfo.getRatioTwo().compareTo(BigDecimal.ZERO)!=0) {
stock = stock.divide(unitInfo.getRatioTwo(),2,BigDecimal.ROUND_HALF_UP);
}
if(materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree() != 0) {
stock = stock.divide(BigDecimal.valueOf(unitInfo.getRatioThree()),2,BigDecimal.ROUND_HALF_UP);
if(materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree()!=null && unitInfo.getRatioThree().compareTo(BigDecimal.ZERO)!=0) {
stock = stock.divide(unitInfo.getRatioThree(),2,BigDecimal.ROUND_HALF_UP);
}
return stock;
}