Commit b85d4d23 by kangxiaoshan

合同上传校验合同编号

parent 63cf5fa6
......@@ -92,7 +92,7 @@
<profile>
<id>test</id>
<properties>
<label>product</label>
<label>dev</label>
<!--数据源配置-->
<datasource.driver>com.mysql.jdbc.Driver</datasource.driver>
<!--//office-->
......
......@@ -119,4 +119,7 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value = "select contract_code from contract where customer_body =?1 and contract_code <> ?2 and status in ('backfirst','normal','late') limit 3 ", nativeQuery = true)
List<String> findContractBodyNames(String customerBody, String contractCode);
@Query(value = "select count(*) from contract where contract_code=?1 ", nativeQuery = true)
int checkByCode(String code);
}
......@@ -1341,7 +1341,6 @@ public class ContractServiceImpl implements ContractService {
}
// if (c.getType().equals(ContractTypeEnum.MAIN.getKey()) && platform.contains("io")) {
//
// } else if (c.getType().equals(ContractTypeEnum.MAIN.getKey())) {
......@@ -2247,6 +2246,7 @@ public class ContractServiceImpl implements ContractService {
int rowNumber = sheet.getLastRowNum();
List<Object[]> args_data = new ArrayList<>();
Map<String, String> codeUniqueDic = new HashMap<>();
for (int j = 1; j <= rowNumber; j++) {
Row row_data = sheet.getRow(j);
Object[] s_data = new Object[titleKey.size() + extend_size];
......@@ -2261,9 +2261,25 @@ public class ContractServiceImpl implements ContractService {
Cell cell = row_data.getCell(w);
int line_num = j + 1;
if (null == cell || cell.getCellTypeEnum().equals(CellType.BLANK)) {
return ResultModel.ERROR("第" + line_num + "行[" + SHEET_TITLE_RESERVE.get(sheetTitle) + "]不能为空");
return ResultModel.ERROR("第" + line_num + "行[" +
SHEET_TITLE_RESERVE.get(sheetTitle) + "]不能为空,请重新上传");
} else {
String dataSTR = formatter.formatCellValue(cell).trim();
//校验合同编号
if ("contract_code".equals(sheetTitle)) {
if (!codeUniqueDic.containsKey(dataSTR)) {
codeUniqueDic.put(dataSTR, "1");
} else {
return ResultModel.ERROR(ResultStatus.CCODE_EXITS.getCode(),
"合同编号[" + dataSTR + "]已存在,请重新上传");
}
int countCode = contractRepository.checkByCode(dataSTR);
if (countCode > 0) {
return ResultModel.ERROR(ResultStatus.CCODE_EXITS.getCode(),
"合同编号[" + dataSTR + "]已存在,请重新上传");
}
}
if ("my_body_name".equals(sheetTitle)) {
if (!cBodyMap.containsKey(dataSTR)) {
......
......@@ -67,6 +67,10 @@ public class ResultModel {
return new ResultModel(errorMessage);
}
public static ResultModel ERROR(int code,String errorMessage) {
return new ResultModel(code,errorMessage);
}
public int getCode() {
return code;
}
......
......@@ -55,7 +55,9 @@ public enum ResultStatus {
EXP_INVALID(11000, "自定义表达式错误"),
NONE_FILE_EXIST(-1000, "上传文件为空"),
FORMAT_FILE_ERRO(-10001, "模板文件格式错误"),
UPLOAD_CONTENT_ERRO(-10002, "模板文件内容错误");
UPLOAD_CONTENT_ERRO(-10002, "模板文件内容错误"),
CCODE_EXITS(-10003, "合同编号已存在");
/**
......
......@@ -45,15 +45,12 @@
<bean id="parentDataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<property name="driverClassName" value="${dataSource.driverClassName}"/>
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="1"/>
<property name="minIdle" value="1"/>
<property name="maxActive" value="20"/>
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="60000"/>
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="300000"/>
</bean>
......
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