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 be0929d2..5b93f0b8 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 @@ -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("支出")) { diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/SystemConfigController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/SystemConfigController.java index 0ae376d1..c5b82fe5 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/SystemConfigController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/SystemConfigController.java @@ -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); + } } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/AccountHead.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/AccountHead.java index 8ed666ba..3befe022 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/AccountHead.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/AccountHead.java @@ -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; } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/AccountHeadExample.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/AccountHeadExample.java index 7b836786..b11be264 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/AccountHeadExample.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/AccountHeadExample.java @@ -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 values) { + addCriterion("discount_money in", values, "discountMoney"); + return (Criteria) this; + } + + public Criteria andDiscountMoneyNotIn(List 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; diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/AccountHeadVo4ListEx.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/AccountHeadVo4ListEx.java index 341d1183..fdc803f5 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/AccountHeadVo4ListEx.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/AccountHeadVo4ListEx.java @@ -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; } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/filter/LogCostFilter.java b/jshERP-boot/src/main/java/com/jsh/erp/filter/LogCostFilter.java index caeffa9b..92b73d3a 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/filter/LogCostFilter.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/filter/LogCostFilter.java @@ -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"; 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 89eeef60..33a6a281 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 @@ -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 select(String type, String roleType, String billNo, String beginTime, String endTime, int offset, int rows) throws Exception{ - List resList = new ArrayList(); - List list=null; + List 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 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; diff --git a/jshERP-boot/src/main/resources/mapper_xml/AccountHeadMapper.xml b/jshERP-boot/src/main/resources/mapper_xml/AccountHeadMapper.xml index 34efcb39..ae90f260 100644 --- a/jshERP-boot/src/main/resources/mapper_xml/AccountHeadMapper.xml +++ b/jshERP-boot/src/main/resources/mapper_xml/AccountHeadMapper.xml @@ -8,6 +8,7 @@ + @@ -76,8 +77,8 @@ - id, type, organ_id, hands_person_id, creator, change_amount, total_price, account_id, - bill_no, bill_time, remark, file_name, tenant_id, delete_flag + id, type, organ_id, hands_person_id, creator, change_amount, discount_money, total_price, + account_id, bill_no, bill_time, remark, file_name, tenant_id, delete_flag