优化财务单据

This commit is contained in:
季圣华
2021-07-01 00:53:46 +08:00
parent c5b7a44740
commit 16b5194842
8 changed files with 196 additions and 173 deletions

View File

@@ -231,10 +231,10 @@ public class DepotHeadController {
allPrice = p1.subtract(p2);
} else if (type.equals("采购退货出库")) {
allPrice = p1.subtract(p2);
} else if (type.equals("付款")) {
allPrice = p1.add(p2);
} else if (type.equals("收款")) {
allPrice = BigDecimal.ZERO.subtract(p1.add(p2));
allPrice = BigDecimal.ZERO.subtract(p1);
} else if (type.equals("付款")) {
allPrice = p1;
} else if (type.equals("收入")) {
allPrice = p1.subtract(p2);
} else if (type.equals("支出")) {

View File

@@ -17,16 +17,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DataAccessException;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.HandlerMapping;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.*;
import java.util.List;
/**
@@ -192,4 +193,76 @@ public class SystemConfigController {
}
return "";
}
/**
* 预览图片&下载文件
* 请求地址http://localhost:8080/common/static/{financial/afsdfasdfasdf_1547866868179.txt}
*
* @param request
* @param response
*/
@GetMapping(value = "/static/**")
public void view(HttpServletRequest request, HttpServletResponse response) {
// ISO-8859-1 ==> UTF-8 进行编码转换
String imgPath = extractPathFromPattern(request);
if(StringUtil.isEmpty(imgPath) || imgPath=="null"){
return;
}
// 其余处理略
InputStream inputStream = null;
OutputStream outputStream = null;
try {
imgPath = imgPath.replace("..", "");
if (imgPath.endsWith(",")) {
imgPath = imgPath.substring(0, imgPath.length() - 1);
}
String fileUrl = filePath + File.separator + imgPath;
File file = new File(fileUrl);
if(!file.exists()){
response.setStatus(404);
throw new RuntimeException("文件不存在..");
}
response.setContentType("application/force-download");// 设置强制下载不打开
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
inputStream = new BufferedInputStream(new FileInputStream(fileUrl));
outputStream = response.getOutputStream();
byte[] buf = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0) {
outputStream.write(buf, 0, len);
}
response.flushBuffer();
} catch (IOException e) {
logger.error("预览文件失败" + e.getMessage());
response.setStatus(404);
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
}
}
/**
* 把指定URL后的字符串全部截断当成参数
* 这么做是为了防止URL中包含中文或者特殊字符/等)时,匹配不了的问题
* @param request
* @return
*/
private static String extractPathFromPattern(final HttpServletRequest request) {
String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
}
}

View File

@@ -16,6 +16,8 @@ public class AccountHead {
private BigDecimal changeAmount;
private BigDecimal discountMoney;
private BigDecimal totalPrice;
private Long accountId;
@@ -80,6 +82,14 @@ public class AccountHead {
this.changeAmount = changeAmount;
}
public BigDecimal getDiscountMoney() {
return discountMoney;
}
public void setDiscountMoney(BigDecimal discountMoney) {
this.discountMoney = discountMoney;
}
public BigDecimal getTotalPrice() {
return totalPrice;
}

View File

@@ -476,6 +476,66 @@ public class AccountHeadExample {
return (Criteria) this;
}
public Criteria andDiscountMoneyIsNull() {
addCriterion("discount_money is null");
return (Criteria) this;
}
public Criteria andDiscountMoneyIsNotNull() {
addCriterion("discount_money is not null");
return (Criteria) this;
}
public Criteria andDiscountMoneyEqualTo(BigDecimal value) {
addCriterion("discount_money =", value, "discountMoney");
return (Criteria) this;
}
public Criteria andDiscountMoneyNotEqualTo(BigDecimal value) {
addCriterion("discount_money <>", value, "discountMoney");
return (Criteria) this;
}
public Criteria andDiscountMoneyGreaterThan(BigDecimal value) {
addCriterion("discount_money >", value, "discountMoney");
return (Criteria) this;
}
public Criteria andDiscountMoneyGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("discount_money >=", value, "discountMoney");
return (Criteria) this;
}
public Criteria andDiscountMoneyLessThan(BigDecimal value) {
addCriterion("discount_money <", value, "discountMoney");
return (Criteria) this;
}
public Criteria andDiscountMoneyLessThanOrEqualTo(BigDecimal value) {
addCriterion("discount_money <=", value, "discountMoney");
return (Criteria) this;
}
public Criteria andDiscountMoneyIn(List<BigDecimal> values) {
addCriterion("discount_money in", values, "discountMoney");
return (Criteria) this;
}
public Criteria andDiscountMoneyNotIn(List<BigDecimal> values) {
addCriterion("discount_money not in", values, "discountMoney");
return (Criteria) this;
}
public Criteria andDiscountMoneyBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("discount_money between", value1, value2, "discountMoney");
return (Criteria) this;
}
public Criteria andDiscountMoneyNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("discount_money not between", value1, value2, "discountMoney");
return (Criteria) this;
}
public Criteria andTotalPriceIsNull() {
addCriterion("total_price is null");
return (Criteria) this;

View File

@@ -3,150 +3,18 @@ package com.jsh.erp.datasource.entities;
import java.math.BigDecimal;
import java.util.Date;
public class AccountHeadVo4ListEx {
private Long id;
private String type;
private Long organId;
private Long handsPersonId;
private BigDecimal changeAmount;
private BigDecimal totalPrice;
private Long accountId;
private String billNo;
private Date billTime;
private String remark;
private String fileName;
private Long tenantId;
private String deleteFlag;
public class AccountHeadVo4ListEx extends AccountHead{
private String organName;
private String handsPersonName;
private Long creator;
private String userName;
private String accountName;
private String billTimeStr;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Long getOrganId() {
return organId;
}
public void setOrganId(Long organId) {
this.organId = organId;
}
public Long getHandsPersonId() {
return handsPersonId;
}
public void setHandsPersonId(Long handsPersonId) {
this.handsPersonId = handsPersonId;
}
public BigDecimal getChangeAmount() {
return changeAmount;
}
public void setChangeAmount(BigDecimal changeAmount) {
this.changeAmount = changeAmount;
}
public BigDecimal getTotalPrice() {
return totalPrice;
}
public void setTotalPrice(BigDecimal totalPrice) {
this.totalPrice = totalPrice;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
public String getBillNo() {
return billNo;
}
public void setBillNo(String billNo) {
this.billNo = billNo;
}
public Date getBillTime() {
return billTime;
}
public void setBillTime(Date billTime) {
this.billTime = billTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public Long getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
public String getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(String deleteFlag) {
this.deleteFlag = deleteFlag;
}
public String getOrganName() {
return organName;
}
@@ -163,14 +31,6 @@ public class AccountHeadVo4ListEx {
this.handsPersonName = handsPersonName;
}
public Long getCreator() {
return creator;
}
public void setCreator(Long creator) {
this.creator = creator;
}
public String getUserName() {
return userName;
}

View File

@@ -18,8 +18,9 @@ import java.util.regex.Pattern;
@WebFilter(filterName = "LogCostFilter", urlPatterns = {"/*"},
initParams = {@WebInitParam(name = "ignoredUrl", value = ".ico"),
@WebInitParam(name = "filterPath",
value = "/jshERP-boot/user/login#/jshERP-boot/user/registerUser#/jshERP-boot/user/randomImage" +
"#/jshERP-boot/platformConfig/getPlatform#/jshERP-boot/v2/api-docs#/jshERP-boot/webjars")})
value = "/jshERP-boot/user/login#/jshERP-boot/user/registerUser#/jshERP-boot/user/randomImage#" +
"/jshERP-boot/platformConfig/getPlatform#/jshERP-boot/v2/api-docs#/jshERP-boot/webjars#" +
"/jshERP-boot/systemConfig/static")})
public class LogCostFilter implements Filter {
private static final String FILTER_PATH = "filterPath";

View File

@@ -18,6 +18,7 @@ import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
@@ -49,6 +50,8 @@ public class AccountHeadService {
private LogService logService;
@Resource
private AccountItemMapperEx accountItemMapperEx;
@Value(value="${file.path}")
private String filePath;
public AccountHead getAccountHead(long id) throws Exception {
AccountHead result=null;
@@ -85,28 +88,27 @@ public class AccountHeadService {
}
public List<AccountHeadVo4ListEx> select(String type, String roleType, String billNo, String beginTime, String endTime, int offset, int rows) throws Exception{
List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>();
List<AccountHeadVo4ListEx> list=null;
List<AccountHeadVo4ListEx> resList = new ArrayList<>();
try{
String [] creatorArray = getCreatorArray(roleType);
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
list = accountHeadMapperEx.selectByConditionAccountHead(type, creatorArray, billNo, beginTime, endTime, offset, rows);
List<AccountHeadVo4ListEx> list = accountHeadMapperEx.selectByConditionAccountHead(type, creatorArray, billNo, beginTime, endTime, offset, rows);
if (null != list) {
for (AccountHeadVo4ListEx ah : list) {
if(ah.getChangeAmount() != null) {
ah.setChangeAmount(ah.getChangeAmount().abs());
}
if(ah.getTotalPrice() != null) {
ah.setTotalPrice(ah.getTotalPrice().abs());
}
ah.setBillTimeStr(getCenternTime(ah.getBillTime()));
resList.add(ah);
}
}
}catch(Exception e){
JshException.readFail(logger, e);
}
if (null != list) {
for (AccountHeadVo4ListEx ah : list) {
if(ah.getChangeAmount() != null) {
ah.setChangeAmount(ah.getChangeAmount().abs());
}
if(ah.getTotalPrice() != null) {
ah.setTotalPrice(ah.getTotalPrice().abs());
}
ah.setBillTimeStr(getCenternTime(ah.getBillTime()));
resList.add(ah);
}
}
return resList;
}
@@ -315,8 +317,8 @@ public class AccountHeadService {
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.subtract((allMoney(getS, "", "合计",endTime)).multiply(new BigDecimal(i)));
sum = sum.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;