Commit ec062bbf by kangxiaoshan

1

parent 7db24d88
...@@ -55,6 +55,7 @@ public class Contract { ...@@ -55,6 +55,7 @@ public class Contract {
private Long firstBackId;//先回款记录的id private Long firstBackId;//先回款记录的id
/** /**
* 新增字段 20190427 * 新增字段 20190427
*/ */
...@@ -73,6 +74,8 @@ public class Contract { ...@@ -73,6 +74,8 @@ public class Contract {
private String erroMessage; private String erroMessage;
private String tradeName;
@Id @Id
@GeneratedValue @GeneratedValue
...@@ -432,6 +435,15 @@ public class Contract { ...@@ -432,6 +435,15 @@ public class Contract {
this.typeId = typeId; this.typeId = typeId;
} }
@Transient
public String getTradeName() {
return tradeName;
}
public void setTradeName(String tradeName) {
this.tradeName = tradeName;
}
// public String getCreaterName() { // public String getCreaterName() {
// return createrName; // return createrName;
// } // }
......
...@@ -2,7 +2,6 @@ package common.service.impl; ...@@ -2,7 +2,6 @@ package common.service.impl;
import adi.model.ADIUser; import adi.model.ADIUser;
import adi.service.ADIAccountService; import adi.service.ADIAccountService;
import common.jdbc.ContractDao;
import common.model.*; import common.model.*;
import common.repository.*; import common.repository.*;
import common.service.AuthService; import common.service.AuthService;
...@@ -16,15 +15,11 @@ import net.sf.json.JSONArray; ...@@ -16,15 +15,11 @@ import net.sf.json.JSONArray;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import tkio.model.Account; import tkio.model.Account;
...@@ -37,11 +32,9 @@ import tkio.service.AccountService; ...@@ -37,11 +32,9 @@ import tkio.service.AccountService;
import tkio.service.TkioAccountService; import tkio.service.TkioAccountService;
import userio.service.AccountIOService; import userio.service.AccountIOService;
import userio.service.IOAccountService; import userio.service.IOAccountService;
import util.*;
import util.DateUtil; import util.DateUtil;
import util.*;
import javax.sql.DataSource;
import javax.transaction.Transaction;
import java.beans.BeanInfo; import java.beans.BeanInfo;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.beans.Introspector; import java.beans.Introspector;
...@@ -51,6 +44,8 @@ import java.lang.reflect.InvocationTargetException; ...@@ -51,6 +44,8 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -94,6 +89,21 @@ public class ContractServiceImpl implements ContractService { ...@@ -94,6 +89,21 @@ public class ContractServiceImpl implements ContractService {
put("签约销售", "sale"); put("签约销售", "sale");
}}; }};
private static final Map<String, String> SHEET_TITLE_RESERVE = new HashMap() {{
put("my_body_name", "我方签约主体");
put("customer_body", "客户签约主体");
put("trade_type", "行业分类");
put("money", "合同金额");
put("email", "客户主账号");
put("contract_code", "合同编号");
put("contract_type", "签约类型");
put("price_level", "套餐");
put("type_id", "合同类型");
put("start_date", "合同开始日期");
put("end_date", "合同结束日期");
put("sale", "签约销售");
}};
public static final String UPLOAD_TITLE = "我方签约主体,客户签约主体,行业分类,合同开始日期,合同结束日期," + public static final String UPLOAD_TITLE = "我方签约主体,客户签约主体,行业分类,合同开始日期,合同结束日期," +
"签约销售,客户主账号,合同编号,签约类型,套餐,合同金额"; "签约销售,客户主账号,合同编号,签约类型,套餐,合同金额";
...@@ -1243,10 +1253,14 @@ public class ContractServiceImpl implements ContractService { ...@@ -1243,10 +1253,14 @@ public class ContractServiceImpl implements ContractService {
// 获取字典数据 // 获取字典数据
this.getDicMapDatas(saleMap, typeMap, null, null, packageBaseMap, platform); this.getDicMapDatas(saleMap, typeMap, null, null, packageBaseMap, platform);
Map<String, String> bodyMap = contractBodyRepository.findAllCodeDis().stream().collect(Collectors.toMap(ContractBody::getCode, ContractBody::getName));
Map<Long,String> tradeTypeMap = tradeTypeRepsitory.findAll().stream().collect(Collectors.toMap(TradeType::getId, TradeType::getName));
if (ValidateUtil.isValid(contractList)) { if (ValidateUtil.isValid(contractList)) {
for (Contract c : contractList) { for (Contract c : contractList) {
c.setMyBodyName(bodyMap.get(c.getMyBodyCode()));
c.setTradeName(tradeTypeMap.get(c.getTradeType()));
if ((c.getExtraFlow() != null && c.getExtraFlow() > 0) || if ((c.getExtraFlow() != null && c.getExtraFlow() > 0) ||
(c.getDiscountTimeLong() != null && c.getDiscountTimeLong() > 0)) { (c.getDiscountTimeLong() != null && c.getDiscountTimeLong() > 0)) {
...@@ -2106,7 +2120,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -2106,7 +2120,7 @@ public class ContractServiceImpl implements ContractService {
return ResultModel.ERROR("模板标签页名称错误"); return ResultModel.ERROR("模板标签页名称错误");
} }
if (sheetName.equals(platformexcl)) { if (!sheetName.equalsIgnoreCase(platformexcl)) {
return ResultModel.ERROR("请上传对应项目模板处理的数据"); return ResultModel.ERROR("请上传对应项目模板处理的数据");
} }
...@@ -2155,15 +2169,18 @@ public class ContractServiceImpl implements ContractService { ...@@ -2155,15 +2169,18 @@ public class ContractServiceImpl implements ContractService {
Object[] s_data = new Object[titleKey.size() + extend_size]; Object[] s_data = new Object[titleKey.size() + extend_size];
String bodyCode = null; String bodyCode = null;
String ds = null; String ds = null;
if (row_data == null) {
continue;
}
for (int w = 0; w < titleKey.size(); w++) { for (int w = 0; w < titleKey.size(); w++) {
String sheetTitle = titleKey.get(w); String sheetTitle = titleKey.get(w);
Cell cell = row_data.getCell(w); Cell cell = row_data.getCell(w);
int line_num = j + 1;
if (null == cell || cell.getCellTypeEnum().equals(CellType.BLANK)) { if (null == cell || cell.getCellTypeEnum().equals(CellType.BLANK)) {
return ResultModel.ERROR(ResultStatus.UPLOAD_CONTENT_ERRO); return ResultModel.ERROR("第" + line_num + "行[" + SHEET_TITLE_RESERVE.get(sheetTitle) + "]不能为空");
} else { } else {
String dataSTR = formatter.formatCellValue(cell); String dataSTR = formatter.formatCellValue(cell).trim();
int line_num = j + 1;
if ("my_body_name".equals(sheetTitle)) { if ("my_body_name".equals(sheetTitle)) {
if (!cBodyMap.containsKey(dataSTR)) { if (!cBodyMap.containsKey(dataSTR)) {
...@@ -2199,21 +2216,30 @@ public class ContractServiceImpl implements ContractService { ...@@ -2199,21 +2216,30 @@ public class ContractServiceImpl implements ContractService {
} }
} else if ("start_date".equals(sheetTitle) || "end_date".equals(sheetTitle)) { } else if ("start_date".equals(sheetTitle) || "end_date".equals(sheetTitle)) {
String dfmate = cell.getCellStyle().getDataFormatString(); String dfmate = cell.getCellStyle().getDataFormatString();
if ("yyyy/m/d;@".equals(dfmate) && "yyyy\\-mm\\-dd".equals(dfmate)) {
if (!"yyyy/mm;@".equals(dfmate)
&& !"m/d/yy".equals(dfmate)
&& !"yy/m/d".equals(dfmate)
&& !"mm/dd/yy".equals(dfmate)
&& !"dd-mmm-yy".equals(dfmate)
&& !"yyyy/m/d".equals(dfmate)
) {
return ResultModel.ERROR("第" + line_num + "行[日期单元格]错误"); return ResultModel.ERROR("第" + line_num + "行[日期单元格]错误");
} }
try {
String pattern = "yyyy/MM/dd";
DateTime dateTime = DateTime.parse(dataSTR, DateTimeFormat.forPattern(pattern));
s_data[w] = dateTime.toString("yyyy-MM-dd");
if ("start_date".equals(sheetTitle)) { if (org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell)) {
ds = s_data[w].toString(); // 用于转化为日期格式
} Date d = cell.getDateCellValue();
DateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
s_data[w] = formater.format(d);
} else {
s_data[w] = cell.toString();
}
} catch (Exception e) { if ("start_date".equals(sheetTitle)) {
return ResultModel.ERROR("第" + line_num + "行[日期]错误"); ds = s_data[w].toString();
} }
} else { } else {
s_data[w] = dataSTR; s_data[w] = dataSTR;
} }
......
Markdown is supported
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