Commit 9550c031 authored by 乾坤平台's avatar 乾坤平台 Committed by 季圣华
Browse files

!16 修复一系列问题

Merge pull request !16 from 乾坤平台/master
parents fc03d050 c4623555
...@@ -2,7 +2,29 @@ ...@@ -2,7 +2,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<profiles>
<profile>
<id>dev</id>
<properties>
<activatedProperties>dev</activatedProperties>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<activatedProperties>test</activatedProperties>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<activatedProperties>prod</activatedProperties>
</properties>
</profile>
</profiles>
<groupId>com.jsh</groupId> <groupId>com.jsh</groupId>
<artifactId>jshERP</artifactId> <artifactId>jshERP</artifactId>
<version>2.0.2-SNAPSHOT</version> <version>2.0.2-SNAPSHOT</version>
...@@ -14,7 +36,7 @@ ...@@ -14,7 +36,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version> <version>2.0.0.RELEASE</version>
</parent> </parent>
<properties> <properties>
......
-- noinspection SqlNoDataSourceInspectionForFile
/* /*
Navicat MySQL Data Transfer Navicat MySQL Data Transfer
   
...@@ -69,8 +71,8 @@ CREATE TABLE `jsh_account` ( ...@@ -69,8 +71,8 @@ CREATE TABLE `jsh_account` (
`Id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `Id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`Name` varchar(50) DEFAULT NULL COMMENT '名称', `Name` varchar(50) DEFAULT NULL COMMENT '名称',
`SerialNo` varchar(50) DEFAULT NULL COMMENT '编号', `SerialNo` varchar(50) DEFAULT NULL COMMENT '编号',
`InitialAmount` double DEFAULT NULL COMMENT '期初金额', `InitialAmount` decimal(24, 6) DEFAULT NULL COMMENT '期初金额',
`CurrentAmount` double DEFAULT NULL COMMENT '当前余额', `CurrentAmount` decimal(24, 6) DEFAULT NULL COMMENT '当前余额',
`Remark` varchar(100) DEFAULT NULL COMMENT '备注', `Remark` varchar(100) DEFAULT NULL COMMENT '备注',
`IsDefault` bit(1) DEFAULT NULL COMMENT '是否默认', `IsDefault` bit(1) DEFAULT NULL COMMENT '是否默认',
PRIMARY KEY (`Id`) PRIMARY KEY (`Id`)
...@@ -94,8 +96,8 @@ CREATE TABLE `jsh_accounthead` ( ...@@ -94,8 +96,8 @@ CREATE TABLE `jsh_accounthead` (
`Type` varchar(50) DEFAULT NULL COMMENT '类型(支出/收入/收款/付款/转账)', `Type` varchar(50) DEFAULT NULL COMMENT '类型(支出/收入/收款/付款/转账)',
`OrganId` bigint(20) DEFAULT NULL COMMENT '单位Id(收款/付款单位)', `OrganId` bigint(20) DEFAULT NULL COMMENT '单位Id(收款/付款单位)',
`HandsPersonId` bigint(20) DEFAULT NULL COMMENT '经手人Id', `HandsPersonId` bigint(20) DEFAULT NULL COMMENT '经手人Id',
`ChangeAmount` double DEFAULT NULL COMMENT '变动金额(优惠/收款/付款/实付)', `ChangeAmount` decimal(24, 6) DEFAULT NULL COMMENT '变动金额(优惠/收款/付款/实付)',
`TotalPrice` double DEFAULT NULL COMMENT '合计金额', `TotalPrice` decimal(24, 6) DEFAULT NULL COMMENT '合计金额',
`AccountId` bigint(20) DEFAULT NULL COMMENT '账户(收款/付款)', `AccountId` bigint(20) DEFAULT NULL COMMENT '账户(收款/付款)',
`BillNo` varchar(50) DEFAULT NULL COMMENT '单据编号', `BillNo` varchar(50) DEFAULT NULL COMMENT '单据编号',
`BillTime` datetime DEFAULT NULL COMMENT '单据日期', `BillTime` datetime DEFAULT NULL COMMENT '单据日期',
...@@ -139,7 +141,7 @@ CREATE TABLE `jsh_accountitem` ( ...@@ -139,7 +141,7 @@ CREATE TABLE `jsh_accountitem` (
`HeaderId` bigint(20) NOT NULL COMMENT '表头Id', `HeaderId` bigint(20) NOT NULL COMMENT '表头Id',
`AccountId` bigint(20) DEFAULT NULL COMMENT '账户Id', `AccountId` bigint(20) DEFAULT NULL COMMENT '账户Id',
`InOutItemId` bigint(20) DEFAULT NULL COMMENT '收支项目Id', `InOutItemId` bigint(20) DEFAULT NULL COMMENT '收支项目Id',
`EachAmount` double DEFAULT NULL COMMENT '单项金额', `EachAmount` decimal(24, 6) DEFAULT NULL COMMENT '单项金额',
`Remark` varchar(100) DEFAULT NULL COMMENT '单据备注', `Remark` varchar(100) DEFAULT NULL COMMENT '单据备注',
PRIMARY KEY (`Id`), PRIMARY KEY (`Id`),
KEY `FK9F4CBAC0AAE50527` (`AccountId`), KEY `FK9F4CBAC0AAE50527` (`AccountId`),
...@@ -218,7 +220,7 @@ CREATE TABLE `jsh_asset` ( ...@@ -218,7 +220,7 @@ CREATE TABLE `jsh_asset` (
`labels` varchar(255) DEFAULT NULL COMMENT '标签:以空格为分隔符', `labels` varchar(255) DEFAULT NULL COMMENT '标签:以空格为分隔符',
`status` smallint(6) DEFAULT NULL COMMENT '资产的状态:0==在库,1==在用,2==消费', `status` smallint(6) DEFAULT NULL COMMENT '资产的状态:0==在库,1==在用,2==消费',
`userID` bigint(20) DEFAULT NULL COMMENT '用户ID', `userID` bigint(20) DEFAULT NULL COMMENT '用户ID',
`price` double DEFAULT NULL COMMENT '购买价格', `price` decimal(24, 6) DEFAULT NULL COMMENT '购买价格',
`purchasedate` datetime DEFAULT NULL COMMENT '购买日期', `purchasedate` datetime DEFAULT NULL COMMENT '购买日期',
`periodofvalidity` datetime DEFAULT NULL COMMENT '有效日期', `periodofvalidity` datetime DEFAULT NULL COMMENT '有效日期',
`warrantydate` datetime DEFAULT NULL COMMENT '保修日期', `warrantydate` datetime DEFAULT NULL COMMENT '保修日期',
...@@ -321,8 +323,8 @@ CREATE TABLE `jsh_depot` ( ...@@ -321,8 +323,8 @@ CREATE TABLE `jsh_depot` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(20) DEFAULT NULL COMMENT '仓库名称', `name` varchar(20) DEFAULT NULL COMMENT '仓库名称',
`address` varchar(50) DEFAULT NULL COMMENT '仓库地址', `address` varchar(50) DEFAULT NULL COMMENT '仓库地址',
`warehousing` double DEFAULT NULL COMMENT '仓储费', `warehousing` decimal(24, 6) DEFAULT NULL COMMENT '仓储费',
`truckage` double DEFAULT NULL COMMENT '搬运费', `truckage` decimal(24, 6) DEFAULT NULL COMMENT '搬运费',
`type` int(10) DEFAULT NULL COMMENT '类型', `type` int(10) DEFAULT NULL COMMENT '类型',
`sort` varchar(10) DEFAULT NULL COMMENT '排序', `sort` varchar(10) DEFAULT NULL COMMENT '排序',
`remark` varchar(100) DEFAULT NULL COMMENT '描述', `remark` varchar(100) DEFAULT NULL COMMENT '描述',
...@@ -343,6 +345,8 @@ INSERT INTO `jsh_depot` VALUES ('6', '1269520625', null, null, null, '1', '2', ' ...@@ -343,6 +345,8 @@ INSERT INTO `jsh_depot` VALUES ('6', '1269520625', null, null, null, '1', '2', '
-- Table structure for `jsh_depothead` -- Table structure for `jsh_depothead`
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `jsh_depothead`; DROP TABLE IF EXISTS `jsh_depothead`;
-- noinspection SqlNoDataSourceInspection
CREATE TABLE `jsh_depothead` ( CREATE TABLE `jsh_depothead` (
`Id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `Id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`Type` varchar(50) DEFAULT NULL COMMENT '类型(出库/入库)', `Type` varchar(50) DEFAULT NULL COMMENT '类型(出库/入库)',
...@@ -356,18 +360,18 @@ CREATE TABLE `jsh_depothead` ( ...@@ -356,18 +360,18 @@ CREATE TABLE `jsh_depothead` (
`OrganId` bigint(20) DEFAULT NULL COMMENT '供应商Id', `OrganId` bigint(20) DEFAULT NULL COMMENT '供应商Id',
`HandsPersonId` bigint(20) DEFAULT NULL COMMENT '采购/领料-经手人Id', `HandsPersonId` bigint(20) DEFAULT NULL COMMENT '采购/领料-经手人Id',
`AccountId` bigint(20) DEFAULT NULL COMMENT '账户Id', `AccountId` bigint(20) DEFAULT NULL COMMENT '账户Id',
`ChangeAmount` double DEFAULT NULL COMMENT '变动金额(收款/付款)', `ChangeAmount` decimal(24, 6) DEFAULT NULL COMMENT '变动金额(收款/付款)',
`AllocationProjectId` bigint(20) DEFAULT NULL COMMENT '调拨时,对方项目Id', `AllocationProjectId` bigint(20) DEFAULT NULL COMMENT '调拨时,对方项目Id',
`TotalPrice` double DEFAULT NULL COMMENT '合计金额', `TotalPrice` decimal(24, 6) DEFAULT NULL COMMENT '合计金额',
`PayType` varchar(50) DEFAULT NULL COMMENT '付款类型(现金、记账等)', `PayType` varchar(50) DEFAULT NULL COMMENT '付款类型(现金、记账等)',
`Remark` varchar(1000) DEFAULT NULL COMMENT '备注', `Remark` varchar(1000) DEFAULT NULL COMMENT '备注',
`Salesman` varchar(50) DEFAULT NULL COMMENT '业务员(可以多个)', `Salesman` varchar(50) DEFAULT NULL COMMENT '业务员(可以多个)',
`AccountIdList` varchar(50) DEFAULT NULL COMMENT '多账户ID列表', `AccountIdList` varchar(50) DEFAULT NULL COMMENT '多账户ID列表',
`AccountMoneyList` varchar(200) DEFAULT '' COMMENT '多账户金额列表', `AccountMoneyList` varchar(200) DEFAULT '' COMMENT '多账户金额列表',
`Discount` double DEFAULT NULL COMMENT '优惠率', `Discount` decimal(24, 6) DEFAULT NULL COMMENT '优惠率',
`DiscountMoney` double DEFAULT NULL COMMENT '优惠金额', `DiscountMoney` decimal(24, 6) DEFAULT NULL COMMENT '优惠金额',
`DiscountLastMoney` double DEFAULT NULL COMMENT '优惠后金额', `DiscountLastMoney` decimal(24, 6) DEFAULT NULL COMMENT '优惠后金额',
`OtherMoney` double DEFAULT NULL COMMENT '销售或采购费用合计', `OtherMoney` decimal(24, 6) DEFAULT NULL COMMENT '销售或采购费用合计',
`OtherMoneyList` varchar(200) DEFAULT NULL COMMENT '销售或采购费用涉及项目Id数组(包括快递、招待等)', `OtherMoneyList` varchar(200) DEFAULT NULL COMMENT '销售或采购费用涉及项目Id数组(包括快递、招待等)',
`OtherMoneyItem` varchar(200) DEFAULT NULL COMMENT '销售或采购费用涉及项目(包括快递、招待等)', `OtherMoneyItem` varchar(200) DEFAULT NULL COMMENT '销售或采购费用涉及项目(包括快递、招待等)',
`AccountDay` int(10) DEFAULT NULL COMMENT '结算天数', `AccountDay` int(10) DEFAULT NULL COMMENT '结算天数',
...@@ -484,19 +488,19 @@ CREATE TABLE `jsh_depotitem` ( ...@@ -484,19 +488,19 @@ CREATE TABLE `jsh_depotitem` (
`HeaderId` bigint(20) NOT NULL COMMENT '表头Id', `HeaderId` bigint(20) NOT NULL COMMENT '表头Id',
`MaterialId` bigint(20) NOT NULL COMMENT '材料Id', `MaterialId` bigint(20) NOT NULL COMMENT '材料Id',
`MUnit` varchar(20) DEFAULT NULL COMMENT '商品计量单位', `MUnit` varchar(20) DEFAULT NULL COMMENT '商品计量单位',
`OperNumber` double DEFAULT NULL COMMENT '数量', `OperNumber` decimal(24, 6) DEFAULT NULL COMMENT '数量',
`BasicNumber` double DEFAULT NULL COMMENT '基础数量,如kg、瓶', `BasicNumber` decimal(24, 6) DEFAULT NULL COMMENT '基础数量,如kg、瓶',
`UnitPrice` double DEFAULT NULL COMMENT '单价', `UnitPrice` decimal(24, 6) DEFAULT NULL COMMENT '单价',
`TaxUnitPrice` double DEFAULT NULL COMMENT '含税单价', `TaxUnitPrice` decimal(24, 6) DEFAULT NULL COMMENT '含税单价',
`AllPrice` double DEFAULT NULL COMMENT '金额', `AllPrice` decimal(24, 6) DEFAULT NULL COMMENT '金额',
`Remark` varchar(200) DEFAULT NULL COMMENT '描述', `Remark` varchar(200) DEFAULT NULL COMMENT '描述',
`Img` varchar(50) DEFAULT NULL COMMENT '图片', `Img` varchar(50) DEFAULT NULL COMMENT '图片',
`Incidentals` double DEFAULT NULL COMMENT '运杂费', `Incidentals` decimal(24, 6) DEFAULT NULL COMMENT '运杂费',
`DepotId` bigint(20) DEFAULT NULL COMMENT '仓库ID(库存是统计出来的)', `DepotId` bigint(20) DEFAULT NULL COMMENT '仓库ID(库存是统计出来的)',
`AnotherDepotId` bigint(20) DEFAULT NULL COMMENT '调拨时,对方仓库Id', `AnotherDepotId` bigint(20) DEFAULT NULL COMMENT '调拨时,对方仓库Id',
`TaxRate` double DEFAULT NULL COMMENT '税率', `TaxRate` decimal(24, 6) DEFAULT NULL COMMENT '税率',
`TaxMoney` double DEFAULT NULL COMMENT '税额', `TaxMoney` decimal(24, 6) DEFAULT NULL COMMENT '税额',
`TaxLastMoney` double DEFAULT NULL COMMENT '价税合计', `TaxLastMoney` decimal(24, 6) DEFAULT NULL COMMENT '价税合计',
`OtherField1` varchar(50) DEFAULT NULL COMMENT '自定义字段1-品名', `OtherField1` varchar(50) DEFAULT NULL COMMENT '自定义字段1-品名',
`OtherField2` varchar(50) DEFAULT NULL COMMENT '自定义字段2-型号', `OtherField2` varchar(50) DEFAULT NULL COMMENT '自定义字段2-型号',
`OtherField3` varchar(50) DEFAULT NULL COMMENT '自定义字段3-制造商', `OtherField3` varchar(50) DEFAULT NULL COMMENT '自定义字段3-制造商',
...@@ -4885,17 +4889,17 @@ CREATE TABLE `jsh_material` ( ...@@ -4885,17 +4889,17 @@ CREATE TABLE `jsh_material` (
`CategoryId` bigint(20) DEFAULT NULL COMMENT '产品类型', `CategoryId` bigint(20) DEFAULT NULL COMMENT '产品类型',
`Name` varchar(50) DEFAULT NULL COMMENT '名称', `Name` varchar(50) DEFAULT NULL COMMENT '名称',
`Mfrs` varchar(50) DEFAULT NULL COMMENT '制造商', `Mfrs` varchar(50) DEFAULT NULL COMMENT '制造商',
`Packing` double DEFAULT NULL COMMENT '包装(KG/包)', `Packing` decimal(24, 6) DEFAULT NULL COMMENT '包装(KG/包)',
`SafetyStock` double DEFAULT NULL COMMENT '安全存量(KG)', `SafetyStock` decimal(24, 6) DEFAULT NULL COMMENT '安全存量(KG)',
`Model` varchar(50) DEFAULT NULL COMMENT '型号', `Model` varchar(50) DEFAULT NULL COMMENT '型号',
`Standard` varchar(50) DEFAULT NULL COMMENT '规格', `Standard` varchar(50) DEFAULT NULL COMMENT '规格',
`Color` varchar(50) DEFAULT NULL COMMENT '颜色', `Color` varchar(50) DEFAULT NULL COMMENT '颜色',
`Unit` varchar(50) DEFAULT NULL COMMENT '单位-单个', `Unit` varchar(50) DEFAULT NULL COMMENT '单位-单个',
`Remark` varchar(100) DEFAULT NULL COMMENT '备注', `Remark` varchar(100) DEFAULT NULL COMMENT '备注',
`RetailPrice` double DEFAULT NULL COMMENT '零售价', `RetailPrice` decimal(24, 6) DEFAULT NULL COMMENT '零售价',
`LowPrice` double DEFAULT NULL COMMENT '最低售价', `LowPrice` decimal(24, 6) DEFAULT NULL COMMENT '最低售价',
`PresetPriceOne` double DEFAULT NULL COMMENT '预设售价一', `PresetPriceOne` decimal(24, 6) DEFAULT NULL COMMENT '预设售价一',
`PresetPriceTwo` double DEFAULT NULL COMMENT '预设售价二', `PresetPriceTwo` decimal(24, 6) DEFAULT NULL COMMENT '预设售价二',
`UnitId` bigint(20) DEFAULT NULL COMMENT '计量单位Id', `UnitId` bigint(20) DEFAULT NULL COMMENT '计量单位Id',
`FirstOutUnit` varchar(50) DEFAULT NULL COMMENT '首选出库单位', `FirstOutUnit` varchar(50) DEFAULT NULL COMMENT '首选出库单位',
`FirstInUnit` varchar(50) DEFAULT NULL COMMENT '首选入库单位', `FirstInUnit` varchar(50) DEFAULT NULL COMMENT '首选入库单位',
...@@ -5028,18 +5032,18 @@ CREATE TABLE `jsh_supplier` ( ...@@ -5028,18 +5032,18 @@ CREATE TABLE `jsh_supplier` (
`isystem` tinyint(4) DEFAULT NULL COMMENT '是否系统自带 0==系统 1==非系统', `isystem` tinyint(4) DEFAULT NULL COMMENT '是否系统自带 0==系统 1==非系统',
`type` varchar(20) DEFAULT NULL COMMENT '类型', `type` varchar(20) DEFAULT NULL COMMENT '类型',
`enabled` bit(1) DEFAULT NULL COMMENT '启用', `enabled` bit(1) DEFAULT NULL COMMENT '启用',
`AdvanceIn` double DEFAULT '0' COMMENT '预收款', `AdvanceIn` decimal(24, 6) DEFAULT '0' COMMENT '预收款',
`BeginNeedGet` double DEFAULT NULL COMMENT '期初应收', `BeginNeedGet` decimal(24, 6) DEFAULT NULL COMMENT '期初应收',
`BeginNeedPay` double DEFAULT NULL COMMENT '期初应付', `BeginNeedPay` decimal(24, 6) DEFAULT NULL COMMENT '期初应付',
`AllNeedGet` double DEFAULT NULL COMMENT '累计应收', `AllNeedGet` decimal(24, 6) DEFAULT NULL COMMENT '累计应收',
`AllNeedPay` double DEFAULT NULL COMMENT '累计应付', `AllNeedPay` decimal(24, 6) DEFAULT NULL COMMENT '累计应付',
`fax` varchar(30) DEFAULT NULL COMMENT '传真', `fax` varchar(30) DEFAULT NULL COMMENT '传真',
`telephone` varchar(30) DEFAULT NULL COMMENT '手机', `telephone` varchar(30) DEFAULT NULL COMMENT '手机',
`address` varchar(50) DEFAULT NULL COMMENT '地址', `address` varchar(50) DEFAULT NULL COMMENT '地址',
`taxNum` varchar(50) DEFAULT NULL COMMENT '纳税人识别号', `taxNum` varchar(50) DEFAULT NULL COMMENT '纳税人识别号',
`bankName` varchar(50) DEFAULT NULL COMMENT '开户行', `bankName` varchar(50) DEFAULT NULL COMMENT '开户行',
`accountNumber` varchar(50) DEFAULT NULL COMMENT '账号', `accountNumber` varchar(50) DEFAULT NULL COMMENT '账号',
`taxRate` double DEFAULT NULL COMMENT '税率', `taxRate` decimal(24, 6) DEFAULT NULL COMMENT '税率',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8 COMMENT='供应商/客户信息表'; ) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8 COMMENT='供应商/客户信息表';
   
......
...@@ -8,8 +8,11 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -8,8 +8,11 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication @SpringBootApplication
@MapperScan(basePackages = {"com.jsh.erp.datasource.mappers"}) @MapperScan(basePackages = {"com.jsh.erp.datasource.mappers"})
@EnableScheduling @EnableScheduling
public class ErpApplication { public class ErpApplication{
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(ErpApplication.class, args); SpringApplication.run(ErpApplication.class, args);
} }
} }
package com.jsh.erp.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.sql.DataSource;
@Configuration
@EnableTransactionManagement(proxyTargetClass = true)
public class DbConfig {
private static final Logger logger = LoggerFactory.getLogger(DbConfig.class);
@Bean(name = "erpDatasource")
@Primary
public DataSource erpDatasource(ErpDatasourceProperties properties){
try {
DruidDataSource datasource = new DruidDataSource();
datasource.setDriverClassName(properties.driverClassName);
datasource.setUrl(properties.url);
datasource.setUsername(properties.username);
datasource.setPassword(properties.password);
datasource.setInitialSize(1);
datasource.setMinIdle(1);
datasource.setMaxWait(60000);
datasource.setMaxActive(5);
datasource.setTimeBetweenEvictionRunsMillis(60000);
datasource.setValidationQuery("select '1'");
datasource.setTestOnBorrow(false);
datasource.setTestOnReturn(false);
datasource.setTestWhileIdle(true);
datasource.setPoolPreparedStatements(true);
datasource.setMaxOpenPreparedStatements(20);
datasource.setMinEvictableIdleTimeMillis(300000);
datasource.init();
return datasource;
}catch (Exception e){
logger.error("服务启动失败,jsh_erp数据库Datasource初始化失败:"+e.getMessage());
throw new IllegalArgumentException(e);
}
}
@Bean
@Primary
public JdbcTemplate jdbcTemplate(@Qualifier("erpDatasource") DataSource dataSource) {
return new JdbcTemplate(dataSource);
}
@Configuration
@ConfigurationProperties(prefix = "erpDatasource")
public static class ErpDatasourceProperties {
private String driverClassName;
private String url;
private String username;
private String password;
public String getDriverClassName() {
return driverClassName;
}
public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
}
...@@ -2,31 +2,24 @@ package com.jsh.erp.config; ...@@ -2,31 +2,24 @@ package com.jsh.erp.config;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.io.File; import java.io.File;
@Configuration //@Configuration
public class WebConfig { public class WebConfig {
private static final Logger logger = LoggerFactory.getLogger(WebConfig.class); private static final Logger logger = LoggerFactory.getLogger(WebConfig.class);
@Configuration @Configuration
@ConfigurationProperties(prefix = "web.front") public static class FrontEnd implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {
public static class FrontEnd implements EmbeddedServletContainerCustomizer { @Value("${web.front.baseDir}")
private File baseDir; private File baseDir;
public File getBaseDir() {
return baseDir;
}
public void setBaseDir(File baseDir) {
this.baseDir = baseDir;
}
@Override @Override
public void customize(ConfigurableEmbeddedServletContainer container) { public void customize(ConfigurableServletWebServerFactory factory) {
if (!baseDir.exists()) { if (!baseDir.exists()) {
if (!baseDir.mkdir()) { if (!baseDir.mkdir()) {
logger.info("create web.front base path:" + baseDir + " failed!already exists!"); logger.info("create web.front base path:" + baseDir + " failed!already exists!");
...@@ -34,7 +27,7 @@ public class WebConfig { ...@@ -34,7 +27,7 @@ public class WebConfig {
logger.info("create web.front base path:" + baseDir + " success!"); logger.info("create web.front base path:" + baseDir + " success!");
} }
} }
container.setDocumentRoot(baseDir); factory.setDocumentRoot(baseDir);
} }
} }
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
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.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -94,7 +95,7 @@ public class AccountController { ...@@ -94,7 +95,7 @@ public class AccountController {
public BaseResponseInfo findAccountInOutList(@RequestParam("currentPage") Integer currentPage, public BaseResponseInfo findAccountInOutList(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize, @RequestParam("pageSize") Integer pageSize,
@RequestParam("accountId") Long accountId, @RequestParam("accountId") Long accountId,
@RequestParam("initialAmount") Double initialAmount, @RequestParam("initialAmount") BigDecimal initialAmount,
HttpServletRequest request) { HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
...@@ -107,8 +108,8 @@ public class AccountController { ...@@ -107,8 +108,8 @@ public class AccountController {
if (null != dataList) { if (null != dataList) {
for (AccountVo4InOutList aEx : dataList) { for (AccountVo4InOutList aEx : dataList) {
String timeStr = aEx.getOperTime().toString(); String timeStr = aEx.getOperTime().toString();
Double balance = accountService.getAccountSum(accountId, timeStr, "date") + accountService.getAccountSumByHead(accountId, timeStr, "date") BigDecimal balance = accountService.getAccountSum(accountId, timeStr, "date").add(accountService.getAccountSumByHead(accountId, timeStr, "date"))
+ accountService.getAccountSumByDetail(accountId, timeStr, "date") + accountService.getManyAccountSum(accountId, timeStr, "date") + initialAmount; .add(accountService.getAccountSumByDetail(accountId, timeStr, "date")).add(accountService.getManyAccountSum(accountId, timeStr, "date")).add(initialAmount);
aEx.setBalance(balance); aEx.setBalance(balance);
dataArray.add(aEx); dataArray.add(aEx);
} }
......
...@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
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.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -69,7 +70,7 @@ public class AccountHeadController { ...@@ -69,7 +70,7 @@ public class AccountHeadController {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
try { try {
JSONObject outer = new JSONObject(); JSONObject outer = new JSONObject();
Double sum = 0.0; BigDecimal sum = BigDecimal.ZERO;
String getS = supplierId.toString(); String getS = supplierId.toString();
int i = 1; int i = 1;
if (supType.equals("customer")) { //客户 if (supType.equals("customer")) { //客户
...@@ -78,10 +79,14 @@ public class AccountHeadController { ...@@ -78,10 +79,14 @@ public class AccountHeadController {
i = -1; i = -1;
} }
//收付款部分 //收付款部分
sum = sum + (allMoney(getS, "付款", "合计",endTime) + allMoney(getS, "付款", "实际",endTime)) * i; // sum = sum + (allMoney(getS, "付款", "合计",endTime) + allMoney(getS, "付款", "实际",endTime)) * i;
sum = sum - (allMoney(getS, "收款", "合计",endTime) + allMoney(getS, "收款", "实际",endTime)) * i; sum = sum.add((allMoney(getS, "付款", "合计",endTime).add(allMoney(getS, "付款", "实际",endTime))).multiply(new BigDecimal(i)));
sum = sum + (allMoney(getS, "收入", "合计",endTime) - allMoney(getS, "收入", "实际",endTime)) * i; // sum = sum - (allMoney(getS, "收款", "合计",endTime) + allMoney(getS, "收款", "实际",endTime)) * i;
sum = sum - (allMoney(getS, "支出", "合计",endTime) - allMoney(getS, "支出", "实际",endTime)) * i; sum = sum.subtract((allMoney(getS, "收款", "合计",endTime).add(allMoney(getS, "收款", "实际",endTime))).multiply(new BigDecimal(i)));
// sum = sum + (allMoney(getS, "收入", "合计",endTime) - allMoney(getS, "收入", "实际",endTime)) * i;
sum = sum.add((allMoney(getS, "收入", "合计",endTime).subtract(allMoney(getS, "收入", "实际",endTime))).multiply(new BigDecimal(i)));
// sum = sum - (allMoney(getS, "支出", "合计",endTime) - allMoney(getS, "支出", "实际",endTime)) * i;
sum = sum.subtract((allMoney(getS, "支出", "合计",endTime).subtract(allMoney(getS, "支出", "实际",endTime))).multiply(new BigDecimal(i)));
outer.put("getAllMoney", sum); outer.put("getAllMoney", sum);
map.put("rows", outer); map.put("rows", outer);
res.code = 200; res.code = 200;
...@@ -96,7 +101,7 @@ public class AccountHeadController { ...@@ -96,7 +101,7 @@ public class AccountHeadController {
/** /**
* 根据编号查询单据信息 * 根据编号查询单据信息
* @param number * @param billNo
* @param request * @param request
* @return * @return
*/ */
...@@ -124,15 +129,15 @@ public class AccountHeadController { ...@@ -124,15 +129,15 @@ public class AccountHeadController {
* 统计总金额 * 统计总金额
* @param getS * @param getS
* @param type * @param type
* @param subType
* @param mode 合计或者金额 * @param mode 合计或者金额
* @param endTime
* @return * @return
*/ */
public Double allMoney(String getS, String type, String mode, String endTime) { public BigDecimal allMoney(String getS, String type, String mode, String endTime) {
Double allMoney = 0.0; BigDecimal allMoney = BigDecimal.ZERO;
try { try {
Integer supplierId = Integer.valueOf(getS); Integer supplierId = Integer.valueOf(getS);
Double sum = accountHeadService.findAllMoney(supplierId, type, mode, endTime); BigDecimal sum = accountHeadService.findAllMoney(supplierId, type, mode, endTime);
if(sum != null) { if(sum != null) {
allMoney = sum; allMoney = sum;
} }
...@@ -140,8 +145,8 @@ public class AccountHeadController { ...@@ -140,8 +145,8 @@ public class AccountHeadController {
e.printStackTrace(); e.printStackTrace();
} }
//返回正数,如果负数也转为正数 //返回正数,如果负数也转为正数
if (allMoney < 0) { if ((allMoney.compareTo(BigDecimal.ZERO))==-1) {
allMoney = -allMoney; allMoney = allMoney.abs();
} }
return allMoney; return allMoney;
} }
......
...@@ -9,11 +9,13 @@ import com.jsh.erp.utils.*; ...@@ -9,11 +9,13 @@ import com.jsh.erp.utils.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -31,7 +33,19 @@ public class AccountItemController { ...@@ -31,7 +33,19 @@ public class AccountItemController {
@Resource @Resource
private AccountItemService accountItemService; private AccountItemService accountItemService;
/**
* create by: cjl
* description:
* 业务逻辑操作放在service层,controller只做参数解析和视图封装
* create time: 2019/1/11 15:08
* @Param: inserted
 * @Param: deleted
 * @Param: updated
 * @Param: headerId
 * @Param: listType
 * @Param: request
* @return java.lang.String
*/
@PostMapping(value = "/saveDetials") @PostMapping(value = "/saveDetials")
public String saveDetials(@RequestParam("inserted") String inserted, public String saveDetials(@RequestParam("inserted") String inserted,
@RequestParam("deleted") String deleted, @RequestParam("deleted") String deleted,
...@@ -39,67 +53,10 @@ public class AccountItemController { ...@@ -39,67 +53,10 @@ public class AccountItemController {
@RequestParam("headerId") Long headerId, @RequestParam("headerId") Long headerId,
@RequestParam("listType") String listType, @RequestParam("listType") String listType,
HttpServletRequest request) { HttpServletRequest request) {
Map<String, Object> objectMap = new HashMap<String, Object>(); Map<String, Object> objectMap = new HashMap<String, Object>();
try { try {
//转为json accountItemService.saveDetials(inserted,deleted,updated,headerId,listType);
JSONArray insertedJson = JSONArray.parseArray(inserted);
JSONArray deletedJson = JSONArray.parseArray(deleted);
JSONArray updatedJson = JSONArray.parseArray(updated);
if (null != insertedJson) {
for (int i = 0; i < insertedJson.size(); i++) {
AccountItem accountItem = new AccountItem();
JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i));
accountItem.setHeaderid(headerId);
if (tempInsertedJson.get("AccountId") != null && !tempInsertedJson.get("AccountId").equals("")) {
accountItem.setAccountid(tempInsertedJson.getLong("AccountId"));
}
if (tempInsertedJson.get("InOutItemId") != null && !tempInsertedJson.get("InOutItemId").equals("")) {
accountItem.setInoutitemid(tempInsertedJson.getLong("InOutItemId"));
}
if (tempInsertedJson.get("EachAmount") != null && !tempInsertedJson.get("EachAmount").equals("")) {
Double eachAmount = tempInsertedJson.getDouble("EachAmount");
if (listType.equals("付款")) {
eachAmount = 0 - eachAmount;
}
accountItem.setEachamount(eachAmount);
} else {
accountItem.setEachamount(0.0);
}
accountItem.setRemark(tempInsertedJson.getString("Remark"));
accountItemService.insertAccountItemWithObj(accountItem);
}
}
if (null != deletedJson) {
for (int i = 0; i < deletedJson.size(); i++) {
JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i));
accountItemService.deleteAccountItem(tempDeletedJson.getLong("Id"));
}
}
if (null != updatedJson) {
for (int i = 0; i < updatedJson.size(); i++) {
JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i));
AccountItem accountItem = accountItemService.getAccountItem(tempUpdatedJson.getLong("Id"));
accountItem.setId(tempUpdatedJson.getLong("Id"));
accountItem.setHeaderid(headerId);
if (tempUpdatedJson.get("AccountId") != null && !tempUpdatedJson.get("AccountId").equals("")) {
accountItem.setAccountid(tempUpdatedJson.getLong("AccountId"));
}
if (tempUpdatedJson.get("InOutItemId") != null && !tempUpdatedJson.get("InOutItemId").equals("")) {
accountItem.setInoutitemid(tempUpdatedJson.getLong("InOutItemId"));
}
if (tempUpdatedJson.get("EachAmount") != null && !tempUpdatedJson.get("EachAmount").equals("")) {
Double eachAmount = tempUpdatedJson.getDouble("EachAmount");
if (listType.equals("付款")) {
eachAmount = 0 - eachAmount;
}
accountItem.setEachamount(eachAmount);
} else {
accountItem.setEachamount(0.0);
}
accountItem.setRemark(tempUpdatedJson.getString("Remark"));
accountItemService.updateAccountItemWithObj(accountItem);
}
}
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} catch (DataAccessException e) { } catch (DataAccessException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -130,8 +87,8 @@ public class AccountItemController { ...@@ -130,8 +87,8 @@ public class AccountItemController {
item.put("AccountName", ai.getAccountName()); item.put("AccountName", ai.getAccountName());
item.put("InOutItemId", ai.getInoutitemid()); item.put("InOutItemId", ai.getInoutitemid());
item.put("InOutItemName", ai.getInOutItemName()); item.put("InOutItemName", ai.getInOutItemName());
Double eachAmount = ai.getEachamount(); BigDecimal eachAmount = ai.getEachamount();
item.put("EachAmount", eachAmount < 0 ? 0 - eachAmount : eachAmount); item.put("EachAmount", (eachAmount.compareTo(BigDecimal.ZERO))==-1 ? BigDecimal.ZERO.subtract(eachAmount): eachAmount);
item.put("Remark", ai.getRemark()); item.put("Remark", ai.getRemark());
dataArray.add(item); dataArray.add(item);
} }
......
...@@ -17,7 +17,9 @@ import org.springframework.web.bind.annotation.*; ...@@ -17,7 +17,9 @@ import org.springframework.web.bind.annotation.*;
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.Date; import java.sql.Date;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -312,41 +314,42 @@ public class DepotHeadController { ...@@ -312,41 +314,42 @@ public class DepotHeadController {
dha.setNumber(dha.getNumber()); //单据编号 dha.setNumber(dha.getNumber()); //单据编号
dha.setType(dha.getType()); //类型 dha.setType(dha.getType()); //类型
String type = dha.getType(); String type = dha.getType();
Double p1 = 0.0; BigDecimal p1 = BigDecimal.ZERO ;
Double p2 = 0.0; BigDecimal p2 = BigDecimal.ZERO;
if (dha.getDiscountLastMoney() != null) { if (dha.getDiscountLastMoney() != null) {
p1 = dha.getDiscountLastMoney(); p1 = dha.getDiscountLastMoney();
} }
if (dha.getChangeAmount() != null) { if (dha.getChangeAmount() != null) {
p2 = dha.getChangeAmount(); p2 = dha.getChangeAmount();
} }
Double allPrice = 0.0; BigDecimal allPrice = BigDecimal.ZERO;
if (p1 < 0) { if ((p1.compareTo(BigDecimal.ZERO))==-1) {
p1 = -p1; p1 = p1.abs();
} }
if (p2 < 0) { if ((p2 .compareTo(BigDecimal.ZERO))==-1) {
p2 = -p2; p2 = p2.abs();
} }
if (type.equals("采购入库")) { if (type.equals("采购入库")) {
allPrice = -(p1 - p2); allPrice = p2 .subtract(p1);
} else if (type.equals("销售退货入库")) { } else if (type.equals("销售退货入库")) {
allPrice = -(p1 - p2); allPrice = p2 .subtract(p1);
} else if (type.equals("销售出库")) { } else if (type.equals("销售出库")) {
allPrice = p1 - p2; allPrice = p1 .subtract(p2);
} else if (type.equals("采购退货出库")) { } else if (type.equals("采购退货出库")) {
allPrice = p1 - p2; allPrice = p1 .subtract(p2);
} else if (type.equals("付款")) { } else if (type.equals("付款")) {
allPrice = p1 + p2; allPrice = p1.add(p2);
} else if (type.equals("收款")) { } else if (type.equals("收款")) {
allPrice = -(p1 + p2); allPrice = BigDecimal.ZERO.subtract(p1.add(p2));
} else if (type.equals("收入")) { } else if (type.equals("收入")) {
allPrice = p1 - p2; allPrice = p1 .subtract(p2);
} else if (type.equals("支出")) { } else if (type.equals("支出")) {
allPrice = -(p1 - p2); allPrice = p2 .subtract(p1);
} }
dha.setDiscountLastMoney(p1); //金额 dha.setDiscountLastMoney(p1); //金额
dha.setChangeAmount(p2); //金额 dha.setChangeAmount(p2); //金额
dha.setAllPrice(Double.parseDouble(String.format("%.2f", allPrice * j))); //计算后的金额 DecimalFormat df = new DecimalFormat(".##");
dha.setAllPrice(new BigDecimal(df.format(allPrice .multiply(new BigDecimal(j))))); //计算后的金额
dha.setSupplierName(dha.getSupplierName()); //供应商 dha.setSupplierName(dha.getSupplierName()); //供应商
dha.setoTime(dha.getoTime()); //入库出库日期 dha.setoTime(dha.getoTime()); //入库出库日期
resList.add(dha); resList.add(dha);
...@@ -380,7 +383,7 @@ public class DepotHeadController { ...@@ -380,7 +383,7 @@ public class DepotHeadController {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
try { try {
JSONObject outer = new JSONObject(); JSONObject outer = new JSONObject();
Double sum = 0.0; BigDecimal sum = BigDecimal.ZERO;
String getS = supplierId.toString(); String getS = supplierId.toString();
int i = 1; int i = 1;
if (supType.equals("customer")) { //客户 if (supType.equals("customer")) { //客户
...@@ -389,10 +392,14 @@ public class DepotHeadController { ...@@ -389,10 +392,14 @@ public class DepotHeadController {
i = -1; i = -1;
} }
//进销部分 //进销部分
sum = sum - (allMoney(getS, "入库", "采购", "合计",endTime) - allMoney(getS, "入库", "采购", "实际",endTime)) * i; // sum = sum - (allMoney(getS, "入库", "采购", "合计",endTime) - allMoney(getS, "入库", "采购", "实际",endTime)) * i;
sum = sum - (allMoney(getS, "入库", "销售退货", "合计",endTime) - allMoney(getS, "入库", "销售退货", "实际",endTime)) * i; sum = sum.subtract((allMoney(getS, "入库", "采购", "合计",endTime).subtract(allMoney(getS, "入库", "采购", "实际",endTime))).multiply(new BigDecimal(i)));
sum = sum + (allMoney(getS, "出库", "销售", "合计",endTime) - allMoney(getS, "出库", "销售", "实际",endTime)) * i; // sum = sum - (allMoney(getS, "入库", "销售退货", "合计",endTime) - allMoney(getS, "入库", "销售退货", "实际",endTime)) * i;
sum = sum + (allMoney(getS, "出库", "采购退货", "合计",endTime) - allMoney(getS, "出库", "采购退货", "实际",endTime)) * i; sum = sum.subtract((allMoney(getS, "入库", "销售退货", "合计",endTime).subtract(allMoney(getS, "入库", "销售退货", "实际",endTime))).multiply(new BigDecimal(i)));
// sum = sum + (allMoney(getS, "出库", "销售", "合计",endTime) - allMoney(getS, "出库", "销售", "实际",endTime)) * i;
sum = sum.add((allMoney(getS, "出库", "销售", "合计",endTime).subtract(allMoney(getS, "出库", "销售", "实际",endTime))).multiply(new BigDecimal(i)));
// sum = sum + (allMoney(getS, "出库", "采购退货", "合计",endTime) - allMoney(getS, "出库", "采购退货", "实际",endTime)) * i;
sum = sum.add((allMoney(getS, "出库", "采购退货", "合计",endTime).subtract(allMoney(getS, "出库", "采购退货", "实际",endTime))).multiply(new BigDecimal(i)));
outer.put("getAllMoney", sum); outer.put("getAllMoney", sum);
map.put("rows", outer); map.put("rows", outer);
res.code = 200; res.code = 200;
...@@ -440,11 +447,11 @@ public class DepotHeadController { ...@@ -440,11 +447,11 @@ public class DepotHeadController {
* @param mode 合计或者金额 * @param mode 合计或者金额
* @return * @return
*/ */
public Double allMoney(String getS, String type, String subType, String mode, String endTime) { public BigDecimal allMoney(String getS, String type, String subType, String mode, String endTime) {
Double allMoney = 0.0; BigDecimal allMoney = BigDecimal.ZERO;
try { try {
Integer supplierId = Integer.valueOf(getS); Integer supplierId = Integer.valueOf(getS);
Double sum = depotHeadService.findAllMoney(supplierId, type, subType, mode, endTime); BigDecimal sum = depotHeadService.findAllMoney(supplierId, type, subType, mode, endTime);
if(sum != null) { if(sum != null) {
allMoney = sum; allMoney = sum;
} }
...@@ -452,8 +459,8 @@ public class DepotHeadController { ...@@ -452,8 +459,8 @@ public class DepotHeadController {
e.printStackTrace(); e.printStackTrace();
} }
//返回正数,如果负数也转为正数 //返回正数,如果负数也转为正数
if (allMoney < 0) { if ((allMoney.compareTo(BigDecimal.ZERO))==-1) {
allMoney = -allMoney; allMoney = allMoney.abs();
} }
return allMoney; return allMoney;
} }
......
...@@ -18,6 +18,7 @@ import javax.annotation.Resource; ...@@ -18,6 +18,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -270,19 +271,19 @@ public class MaterialController { ...@@ -270,19 +271,19 @@ public class MaterialController {
for (int i = 1; i < src.getRows(); i++) { for (int i = 1; i < src.getRows(); i++) {
Material m = new Material(); Material m = new Material();
m.setName(ExcelUtils.getContent(src, i, 0)); m.setName(ExcelUtils.getContent(src, i, 0));
m.setCategoryid(1l); //根目录 m.setCategoryid(1L); //根目录
m.setModel(ExcelUtils.getContent(src, i, 2)); m.setModel(ExcelUtils.getContent(src, i, 2));
String safetyStock = ExcelUtils.getContent(src, i, 3); String safetyStock = ExcelUtils.getContent(src, i, 3);
m.setSafetystock(parseDoubleEx(safetyStock)); m.setSafetystock(parseBigDecimalEx(safetyStock));
m.setUnit(ExcelUtils.getContent(src, i, 4)); m.setUnit(ExcelUtils.getContent(src, i, 4));
String retailprice = ExcelUtils.getContent(src, i, 5); String retailprice = ExcelUtils.getContent(src, i, 5);
m.setRetailprice(parseDoubleEx(retailprice)); m.setRetailprice(parseBigDecimalEx(retailprice));
String lowPrice = ExcelUtils.getContent(src, i, 6); String lowPrice = ExcelUtils.getContent(src, i, 6);
m.setLowprice(parseDoubleEx(lowPrice)); m.setLowprice(parseBigDecimalEx(lowPrice));
String presetpriceone = ExcelUtils.getContent(src, i, 7); String presetpriceone = ExcelUtils.getContent(src, i, 7);
m.setPresetpriceone(parseDoubleEx(presetpriceone)); m.setPresetpriceone(parseBigDecimalEx(presetpriceone));
String presetpricetwo = ExcelUtils.getContent(src, i, 8); String presetpricetwo = ExcelUtils.getContent(src, i, 8);
m.setPresetpricetwo(parseDoubleEx(presetpricetwo)); m.setPresetpricetwo(parseBigDecimalEx(presetpricetwo));
m.setRemark(ExcelUtils.getContent(src, i, 9)); m.setRemark(ExcelUtils.getContent(src, i, 9));
String enabled = ExcelUtils.getContent(src, i, 10); String enabled = ExcelUtils.getContent(src, i, 10);
m.setEnabled(enabled.equals("启用")? true: false); m.setEnabled(enabled.equals("启用")? true: false);
...@@ -299,9 +300,9 @@ public class MaterialController { ...@@ -299,9 +300,9 @@ public class MaterialController {
response.sendRedirect("../pages/materials/material.html"); response.sendRedirect("../pages/materials/material.html");
} }
public Double parseDoubleEx(String str){ public BigDecimal parseBigDecimalEx(String str){
if(!StringUtil.isEmpty(str)) { if(!StringUtil.isEmpty(str)) {
return Double.parseDouble(str); return new BigDecimal(str);
} else { } else {
return null; return null;
} }
......
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