Commit 81f87eee authored by huyuchen's avatar huyuchen

huyc 项目档案代码提交

parent f0bd1301
package com.yifu.cloud.plus.v1.yifu.archives.util;
import lombok.extern.slf4j.Slf4j;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.compile;
/**
* 身份证处理
* @Author fxj
* @Date 2019-11-15
* @return
**/
@Slf4j
public class IdCardUtil {
public static int IdNOToAge(String IdNO){
int leh = IdNO.length();
Date dates=null;
SimpleDateFormat df = new SimpleDateFormat("yyyy");
String year=df.format(new Date());
dates = getBirthdate(IdNO);
int u=Integer.parseInt(year)-Integer.parseInt(df.format(dates));
return u;
}
/**
* 提取身份证中的出生日期,身份证非法则返回空
* @param idNum
* @return
*/
public static Date getBirthdate(String idNum){
Pattern idNumPattern = null;
Matcher idNumMatcher = null;
Date date = null;
//定义判别用户身份证号的正则表达式(要么是15位,要么是18位,最后一位可以为字母)
idNumPattern = compile("(\\d{14}[0-9a-zA-Z])|(\\d{17}[0-9a-zA-Z])");
//通过Pattern获得Matcher
idNumMatcher = idNumPattern.matcher(idNum);
//判断用户输入是否为身份证号
if(idNumMatcher.matches()){
Pattern birthDatePattern =null;
Matcher birthDateMather = null;
String year = null;
if(idNum.length()==18){
//如果是,定义正则表达式提取出身份证中的出生日期
birthDatePattern= compile("\\d{6}(\\d{4})(\\d{2})(\\d{2}).*");//身份证上的前6位以及出生年月日
//通过Pattern获得Matcher
birthDateMather= birthDatePattern.matcher(idNum);
}else if(idNum.length()==15){
//如果是,定义正则表达式提取出身份证中的出生日期
birthDatePattern= compile("\\d{6}(\\d{2})(\\d{2})(\\d{2}).*");//身份证上的前6位以及出生年月日
//通过Pattern获得Matcher
birthDateMather= birthDatePattern.matcher(idNum);
}
//通过Matcher获得用户的出生年月日
if(birthDateMather.find()){
if(idNum.length()==18){
year = birthDateMather.group(1);
}else if(idNum.length()==15){
year = "19"+birthDateMather.group(1);
}
String month = birthDateMather.group(2);
String datetemp = birthDateMather.group(3);
String dateStr =year+"-"+month+"-"+datetemp;
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd" );
Date shijian = null;
try {
shijian =sdf.parse(dateStr);
String temp = sdf.format(shijian);
if(dateStr.equals(temp)){
//输出用户的出生年月日
date = shijian;
}
} catch (ParseException e) {
//数据有误
}
}
}
return date;
}
/**
* 获取身份证的性别
* @Author fxj
* @Date 2019-12-25
* @param idNum
* @return
**/
public static String getSex(String idNum){
Pattern idNumPattern = null;
Matcher idNumMatcher = null;
Date date = null;
//定义判别用户身份证号的正则表达式(要么是15位,要么是18位,最后一位可以为字母)
idNumPattern = compile("(\\d{14}[0-9a-zA-Z])|(\\d{17}[0-9a-zA-Z])");
//通过Pattern获得Matcher
idNumMatcher = idNumPattern.matcher(idNum);
//判断用户输入是否为身份证号
String sex = null;
if(idNumMatcher.matches()) {
if (idNum.length() == 18) {
if (Integer.parseInt(idNum.substring(16).substring(0, 1)) % 2 == 0) {// 判断性别
sex = "2";
} else {
sex = "1";
}
} else if (idNum.length() == 15) {
if (Integer.parseInt(idNum.substring(14, 15)) % 2 == 0) {
sex = "2";
} else {
sex = "1";
}
}
}
return sex;
}
}
package com.yifu.cloud.plus.v1.yifu.archives.config;
import com.yifu.cloud.plus.v1.yifu.archives.utils.FddUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class FddAutoConfigue {
@Bean
public FddUtil getFddUtils() {
return new FddUtil();
}
}
......@@ -17,12 +17,21 @@
package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem;
import com.yifu.cloud.plus.v1.yifu.archives.Constants.EmployeeConstants;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractAttachInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.FddContractAttachInfoService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprUpmsProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
......@@ -31,6 +40,11 @@ import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 法大大合同附属信息表
......@@ -43,10 +57,14 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping("/fddcontractattachinfo" )
@Tag(name = "法大大合同附属信息表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
@Slf4j
@EnableConfigurationProperties(DaprUpmsProperties.class)
public class FddContractAttachInfoController {
private final FddContractAttachInfoService fddContractAttachInfoService;
private final DaprUpmsProperties daprUpmsProperties;
/**
* 分页查询
* @param page 分页对象
......@@ -55,7 +73,6 @@ public class FddContractAttachInfoController {
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('demo_fddcontractattachinfo_get')" )
public R getFddContractAttachInfoPage(Page page, FddContractAttachInfo fddContractAttachInfo) {
return R.ok(fddContractAttachInfoService.getFddContractAttachInfoPage(page, fddContractAttachInfo));
}
......@@ -67,7 +84,6 @@ public class FddContractAttachInfoController {
*/
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('demo_fddcontractattachinfo_get')")
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('demo_fddcontractattachinfo_get')" )
public R getById(@PathVariable("id" ) String id) {
return R.ok(fddContractAttachInfoService.getById(id));
}
......@@ -111,4 +127,126 @@ public class FddContractAttachInfoController {
return R.ok(fddContractAttachInfoService.removeById(id));
}
/**
* @param jsonString
* @Author: huyc
* @Date: 2022/6/30
* @Description: 法大大合同基础信息更新
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.Boolean>
**/
@Operation(summary = "法大大合同基础信息新增", description = "法大大合同基础信息新增")
@SysLog("法大大合同基础信息新增")
@PostMapping("/batchAddFddEmpInfo")
public R batchAddFddEmpInfo(@RequestBody String jsonString) {
R<List<SysDictItem>> res = null;
ExcelUtil<FddContractAttachInfo> util1 = null;
try {
// 调用字典服务,渲染字典值
res = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(), daprUpmsProperties.getAppId()
, "/dict/inner/getDictList", null, Map.class, SecurityConstants.FROM_IN);
Map<String, String> dicMap = new HashMap<>();
if (null != res.getData()) {
for (SysDictItem dict : res.getData()) {
dicMap.put(dict.getType() + CommonConstants.DOWN_LINE_STRING + dict.getLabel(), dict.getValue());
}
}
jsonString = URLDecoder.decode(jsonString, CommonConstants.UTF8).replace("=", "");
util1 = new ExcelUtil<>(FddContractAttachInfo.class);
//传参字典数据MAP具体见方法实现
util1.getJsonStringToList(jsonString, dicMap);
if (null != util1.getErrorInfo() && !util1.getErrorInfo().isEmpty()) {
return R.failed(util1.getErrorInfo(),"数据异常");
} else {
if (null != util1.getEntityList()) {
List<ErrorMessage> errorInfo = fddContractAttachInfoService.batchAdd(util1.getEntityList());
Map<String,Object> variableMap = new HashMap<>();
Map<Integer,Object> map = new HashMap<>();
boolean allExitContract = errorInfo.stream().allMatch(e-> e.getMessage().equals("存在“在用”的合同"));
if (allExitContract) {
variableMap.put("allMatch","true");
for (ErrorMessage errorMessage :errorInfo){
map.put(errorMessage.getLineNum(),util1.getEntityList().get(errorMessage.getLineNum()-2));
}
variableMap.put("data",map);
}
return R.ok(variableMap);
} else {
return R.ok(null,"无数据可导入");
}
}
} catch (Exception e) {
log.error(e.getMessage());
return R.failed("导入数据失败");
}
}
/**
* @param jsonString
* @Author: huyc
* @Date: 2022/6/30
* @Description: 法大大合同基础信息更新
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.Boolean>
**/
@Operation(summary = "法大大合同基础信息更新", description = "法大大合同基础信息更新")
@SysLog("法大大合同基础信息更新")
@PostMapping("/batchUpdateFddEmpInfo")
public R batchUpdateFddEmpInfo(@RequestBody String jsonString) {
R<List<SysDictItem>> res = null;
ExcelUtil<FddContractAttachInfo> util1 = null;
try {
// 调用字典服务,渲染字典值
res = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(), daprUpmsProperties.getAppId()
, "/dict/inner/getDictList", null, Map.class, SecurityConstants.FROM_IN);
Map<String, String> dicMap = new HashMap<>();
if (null != res.getData()) {
for (SysDictItem dict : res.getData()) {
dicMap.put(dict.getType() + CommonConstants.DOWN_LINE_STRING + dict.getLabel(), dict.getValue());
}
}
jsonString = URLDecoder.decode(jsonString, CommonConstants.UTF8).replace("=", "");
util1 = new ExcelUtil<>(FddContractAttachInfo.class);
//传参字典数据MAP具体见方法实现
util1.getJsonStringToList(jsonString, dicMap);
if (null != util1.getErrorInfo() && !util1.getErrorInfo().isEmpty()) {
return R.failed(util1.getErrorInfo(),"");
} else {
if (null != util1.getEntityList()) {
List<ErrorMessage> errorInfo = fddContractAttachInfoService.batchUpdate(util1.getEntityList());
return R.ok(errorInfo,"数据导入解析成功!");
} else {
return R.ok(null,EmployeeConstants.NO_DATA_UPDATE);
}
}
} catch (Exception e) {
log.error(e.getMessage());
return R.failed(EmployeeConstants.DATA_UPDATE_FAIL);
}
}
/**
* @param entityList
* @Author: huyc
* @Date: 2022/06/30
* @Description: 批量发送法大大电子合同定稿任务
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(summary = "批量发送法大大电子合同定稿任务", description = "批量发送法大大电子合同定稿任务")
@SysLog("批量发送法大大电子合同定稿任务")
@PostMapping("/sendTask")
public R sendTask(@RequestBody List<FddContractAttachInfo> entityList) {
if (null == entityList) {
return R.failed("数据为空!");
}
List<ErrorMessage> errorInfo = fddContractAttachInfoService.sendTask(entityList);
return R.ok(errorInfo);
}
}
......@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fadada.api.exception.ApiException;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractTemplate;
import com.yifu.cloud.plus.v1.yifu.archives.service.FddContractTemplateService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -31,6 +32,11 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDateTime;
/**
......@@ -73,19 +79,6 @@ public class FddContractTemplateController {
return R.ok(fddContractTemplateService.getById(id));
}
/**
* 新增法大大员工合同模板
* @param fddContractTemplate 法大大员工合同模板
* @return R
*/
@Operation(summary = "新增法大大员工合同模板", description = "新增法大大员工合同模板:hasPermission('demo_fddcontracttemplate_add')")
@SysLog("新增法大大员工合同模板" )
@PostMapping
@PreAuthorize("@pms.hasPermission('demo_fddcontracttemplate_add')" )
public R save(@RequestBody FddContractTemplate fddContractTemplate) {
return R.ok(fddContractTemplateService.save(fddContractTemplate));
}
/**
* 修改法大大员工合同模板
* @param fddContractTemplate 法大大员工合同模板
......@@ -96,7 +89,7 @@ public class FddContractTemplateController {
@PutMapping
@PreAuthorize("@pms.hasPermission('demo_fddcontracttemplate_edit')" )
public R updateById(@RequestBody FddContractTemplate fddContractTemplate) {
return R.ok(fddContractTemplateService.updateById(fddContractTemplate));
return R.ok(fddContractTemplateService.changeInfo(fddContractTemplate));
}
/**
......@@ -112,4 +105,71 @@ public class FddContractTemplateController {
return R.ok(fddContractTemplateService.removeById(id));
}
/**
* 新增合同模板
* @param fddContractTemplate
* @return R
*/
@Operation(summary = "新增合同模板", description = "新增合同模板")
@SysLog("新增合同模板" )
@PostMapping
public R save(@Valid @RequestBody FddContractTemplate fddContractTemplate) {
return fddContractTemplateService.saveInfo(fddContractTemplate);
}
/**
* @param file
* @Author: huyc
* @Date: 2022/6/30
* @Description: 法大大模板上传
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(summary = "法大大模板上传", description = "法大大模板上传")
@SysLog("法大大模板上传" )
@PostMapping("/upload")
public R<String> upload(@RequestBody MultipartFile file, @RequestParam String id) throws ApiException, IOException {
return fddContractTemplateService.upload(file, id);
}
/**
* @Author: huyc
* @Date: 2022/6/30
* @Description: 模板文件删除
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(summary = "模板文件删除", description = "模板文件删除")
@SysLog("模板文件删除" )
@PostMapping("/del")
public R<String> delCompanyTemplateFile(@RequestParam String id) throws ApiException {
return fddContractTemplateService.delCompanyTemplateFile(id);
}
/**
* @Author: huyc
* @Date: 2022/6/30
* @Description: 获取模板维护地址
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(summary = "获取模板维护地址", description = "获取模板维护地址")
@SysLog("获取模板维护地址" )
@GetMapping("/getTemplateMainUrl")
public R<String> getTemplateMainUrl(@RequestParam String id) throws ApiException {
return fddContractTemplateService.getTemplateMainUrl(id);
}
/**
* @Author: huyc
* @Date: 2022/6/30
* @Description: 获取模板文件预览地址
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(summary = "获取模板文件预览地址", description = "获取模板文件预览地址")
@SysLog("获取模板文件预览地址")
@GetMapping("/getCompanyTemplatePreviewUrl")
public R<String> getCompanyTemplatePreviewUrl(@RequestParam String id) throws ApiException {
return fddContractTemplateService.getCompanyTemplatePreviewUrl(id);
}
}
......@@ -18,8 +18,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -58,8 +56,8 @@ public class FddController {
private FddCompanyInfoService fddCompanyInfoService;
@Autowired
private FddContractAttachInfoService fddContractAttachInfoService;
// @Autowired
// private TEmployeeContractInfoService employeeContractInfoService;
@Autowired
private TEmployeeContractInfoService employeeContractInfoService;
ExecutorService executorService = Executors.newFixedThreadPool(10);
......@@ -168,31 +166,22 @@ public class FddController {
//实名认证成功发送电子合同
executorService.submit(() -> {
try {
// //先查询下有没有没发送这个员工没发送的电子合同。如果有则发送
// List<FddContractAttachInfo> attachInfos = fddContractAttachInfoService.getListByNoInfoByEmpIdcard(entity.getIdCard());
// //自动创建定稿任务.查看是否有未定稿的数据。有的话自动发送
// if (attachInfos.size() == CommonConstants.ZERO_INT) {
// return;
// }
// FddContractAttachInfo fddContractAttachInfo = attachInfos.get(CommonConstants.ZERO_INT);
// TEmployeeContractInfo employeeContractInfo = employeeContractInfoService.getById(fddContractAttachInfo.getContractId());
// TEmployeeInfo employeeInfo = employeeInfoService.getById(employeeContractInfo.getEmpId());
//获取合同创建人
// String createUserId = fddContractAttachInfo.getCreateUserId();
// FeginExtendUser feginExtendUser = new FeginExtendUser();
// R<List<SysUser>> remoteUserServiceSimpleUser = remoteUserService.getAllUserInfoByUserIds(createUserId, SecurityConstants.FROM_IN);
// SysUser sysUser = remoteUserServiceSimpleUser.getData().get(CommonConstants.ZERO_INT);
// feginExtendUser.setPhone(sysUser.getPhone());
// feginExtendUser.setNickName(sysUser.getNickname());
// R<String> returnR = fddContractInfoService.saveEmpContract(fddContractAttachInfo, feginExtendUser);
// if (returnR != null) {
// //记录返回信息
// if(returnR.getCode()== CommonConstants.SUCCESS){
// fddContractAttachInfo.setRemark("成功");
// }else {
// fddContractAttachInfo.setRemark(returnR.getMsg());
// }
// }
//先查询下有没有没发送这个员工没发送的电子合同。如果有则发送
List<FddContractAttachInfo> attachInfos = fddContractAttachInfoService.getListByNoInfoByEmpIdcard(entity.getIdCard());
//自动创建定稿任务.查看是否有未定稿的数据。有的话自动发送
if (attachInfos.size() == CommonConstants.ZERO_INT) {
return;
}
FddContractAttachInfo fddContractAttachInfo = attachInfos.get(CommonConstants.ZERO_INT);
R<String> returnR = fddContractInfoService.saveEmpContract(fddContractAttachInfo);
if (returnR != null) {
//记录返回信息
if(returnR.getCode()== CommonConstants.SUCCESS){
fddContractAttachInfo.setRemark("成功");
}else {
fddContractAttachInfo.setRemark(returnR.getMsg());
}
}
} catch (Exception e) {
e.printStackTrace();
}
......@@ -216,16 +205,16 @@ public class FddController {
executorService.submit(() -> {
try {
//自动创建定稿任务
// R<String> returnR = fddContractInfoService.createTaskByDraftId(fddContractInfo);
// if(returnR!=null){
// //记录返回信息
// if(returnR.getCode()==CommonConstants.SUCCESS){
// fddContractInfo.setRemark("成功");
// }else {
// fddContractInfo.setRemark(returnR.getMsg());
// }
// fddContractInfoService.updateById(fddContractInfo);
// }
R<String> returnR = fddContractInfoService.createTaskByDraftId(fddContractInfo);
if(returnR!=null){
//记录返回信息
if(returnR.getCode()==CommonConstants.SUCCESS){
fddContractInfo.setRemark("成功");
}else {
fddContractInfo.setRemark(returnR.getMsg());
}
fddContractInfoService.updateById(fddContractInfo);
}
} catch (Exception e) {
e.printStackTrace();
}
......@@ -263,14 +252,14 @@ public class FddController {
// 2021-3-15 16:24 hgw 全部签名成功,更新合同的状态:
if (CommonConstants.TWO_STRING.equals(fddContractInfo.getSendSignStatus())
&& CommonConstants.TWO_STRING.equals(fddContractInfo.getReceiveSignStatus())) {
// fddContractAttachInfoService.saveEmpAndAttarch(fddContractInfo);
fddContractAttachInfoService.saveEmpAndAttarch(fddContractInfo);
// TEmployeeContractInfo ec = employeeContractInfoService.getById(fddContractInfo.getContractId());
// // 如果合同的状态是待电子签,则变更为已电子签
// if (ec != null && ec.getIsSign() != null && ec.getIsSign() == CommonConstants.ONE_INT) {
// ec.setIsSign(CommonConstants.ZERO_INT);
// employeeContractInfoService.updateById(ec);
// }
TEmployeeContractInfo ec = employeeContractInfoService.getById(fddContractInfo.getContractId());
// 如果合同的状态是待电子签,则变更为已电子签
if (ec != null && ec.getIsSign() != null && ec.getIsSign() == CommonConstants.ONE_INT) {
ec.setIsSign(CommonConstants.ZERO_INT);
employeeContractInfoService.updateById(ec);
}
}
return R.ok();
}else if (StringUtils.equals(fddEvent, "notifyUrlVerify")) {
......
......@@ -22,7 +22,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractAttachInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractInfo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import java.io.InputStream;
import java.util.List;
/**
......@@ -46,4 +50,12 @@ public interface FddContractAttachInfoService extends IService<FddContractAttach
* @return
*/
List<FddContractAttachInfo> getListByNoInfoByEmpIdcard(String empIdcard);
List<ErrorMessage> sendTask(List<FddContractAttachInfo> entityList);
R<String> saveEmpAndAttarch(FddContractInfo fddContractInfo);
List<ErrorMessage> batchAdd(List<FddContractAttachInfo> entityList);
List<ErrorMessage> batchUpdate(List<FddContractAttachInfo> entityList);
}
......@@ -110,4 +110,6 @@ public interface FddContractInfoService extends IService<FddContractInfo> {
* @return: R
**/
R<String> moveFileToEmpConcat(FddContractInfo fddContractInfo, HttpServletResponse response) throws ApiException, IOException;
R<String> generalEmployeeParam(FddContractAttachInfo attachInfo, boolean signFlag);
}
......@@ -23,6 +23,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fadada.api.exception.ApiException;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractTemplate;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
/**
* 法大大员工合同模板
......@@ -39,4 +43,46 @@ public interface FddContractTemplateService extends IService<FddContractTemplate
*/
IPage<FddContractTemplate> getFddContractTemplatePage(Page<FddContractTemplate> page, FddContractTemplate fddContractTemplate) throws ApiException;
/**
* 保存合同模板
* @param fddContractTemplate 法大大员工合同模板
* @return
*/
R saveInfo(FddContractTemplate fddContractTemplate);
/**
* 修改合同模板
* @param fddContractTemplate 法大大员工合同模板
* @return
*/
R changeInfo(FddContractTemplate fddContractTemplate);
/**
* 法大大模板上传
* @param file 文件
* @param id 模板id
* @return
*/
R<String> upload(MultipartFile file, String id) throws ApiException, IOException;
/**
* 获取模板维护地址
* @param id 模板id
* @return
*/
R<String> getTemplateMainUrl(String id) throws ApiException;
/**
* 获取模板文件预览地址
* @param id 模板id
* @return
*/
R<String> getCompanyTemplatePreviewUrl(String id) throws ApiException;
/**
* 模板文件删除
* @param id 模板id
* @return
*/
R<String> delCompanyTemplateFile(String id) throws ApiException;
}
......@@ -49,6 +49,7 @@ import com.fadada.api.client.SignTaskClient;
import com.fadada.api.exception.ApiException;
import com.google.common.collect.Maps;
import com.yifu.cloud.plus.v1.yifu.archives.entity.*;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.FddContractAttachInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.FddContractInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.*;
import com.yifu.cloud.plus.v1.yifu.archives.utils.FddUtil;
......@@ -105,7 +106,7 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe
@Autowired
private FddSealPersonAuthService fddSealPersonAuthService;
@Autowired
private FddContractAttachInfoService fddContractAttachInfoService;
private FddContractAttachInfoMapper fddContractAttachInfoMapper;
// @Autowired
// private TEmployeeContractInfoService employeeContractInfoService;
// @Autowired
......@@ -284,7 +285,7 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe
return R.failed("合同签署任务已完成,不能作废重签");
}
YifuUser user = SecurityUtils.getUser();
FddContractAttachInfo fddContractAttachInfo = fddContractAttachInfoService.getOne(Wrappers.<FddContractAttachInfo>query().lambda()
FddContractAttachInfo fddContractAttachInfo = fddContractAttachInfoMapper.selectOne(Wrappers.<FddContractAttachInfo>query().lambda()
.eq(FddContractAttachInfo::getContractId,entity.getContractId()));
if (!user.getId().equals(fddContractAttachInfo.getCreateBy())) {
return R.failed("当前用户不是电子合同导入用户,不能操作");
......@@ -768,6 +769,99 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe
}
}
@Override
public R<String> generalEmployeeParam(FddContractAttachInfo attachInfo, boolean signFlag) {
JSONObject paramter = new JSONObject();
if (StringUtils.isEmpty(attachInfo.getEmpName())) {
return R.failed("姓名为空,请去档案补充对应信息!");
}
paramter.put("name", attachInfo.getEmpName());
Date date = IdcardUtil.getBirthDate(attachInfo.getEmpIdcard());
if (LocalDateTimeUtils.convertDateToLDT(date) == null) {
return R.failed("出生年月为空,请去档案补充对应信息!");
}
paramter.put("birth", DateUtil.format(LocalDateTimeUtils.convertDateToLDT(date), DatePattern.NORM_DATE_PATTERN));
if (StringUtils.isEmpty(attachInfo.getEmpIdcard())) {
return R.failed("身份证号为空,请去档案补充对应信息!");
}
paramter.put("id_card", attachInfo.getEmpIdcard());
int sex = IdcardUtil.getGenderByIdCard(attachInfo.getEmpIdcard());
if (sex == 0) {
paramter.put("sex", "女");
} else if (sex == 1) {
paramter.put("sex", "男");
}
if (StringUtils.isEmpty(attachInfo.getEmpPhone())) {
return R.failed("手机号为空,请去档案补充对应信息!");
}
paramter.put("mobile", attachInfo.getEmpPhone());
//固定期限
paramter.put("contractType", "一");
paramter.put("fcontractStartY", DateUtil.format(localDate2Date(attachInfo.getContractStart()), "yyyy"));
paramter.put("fcontractStartM", DateUtil.format(localDate2Date(attachInfo.getContractStart()), "MM"));
paramter.put("fcontractStartD", DateUtil.format(localDate2Date(attachInfo.getContractStart()), "dd"));
paramter.put("fcontractEndY", DateUtil.format(localDate2Date(attachInfo.getContractEnd()), "yyyy"));
paramter.put("fcontractEndM", DateUtil.format(localDate2Date(attachInfo.getContractEnd()), "MM"));
paramter.put("fcontractEndD", DateUtil.format(localDate2Date(attachInfo.getContractEnd()), "dd"));
//合同起止时间填充,新签需要判断是否有试用期,试用期工资
if (!signFlag) {
if (attachInfo.getPeriodStart() == null) {
return R.failed("新签试用期开始时间为空");
}
paramter.put("fPeriodStartY", DateUtil.format(localDate2Date(attachInfo.getPeriodStart()), "yyyy"));
paramter.put("fPeriodStartM", DateUtil.format(localDate2Date(attachInfo.getPeriodStart()), "MM"));
paramter.put("fPeriodStartD", DateUtil.format(localDate2Date(attachInfo.getPeriodStart()), "dd"));
if (attachInfo.getPeriodEnd() == null) {
return R.failed("新签试用期结束时间为空");
}
paramter.put("fPeriodEndY", DateUtil.format(localDate2Date(attachInfo.getPeriodEnd()), "yyyy"));
paramter.put("fPeriodEndM", DateUtil.format(localDate2Date(attachInfo.getPeriodEnd()), "MM"));
paramter.put("fPeriodEndD", DateUtil.format(localDate2Date(attachInfo.getPeriodEnd()), "dd"));
if (attachInfo.getPeriodSalaryPerMonth() == null) {
return R.failed("新签试用期工资为空");
}
paramter.put("periodSalaryPerMonth", attachInfo.getPeriodSalaryPerMonth());
}
//工作地点和岗位填充
if (StringUtils.isEmpty(attachInfo.getPost())) {
return R.failed("员工岗位为空,请去档案补充对应信息!");
}
paramter.put("post", attachInfo.getPost());
if (StringUtils.isEmpty(attachInfo.getWorkSpace())) {
return R.failed("员工工作地点为空");
}
paramter.put("workSpace", attachInfo.getWorkSpace());
//工时制
paramter.put("workingHours", "");
//工资标准
if(StringUtils.isEmpty(attachInfo.getSalaryType())){
return R.failed("工资形式不能为空");
}
String salaryTypeKey = "salaryType";
if (StringUtils.equals(CommonConstants.ONE_STRING, attachInfo.getSalaryType())) {
paramter.put(salaryTypeKey, CommonConstants.ONE_STRING);
//计时工资
if (attachInfo.getSalaryStandardPerHour()==null) {
return R.failed("计时工资为空");
}
paramter.put("salaryStrandPh", String.valueOf(attachInfo.getSalaryStandardPerHour()));
} else if (StringUtils.equals(CommonConstants.TWO_STRING, attachInfo.getSalaryType())) {
paramter.put(salaryTypeKey, CommonConstants.TWO_STRING);
if (attachInfo.getSalaryStandardPerPiece()==null) {
return R.failed("计件工资为空");
}
//计月工资
paramter.put("salaryStrandPp", String.valueOf(attachInfo.getSalaryStandardPerPiece()));
} else if (StringUtils.equals(CommonConstants.THREE_STRING, attachInfo.getSalaryType())) {
paramter.put(salaryTypeKey, CommonConstants.THREE_STRING);
} else {
return R.failed("未知的工资标准类型");
}
return new R<>(paramter.toJSONString());
}
public static Date localDate2Date(LocalDate localDate) {
if (null == localDate) {
return null;
......@@ -789,7 +883,7 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe
if (reviseTaskDetailR.getCode() != CommonConstants.SUCCESS) {
return R.failed(reviseTaskDetailR.getMsg());
}
FddContractAttachInfo attachInfo = fddContractAttachInfoService.getOne(Wrappers.<FddContractAttachInfo>query().lambda().eq(FddContractAttachInfo::getContractId, entity.getContractId()));
FddContractAttachInfo attachInfo = fddContractAttachInfoMapper.selectOne(Wrappers.<FddContractAttachInfo>query().lambda().eq(FddContractAttachInfo::getContractId, entity.getContractId()));
int status = reviseTaskDetailR.getData();
CancelReviseTaskReq req = new CancelReviseTaskReq();
if (status == CommonConstants.ZERO_INT || status == CommonConstants.ONE_INT) {
......
......@@ -20,9 +20,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fadada.api.bean.req.template.GetTemplateDetailReq;
import com.fadada.api.bean.req.template.*;
import com.fadada.api.bean.rsp.BaseRsp;
import com.fadada.api.bean.rsp.template.GetCompanyTemplatePreviewUrlRsp;
import com.fadada.api.bean.rsp.template.GetTemplateDetailRsp;
import com.fadada.api.bean.rsp.template.GetTemplateMainUrlRsp;
import com.fadada.api.bean.rsp.template.UploadCompanyTemplateFileRsp;
import com.fadada.api.client.TemplateClient;
import com.fadada.api.exception.ApiException;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractTemplate;
......@@ -30,13 +33,17 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractTemplateFile;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.FddContractTemplateMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.FddContractTemplateFileService;
import com.yifu.cloud.plus.v1.yifu.archives.service.FddContractTemplateService;
import com.yifu.cloud.plus.v1.yifu.archives.service.FddReqLogService;
import com.yifu.cloud.plus.v1.yifu.archives.utils.FddUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
/**
......@@ -51,7 +58,8 @@ public class FddContractTemplateServiceImpl extends ServiceImpl<FddContractTempl
@Autowired
private FddUtil fddUtil;
@Autowired
private FddReqLogService reqLogService;
@Autowired
private FddContractTemplateFileService templateFileService;
......@@ -84,4 +92,146 @@ public class FddContractTemplateServiceImpl extends ServiceImpl<FddContractTempl
}
return fddContractTemplatePage;
}
@Override
public R saveInfo(FddContractTemplate fddContractTemplate) {
long count = this.count(Wrappers.<FddContractTemplate>query().lambda()
.eq(FddContractTemplate::getLocalName,fddContractTemplate.getLocalName())
);
if (count > CommonConstants.ZERO_INT) {
return R.failed("已存在相同模板名称记录");
}
boolean save = this.save(fddContractTemplate);
if (save) {
return R.ok();
}
return R.failed("失败");
}
@Override
public R<Boolean> changeInfo(FddContractTemplate fddContractTemplate) {
long count = this.count(Wrappers.<FddContractTemplate>query().lambda()
.eq(FddContractTemplate::getLocalName,fddContractTemplate.getLocalName())
.notIn(FddContractTemplate::getId, fddContractTemplate.getId()));
if (count > CommonConstants.ZERO_INT) {
return R.failed("已存在相同模板名称记录");
}
return new R<>(this.updateById(fddContractTemplate));
}
@Override
public R<String> upload(MultipartFile file, String id) throws ApiException, IOException {
FddContractTemplate entity = this.getById(id);
if (entity == null) {
return R.failed("未查询到相关记录");
}
if (StringUtils.isNotEmpty(entity.getFddTemplateId())) {
return R.failed("已上传法大大模板");
}
//发送请求
UploadCompanyTemplateFileReq req = new UploadCompanyTemplateFileReq();
req.setToken(fddUtil.getToken());
req.setFileType(CommonConstants.ONE_INT, null);
TemplateClient client = new TemplateClient(fddUtil.getFadadaApiClient());
BaseRsp<UploadCompanyTemplateFileRsp> rsp = client.uploadCompanyTemplateFile(req, FddSealInfoServiceImpl.multipartFileToFile(file));
reqLogService.saveLog(Thread.currentThread().getStackTrace()[1].getClassName(),Thread.currentThread().getStackTrace()[1].getMethodName(),req, rsp);
//校验参数
if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
entity.setFddTemplateId(rsp.getData().getTemplateId());
this.updateById(entity);
//生成文件模板记录
FddContractTemplateFile templateFile = new FddContractTemplateFile();
templateFile.setFddTemplateId(entity.getFddTemplateId());
templateFile.setFddFileId(rsp.getData().getFileId());
templateFileService.save(templateFile);
return R.ok();
} else {
return R.failed("上传失败");
}
}
@Override
public R<String> delCompanyTemplateFile(String id) throws ApiException {
FddContractTemplate entity = this.getById(id);
if (entity == null) {
return R.failed("未查询到相关记录");
}
if (StringUtils.isEmpty(entity.getFddTemplateId())) {
return R.failed("法大大模板未上传");
}
//发送请求
DelCompanyTemplateFileReq req = new DelCompanyTemplateFileReq();
req.setToken(fddUtil.getToken());
DelCompanyTemplateFileReq.TemplateInfo templateInfo = new DelCompanyTemplateFileReq.TemplateInfo();
templateInfo.setTemplateId(entity.getFddTemplateId());
req.setTemplateInfo(templateInfo);
TemplateClient client = new TemplateClient(fddUtil.getFadadaApiClient());
BaseRsp<UploadCompanyTemplateFileRsp> rsp = client.delCompanyTemplateFile(req);
reqLogService.saveLog(Thread.currentThread().getStackTrace()[1].getClassName(),Thread.currentThread().getStackTrace()[1].getMethodName(),req, rsp);
//校验参数
if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
baseMapper.updateTeFddTemplateNull(entity.getId());
//删除附件
templateFileService.remove(Wrappers.<FddContractTemplateFile>query().lambda().eq(FddContractTemplateFile::getFddTemplateId,entity.getFddTemplateId()));
return R.ok();
} else {
return R.failed("删除失败");
}
}
@Override
public R<String> getTemplateMainUrl(String id) throws ApiException {
FddContractTemplate entity = this.getById(id);
if (entity == null) {
return R.failed("未查询到相关记录");
}
if (StringUtils.isEmpty(entity.getFddTemplateId())) {
return R.failed("法大大模板未上传");
}
//发送请求
GetTemplateMainUrlReq req = new GetTemplateMainUrlReq();
req.setToken(fddUtil.getToken());
GetTemplateMainUrlReq.TemplateInfo templateInfo = new GetTemplateMainUrlReq.TemplateInfo();
templateInfo.setTemplateId(entity.getFddTemplateId());
req.setTemplateInfo(templateInfo);
TemplateClient client = new TemplateClient(fddUtil.getFadadaApiClient());
BaseRsp<GetTemplateMainUrlRsp> rsp = client.getTemplateMainUrl(req);
reqLogService.saveLog(Thread.currentThread().getStackTrace()[1].getClassName(),Thread.currentThread().getStackTrace()[1].getMethodName(),req, rsp);
//校验参数
if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
entity.setModifyUploadStatus(CommonConstants.ONE_STRING);
this.updateById(entity);
return new R<>(rsp.getData().getEditTemplateUrl());
} else {
return R.failed("获取失败");
}
}
@Override
public R<String> getCompanyTemplatePreviewUrl(String id) throws ApiException {
FddContractTemplate entity = this.getById(id);
if (entity == null) {
return R.failed("未查询到相关记录");
}
if (StringUtils.isEmpty(entity.getFddTemplateId())) {
return R.failed("法大大模板未上传");
}
//发送请求
GetEditCompanyTemplateUrlReq req = new GetEditCompanyTemplateUrlReq();
req.setToken(fddUtil.getToken());
GetEditCompanyTemplateUrlReq.TemplateInfo templateInfo = new GetEditCompanyTemplateUrlReq.TemplateInfo();
templateInfo.setTemplateId(entity.getFddTemplateId());
req.setTemplateInfo(templateInfo);
TemplateClient client = new TemplateClient(fddUtil.getFadadaApiClient());
BaseRsp<GetCompanyTemplatePreviewUrlRsp> rsp = client.getCompanyTemplatePreviewUrl(req);
reqLogService.saveLog(Thread.currentThread().getStackTrace()[1].getClassName(),Thread.currentThread().getStackTrace()[1].getMethodName(),req, rsp);
//校验参数
if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
return new R<>(rsp.getData().getTemplatePreviewUrl());
} else {
return R.failed(rsp.getMsg());
}
}
}
......@@ -42,7 +42,9 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.util.List;
/**
......@@ -222,4 +224,46 @@ public class FddSealInfoServiceImpl extends ServiceImpl<FddSealInfoMapper, FddSe
reqLogService.saveLog(this.getClass().getName(), Thread.currentThread().getStackTrace()[1].getMethodName(), req, rsp);
return rsp;
}
/**
* @param file
* @Author: huyc
* @Date: 2022/6/30
* @Description: MultipartFile转file
* @return: java.io.File
**/
public static File multipartFileToFile(MultipartFile file) throws IOException {
File toFile;
InputStream ins;
ins = file.getInputStream();
toFile = new File(file.getOriginalFilename());
inputStreamToFile(ins, toFile);
ins.close();
return toFile;
}
/**
* @param ins
* @param file
* @Author: huyc
* @Date: 2022/6/30
* @Description: 获取流文件
* @return: void
**/
private static void inputStreamToFile(InputStream ins, File file) throws IOException {
try {
OutputStream os = new FileOutputStream(file);
int bytesRead;
int byteLength = 8192;
byte[] buffer = new byte[byteLength];
while ((bytesRead = ins.read(buffer, 0, byteLength)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
ins.close();
} catch (IOException e) {
e.printStackTrace();
throw e;
}
}
}
......@@ -6,6 +6,7 @@ import com.fadada.api.bean.rsp.BaseRsp;
import com.fadada.api.bean.rsp.oauth2.AccessTokenRsp;
import com.fadada.api.client.Oauth2Client;
import com.fadada.api.exception.ApiException;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem;
import com.yifu.cloud.plus.v1.yifu.archives.config.FddConfigProperties;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddReqLog;
import com.yifu.cloud.plus.v1.yifu.archives.service.FddReqLogService;
......@@ -96,6 +97,4 @@ public class FddUtil {
}
return accessToken;
}
}
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.archives.config.FddAutoConfigue
\ No newline at end of file
......@@ -71,6 +71,11 @@
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.35</version>
</dependency>
<!-- aliyun-sdk-oss -->
<dependency>
......
package com.yifu.cloud.plus.v1.yifu.common.core.exception;
import lombok.NoArgsConstructor;
@NoArgsConstructor //@NoArgsConstructor: 自动生成无参数构造函数。
public class ExcelException extends RuntimeException {
public ExcelException(String message) {
super(message);
}
public ExcelException(Throwable cause) {
super(cause);
}
public ExcelException(String message, Throwable cause) {
super(message, cause);
}
public ExcelException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
package com.yifu.cloud.plus.v1.yifu.common.core.util;
import com.alibaba.fastjson.JSONObject;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ValidityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ExcelException;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
......@@ -32,6 +34,11 @@ public class ExcelUtil <T> implements Serializable {
private HashMap<Integer, ErrorMessage> errorMessageHashMap;
/**
* 用于返回实体
*/
private List<T> entityList;
public ExcelUtil(Class<T> clazz) {
this.clazz = clazz;
this.fields =clazz.getDeclaredFields();
......@@ -730,4 +737,204 @@ public class ExcelUtil <T> implements Serializable {
}
return errorMessageHashMap;
}
/**
* 将JSONSTRING数据源的数据导入到list
*
* @param jsonStr 接收的对象JSON串
* @param dicMap HashMap<dateType_value,dataValue_dataId> 如 {EMPTYPE_兼职工伤,ID}
* @author fxj
* @date 2019/08/01
*/
public void getJsonStringToList(String jsonStr, Map<String, String> dicMap) {
List<HashMap> list = null;
List<T> listt = new ArrayList<T>();
list = JSONObject.parseArray(jsonStr, HashMap.class);
List<ErrorMessage> errorList = new ArrayList<ErrorMessage>();
HashMap<Integer, ErrorMessage> errorMessageHashMap = new HashMap<Integer, ErrorMessage>();
try {
// 得到数据的条数
int rows = list.size();
// 有数据时才处理
if (rows > 0) {
// 得到类的所有field
Field[] allFields = clazz.getDeclaredFields();
Field field;
// 定义一个map用于存放列的序号和field
Map<Integer, Field> fieldsMap = new HashMap<Integer, Field>();
for (int i = 0, index = 0; i < allFields.length; i++) {
field = allFields[i];
// 将有注解的field存放到map中
if (field.isAnnotationPresent(ExcelAttribute.class)) {
// 设置类的私有字段属性可访问
field.setAccessible(true);
fieldsMap.put(index, field);
index++;
}
}
//存储错误数据
String error = "";
//临时存储单元格数据
String tempStr = "";
// 从第1行开始取数据
T entity = null;
HashMap temp;
ExcelAttribute attr;
String c = null;
Class<?> fieldType;
ErrorMessage errorTemp = null;
for (int i = 0; i < rows; i++) {
// 得到一行中的所有单元格对象.
temp = list.get(i);
entity = clazz.newInstance();
for (int j = 0; j < fieldsMap.size(); j++) {
// 从map中得到对应列的field
field = fieldsMap.get(j);
//获取属性对应的注解属性
attr = field.getAnnotation(ExcelAttribute.class);
// 单元格中的内容.
c = getStringValByObject(getFieldValueByName(attr.name(), temp));
if (c != null) {
c = c.trim();
}
//校验字段是否符合要求 返回错误信息
error = validateUtil(c, attr, i + 2);
if (null != error) {
errorList.add(new ErrorMessage(i + 2, error));
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(i + 2, error), errorTemp);
continue;
}
if (field == null) {
continue;
}
//单元格数据为空不需要处理了
if (!StringUtils.isNotBlank(c)) {
continue;
}
//如果是需要从字典表取值数据的话在这里处理即可
if (attr.isDataId() && null != dicMap) {
if (Common.isNotNull(attr.dataType())) {
//非区域字段处理
if (Common.isNotNull(attr.parentField())){
tempStr = dicMap.get(attr.dataType() + "_" + c.trim() + "_" + getFieldValueByName(attr.parentField(), entity, DateUtil.ISO_EXPANDED_DATE_FORMAT));
}else {
tempStr = dicMap.get(attr.dataType() + "_" + c.trim());
}
} else {
if (attr.isArea()) {
//区域字段处理
if (Common.isEmpty(attr.parentField())) {
tempStr = dicMap.get(c.trim() + "_0");
} else {
tempStr = dicMap.get(c.trim() + "_" + getFieldValueByName(attr.parentField(), entity, DateUtil.ISO_EXPANDED_DATE_FORMAT));
}
} else {
//直接按值去找数据
tempStr = dicMap.get(c.trim());
}
}
if (!StringUtils.isNotBlank(tempStr)) {
if (attr.isOrgan()) {
errorList.add(new ErrorMessage(i + 2, "未找到:" + c + "的单位或结算主体数据,请确认存在结算主体权限"));
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(i + 2, "未找到:" + c + "的单位或结算主体数据,请确认存在结算主体权限"), errorTemp);
}
if (attr.isArea()) {
errorList.add(new ErrorMessage(i + 2, "未找到:" + c + "的区域数据"));
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(i + 2, "未找到:" + c + "的区域数据"), errorTemp);
} else {
if (Common.isNotNull(attr.errorInfoImport())) {
errorList.add(new ErrorMessage(i + 2, "数据'" + c + "':" + attr.errorInfoImport()));
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(i + 2, "数据'" + c + "':" + attr.errorInfoImport()), errorTemp);
} else {
errorList.add(new ErrorMessage(i + 2, "未找到:" + c + "的字典数据"));
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(i + 2, "未找到:" + c + "的字典数据"), errorTemp);
}
}
continue;
} else {
c = tempStr;
}
}
// 取得类型,并根据对象类型设置值.
fieldType = field.getType();
if (fieldType == null) {
continue;
}
if (String.class == fieldType) {
field.set(entity, c);
} else if (BigDecimal.class == fieldType) {
c = c.indexOf('%') != -1 ? c.replace("%", "") : c;
field.set(entity, BigDecimal.valueOf(Double.valueOf(c)));
} else if (Date.class == fieldType && Common.isNotNull(c.trim())) {
field.set(entity, DateUtil.stringToDate(c.trim(), Common.isEmpty(attr.dateFormat()) ? DateUtil.ISO_EXPANDED_DATE_FORMAT : attr.dateFormat()));
} else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType)) {
field.set(entity, Integer.parseInt(c));
} else if ((Long.TYPE == fieldType) || (Long.class == fieldType)) {
field.set(entity, Long.valueOf(c));
} else if ((Float.TYPE == fieldType) || (Float.class == fieldType)) {
field.set(entity, Float.valueOf(c));
} else if ((Short.TYPE == fieldType) || (Short.class == fieldType)) {
field.set(entity, Short.valueOf(c));
} else if ((Double.TYPE == fieldType) || (Double.class == fieldType)) {
field.set(entity, Double.valueOf(c));
} else if (Character.TYPE == fieldType) {
if ((c != null) && (c.length() > 0)) {
field.set(entity, Character.valueOf(c.charAt(0)));
}
} else if (LocalDateTime.class == fieldType && Common.isNotNull(c.trim())) {
String dc = c.trim().replace(CommonConstants.CENTER_SPLIT_LINE_STRING, "")
.replace(CommonConstants.SLASH_SPLIT_LINE_STRING, "");
try {
if (dc.length() > CommonConstants.EIGHT_INT) {
field.set(entity, LocalDateTimeUtils.convertDateToLDT(DateUtil.stringToDate(dc, DateUtil.DATETIME_PATTERN_CONTAINS)));
}else {
field.set(entity, LocalDateTimeUtils.convertDateToLDT(DateUtil.stringToDate(dc, DateUtil.ISO_DATE_FORMAT)));
}
} catch (Exception e) {
if (dc.length() > CommonConstants.EIGHT_INT) {
errorList.add(new ErrorMessage(i + 2, attr.name() + ":" +
c.trim() + "应满足时间格式:" + DateUtil.DATETIME_PATTERN_SECOND));
errorMessageHashMap = initErrorMessage(errorMessageHashMap,
new ErrorMessage(i + 2, attr.name() + ":" +
c.trim() + "应满足时间格式:" + DateUtil.DATETIME_PATTERN_SECOND), errorTemp);
continue;
} else {
errorList.add(new ErrorMessage(i + 2, attr.name() + ":" +
c.trim() + "应满足时间格式:" + DateUtil.ISO_DATE_FORMAT));
errorMessageHashMap = initErrorMessage(errorMessageHashMap,
new ErrorMessage(i + 2, attr.name() + ":" +
c.trim() + "应满足时间格式:" + DateUtil.ISO_DATE_FORMAT), errorTemp);
continue;
}
}
} else if (LocalDate.class == fieldType && !Common.isEmpty(c.trim())) {
try {
field.set(entity, LocalDate.parse(c.trim().replace(CommonConstants.CENTER_SPLIT_LINE_STRING, ""), DateTimeFormatter.ofPattern(DateUtil.ISO_DATE_FORMAT)));
} catch (Exception e) {
errorList.add(new ErrorMessage(i + 2, attr.name() + ":" + c.trim() + "应满足时间格式:" + DateUtil.ISO_DATE_FORMAT));
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(i + 2, attr.name() + ":" + c.trim() + "应满足时间格式:" + DateUtil.ISO_DATE_FORMAT), errorTemp);
continue;
}
}
}
if (null == error) {
if (entity != null) {
listt.add(entity);
}
} else {
continue;
}
}
}
} catch (Exception e) {
throw new ExcelException("将jsonString数据源的数据导入到list异常:" + e.getMessage(), e);
}
this.setEntityList(listt);
this.setErrorInfo(errorList);
this.setErrorMessageHashMap(errorMessageHashMap);
}
}
......@@ -335,5 +335,18 @@ public class DictController {
return sysDictItemService.getLableFronValue(value,type);
}
/**
* @Description: itemType 获取对应的字典数据
* @Author: hgw
* @Date: 2022/6/22 18:19
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.Map < java.lang.String, java.util.Map < java.lang.String, java.lang.String>>>
**/
@Inner
@PostMapping("/inner/getDictList")
public R<List<SysDictItem>> getDictList(@RequestParam(value = "itemType", required = false) String itemType) {
List<SysDictItem> allList = sysDictItemService.list(Wrappers.<SysDictItem>query().lambda()
.in(SysDictItem::getType,itemType)
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING));
return new R<>(allList);
}
}
......@@ -18,6 +18,9 @@ package com.yifu.cloud.plus.v1.yifu.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 字典项
......@@ -28,4 +31,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
List<SysDictItem> getDictToLable(@Param("itemType")String itemType);
}
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