|
@@ -1,12 +1,19 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
import java.util.List;
|
|
|
+
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.common.utils.bean.BeanValidators;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.ruoyi.system.mapper.ContractTableMapper;
|
|
|
import com.ruoyi.system.domain.ContractTable;
|
|
|
import com.ruoyi.system.service.IContractTableService;
|
|
|
|
|
|
+import javax.validation.Validator;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* B类Service业务层处理
|
|
|
*
|
|
@@ -19,6 +26,10 @@ public class ContractTableServiceImpl implements IContractTableService
|
|
|
@Autowired
|
|
|
private ContractTableMapper contractTableMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ protected Validator validator;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 查询B类
|
|
|
*
|
|
@@ -90,4 +101,61 @@ public class ContractTableServiceImpl implements IContractTableService
|
|
|
{
|
|
|
return contractTableMapper.deleteContractTableById(id);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String importCon(List<ContractTable> stuList, Boolean isUpdateSupport, String operName) {
|
|
|
+ if (StringUtils.isNull(stuList) || stuList.size() == 0)
|
|
|
+ {
|
|
|
+ throw new ServiceException("导入B类证书基本信息数据不能为空!");
|
|
|
+ }
|
|
|
+ int successNum = 0;
|
|
|
+ int failureNum = 0;
|
|
|
+ StringBuilder successMsg = new StringBuilder();
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
+ for (ContractTable con : stuList)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ // 验证是否存在这个用户
|
|
|
+ ContractTable u = contractTableMapper.selectContractTableByCode(con.getdCode());
|
|
|
+ if (StringUtils.isNull(u))
|
|
|
+ {
|
|
|
+ BeanValidators.validateWithException(validator, con);
|
|
|
+ con.setCreateBy(operName);
|
|
|
+ this.insertContractTable(con);
|
|
|
+ successNum++;
|
|
|
+ successMsg.append("<br/>" + successNum + "、身份证或者编码 " + con.getdCode() + " 导入成功");
|
|
|
+ }
|
|
|
+ else if (isUpdateSupport)
|
|
|
+ {
|
|
|
+ BeanValidators.validateWithException(validator, con);
|
|
|
+ con.setUpdateBy(operName);
|
|
|
+ this.updateContractTable(con);
|
|
|
+ successNum++;
|
|
|
+ successMsg.append("<br/>" + successNum + "、身份证或者编码 " + con.getdCode() + " 更新成功");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>" + failureNum + "、身份证或者编码 " + con.getdCode() + " 已存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ failureNum++;
|
|
|
+ String msg = "<br/>" + failureNum + "、身份证或者编码 " + con.getdCode() + " 导入失败:";
|
|
|
+ failureMsg.append(msg + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (failureNum > 0)
|
|
|
+ {
|
|
|
+ failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
+ throw new ServiceException(failureMsg.toString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
+ }
|
|
|
+ return successMsg.toString();
|
|
|
+ }
|
|
|
}
|