Commit 0fe21cb8 authored by hongguangwu's avatar hongguangwu

Merge remote-tracking branch 'origin/develop'

# Conflicts:
#	yifu-common/yifu-common-dapr/src/main/resources/daprConfig.properties
parents f6e292df 2909e997
package com.yifu.cloud.plus.v1.check.vo;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @Author hgw
* @Date 2024-4-16 19:39:51
*/
@Data
public class CheckIdCardListVo implements Serializable {
// 200:成功; 其他:失败
private int code;
// 错误信息
private String errorMsg;
// 其他内容
private List<TCheckIdCard> checkList = new ArrayList<>();
}
...@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard; import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.service.TCheckIdCardService; import com.yifu.cloud.plus.v1.check.service.TCheckIdCardService;
import com.yifu.cloud.plus.v1.check.vo.CheckIdCardListVo;
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.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner; import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
...@@ -176,4 +178,35 @@ public class TCheckIdCardController { ...@@ -176,4 +178,35 @@ public class TCheckIdCardController {
public R<List<TCheckIdCard>> checkSalaryIdCard(@RequestBody List<TCheckIdCard> checkList) { public R<List<TCheckIdCard>> checkSalaryIdCard(@RequestBody List<TCheckIdCard> checkList) {
return tCheckIdCardService.checkSalaryIdCard(checkList); return tCheckIdCardService.checkSalaryIdCard(checkList);
} }
/**
* @Description: 批量校验姓名身份证
* @Author: hgw
* @Date: 2024-4-16 19:47:20
* @return: com.yifu.cloud.v1.common.core.util.R
**/
@Operation(description = "批量校验姓名身份证")
@SysLog("批量校验姓名身份证")
@Inner
@PostMapping("/inner/checkIdCardList")
public CheckIdCardListVo checkIdCardList(@RequestBody CheckIdCardListVo vo) {
CheckIdCardListVo returnVo = new CheckIdCardListVo();
R<List<TCheckIdCard>> checkR = tCheckIdCardService.checkSalaryIdCard(vo.getCheckList());
if (checkR != null) {
if (checkR.getCode() == CommonConstants.SUCCESS) {
returnVo.setCode(CommonConstants.SUCCESS);
return returnVo;
} else {
returnVo.setCode(checkR.getCode());
returnVo.setErrorMsg(checkR.getMsg());
returnVo.setCheckList(checkR.getData());
return returnVo;
}
} else {
returnVo.setCode(CommonConstants.FAIL);
returnVo.setErrorMsg("校验服务无返回!");
return returnVo;
}
}
} }
...@@ -168,6 +168,9 @@ public interface CacheConstants { ...@@ -168,6 +168,9 @@ public interface CacheConstants {
String FUND_IMPORT_HANDLE_LOCK = "fund_import_handle_handle_lock"; String FUND_IMPORT_HANDLE_LOCK = "fund_import_handle_handle_lock";
// 项目报销token的key
String WX_REIMBURSEMENT_TOKEN = "WX_REIMBURSEMENT_TOKEN";
public static final String WX_ACCOSS_TOKEN = "WX_ACCOSS_TOKEN"; public static final String WX_ACCOSS_TOKEN = "WX_ACCOSS_TOKEN";
/** /**
......
...@@ -152,4 +152,9 @@ public interface SecurityConstants { ...@@ -152,4 +152,9 @@ public interface SecurityConstants {
**/ **/
String WX_GET_MESSAGE_AUTH_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=%s#wechat_redirect"; String WX_GET_MESSAGE_AUTH_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=%s#wechat_redirect";
// 获取审批单号list hgw 2024-4-12 14:45:25
String WX_GET_APPROVAL_LIST = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovalinfo?access_token={1}";
// 获取审核详情
String WX_GET_APPROVAL_DETAIL = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovaldetail?access_token={1}";
} }
...@@ -23,13 +23,13 @@ spring: ...@@ -23,13 +23,13 @@ spring:
password: ll_mysql password: ll_mysql
jdbc-url: jdbc:mysql://192.168.1.122:33306/ekp?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true jdbc-url: jdbc:mysql://192.168.1.122:33306/ekp?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
hikari: hikari:
minimum-idle: 10 # 最小空闲连接数量 minimum-idle: 20 # 最小空闲连接数量
idle-timeout: 60000 # 空闲连接存活最大时间,默认600000(10分钟) idle-timeout: 60000 # 空闲连接存活最大时间,默认600000(10分钟)
maximum-pool-size: 12 # 连接池最大连接数,默认是10 maximum-pool-size: 12 # 连接池最大连接数,默认是10
auto-commit: true #此属性控制从池返回的连接的默认自动提交行为,默认值:true auto-commit: true #此属性控制从池返回的连接的默认自动提交行为,默认值:true
max-lifetime: 0 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟 max-lifetime: 0 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
ekp: ekp:
url: http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel url: http://192.168.0.251:8080/api/sys-modeling/appModelRestService/addModel
fdModelId: '181d73279372e5a55438a47d7436ab7e' fdModelId: '181d73279372e5a55438a47d7436ab7e'
fdFlowId: '18267f206233f29cbd3c5ee425c9408a' fdFlowId: '18267f206233f29cbd3c5ee425c9408a'
docStatus: '20' docStatus: '20'
......
...@@ -37,4 +37,19 @@ public class EkpPermissionTask { ...@@ -37,4 +37,19 @@ public class EkpPermissionTask {
log.info("-------------刷新EKP权限里的账号信息-定时任务结束------------"); log.info("-------------刷新EKP权限里的账号信息-定时任务结束------------");
} }
/**
* @return
* @Author hgw
* @Description 每天1点,定时同步企业微信审批出差数据
* @Date 2024-4-15 18:24:06
* @Param
**/
public void doSaveQiWeiChuChai() throws Exception {
log.info("-------------获取企业微信出差数据-定时任务开始------------");
HttpDaprUtil.invokeMethodPost(daprEkpPermissionProperties.getAppUrl(), daprEkpPermissionProperties.getAppId(),
"/qiWei/inner/everyDaySaveQiWeiChuChai", "", Object.class,
SecurityConstants.FROM_IN);
log.info("-------------获取企业微信出差数据-定时任务结束------------");
}
} }
\ No newline at end of file
package com.yifu.cloud.plus.v1.yifu.permission.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* 企业微信出差
*/
@TableName(value = "ekp_qiwei_chuchai")
@Data
@Schema(description = "企业微信出差")
public class EkpQiwiChuchai {
@TableField(exist = false)
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键", name = "fdId")
private String fdId;
@Schema(description = "审批编号")
@NotBlank(message = "审批编号不能为空")
private String fdSpNo;
@Schema(description = "申请人姓名")
@NotBlank(message = "申请人姓名不能为空")
private String fdApplyUserName;
@Schema(description = "申请人部门")
@NotBlank(message = "申请人部门不能为空")
private String fdApplyUserDept;
@Schema(description = "申请日期")
@NotNull(message = "申请日期不能为空")
private LocalDateTime fdApplyDate;
@Schema(description = "开始日期")
private LocalDate fdNewBegin;
@Schema(description = "结束日期")
private LocalDate fdNewEnd;
@Schema(description = "出差事由")
private String fdReason;
@Schema(description = "随行人员")
private String fdPerson;
@Schema(description = "出差地点")
private String fdAddress;
@Schema(description = "出发地点")
private String fdOldAddress;
@Schema(description = "出行工具")
private String fdTools;
@Schema(description = "出差地点级别")
private String fdAddressLevel;
@Schema(description = "交通补助")
private String fdJiaoTong;
@Schema(description = "餐饮补助")
private String fdCanYin;
@Schema(description = "人数")
private Integer fdRenShu;
// status 0 初始;1已结算;
@Schema(description = "结算状态")
private String fdStatus;
@Schema(description = "关联结算ID")
private String fdSettleFormId;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}
\ No newline at end of file
package com.yifu.cloud.plus.v1.yifu.permission.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* @Author hgw
* @Date 2024-4-16 15:04:11
* @Description 企业微信用户vo
* @Version 1.0
*/
@Data
public class QiWeiUserVo implements Serializable {
@Schema(description = "用户id")
private String userId;
@Schema(description = "用户姓名")
private String userName;
}
package com.yifu.cloud.plus.v1.msg.config; package com.yifu.cloud.plus.v1.permission.config;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -35,12 +35,15 @@ import java.util.concurrent.TimeUnit; ...@@ -35,12 +35,15 @@ import java.util.concurrent.TimeUnit;
@Slf4j @Slf4j
public class WxConfig { public class WxConfig {
@Value("${wx.corpid}") @Value("${wx.corpid}")
private String corpid; private String corpid;
@Value("${wx.corpsecret}") @Value("${wx.corpsecret}")
private String corpsecret; private String corpsecret;
@Value("${wx.agentid}") // 项目报销获取token专用
private String agentid; @Value("${wx.reimbursementCorpsecret}")
private String reimbursementCorpsecret;
@Value("${wx.agentid}")
private String agentid;
@Value("${wx.authUrl}") @Value("${wx.authUrl}")
private String authUrl; private String authUrl;
...@@ -50,140 +53,153 @@ public class WxConfig { ...@@ -50,140 +53,153 @@ public class WxConfig {
//未授权 //未授权
private String accossTokenInvliad = "40014"; private String accossTokenInvliad = "40014";
/** /**
* @param * @param restTemplate
* @Author: huyc * @Description: 获取项目报销的token
* @Date: 2023/7/28 * @Author: hgw
* @Description: 获取微信accos_token * @Date: 2021/3/24 14:42
* @return: java.lang.String * @return: java.lang.String
**/ **/
public String getAccessToken(RestTemplate restTemplate) { public String getReimbursementToken(RestTemplate restTemplate) {
if (Common.isNotNull(agentid)) { return this.getToken(restTemplate, CacheConstants.WX_REIMBURSEMENT_TOKEN, reimbursementCorpsecret);
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN.concat(agentid), corpsecret); }
}
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN, corpsecret);
}
public String getAccessToken(RestTemplate restTemplate,String corpsecret)throws AuthenticationServiceException { /**
if(Common.isEmpty(corpsecret)){ * @param
throw new AuthenticationServiceException("未找到对应的corpsecret请联系管理员配置"); * @Author: huyc
} * @Date: 2023/7/28
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN.concat(agentid), corpsecret); * @Description: 获取微信accos_token
} * @return: java.lang.String
**/
public String getAccessToken(RestTemplate restTemplate) {
if (Common.isNotNull(agentid)) {
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN.concat(agentid), corpsecret);
}
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN, corpsecret);
}
public String getAccessToken(RestTemplate restTemplate, String corpsecret) throws AuthenticationServiceException {
if (Common.isEmpty(corpsecret)) {
throw new AuthenticationServiceException("未找到对应的corpsecret请联系管理员配置");
}
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN.concat(agentid), corpsecret);
}
/** /**
* @param restTemplate * @param restTemplate
* @param tokenKey * @param tokenKey
* @param corpsecretKey * @param corpsecretKey
* @Description: 获取token * @Description: 获取token
* @Author: huyc * @Author: huyc
* @Date: 2023/7/28 14:46 * @Date: 2023/7/28 14:46
* @return: java.lang.String * @return: java.lang.String
**/ **/
public String getToken(RestTemplate restTemplate,String tokenKey, String corpsecretKey) { public String getToken(RestTemplate restTemplate, String tokenKey, String corpsecretKey) {
Object wxToken = redisTemplate.opsForValue().get(tokenKey); Object wxToken = redisTemplate.opsForValue().get(tokenKey);
if (null != wxToken) { if (null != wxToken) {
return String.valueOf(wxToken); return String.valueOf(wxToken);
} }
String requestTokenUrl = String.format(SecurityConstants.WX_GET_ACCOSS_TOKEN, corpid, corpsecretKey); String requestTokenUrl = String.format(SecurityConstants.WX_GET_ACCOSS_TOKEN, corpid, corpsecretKey);
String result = restTemplate.getForObject(requestTokenUrl, String.class); String result = restTemplate.getForObject(requestTokenUrl, String.class);
if (Common.isEmpty(result)) { if (Common.isEmpty(result)) {
throw new CheckedException("微信授权失败"); throw new CheckedException("微信授权失败");
} }
String token = JSON.parseObject(result).getString("access_token"); String token = JSON.parseObject(result).getString("access_token");
if (Common.isEmpty(token)) { if (Common.isEmpty(token)) {
log.info(result); log.info(result);
throw new CheckedException("获取微信token失败"); throw new CheckedException("获取微信token失败");
} }
redisTemplate.opsForValue().set(tokenKey, token); redisTemplate.opsForValue().set(tokenKey, token);
redisTemplate.expire(tokenKey, 3600, TimeUnit.SECONDS); redisTemplate.expire(tokenKey, 3600, TimeUnit.SECONDS);
return token; return token;
} }
/** /**
* @param * @param
* @Author: huyc * @Author: huyc
* @Date: 2023/7/28 14:43 * @Date: 2023/7/28 14:43
* @Description: 移除微信accossToken * @Description: 移除微信accossToken
* @return: java.lang.String * @return: java.lang.String
**/ **/
public void removeAccessToken() { public void removeAccessToken() {
redisTemplate.delete(CacheConstants.WX_ACCOSS_TOKEN); redisTemplate.delete(CacheConstants.WX_ACCOSS_TOKEN);
} }
/** /**
* @param restTemplate * @param restTemplate
* @param requestMap 请求内容 * @param requestMap 请求内容
* @Author: huyc * @Author: huyc
* @Date: 2023/7/28 14:48 * @Date: 2023/7/28 14:48
* @Description: 发送卡片消息 * @Description: 发送卡片消息
* @return: java.lang.String * @return: java.lang.String
**/ **/
public boolean sendTextCard(RestTemplate restTemplate, Map<String, Object> requestMap) { public boolean sendTextCard(RestTemplate restTemplate, Map<String, Object> requestMap) {
// 必须加上header说明 // 必须加上header说明
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8); headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
Gson gson = new Gson(); Gson gson = new Gson();
log.info(gson.toJson(requestMap)); log.info(gson.toJson(requestMap));
HttpEntity<String> requestEntity = new HttpEntity<>(gson.toJson(requestMap), headers); HttpEntity<String> requestEntity = new HttpEntity<>(gson.toJson(requestMap), headers);
String accessToken = getAccessToken(restTemplate); String accessToken = getAccessToken(restTemplate);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(String.format(SecurityConstants.WX_SEND_MESSAGE, accessToken), requestEntity, String.class); ResponseEntity<String> responseEntity = restTemplate.postForEntity(String.format(SecurityConstants.WX_SEND_MESSAGE, accessToken), requestEntity, String.class);
log.info(JSON.toJSONString(responseEntity)); log.info(JSON.toJSONString(responseEntity));
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(responseEntity)); JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(responseEntity));
JSONObject jsonBody = jsonObject.getJSONObject("body"); JSONObject jsonBody = jsonObject.getJSONObject("body");
if (jsonBody != null) { if (jsonBody != null) {
String errcode = jsonBody.getString("errcode"); String errcode = jsonBody.getString("errcode");
if (accossTokenInvliad.equals(errcode)) { if (accossTokenInvliad.equals(errcode)) {
//删除accossToken缓存 //删除accossToken缓存
removeAccessToken(); removeAccessToken();
return false; return false;
} }
if (!CommonConstants.ZERO_STRING.equals(errcode)) { //非正常,则打印错误日志 if (!CommonConstants.ZERO_STRING.equals(errcode)) { //非正常,则打印错误日志
log.info(jsonObject.toJSONString()); log.info(jsonObject.toJSONString());
} }
} else { } else {
log.info(jsonObject.toJSONString()); log.info(jsonObject.toJSONString());
} }
return true; return true;
} }
/** /**
* @param restTemplate * @param restTemplate
* @param requestMap 请求内容 * @param requestMap 请求内容
* @Author: huyc * @Author: huyc
* @Date: 2023/7/28 14:50 * @Date: 2023/7/28 14:50
* @Description: 发送卡片消息 * @Description: 发送卡片消息
* @return: java.lang.String * @return: java.lang.String
**/ **/
public boolean sendAppTextCard(RestTemplate restTemplate, Map<String, Object> requestMap) { public boolean sendAppTextCard(RestTemplate restTemplate, Map<String, Object> requestMap) {
// 必须加上header说明 // 必须加上header说明
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8); headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
Gson gson = new Gson(); Gson gson = new Gson();
log.info("发企业微信===请求:{}", gson.toJson(requestMap)); log.info("发企业微信===请求:{}", gson.toJson(requestMap));
HttpEntity<String> requestEntity = new HttpEntity<>(gson.toJson(requestMap), headers); HttpEntity<String> requestEntity = new HttpEntity<>(gson.toJson(requestMap), headers);
String accessToken = getAppAccessToken(restTemplate); String accessToken = getAppAccessToken(restTemplate);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(String.format(SecurityConstants.WX_SEND_MESSAGE, accessToken), requestEntity, String.class); ResponseEntity<String> responseEntity = restTemplate.postForEntity(String.format(SecurityConstants.WX_SEND_MESSAGE, accessToken), requestEntity, String.class);
log.info("发企业微信===返回:{}",JSON.toJSONString(responseEntity)); log.info("发企业微信===返回:{}", JSON.toJSONString(responseEntity));
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(responseEntity)); JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(responseEntity));
JSONObject jsonBody = jsonObject.getJSONObject("body"); JSONObject jsonBody = jsonObject.getJSONObject("body");
if (jsonBody != null) { if (jsonBody != null) {
String errcode = jsonBody.getString("errcode"); String errcode = jsonBody.getString("errcode");
if (accossTokenInvliad.equals(errcode)) { if (accossTokenInvliad.equals(errcode)) {
//删除accossToken缓存 //删除accossToken缓存
removeAccessToken(); removeAccessToken();
return false; return false;
} }
if (!CommonConstants.ZERO_STRING.equals(errcode)) { //非正常,则打印错误日志 if (!CommonConstants.ZERO_STRING.equals(errcode)) { //非正常,则打印错误日志
log.info(jsonObject.toJSONString()); log.info(jsonObject.toJSONString());
} }
} else { } else {
log.info(jsonObject.toJSONString()); log.info(jsonObject.toJSONString());
} }
return true; return true;
} }
/** /**
* 功能描述: 获取微信accos_token * 功能描述: 获取微信accos_token
*
* @Author: huyc * @Author: huyc
* @Date: 2023/7/28 14:50 * @Date: 2023/7/28 14:50
* @return: java.lang.String * @return: java.lang.String
......
package com.yifu.cloud.plus.v1.permission.controller;
import com.yifu.cloud.plus.v1.permission.service.QiWeiService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 工资服务-获取微信
*
* @author hgw
* @date 2024-4-10 11:26:50
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/qiWei")
@Tag(name = "工资服务-获取微信")
public class QiWeiController {
private final QiWeiService wxSalaryService;
/**
* @Description: 每日获取当日企业微信审批里的出差
* @Author: hgw
* @Date: 2024-4-11 11:03:34
* @return: com.yifu.cloud.v1.common.core.util.R<java.util.List < com.yifu.cloud.v1.hrms.api.entity.TEventFeeDetail>>
**/
@PostMapping("/inner/everyDaySaveQiWeiChuChai")
@Inner
public R<List<EkpQiwiChuchai>> everyDaySaveQiWeiChuChai() {
String startDay = DateUtil.addDay(-29);
String endDay = DateUtil.addDay(0);
return wxSalaryService.getQiWeiChuChaiAndSave(startDay, endDay);
}
/**
* @param startTime
* @param endTime
* @Description: 获取企业微信审批里的出差
* @Author: hgw
* @Date: 2024-4-11 11:03:30
* @return: com.yifu.cloud.v1.common.core.util.R<java.util.List < com.yifu.cloud.v1.hrms.api.entity.TStatisticsProjectReimburse>>
**/
@Operation(description = "获取企业微信审批里的出差数据:startTime格式:2024-04-10")
@PostMapping("/getQiWeiChuCHaiInfoAndSave")
//@PreAuthorize("@pms.hasPermission('wxhr:wxsalaryauth')")
public R<List<EkpQiwiChuchai>> getQiWeiChuCHaiInfoAndSave(@RequestParam String startTime, @RequestParam String endTime) {
return wxSalaryService.getQiWeiChuChaiAndSave(startTime, endTime);
}
}
package com.yifu.cloud.plus.v1.permission.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai;
import com.yifu.cloud.plus.v1.yifu.permission.vo.QiWeiUserVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 企业微信出差
*
* @Entity generator.domain.TStatisticsProjectReimburse
*/
@Mapper
public interface EkpQiweiChuchaiMapper extends BaseMapper<EkpQiwiChuchai> {
/**
* @param status 状态
* @Description: 获取全部的列表,用来: 拉取企业微信时,不覆盖数据
* @Author: hgw
* @Date: 2021/7/28 18:05
* @return: java.util.List<com.yifu.cloud.v1.hrms.api.entity.salary.TStatisticsProjectReimburse>
**/
List<EkpQiwiChuchai> getAllInfo(@Param("status") String status);
List<QiWeiUserVo> getQiYeWeiXinUserList();
}
package com.yifu.cloud.plus.v1.permission.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai;
import java.util.List;
/**
* 成本支出表
*
* @author hgw
* @date 2024-4-15 17:16:50
*/
public interface QiWeiService extends IService<EkpQiwiChuchai> {
/**
* @param startTime
* @param endTime
* @Description: 获取微信信息
* @Author: hgw
* @Date: 2021-7-28 17:46:01
* @return: com.yifu.cloud.v1.common.core.util.R<java.util.List < com.yifu.cloud.v1.hrms.api.entity.TStatisticsProjectReimburse>>
**/
R<List<EkpQiwiChuchai>> getQiWeiChuChaiAndSave(String startTime, String endTime);
}
package com.yifu.cloud.plus.v1.permission.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.permission.config.WxConfig;
import com.yifu.cloud.plus.v1.permission.mapper.EkpQiweiChuchaiMapper;
import com.yifu.cloud.plus.v1.permission.service.QiWeiService;
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.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai;
import com.yifu.cloud.plus.v1.yifu.permission.vo.QiWeiUserVo;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
* 获取微信信息
*
* @author hgw
* @date 2024-4-15 17:16:57
*/
@Service
@AllArgsConstructor
public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwiChuchai> implements QiWeiService {
private RestTemplate restTemplate = new RestTemplate();
private static final String VALUESTR = "value";
private static final String NEW_NEXT_CURSOR = "new_next_cursor";
private static final String NEW_CURSOR = "new_cursor";
private final WxConfig wxConfig;
/**
* @param startTime
* @param endTime
* @Description: 获取所有的出差
* @Author: hgw
* @Date: 2021/3/24 15:41
* @return: com.yifu.cloud.v1.common.core.util.R<java.util.List < com.yifu.cloud.v1.hrms.api.entity.TStatisticsProjectReimburse>>
**/
@Override
public synchronized R<List<EkpQiwiChuchai>> getQiWeiChuChaiAndSave(String startTime, String endTime) {
try {
// 起止时间
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime startDate = LocalDateTime.parse(startTime + " 00:00:00", df);
LocalDateTime endDate = LocalDateTime.parse(endTime + " 23:59:59", df);
Duration duration = Duration.between(startDate, endDate);
long days = duration.toDays(); //相差的天数
// 判断时间跨度:
if (days > 30) {
return R.failed("时间范围超过30天了:起:" + startTime + ";止:" + endTime);
}
// 获取起月份的起止时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startTimeDate = sdf.parse(startTime + " 00:00:00");
Date endTimeDate = sdf.parse(endTime + " 23:59:59");
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(startTimeDate);
startTime = String.valueOf(rightNow.getTime().getTime() / 1000);
rightNow.setTime(endTimeDate);
endTime = String.valueOf(rightNow.getTime().getTime() / 1000);
// 已被拉取的Map
Map<String, String> cpMap = this.getAllMap();
// 企微姓名Map
Map<String, String> userMap = this.getUserMap();
// 一个月的全量数据
List<EkpQiwiChuchai> cpAllList = new ArrayList<>();
List<EkpQiwiChuchai> returnCpList = new ArrayList<>();
this.getCostPaymentListByMonth(startTime, endTime, cpAllList);
if (!cpAllList.isEmpty()) {
for (EkpQiwiChuchai cp : cpAllList) {
if (cpMap.get(cp.getFdSpNo()) == null) {
returnCpList.add(cp);
}
}
}
// 填充详情
if (!returnCpList.isEmpty()) {
log.error("拉取企业微信出差数据:"+returnCpList.size()+" 条,开始循环拉取明细!");
this.getTStatisticsProjectReimburseDetail(returnCpList, userMap);
log.error("拉取企业微信出差数据结束");
}
// 填充基础数据并保存:
if (!returnCpList.isEmpty()) {
this.saveBatch(returnCpList);
}
cpMap.clear();
userMap.clear();
return new R<>(returnCpList);
} catch (Exception e) {
e.printStackTrace();
log.error("拉取企业微信出差失败:", e);
return R.failed("时间转化失败,请选择合适的时间,例如:2021-07-29,且范围不超过30天。" + e.getMessage());
}
}
/**
* @param startTime
* @param endTime
* @param cpAllList
* @Description: 获取当月的list
* @Author: hgw
* @Date: 2021/3/24 17:50
* @return: void
**/
private void getCostPaymentListByMonth(String startTime, String endTime, List<EkpQiwiChuchai> cpAllList) {
// 当月的全量数据
R<List<EkpQiwiChuchai>> listR = this.getTStatisticsProjectReimburseListByWx(startTime, endTime);
if (listR.getCode() == CommonConstants.SUCCESS) {
cpAllList.addAll(listR.getData());
}
}
/**
* @Description: 从微信-获取所有的支出项
* @Author: hgw
* @Date: 2021/3/18 14:58
* @return: java.util.List<com.yifu.cloud.v1.hrms.api.entity.TStatisticsProjectReimburse>
**/
private R<List<EkpQiwiChuchai>> getTStatisticsProjectReimburseListByWx(String startTime, String endTime) {
String accessToken = wxConfig.getReimbursementToken(restTemplate);
JSONObject json = new JSONObject();
List<Map<String, String>> paramList = new ArrayList<>();
Map<String, String> paramMap = new HashMap<>();
// record_type - 审批单类型属性,1-请假;2-打卡补卡;3-出差;4-外出;5-加班; 6- 调班;7-会议室预定;8-退款审批;9-红包报销审批
paramMap.put("key", "record_type");
paramMap.put("value", "3");
paramList.add(paramMap);
paramMap = new HashMap<>();
// sp_status-审批单状态(1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付
paramMap.put("key", "sp_status");
paramMap.put("value", "2");
paramList.add(paramMap);
json.put("starttime", startTime);
json.put("endtime", endTime);
json.put("filters", paramList);
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
HttpEntity<String> formEntity = new HttpEntity<>(json.toString(), headers);
String dataResultList = restTemplate.postForEntity(SecurityConstants.WX_GET_APPROVAL_LIST, formEntity, String.class, accessToken).getBody();
if (Common.isEmpty(dataResultList)) {
throw new AuthenticationServiceException("获取企业微信审批数据失败");
}
JSONObject jsonObject = JSON.parseObject(dataResultList);
String errcode = jsonObject.getString("errcode");
String errmsg = jsonObject.getString("errmsg");
if (!"0".equals(errcode)) {
return R.failed(errmsg);
}
// 时间段内的总审批单个数
String nextCode = jsonObject.getString(NEW_NEXT_CURSOR);
List<EkpQiwiChuchai> cpList = new ArrayList<>();
this.setTStatisticsProjectReimburseInfo(jsonObject, cpList);
// 如果一次没取全,循环取
while (Common.isNotNull(nextCode)) {
json.put(NEW_CURSOR, nextCode);
formEntity = new HttpEntity<>(json.toString(), headers);
dataResultList = restTemplate.postForEntity(SecurityConstants.WX_GET_APPROVAL_LIST, formEntity, String.class, accessToken).getBody();
if (Common.isEmpty(dataResultList)) {
throw new AuthenticationServiceException("获取企业微信审批数据失败");
}
jsonObject = JSON.parseObject(dataResultList);
this.setTStatisticsProjectReimburseInfo(jsonObject, cpList);
nextCode = jsonObject.getString(NEW_NEXT_CURSOR);
}
return new R<>(cpList);
}
/**
* @Description: 从企业微信-获取详情
* @Author: hgw
* @Date: 2024-4-12 16:55:00
* @return: java.util.List<com.yifu.cloud.v1.hrms.api.entity.TStatisticsProjectReimburse>
**/
private R<List<EkpQiwiChuchai>> getTStatisticsProjectReimburseDetail(List<EkpQiwiChuchai> list, Map<String, String> userMap) {
String accessToken = wxConfig.getReimbursementToken(restTemplate);
int i = 1;
JSONObject jsonDetail;
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
HttpEntity<String> formEntityDetail;
String dataResultDetail;
JSONObject jsonObject;
String errcode;
String errmsg;
String info;
for (EkpQiwiChuchai r : list) {
log.error("企业微信出差【"+i+"/"+""+list.size()+"】条");
jsonDetail = new JSONObject();
jsonDetail.put("sp_no", r.getFdSpNo());
formEntityDetail = new HttpEntity<>(jsonDetail.toString(), headers);
dataResultDetail = restTemplate.postForEntity(SecurityConstants.WX_GET_APPROVAL_DETAIL, formEntityDetail, String.class, accessToken).getBody();
if (Common.isEmpty(dataResultDetail)) {
throw new AuthenticationServiceException("获取企业微信审批详情失败!");
}
jsonObject = JSON.parseObject(dataResultDetail);
errcode = jsonObject.getString("errcode");
errmsg = jsonObject.getString("errmsg");
if (!"0".equals(errcode)) {
return R.failed(errmsg);
}
// 详细信息
info = jsonObject.getString("info");
this.setTStatisticsProjectReimburseDetail(info, r, userMap);
if (i++ >= 600) {
// 企业微信频率限制:接口频率限制 600次/分钟
try {
Thread.sleep(60000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
return new R<>(list);
}
/**
* @Description: 获取全部的列表,用来: 拉取企业微信时,不覆盖数据
* @Author: hgw
* @Date: 2021-7-28 18:14:59
* @return: java.util.Map<java.lang.String, java.lang.String>
**/
private Map<String, String> getAllMap() {
List<EkpQiwiChuchai> cpHistoryList = baseMapper.getAllInfo(null);
Map<String, String> cpMap = new HashMap<>();
for (EkpQiwiChuchai cpHis : cpHistoryList) {
cpMap.put(cpHis.getFdSpNo(), "0");
}
return cpMap;
}
private Map<String, String> getUserMap() {
List<QiWeiUserVo> userList = baseMapper.getQiYeWeiXinUserList();
Map<String, String> userMap = new HashMap<>();
for (QiWeiUserVo cpHis : userList) {
userMap.put(cpHis.getUserId(), cpHis.getUserName());
}
return userMap;
}
/**
* @param jsonObject
* @param cpList
* @Description: 向支出list里塞值
* @Author: hgw
* @Date: 2021/3/18 14:58
* @return: void
**/
private void setTStatisticsProjectReimburseInfo(JSONObject jsonObject, List<EkpQiwiChuchai> cpList) {
EkpQiwiChuchai cp;
String data = jsonObject.getString("sp_no_list");
if (Common.isNotNull(data)) {
List<String> dataList = JSON.parseArray(data, String.class);
for (String datas : dataList) {
cp = new EkpQiwiChuchai();
cp.setFdApplyDate(LocalDateTime.now());
cp.setFdApplyUserName("张三");
cp.setFdSpNo(datas);
cp.setFdStatus(CommonConstants.ZERO_STRING);
cpList.add(cp);
}
}
}
/**
* @param reimburse
* @Description: 向详情里塞值
* @Author: hgw
* @Date: 2024-4-12 17:01:35
* @return: void
**/
private void setTStatisticsProjectReimburseDetail(String info, EkpQiwiChuchai reimburse, Map<String, String> userMap) {
JSONObject jsonObject = JSON.parseObject(info);
if (Common.isNotNull(info)) {
reimburse.setCreateTime(LocalDateTime.now());
String userId = ((JSONObject) jsonObject.get("applyer")).getString("userid");
if (Common.isNotNull(userId) && userMap.get(userId) != null) {
reimburse.setFdApplyUserName(userMap.get(userId));
} else {
reimburse.setFdApplyUserName(userId);
}
reimburse.setFdApplyUserDept(((JSONObject) jsonObject.get("applyer")).getString("partyid"));
reimburse.setFdSpNo(jsonObject.getString("sp_no"));
reimburse.setFdApplyDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(Long.parseLong(String.valueOf(jsonObject.get("apply_time")))), ZoneId.systemDefault()));
// 核心数据
JSONObject applyData = (JSONObject) jsonObject.get("apply_data");
String contents = applyData.getString("contents");
List<HashMap> contentList = JSON.parseArray(contents, HashMap.class);
JSONArray title;
JSONObject value;
JSONObject attendance;
JSONObject dateRange;
JSONObject selector;
JSONArray options;
JSONObject options0;
JSONArray options0value;
JSONObject options0value0;
// 开始时间
LocalDate newBegin = null;
// 结束时间
LocalDate newEnd = null;
// 出差时长
//String newDuration;
// 出差地点级别
String addressLevel= null;
// 交通补助
String jiaoTong= null;
// 餐饮补助
String canYin= null;
// 业务条线归属
//String lineType;
// 出差事由
String reason = null;
// 随行人员
String person = null;
// 出差地点
String address = null;
// 出发地点
String oldAddress = null;
// 出行工具
String tools = "";
for (HashMap content : contentList) {
title = (JSONArray) content.get("title");
if ("出差".equals(((JSONObject) title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR);
attendance = (JSONObject) value.get("attendance");
dateRange = (JSONObject) attendance.get("date_range");
// 28801 是时区+8小时1秒
newBegin = LocalDate.ofEpochDay((Long.parseLong(dateRange.getString("new_begin")) + 28801) / 86400);
newEnd = LocalDate.ofEpochDay((Long.parseLong(dateRange.getString("new_end")) + 28801) / 86400);
//newEnd = LocalDateTime.ofInstant(Instant.ofEpochSecond(Long.valueOf(dateRange.getString("new_end"))), ZoneId.systemDefault());
//newDuration = dateRange.getString("new_duration");
}
/*else if ("岗位级别".equals(((JSONObject)title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR);
selector = (JSONObject) value.get("selector");
options = (JSONArray) selector.get("options");
post = ((JSONObject) ((JSONArray) ((JSONArray) ((JSONObject) options.get(0)).get(VALUESTR)).get(0)).get(0)).getString("text");
} else if ("业务条线归属".equals(((JSONObject)title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR);
selector = (JSONObject) value.get("selector");
options = (JSONArray) selector.get("options");
lineType = ((JSONObject) ((JSONArray) ((JSONArray) ((JSONObject) options.get(0)).get(VALUESTR)).get(0)).get(0)).getString("text");
}*/
else if ("出差事由".equals(((JSONObject) title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR);
if (Common.isNotNull(value)) {
reason = value.getString("text");
}
} else if ("随行人员".equals(((JSONObject) title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR);
if (Common.isNotNull(value)) {
person = value.getString("text");
}
} else if ("出差地点".equals(((JSONObject) title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR);
if (Common.isNotNull(value)) {
address = value.getString("text");
}
} else if ("出发地点".equals(((JSONObject) title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR);
if (Common.isNotNull(value)) {
oldAddress = value.getString("text");
}
} else if ("出差地点级别".equals(((JSONObject) title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR);
if (Common.isNotNull(value)) {
selector = (JSONObject) value.get("selector");
if (Common.isNotNull(selector)) {
options = (JSONArray) selector.get("options");
if (Common.isNotNull(options)) {
options0 = (JSONObject) options.get(0);
if (Common.isNotNull(options0)) {
options0value = (JSONArray) options0.get(VALUESTR);
if (Common.isNotNull(options0value)) {
options0value0 = (JSONObject) options0value.get(0);
if (Common.isNotNull(options0value0)) {
addressLevel = options0value0.getString("text");
}
}
}
}
}
}
} else if (((JSONObject) title.get(0)).getString("text").contains("交通补助")) {
value = (JSONObject) content.get(VALUESTR);
if (value != null && Common.isNotNull(value.getString("text"))) {
jiaoTong = value.getString("text");
}
} else if (((JSONObject) title.get(0)).getString("text").contains("餐饮补助")) {
value = (JSONObject) content.get(VALUESTR);
if (value != null && Common.isNotNull(value.getString("text"))) {
canYin = value.getString("text");
}
} else if ("出行工具".equals(((JSONObject) title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR);
if (Common.isNotNull(value)) {
selector = (JSONObject) value.get("selector");
if (Common.isNotNull(selector)) {
options = (JSONArray) selector.get("options");
if (Common.isNotNull(options)) {
for (int j = 0; j < options.size(); j++) {
options0 = (JSONObject) options.get(j);
options0value = (JSONArray) options0.get(VALUESTR);
options0value0 = (JSONObject) options0value.get(0);
tools += options0value0.getString("text") + ";";
}
}
}
}
}
}
reimburse.setFdNewBegin(newBegin);
reimburse.setFdNewEnd(newEnd);
reimburse.setFdReason(reason);
int renShu = 1;
if (Common.isNotNull(person)) {
int renShu1 = person.split(",").length;
int renShu2 = person.split(",").length;
if (renShu1 > renShu2) {
renShu +=renShu1;
} else {
renShu +=renShu2;
}
}
reimburse.setFdRenShu(renShu);
reimburse.setFdPerson(person);
reimburse.setFdAddress(address);
reimburse.setFdOldAddress(oldAddress);
reimburse.setFdTools(tools);
reimburse.setFdAddressLevel(addressLevel);
reimburse.setFdJiaoTong(jiaoTong);
reimburse.setFdCanYin(canYin);
}
}
}
...@@ -8,6 +8,8 @@ spring: ...@@ -8,6 +8,8 @@ spring:
on-profile: dev on-profile: dev
redis: redis:
host: 127.0.0.1 host: 127.0.0.1
port: 6379
password: '@yf_2017'
datasource: datasource:
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
......
...@@ -83,3 +83,9 @@ springdoc: ...@@ -83,3 +83,9 @@ springdoc:
- group: permission - group: permission
#按包路径匹配 #按包路径匹配
packagesToScan: com.yifu.cloud.plus.v1.permission.controller packagesToScan: com.yifu.cloud.plus.v1.permission.controller
wx:
corpid: wwbcb090af0dfe50e5
corpsecret: o3fLn0u9SFHh5_htpIRBSp2bOibTa8pZGcOJIJqvidQ
agentid: 1000019
authUrl: https://wmp.worfu.com/api
reimbursementCorpsecret: R0nKkvsY-oF41fuQvUXZ-kFG3_g_Ce0bpZt6mByx524
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.permission.mapper.EkpQiweiChuchaiMapper">
<resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai">
<id property="fdId" column="fd_ID" />
<result property="fdSpNo" column="FD_SP_NO"/>
<result property="fdApplyUserName" column="FD_APPLY_USER_NAME"/>
<result property="fdApplyUserDept" column="FD_APPLY_USER_DEPT"/>
<result property="fdApplyDate" column="FD_APPLY_DATE"/>
<result property="fdNewBegin" column="FD_NEW_BEGIN"/>
<result property="fdNewEnd" column="FD_NEW_END"/>
<result property="fdReason" column="FD_REASON"/>
<result property="fdPerson" column="FD_PERSON"/>
<result property="fdAddress" column="FD_ADDRESS"/>
<result property="fdOldAddress" column="FD_OLD_ADDRESS"/>
<result property="fdTools" column="FD_TOOLS"/>
<result property="fdAddressLevel" column="FD_ADDRESS_LEVEL"/>
<result property="fdJiaoTong" column="FD_JIAO_TONG"/>
<result property="fdCanYin" column="FD_CAN_YIN"/>
<result property="fdRenShu" column="FD_REN_SHU"/>
<result property="fdStatus" column="FD_STATUS"/>
<result property="fdSettleFormId" column="FD_SETTLE_FORM_ID"/>
<result property="createTime" column="create_time"/>
</resultMap>
<sql id="Base_Column_List">
a.FD_ID,
a.FD_SP_NO,
a.FD_APPLY_USER_NAME,
a.FD_APPLY_USER_DEPT,
a.FD_APPLY_DATE,
a.FD_NEW_BEGIN,
a.FD_NEW_END,
a.FD_REASON,
a.FD_PERSON,
a.FD_ADDRESS,
a.FD_OLD_ADDRESS,
a.FD_TOOLS,
a.FD_ADDRESS_LEVEL,
a.FD_JIAO_TONG,
a.FD_CAN_YIN,
a.FD_REN_SHU,
a.FD_STATUS,
a.FD_SETTLE_FORM_ID,
a.create_time
</sql>
<!--获取全部的,用来: 拉取企业微信时,不覆盖数据 -->
<select id="getAllInfo" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM ekp_qiwei_chuchai a
<where>
1=1
<if test="status != null and status.trim() != ''">
AND a.FD_STATUS = #{status}
</if>
</where>
</select>
<!--获取全部的,用来: 拉取企业微信时,不覆盖数据 -->
<select id="getQiYeWeiXinUserList" resultType="com.yifu.cloud.plus.v1.yifu.permission.vo.QiWeiUserVo">
SELECT USER_ID as userId,USER_NAME as userName FROM ekp_qiwei_user
</select>
</mapper>
...@@ -48,5 +48,11 @@ ...@@ -48,5 +48,11 @@
<version>1.0.0</version> <version>1.0.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-check-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -37,4 +37,6 @@ public class SalaryConstants { ...@@ -37,4 +37,6 @@ public class SalaryConstants {
public static final String PDEDUCTION_JAVA = "pdeduction"; public static final String PDEDUCTION_JAVA = "pdeduction";
//单位代扣 //单位代扣
public static final String UDEDUCTION_JAVA = "udeduction"; public static final String UDEDUCTION_JAVA = "udeduction";
// 项目报销的 数据来源:0企业微信;1固资划转
public static final Integer[] DATA_SOURCE = {0,1};
} }
package com.yifu.cloud.plus.v1.yifu.salary.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;
/**
* 薪资原表识别主表
*
* @author hgw
* @date 2024-4-1 18:06:46
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("t_salary_standard_original")
@Tag(name = "薪资原表识别主表")
public class TSalaryStandardOriginal extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(type = IdType.ASSIGN_ID)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "主键")
private String id;
/**
* 部门ID
*/
@ExcelAttribute(name = "部门ID", isNotEmpty = true, errorInfo = "部门ID不能为空", maxLength = 32)
@NotBlank(message = "部门ID不能为空")
@Length(max = 32, message = "部门ID不能超过32个字符")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("部门ID")
private String deptId;
/**
* 部门名称
*/
@ExcelAttribute(name = "部门名称", isNotEmpty = true, errorInfo = "部门名称不能为空", maxLength = 50)
@NotBlank(message = "部门名称不能为空")
@Length(max = 50, message = "部门名称不能超过50个字符")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("部门名称")
private String deptName;
/**
* 部门编码
*/
@ExcelAttribute(name = "部门编码", maxLength = 32)
@Length(max = 32, message = "部门编码不能超过32个字符")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("部门编码")
private String deptNo;
/**
* 原表类型
*/
@NotBlank(message = "原表类型不能为空")
@ExcelAttribute(name = "原表类型", maxLength = 50)
@Length(max = 50, message = "原表类型不能超过50个字符")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("原表类型")
private String setName;
/**
* sheet名
*/
@ExcelAttribute(name = "sheet名", maxLength = 100)
@Length(max = 100, message = "sheet名不能超过100个字符")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("sheet名")
private String sheetName;
/**
* 附件名称
*/
@ExcelAttribute(name = "附件名称", maxLength = 200)
@Length(max = 200, message = "附件名称不能超过200个字符")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("附件名称")
private String attaName;
/**
* 资源路径
*/
@ExcelAttribute(name = "资源路径", maxLength = 200)
@Length(max = 200, message = "资源路径不能超过200个字符")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("资源路径")
private String attaSrc;
/**
* 资源地址
*/
@ExcelAttribute(name = "资源地址", maxLength = 100)
@Length(max = 100, message = "资源地址不能超过100个字符")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("资源地址")
private String attaUrl;
/**
* 资源大小
*/
@ExcelAttribute(name = "资源大小")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("资源大小")
private Long attaSize;
/**
* 资源类型(数据字典)
*/
@ExcelAttribute(name = "资源类型(数据字典)", maxLength = 32)
@Length(max = 32, message = "资源类型(数据字典)不能超过32个字符")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("资源类型(数据字典)")
private String attaType;
/**
* 是否删除0:未删除;1:已删除
*/
@ExcelAttribute(name = "是否删除0:未删除;1:已删除")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("是否删除0:未删除;1:已删除")
private Integer deleteFlag;
/**
* 数据所在行
*/
@ExcelAttribute(name = "数据所在行")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("数据所在行")
private Integer dateNum;
/**
* 明细
*/
@TableField(exist = false)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "明细")
private List<TSalaryStandardOriginalDetail> detailList = new ArrayList<>();
}
package com.yifu.cloud.plus.v1.yifu.salary.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
/**
* 薪资原表识别明细表
*
* @author hgw
* @date 2024-4-1 18:10:43
*/
@Data
@TableName("t_salary_standard_original_detail")
@Tag(name = "薪资原表识别明细表")
public class TSalaryStandardOriginalDetail {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(type = IdType.ASSIGN_ID)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "主键")
private String id;
/**
* TSalaryStandardOriginal表的主键
*/
@NotBlank(message = "TSalaryStandardOriginal表的主键不能为空")
@Length(max = 32, message = "TSalaryStandardOriginal表的主键不能超过32个字符")
@ExcelAttribute(name = "TSalaryStandardOriginal表的主键", isNotEmpty = true, errorInfo = "不能为空", maxLength = 32)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "TSalaryStandardOriginal表的主键")
private String originalId;
/**
* 表格列号
*/
@ExcelAttribute(name = "表格列号", isNotEmpty = true, errorInfo = "表格列号不能为空")
@NotBlank(message = "表格列号不能为空")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("表格列号")
private Integer columnNo;
/**
* 原表表头
*/
@Length(max = 50, message = "原表表头不能超过50个字符")
@ExcelAttribute(name = "原表表头", maxLength = 50)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "原表表头")
private String excelName;
/**
* 模板表头
*/
@Length(max = 50, message = "模板表头不能超过50个字符")
@ExcelAttribute(name = "模板表头", maxLength = 50)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "模板表头")
private String modelName;
/**
* 公式标志:MAIN主;ADD加;REDUCE减
*/
@Length(max = 50, message = "公式标志不能超过50个字符")
@ExcelAttribute(name = "公式标志", maxLength = 50)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "公式标志:MAIN主;ADD加;REDUCE减")
private String flag;
/**
* 公式顺序编号(前端使用)
*/
@ExcelAttribute(name = "公式顺序编号")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("公式顺序编号")
private Integer formulaNo;
}
package com.yifu.cloud.plus.v1.yifu.salary.vo;
import lombok.Getter;
import lombok.Setter;
/**
* @author hgw
* @description 薪资原表识别的 列内容 vo
* @date 2024-4-3 09:15:24
*/
@Getter
@Setter
public class ExcelColumnVo {
// 列号
private int lineNum;
// 列内容
private String content;
}
package com.yifu.cloud.plus.v1.yifu.salary.vo;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
/**
* @author hgw
* @description 薪资原表识别的 sheet vo
* @date 2024-4-3 09:15:24
*/
@Getter
@Setter
public class ExcelSheetVo {
// 数据行
private int dataNum;
// sheet名
private String sheetName;
// 解析过程发现的错误信息
private String errorInfo;
// 标题行
private List<ExcelColumnVo> titleList;
// 内容行+列
private List<Map<String, String>> contentList;
}
package com.yifu.cloud.plus.v1.yifu.salary.vo;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal;
import lombok.Getter;
import lombok.Setter;
import org.springframework.web.multipart.MultipartFile;
/**
* @author hgw
* @description 薪资原表识别vo
* @date 2024-4-3 09:15:24
*/
@Getter
@Setter
public class SalaryOriginalVo {
/**
* 附件
*/
//private MultipartFile file;
private MultipartFile file;
private String filename;
private String contentType;
/**
* 配置关系(含配置list)
*/
private TSalaryStandardOriginal salaryOriginal;
}
package com.yifu.cloud.plus.v1.yifu.salary.vo;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardIssueRes;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* @author hgw2
* @description 薪资上传vo
* @date 2023/1/10
*/
@Getter
@Setter
public class SalaryUploadOriginalParamVo {
// 配置
String originalId;
// sheetName;必填
String sheetName;
// 结算主体id;必填
String settleDepart;
// 工资配置结算月等信息的id
String configId;
// 工资类型。必填
String salaryType;
// 订单id
String orderId;
// 是否代发户,默认为空或0:非代发户,1是代发户
Integer isIssue;
// 代发户的配置list
List<TSalaryStandardIssueRes> resList;
}
package com.yifu.cloud.plus.v1.yifu.salary.vo; package com.yifu.cloud.plus.v1.yifu.salary.vo;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardIssueRes; import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardIssueRes;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -35,4 +36,10 @@ public class SalaryUploadParamVo { ...@@ -35,4 +36,10 @@ public class SalaryUploadParamVo {
// 代发户的配置list // 代发户的配置list
List<TSalaryStandardIssueRes> resList; List<TSalaryStandardIssueRes> resList;
// 原表识别,返回校验信息给前端
List<TCheckIdCard> checkList;
// 数据行,从0开始计数的
Integer dataNum;
} }
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.MenuUtil;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginalDetail;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalDetailService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelSheetVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadOriginalParamVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadParamVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.net.URL;
import java.util.List;
/**
* 薪资原表识别导入
*
* @author hgw
* @date 2024-4-2 11:03:33
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/tsalarystandardoriginal")
@Tag(name = "薪资原表识别导入")
public class TSalaryStandardOriginalController {
private final TSalaryStandardOriginalService tSalaryStandardOriginalService;
private final TSalaryStandardOriginalDetailService tSalaryStandardOriginalDetailService;
private final MenuUtil menuUtil;
private final OSSUtil ossUtil;
/**
* 简单分页查询
*
* @param page 分页对象
* @param tSalaryStandardOriginal 原表识别
* @return
*/
@Operation(description = "简单分页查询")
@GetMapping("/page")
public R<IPage<TSalaryStandardOriginal>> getTSalaryStandardOriginalPage(Page<TSalaryStandardOriginal> page, TSalaryStandardOriginal tSalaryStandardOriginal) {
YifuUser user = SecurityUtils.getUser();
menuUtil.setAuthSql(user, tSalaryStandardOriginal);
return new R<>(tSalaryStandardOriginalService.getTSalaryStandardOriginalPage(page, tSalaryStandardOriginal));
}
/**
* 导入工资时的获取识别配置列表
*/
@Operation(description = "导入工资时的获取识别配置列表")
@GetMapping("/getTSalaryStandardOriginalList")
public R<List<TSalaryStandardOriginal>> getTSalaryStandardOriginalList(TSalaryStandardOriginal tSalaryStandardOriginal) {
YifuUser user = SecurityUtils.getUser();
menuUtil.setAuthSql(user, tSalaryStandardOriginal);
return new R<>(tSalaryStandardOriginalService.getTSalaryStandardOriginalList(tSalaryStandardOriginal));
}
/**
* 通过id查询薪资原表识别
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('salary_tsalarystandardoriginal_get')")
@GetMapping("/{id}")
public R<TSalaryStandardOriginal> getById(@PathVariable("id") String id) {
TSalaryStandardOriginal original = tSalaryStandardOriginalService.getById(id);
if (original != null && Common.isNotNull(original.getId())) {
if (Common.isNotNull(original.getAttaSrc())) {
URL url = ossUtil.getObjectUrl(null, original.getAttaSrc());
original.setAttaUrl(url.toString().replace("http", "https"));
}
original.setDetailList(tSalaryStandardOriginalDetailService.getTSalaryStandardOriginalDetailByOrgId(original.getId()));
}
return R.ok(original);
}
/**
* 修改
*
* @param tSalaryStandardOriginal
* @return R
*/
@Operation(summary = "修改薪资原表识别", description = "修改薪资原表识别:hasPermission('salary_tsalarystandardoriginal_edit')")
@SysLog("修改薪资原表识别")
@PutMapping
@PreAuthorize("@pms.hasPermission('salary_tsalarystandardoriginal_edit')")
@Transactional
public R<Boolean> updateById(@RequestBody TSalaryStandardOriginal tSalaryStandardOriginal) {
if (Common.isNotNull(tSalaryStandardOriginal.getId())
&& Common.isNotNull(tSalaryStandardOriginal.getDeptId())
&& Common.isNotNull(tSalaryStandardOriginal.getSetName())) {
List<TSalaryStandardOriginalDetail> detailList = tSalaryStandardOriginal.getDetailList();
if (detailList == null || detailList.isEmpty()) {
return R.failed("请传配置表头list");
}
// 判重
TSalaryStandardOriginal isCur = new TSalaryStandardOriginal();
isCur.setId(tSalaryStandardOriginal.getId());
isCur.setDeptId(tSalaryStandardOriginal.getDeptId());
isCur.setSetName(tSalaryStandardOriginal.getSetName());
List<TSalaryStandardOriginal> curList = tSalaryStandardOriginalService.getTSalaryStandardOriginalList(isCur);
if (curList != null && !curList.isEmpty()) {
return R.failed("该项目下已存在此原表类型,请修改!");
}
// 先删除关系
tSalaryStandardOriginalDetailService.deleteByOrgId(tSalaryStandardOriginal.getId());
for (TSalaryStandardOriginalDetail detail : detailList) {
detail.setOriginalId(tSalaryStandardOriginal.getId());
}
// 再新增权限
tSalaryStandardOriginalDetailService.saveBatch(detailList);
// 再保存
tSalaryStandardOriginalService.updateById(tSalaryStandardOriginal);
return R.ok(true);
} else {
return R.failed("请传参!");
}
}
/**
* 通过id删除薪资原表识别
*
* @param id id
* @return R
*/
@Operation(summary = "通过id删除薪资原表识别", description = "通过id删除薪资原表识别:hasPermission('salary_tsalarystandardoriginal_del')")
@SysLog("通过id删除薪资原表识别")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('salary_tsalarystandardoriginal_del')")
public R<String> removeById(@PathVariable String id) {
TSalaryStandardOriginal original = tSalaryStandardOriginalService.getById(id);
if (original != null && Common.isNotNull(original.getId())) {
original.setDeleteFlag(CommonConstants.ONE_INT);
tSalaryStandardOriginalService.updateById(original);
return R.ok();
} else {
return R.failed("未找到");
}
}
/**
* @param file
* @param tSalaryStandardOriginal
* @Description: 原表识别配置保存
* @Author: hgw
* @Date: 2024/4/2 18:02
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@SysLog("原表识别配置新增")
@Operation(description = "新增")
@PostMapping("/doSave")
public R<String> doSave(MultipartFile file, TSalaryStandardOriginal tSalaryStandardOriginal) throws Exception {
if (tSalaryStandardOriginal != null && Common.isNotNull(tSalaryStandardOriginal.getDeptId())
&& Common.isNotNull(tSalaryStandardOriginal.getSetName()) && file != null) {
List<TSalaryStandardOriginalDetail> detailList = tSalaryStandardOriginal.getDetailList();
if (detailList == null || detailList.isEmpty()) {
return R.failed("请传配置表头list");
}
// 判重
TSalaryStandardOriginal isCur = new TSalaryStandardOriginal();
isCur.setDeptId(tSalaryStandardOriginal.getDeptId());
isCur.setSetName(tSalaryStandardOriginal.getSetName());
List<TSalaryStandardOriginal> curList = tSalaryStandardOriginalService.getTSalaryStandardOriginalList(isCur);
if (curList != null && !curList.isEmpty()) {
return R.failed("该项目下已存在此原表类型,请修改!");
}
// 上传附件
String fileName = file.getOriginalFilename();
//filePath不传默认存储空间的根目录
//jpg,jpeg,png,bmp
String key = "original/" + System.currentTimeMillis() + "_" + fileName;
boolean flag = ossUtil.uploadFileByStream(file.getInputStream(), key, null);
if (flag) {
char slash = '/';
char point = '.';
if (fileName != null) {
if (fileName.lastIndexOf(slash) >= 0) {
tSalaryStandardOriginal.setAttaName(fileName.substring(fileName.lastIndexOf(slash)));
} else {
tSalaryStandardOriginal.setAttaName(fileName);
}
if (fileName.lastIndexOf(point) >= 0) {
tSalaryStandardOriginal.setAttaType(fileName.substring(fileName.lastIndexOf(point)));
} else {
tSalaryStandardOriginal.setAttaType(fileName);
}
}
tSalaryStandardOriginal.setAttaSize(file.getSize());
tSalaryStandardOriginal.setAttaSrc(key);
} else {
return R.failed("failed:上传至存储空间失败");
}
tSalaryStandardOriginalService.save(tSalaryStandardOriginal);
for (TSalaryStandardOriginalDetail detail : detailList) {
detail.setOriginalId(tSalaryStandardOriginal.getId());
}
tSalaryStandardOriginalDetailService.saveBatch(detailList);
return R.ok("保存成功!");
} else {
return R.failed("请传参!");
}
}
/**
* @Description: 获取表头等信息
* @Author: hgw
* @Date: 2024-4-3 16:49:22
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@SysLog("获取表头等信息")
@Operation(description = "获取表头等信息")
@PostMapping("/getExcelHeader")
public R<ExcelSheetVo> getExcelHeader(@RequestBody MultipartFile file, @RequestParam String sheetName) {
return tSalaryStandardOriginalService.getExcelHeader(file, sheetName);
}
/**
* @Description: 新版原表识别导入
* @Author: hgw
* @Date: 2024-4-8 18:04:56
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@SysLog("新版原表识别导入")
@Operation(description = "新版原表识别导入")
@PostMapping("/salaryUploadByOriginal")
public R<SalaryUploadParamVo> salaryUploadByOriginal(MultipartFile file, SalaryUploadOriginalParamVo vo) {
return tSalaryStandardOriginalService.salaryUploadByOriginal(file, vo);
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginalDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 薪资原表识别导入
*
* @author hgw
* @date 2024-4-2 11:57:29
*/
@Mapper
public interface TSalaryStandardOriginalDetailMapper extends BaseMapper<TSalaryStandardOriginalDetail> {
/**
* 薪资原表识别导入-分页
*/
IPage<TSalaryStandardOriginalDetail> getTSalaryStandardOriginalDetailPage(Page<TSalaryStandardOriginalDetail> page
, @Param("tSalaryStandardOriginalDetail") TSalaryStandardOriginalDetail tSalaryStandardOriginalDetail);
/**
* 薪资原表识别导入-分页
*/
List<TSalaryStandardOriginalDetail> getTSalaryStandardOriginalDetailByOrgId(@Param("originalId") String originalId);
/**
* @Description: 删除关系
* @Author: hgw
* @Date: 2024/4/3 15:42
* @return: int
**/
int deleteByOrgId(@Param("originalId") String originalId);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 薪资原表识别导入
*
* @author hgw
* @date 2024-4-2 11:57:29
*/
@Mapper
public interface TSalaryStandardOriginalMapper extends BaseMapper<TSalaryStandardOriginal> {
/**
* 薪资原表识别导入-分页
*/
IPage<TSalaryStandardOriginal> getTSalaryStandardOriginalPage(Page<TSalaryStandardOriginal> page
, @Param("tSalaryStandardOriginal") TSalaryStandardOriginal tSalaryStandardOriginal);
/**
* 薪资原表识别导入-分页
*/
List<TSalaryStandardOriginal> getTSalaryStandardOriginalList(
@Param("tSalaryStandardOriginal") TSalaryStandardOriginal tSalaryStandardOriginal);
/**
* 特殊身份证允许识别为数据行
*/
List<String> getSpecialIdCardList();
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.service;
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.salary.entity.TSalaryStandardOriginalDetail;
import java.util.List;
/**
* 薪资原表识别
*
* @author hgw
* @date 2024-4-2 17:20:36
*/
public interface TSalaryStandardOriginalDetailService extends IService<TSalaryStandardOriginalDetail> {
/**
* @Description: 分页查询
* @Author: hgw
* @Date: 2024/4/2 17:20
* @return:
**/
IPage<TSalaryStandardOriginalDetail> getTSalaryStandardOriginalPage(Page<TSalaryStandardOriginalDetail> page, TSalaryStandardOriginalDetail tSalaryStandardOriginalDetail);
/**
* @param originalId
* @Description: 获取详情
* @Author: hgw
* @Date: 2024/4/2 18:18
* @return: java.util.List<com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginalDetail>
**/
List<TSalaryStandardOriginalDetail> getTSalaryStandardOriginalDetailByOrgId(String originalId);
/**
* @param originalId
* @Description: 删除关系
* @Author: hgw
* @Date: 2024/4/3 15:39
* @return: boolean
**/
int deleteByOrgId(String originalId);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.service;
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.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal;
import com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelSheetVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadOriginalParamVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadParamVo;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* 薪资原表识别
*
* @author hgw
* @date 2024-4-2 17:20:36
*/
public interface TSalaryStandardOriginalService extends IService<TSalaryStandardOriginal> {
/**
* @Description: 分页查询
* @Author: hgw
* @Date: 2024/4/2 17:20
* @return:
**/
IPage<TSalaryStandardOriginal> getTSalaryStandardOriginalPage(Page<TSalaryStandardOriginal> page, TSalaryStandardOriginal tSalaryStandardOriginal);
List<TSalaryStandardOriginal> getTSalaryStandardOriginalList(TSalaryStandardOriginal tSalaryStandardOriginal);
/**
* @param file
* @Description: 识别表头主类
* @Author: hgw
* @Date: 2024/4/3 17:40
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelVo>
**/
R<ExcelSheetVo> getExcelHeader(MultipartFile file, String sheetName);
/**
* @param excelVo
* @Description: 新版原表识别导入
* @Author: hgw
* @Date: 2024/4/8 18:05
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage>>
**/
R<SalaryUploadParamVo> salaryUploadByOriginal(MultipartFile file, SalaryUploadOriginalParamVo excelVo);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginalDetail;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryStandardOriginalDetailMapper;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalDetailService;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 薪资原表识别
* @author hgw
* @date 2024-4-2 17:20:46
*/
@Log4j2
@Service
@AllArgsConstructor
public class TSalaryStandardOriginalDetailServiceImpl extends ServiceImpl<TSalaryStandardOriginalDetailMapper, TSalaryStandardOriginalDetail>
implements TSalaryStandardOriginalDetailService {
/**
* @Description: 分页查询
* @Author: hgw
* @Date: 2024/4/2 17:19
* @return:
**/
@Override
public IPage<TSalaryStandardOriginalDetail> getTSalaryStandardOriginalPage(Page<TSalaryStandardOriginalDetail> page, TSalaryStandardOriginalDetail tSalaryStandardOriginalDetail) {
return baseMapper.getTSalaryStandardOriginalDetailPage(page, tSalaryStandardOriginalDetail);
}
@Override
public List<TSalaryStandardOriginalDetail> getTSalaryStandardOriginalDetailByOrgId(String originalId) {
return baseMapper.getTSalaryStandardOriginalDetailByOrgId(originalId);
}
/**
* @Description: 删除关系
* @Author: hgw
* @Date: 2024/4/3 15:42
* @return: int
**/
@Override
public int deleteByOrgId(String originalId) {
return baseMapper.deleteByOrgId(originalId);
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginalDetail;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryStandardOriginalMapper;
import com.yifu.cloud.plus.v1.yifu.salary.service.SalaryUploadService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalDetailService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalService;
import com.yifu.cloud.plus.v1.yifu.salary.util.SalaryConstants;
import com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelColumnVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelSheetVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadOriginalParamVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadParamVo;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 薪资原表识别
*
* @author hgw
* @date 2024-4-2 17:20:46
*/
@Log4j2
@Service
@AllArgsConstructor
public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStandardOriginalMapper, TSalaryStandardOriginal>
implements TSalaryStandardOriginalService {
private final SalaryUploadService salaryUploadService;
private final TSalaryStandardOriginalDetailService tSalaryStandardOriginalDetailService;
/**
* @Description: 分页查询
* @Author: hgw
* @Date: 2024/4/2 17:19
* @return:
**/
@Override
public IPage<TSalaryStandardOriginal> getTSalaryStandardOriginalPage(Page<TSalaryStandardOriginal> page, TSalaryStandardOriginal tSalaryStandardOriginal) {
return baseMapper.getTSalaryStandardOriginalPage(page, tSalaryStandardOriginal);
}
/**
* @Description: 分页查询
* @Author: hgw
* @Date: 2024/4/2 17:19
* @return:
**/
@Override
public List<TSalaryStandardOriginal> getTSalaryStandardOriginalList(TSalaryStandardOriginal tSalaryStandardOriginal) {
return baseMapper.getTSalaryStandardOriginalList(tSalaryStandardOriginal);
}
/**
* @param file
* @Description: 核心解析
* @Author: hgw
* @Date: 2024/4/8 17:05
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelVo>
**/
@Override
public R<ExcelSheetVo> getExcelHeader(MultipartFile file, String sheetName) {
// 特殊身份证允许识别为数据行
List<String> specialIdCardList = baseMapper.getSpecialIdCardList();
try {
//对前端传递的文件进行校验
if (file == null || file.isEmpty()) {
return R.failed("文件为空,重新上传");
}
//对前端传递的文件进行校验
if (Common.isEmpty(sheetName)) {
return R.failed("sheet名为空,请选择!");
}
//获取文件名称 判断文件是否为 Execl
String filename = file.getOriginalFilename();
if (filename == null || Common.isEmpty(filename)) {
return R.failed("文件名称为空,请重新上传!");
}
if (!(filename.endsWith(".xls") || filename.endsWith(".xlsx"))) {
return R.failed("文件名称格式有误,请重新上传!" + filename);
}
R<ExcelSheetVo> voR;
ExcelSheetVo vo = null;
InputStream inputStream = file.getInputStream();
//根据文件格式 对应不同的api解析
if (filename.endsWith(".xlsx")) {
voR = readXlsx(inputStream, specialIdCardList, true, sheetName);
} else {
voR = readXls(inputStream, specialIdCardList, true, sheetName);
}
if (voR != null && voR.getCode() == CommonConstants.SUCCESS) {
vo = voR.getData();
} else {
return R.failed(voR == null ? "识别表格异常!" : voR.getMsg());
}
//数据保存
if (Common.isNotNull(vo.getErrorInfo())) {
return R.failed(vo.getErrorInfo());
}
return R.ok(vo);
} catch (IOException e) {
e.printStackTrace();
log.error("解析表头失败!" + e.getMessage());
}
return R.failed("解析表头失败");
}
/**
* @param inputStream
* @param specialIdCardList
* @param titleFlag true:返回title;false:返回content
* @Description: 解析xls
* @Author: hgw
* @Date: 2024/4/8 17:02
* @return: com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelVo
**/
private R<ExcelSheetVo> readXls(InputStream inputStream, List<String> specialIdCardList, boolean titleFlag
, String sheetName) throws IOException {
HSSFWorkbook sheets = null;
ExcelSheetVo sheetVo = new ExcelSheetVo();
try {
List<ExcelColumnVo> titleList;
List<ExcelColumnVo> columnList;
ExcelColumnVo columnVo;
// 内容list
List<Map<String, String>> contentList;
// 每一行的内容map
Map<String, String> contentMap;
// 存储每一列有值的表头
Map<String, String> titleMap = new HashMap<>();
sheets = new HSSFWorkbook(inputStream);
// sheet
HSSFSheet sheetAt;
HSSFRow row;
// 获取sheet数量
int sheetNum = sheets.getNumberOfSheets();
// 每个单元格内容
String cellValue;
// 内容行
int dataRow;
// 身份证所在列
int idCardColumn = -1;
// 空白列起始号
int nullColumn = -1;
// 上一个空白行
int preNullColumn = -1;
// 空白列数(一旦数量达到 maxNullColumNum,将停止循环列,并删除title list与content)
int nullColumnNum = 0;
// 极限空白列,超过阈值,将不继续循环列
int maxNullColumNum = 10;
String idCardValue = null;
// 数据行是否被确认,true否
boolean dataRowFlag;
// 超过极限空白列maxNullColumNum,只循环表头 true:未超越
boolean nullFlag = true;
// 极限空白表头列,超过阈值,将不继续循环列
int maxTitleNullColumNum = 50;
HSSFCell cell;
// 循环每个sheet
for (int i = 0; i < sheetNum; i++) {
sheetAt = sheets.getSheetAt(i);
if (Common.isNotNull(sheetAt.getSheetName()) && Common.isNotNull(sheetName)
&& sheetName.equals(sheetAt.getSheetName())) {
contentList = new ArrayList<>();
// 塞sheet名称
sheetVo.setSheetName(sheetAt.getSheetName());
titleList = new ArrayList<>();
// 初始化每个sheet的数据行
dataRow = 0;
dataRowFlag = true;
// 循环当前sheet的每行内容
for (int rowNum = 0; rowNum <= sheetAt.getLastRowNum(); rowNum++) {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
nullFlag = true;
idCardValue = null;
contentMap = new HashMap<>();
columnList = new ArrayList<>();
row = sheetAt.getRow(rowNum);
if (row != null) {
for (int cellNum = 0; cellNum < row.getLastCellNum(); cellNum++) {
columnVo = new ExcelColumnVo();
try {
cell = row.getCell(cellNum);
if (cell == null) {
cellValue = "";
} else {
if (cell.getCellType() == CellType.FORMULA) {
cell.setCellType(CellType.STRING);
cellValue = cell.getStringCellValue();
} else if (CellType.STRING == cell.getCellType()) {
cellValue = row.getCell(cellNum).getStringCellValue();
} else if (CellType.NUMERIC == cell.getCellType()) {
try {
cellValue = String.valueOf(row.getCell(cellNum).getNumericCellValue());
if (cellValue.contains("E")) {
cellValue = String.valueOf(new DecimalFormat("#").format(row.getCell(cellNum).getNumericCellValue()));
}
} catch (NumberFormatException e) {
cell.setCellType(CellType.STRING);
cellValue = String.valueOf(row.getCell(cellNum).getStringCellValue());
}
} else if (HSSFDateUtil.isCellDateFormatted(cell)) {
cellValue = String.valueOf(row.getCell(cellNum).getDateCellValue());
} else if (CellType.BOOLEAN == cell.getCellType()) {
cellValue = String.valueOf(row.getCell(cellNum).getBooleanCellValue());
} else {
cellValue = row.getCell(cellNum).getStringCellValue();
}
}
} catch (Exception e) {
cellValue = "";
//sheetVo.setErrorInfo("请注意单元格格式,第" + (i + 1) + "个sheet,第" + (rowNum + 1) + "行第" + (cellNum + 1) + "列。" + e.getMessage())
//return sheetVo
}
if (Common.isNotNull(cellValue) && dataRowFlag
&& (((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue))
// 特殊身份证允许识别
|| regSpecialIdCard(cellValue, specialIdCardList))) {
dataRow = rowNum;
idCardColumn = cellNum;
dataRowFlag = false;
}
columnVo.setLineNum(cellNum);
columnVo.setContent(cellValue);
if (Common.isNotNull(cellValue)) {
titleMap.put(String.valueOf(cellNum), cellValue);
}
if (nullFlag) {
contentMap.put(String.valueOf(cellNum), cellValue);
if (dataRowFlag) {
if (Common.isEmpty(cellValue)) {
if (titleMap.get(String.valueOf(cellNum)) != null) {
columnVo.setContent(titleMap.get(String.valueOf(cellNum)));
} else {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
columnVo.setContent("空白列" + cellNum);
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
}
columnList.add(columnVo);
} else {
if (Common.isEmpty(cellValue)) {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
}
}
if (nullColumnNum >= maxNullColumNum) {
for (int num = maxNullColumNum - 1; num >= 0; num--) {
if (dataRowFlag) {
columnList.remove(nullColumn + num);
}
contentMap.remove(String.valueOf(nullColumn + num));
}
nullFlag = false;
}
if (idCardColumn != -1 && cellNum == idCardColumn) {
idCardValue = cellValue;
}
} else {
if (Common.isEmpty(cellValue)) {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
}
// 表头Map超过50,跳出当前行的列循环
if (nullColumnNum >= maxTitleNullColumNum) {
break;
}
}
}
if (!dataRowFlag) {
contentList.add(contentMap);
} else {
titleList = new ArrayList<>(columnList);
}
}
if (rowNum >= 50 && dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!");
}
if (titleFlag && !dataRowFlag) {
break;
}
// 阻断空白行
if (idCardColumn != -1 && Common.isEmpty(idCardValue)) {
if (!contentList.isEmpty() && contentList.size() > 1) {
contentList.remove(contentList.size() - 1);
}
break;
}
}
if (dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!!");
}
sheetVo.setDataNum(dataRow);
sheetVo.setTitleList(titleList);
sheetVo.setContentList(contentList);
return R.ok(sheetVo);
}
}
} catch (IOException e) {
e.printStackTrace();
if (sheets != null) {
sheets.close();
}
} finally {
if (sheets != null) {
sheets.close();
}
}
return R.ok(sheetVo);
}
/**
* @param inputStream
* @param specialIdCardList
* @param titleFlag true:返回title;false:返回content
* @Description: 解析xlsx
* @Author: hgw
* @Date: 2024/4/8 17:02
* @return: com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelVo
**/
private R<ExcelSheetVo> readXlsx(InputStream inputStream, List<String> specialIdCardList, boolean titleFlag
, String sheetName) throws IOException {
XSSFWorkbook sheets = null;
ExcelSheetVo sheetVo = new ExcelSheetVo();
try {
List<ExcelColumnVo> titleList;
List<ExcelColumnVo> columnList;
ExcelColumnVo columnVo;
// 内容list
List<Map<String, String>> contentList;
// 每一行的内容map
Map<String, String> contentMap;
// 存储每一列有值的表头
Map<String, String> titleMap = new HashMap<>();
sheets = new XSSFWorkbook(inputStream);
// sheet
XSSFSheet sheetAt;
XSSFRow row;
// 获取sheet数量
int sheetNum = sheets.getNumberOfSheets();
// 每个单元格内容
String cellValue;
// 内容行
int dataRow;
// 身份证所在列
int idCardColumn = -1;
// 空白列起始号
int nullColumn = -1;
// 上一个空白行
int preNullColumn = -1;
// 空白列数(一旦数量达到 maxNullColumNum,将停止循环列,并删除title list与content)
int nullColumnNum = 0;
// 极限空白列,超过阈值,将不继续循环列
int maxNullColumNum = 10;
String idCardValue = null;
// 数据行是否被确认,true否
boolean dataRowFlag;
// 超过极限空白列maxNullColumNum,只循环表头 true:未超越
boolean nullFlag = true;
// 极限空白表头列,超过阈值,将不继续循环列
int maxTitleNullColumNum = 50;
XSSFCell cell;
// 循环每个sheet
for (int i = 0; i < sheetNum; i++) {
sheetAt = sheets.getSheetAt(i);
if (Common.isNotNull(sheetAt.getSheetName()) && Common.isNotNull(sheetName)
&& sheetName.equals(sheetAt.getSheetName())) {
contentList = new ArrayList<>();
// 塞sheet名称
sheetVo.setSheetName(sheetAt.getSheetName());
titleList = new ArrayList<>();
// 初始化每个sheet的数据行
dataRow = 0;
dataRowFlag = true;
// 循环当前sheet的每行内容
for (int rowNum = 0; rowNum <= sheetAt.getLastRowNum(); rowNum++) {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
nullFlag = true;
idCardValue = null;
contentMap = new HashMap<>();
columnList = new ArrayList<>();
row = sheetAt.getRow(rowNum);
if (row != null) {
for (int cellNum = 0; cellNum < row.getLastCellNum(); cellNum++) {
columnVo = new ExcelColumnVo();
try {
cell = row.getCell(cellNum);
if (cell == null) {
cellValue = "";
} else {
if (cell.getCellType() == CellType.FORMULA) {
cell.setCellType(CellType.STRING);
cellValue = cell.getStringCellValue();
} else if (CellType.STRING == cell.getCellType()) {
cellValue = row.getCell(cellNum).getStringCellValue();
} else if (CellType.NUMERIC == cell.getCellType()) {
try {
cellValue = String.valueOf(row.getCell(cellNum).getNumericCellValue());
if (cellValue.contains("E")) {
cellValue = String.valueOf(new DecimalFormat("#").format(row.getCell(cellNum).getNumericCellValue()));
}
} catch (NumberFormatException e) {
cell.setCellType(CellType.STRING);
cellValue = String.valueOf(row.getCell(cellNum).getStringCellValue());
}
} else if (HSSFDateUtil.isCellDateFormatted(cell)) {
cellValue = String.valueOf(row.getCell(cellNum).getDateCellValue());
} else if (CellType.BOOLEAN == cell.getCellType()) {
cellValue = String.valueOf(row.getCell(cellNum).getBooleanCellValue());
} else {
cellValue = row.getCell(cellNum).getStringCellValue();
}
}
} catch (Exception e) {
cellValue = "";
//sheetVo.setErrorInfo("请注意单元格格式,第" + (i + 1) + "个sheet,第" + (rowNum + 1) + "行第" + (cellNum + 1) + "列。" + e.getMessage())
//return sheetVo
}
if (Common.isNotNull(cellValue) && dataRowFlag
&& (((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue))
// 特殊身份证允许识别
|| regSpecialIdCard(cellValue, specialIdCardList))) {
dataRow = rowNum;
idCardColumn = cellNum;
dataRowFlag = false;
}
columnVo.setLineNum(cellNum);
columnVo.setContent(cellValue);
if (Common.isNotNull(cellValue)) {
titleMap.put(String.valueOf(cellNum), cellValue);
}
if (nullFlag) {
contentMap.put(String.valueOf(cellNum), cellValue);
if (dataRowFlag) {
if (Common.isEmpty(cellValue)) {
if (titleMap.get(String.valueOf(cellNum)) != null) {
columnVo.setContent(titleMap.get(String.valueOf(cellNum)));
} else {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
columnVo.setContent("空白列" + cellNum);
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
}
columnList.add(columnVo);
} else {
if (Common.isEmpty(cellValue)) {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
}
}
if (nullColumnNum >= maxNullColumNum) {
for (int num = maxNullColumNum - 1; num >= 0; num--) {
if (dataRowFlag) {
columnList.remove(nullColumn + num);
}
contentMap.remove(String.valueOf(nullColumn + num));
}
nullFlag = false;
}
if (idCardColumn != -1 && cellNum == idCardColumn) {
idCardValue = cellValue;
}
} else {
if (Common.isEmpty(cellValue)) {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
}
// 表头Map超过50,跳出当前行的列循环
if (nullColumnNum >= maxTitleNullColumNum) {
break;
}
}
}
if (!dataRowFlag) {
contentList.add(contentMap);
} else {
titleList = new ArrayList<>(columnList);
}
}
if (rowNum >= 50 && dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!");
}
if (titleFlag && !dataRowFlag) {
break;
}
// 阻断空白行
if (idCardColumn != -1 && Common.isEmpty(idCardValue)) {
if (!contentList.isEmpty() && contentList.size() > 1) {
contentList.remove(contentList.size() - 1);
}
break;
}
}
if (dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!!");
}
sheetVo.setDataNum(dataRow);
sheetVo.setTitleList(titleList);
sheetVo.setContentList(contentList);
return R.ok(sheetVo);
}
}
} catch (IOException e) {
e.printStackTrace();
if (sheets != null) {
sheets.close();
}
} finally {
if (sheets != null) {
sheets.close();
}
}
return R.ok(sheetVo);
}
/**
* @param content
* @Description: 判断特殊身份证
* 格式正确返回true
* @Author: hgw
* @Date: 2024-4-8 15:33:04
* @return: boolean
**/
private static boolean regSpecialIdCard(String content, List<String> specialIdCardList) {
if (specialIdCardList != null && !specialIdCardList.isEmpty()) {
for (int i = 0; i < specialIdCardList.size(); i++) {
if (specialIdCardList.get(i).equals(content)) {
return true;
}
}
}
return false;
}
/**
* @param content
* @Description: 判断身份证格式:18位数字,17位数字+X,15位数字,14位数字+X
* 格式正确返回true
* @Author: hgw
* @Date: 2022/5/13 11:53
* @return: boolean
**/
private static boolean regIdCard(String content) {
boolean flag = false;
Pattern p = Pattern.compile("\\d{18}|\\d{17}X|\\d{15}|\\d{14}X");
Matcher m = p.matcher(content);
if (m.matches()) {
flag = true;
}
return flag;
}
/**
* @param excelVo
* @Description: 新版原表识别导入
* @Author: hgw
* @Date: 2024/4/8 18:22
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage>>
**/
@Override
public R<SalaryUploadParamVo> salaryUploadByOriginal(MultipartFile file, SalaryUploadOriginalParamVo excelVo) {
return this.getExcelContent(file, excelVo);
}
/**
* @param excelVo
* @Description: 核心解析-内容
* @Author: hgw
* @Date: 2024-4-8 18:20:22
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelVo>
**/
private R<SalaryUploadParamVo> getExcelContent(MultipartFile file, SalaryUploadOriginalParamVo excelVo) {
try {
String sheetName = excelVo.getSheetName();
// 配置
String originalId = excelVo.getOriginalId();
// 特殊身份证允许识别为数据行
List<String> specialIdCardList = baseMapper.getSpecialIdCardList();
//对前端传递的文件进行校验
if (Common.isEmpty(originalId)) {
return R.failed("识别配置为空,请选择识别配置!");
}
List<TSalaryStandardOriginalDetail> detailList = tSalaryStandardOriginalDetailService.getTSalaryStandardOriginalDetailByOrgId(originalId);
Map<String, TSalaryStandardOriginalDetail> detailMap = new HashMap<>();
for (TSalaryStandardOriginalDetail detail : detailList) {
if (Common.isEmpty(detail.getModelName())
&& ("是否新员工(默认否)".equals(detail.getExcelName())
|| "开户行总行".equals(detail.getExcelName())
|| "开户行省".equals(detail.getExcelName())
|| "开户行市".equals(detail.getExcelName())
|| "开户行支行".equals(detail.getExcelName())
|| "银行卡号".equals(detail.getExcelName())
|| "手机号码".equals(detail.getExcelName())
|| "计税月份".equals(detail.getExcelName()))) {
detail.setModelName(detail.getExcelName());
}
detailMap.put(String.valueOf(detail.getColumnNo()), detail);
}
//对前端传递的文件进行校验
if (Common.isEmpty(sheetName)) {
return R.failed("sheet名为空,请选择!");
}
//对前端传递的文件进行校验
if (file == null || file.isEmpty()) {
return R.failed("文件为空,重新上传");
}
//获取文件名称 判断文件是否为 Execl
String filename = file.getOriginalFilename();
if (filename == null || Common.isEmpty(filename)) {
return R.failed("文件名称为空,请重新上传!");
}
if (!(filename.endsWith(".xls") || filename.endsWith(".xlsx"))) {
return R.failed("文件名称格式有误,请重新上传!" + filename);
}
String jsonString = null;
InputStream inputStream = file.getInputStream();
R<ExcelSheetVo> voR;
ExcelSheetVo vo;
//根据文件格式 对应不同的api解析
if (filename.endsWith(".xlsx")) {
voR = readXlsx(inputStream, specialIdCardList, false, sheetName);
} else {
voR = readXls(inputStream, specialIdCardList, false, sheetName);
}
if (voR != null && voR.getCode() == CommonConstants.SUCCESS) {
vo = voR.getData();
} else {
return R.failed(voR == null ? "识别表格异常!" : voR.getMsg());
}
if (vo.getTitleList() != null && !vo.getTitleList().isEmpty()) {
ExcelColumnVo title;
TSalaryStandardOriginalDetail detail;
for (int i = 0; i < vo.getTitleList().size(); i++) {
title = vo.getTitleList().get(i);
if (Common.isNotNull(title.getContent())) {
if (detailMap.get(String.valueOf(title.getLineNum())) == null) {
if (!"是否新员工(默认否)".equals(title.getContent())
&& !"开户行总行".equals(title.getContent())
&& !"开户行省".equals(title.getContent())
&& !"开户行市".equals(title.getContent())
&& !"开户行支行".equals(title.getContent())
&& !"银行卡号".equals(title.getContent())
&& !"手机号码".equals(title.getContent())
&& !"计税月份".equals(title.getContent())) {
return R.failed("未找到对应配置的表头,请核实导入的原表信息后,重新尝试!");
//return R.failed("表头与导入的不一致,第" + title.getLineNum() + "列表头【" + title.getContent() + "】未找到配置,请先配置表头!");
} else if ("是否新员工(默认否)".equals(title.getContent())
|| "开户行总行".equals(title.getContent())
|| "开户行省".equals(title.getContent())
|| "开户行市".equals(title.getContent())
|| "开户行支行".equals(title.getContent())
|| "银行卡号".equals(title.getContent())
|| "手机号码".equals(title.getContent())
|| "计税月份".equals(title.getContent())) {
detail = new TSalaryStandardOriginalDetail();
detail.setModelName(title.getContent());
detailMap.put(String.valueOf(title.getLineNum()), detail);
}
} else if (!title.getContent().equals(detailMap.get(String.valueOf(title.getLineNum())).getExcelName())
&& (!"是否新员工(默认否)".equals(title.getContent())
|| !"开户行总行".equals(title.getContent())
|| !"开户行省".equals(title.getContent())
|| !"开户行市".equals(title.getContent())
|| !"开户行支行".equals(title.getContent())
|| !"银行卡号".equals(title.getContent())
|| !"手机号码".equals(title.getContent())
|| !"计税月份".equals(title.getContent()))
) {
return R.failed("未找到对应配置的表头,请核实导入的原表信息后,重新尝试!!");
//return R.failed("表头与导入的不一致,第" + (i + 1) + "列应为【" + detailMap.get(String.valueOf(title.getLineNum())).getExcelName() + "】,实际为【" + title.getContent() + "】");
}
} else if (detailMap.get(String.valueOf(title.getLineNum())) != null && Common.isNotNull(detailMap.get(String.valueOf(title.getLineNum())).getExcelName())) {
return R.failed("未找到对应配置的表头,请核实导入的原表信息后,重新尝试!!!");
//return R.failed("表头与导入的不一致,第" + (i + 1) + "列应为【" + detailMap.get(String.valueOf(title.getLineNum())).getExcelName() + "】,实际为空!");
}
}
} else {
return R.failed("表格没有表头,请检查表格数据!");
}
if (vo.getContentList() != null && !vo.getContentList().isEmpty()) {
// 智能识别表头
TSalaryStandardOriginalDetail detail;
List<Map<String, String>> contentList = new ArrayList<>();
Map<String, String> newRowMap;
String value;
String oldValue;
int i = 0;
List<TCheckIdCard> checkList = new ArrayList<>();
TCheckIdCard check;
// StringBuilder errMsg = new StringBuilder()
for (Map<String, String> rowMap : vo.getContentList()) {
i++;
newRowMap = new HashMap<>();
check = new TCheckIdCard();
for (Map.Entry<String, String> column : rowMap.entrySet()) {
detail = detailMap.get(column.getKey());
if (detail != null && Common.isNotNull(detail.getModelName())) {
value = column.getValue();
try {
if ("REDUCE".equals(detail.getFlag())) {
value = String.valueOf(new BigDecimal(value).negate());
}
oldValue = newRowMap.get(detail.getModelName());
if (oldValue != null) {
value = String.valueOf(new BigDecimal(oldValue).add(new BigDecimal(value))
.setScale(SalaryConstants.PLACES, BigDecimal.ROUND_HALF_UP));
}
} catch (NumberFormatException e) {
return R.failed("数据行第 " + i + " 行,第 " + (Integer.parseInt(column.getKey()) + 1) + " 列 不是金额,不可以进行加减计算!");
}
newRowMap.put(detail.getModelName(), value);
if (SalaryConstants.ID_NUMBER.equals(detail.getModelName())) {
check.setIdCard(value);
}
if (SalaryConstants.EMP_NAME2.equals(detail.getModelName())) {
check.setName(value);
}
}
}
if (Common.isEmpty(check.getIdCard())) {
return R.failed("数据行第 " + i + " 行,无身份证号!");
}
if (Common.isEmpty(check.getName())) {
return R.failed("数据行第 " + i + " 行,无员工姓名!");
}
// 调用校验服务
/*String pre = "姓名与身份证验证:";
R<TCheckIdCard> checkListR = HttpDaprUtil.invokeMethodPost(checkProperties.getAppUrl(), checkProperties.getAppId()
, "/tcheckidcard/inner/checkIdCardSingle", check, TCheckIdCard.class, SecurityConstants.FROM_IN);
if (checkListR != null && checkListR.getData() != null) {
TCheckIdCard checkR = checkListR.getData();
if (checkR == null || Common.isEmpty(checkR.getIsTrue())) {
errMsg.append("第 ").append(i).append(" 行:").append(check.getIdCard()).append(pre).append("校验服务器未返回,请联系管理员!");
} else if (checkR.getIsTrue() == CommonConstants.ZERO_INT) {
errMsg.append("第 ").append(i).append(" 行:").append(check.getIdCard()).append(pre).append(check.getReason());
}
} else {
errMsg.append("第 ").append(i).append(" 行:").append(check.getIdCard()).append(pre).append("校验服务器未返回,请联系管理员!!");
}*/
checkList.add(check);
contentList.add(newRowMap);
}
/*if (Common.isNotNull(errMsg) && Common.isNotNull(errMsg.toString())) {
return R.failed(errMsg.toString());
}*/
/*// 调用校验服务
CheckIdCardListVo checkVo = new CheckIdCardListVo();
checkVo.setCheckList(checkList);
R<CheckIdCardListVo> checkListR = HttpDaprUtil.invokeMethodPost(checkProperties.getAppUrl(), checkProperties.getAppId()
, "/tcheckidcard/inner/checkIdCardList", checkVo, CheckIdCardListVo.class, SecurityConstants.FROM_IN);
if (checkListR != null && checkListR.getData() != null) {
CheckIdCardListVo checkReturnVo = checkListR.getData();
if (checkReturnVo.getCode() != CommonConstants.SUCCESS) {
if (checkReturnVo.getCheckList() != null && !checkReturnVo.getCheckList().isEmpty()) {
int cardRow = 0;
StringBuilder errMsg = new StringBuilder();
for (TCheckIdCard card : checkReturnVo.getCheckList()) {
cardRow++;
if (card.getIsTrue() == 0) {
errMsg.append(" 第").append(cardRow).append("行:").append(card.getIdCard()).append(",姓名身份证校验错误! ");
}
}
return R.failed(errMsg.toString());
} else {
return R.failed(checkReturnVo.getErrorMsg());
}
}
} else {
return R.failed("原表识别校验姓名身份证,但是校验服务器未返回,请联系管理员!");
}*/
// 最后转化为jsonString
jsonString = JSON.toJSON(contentList).toString();
SalaryUploadParamVo returnVo = new SalaryUploadParamVo();
returnVo.setDataNum(vo.getDataNum());
returnVo.setCheckList(checkList);
returnVo.setJsonString(jsonString);
returnVo.setSalaryType(excelVo.getSalaryType());
returnVo.setConfigId(excelVo.getConfigId());
returnVo.setIsIssue(excelVo.getIsIssue());
returnVo.setOrderId(excelVo.getOrderId());
returnVo.setResList(excelVo.getResList());
returnVo.setSettleDepart(excelVo.getSettleDepart());
//数据保存
return R.ok(returnVo);
}
return R.failed("无法识别数据!请联系管理员");
} catch (IOException e) {
e.printStackTrace();
}
return R.failed("无法识别数据!请联系管理员!");
}
}
...@@ -143,6 +143,11 @@ public class SalaryAccountUtil implements Serializable { ...@@ -143,6 +143,11 @@ public class SalaryAccountUtil implements Serializable {
List<String> otherIdCard = new ArrayList<>(); List<String> otherIdCard = new ArrayList<>();
BigDecimal phoneSubsidyMoney; BigDecimal phoneSubsidyMoney;
TSalaryAccountItem phoneSubsidyItem; TSalaryAccountItem phoneSubsidyItem;
// 基础的数据行,用于返回信息
int dataRow = 2;
if (Common.isNotNull(vo.getDataNum())) {
dataRow = 1 + vo.getDataNum();
}
for (int i = 0; i < rows; i++) { for (int i = 0; i < rows; i++) {
annualBonusFlag = false; annualBonusFlag = false;
errorFlag = true; errorFlag = true;
...@@ -169,8 +174,8 @@ public class SalaryAccountUtil implements Serializable { ...@@ -169,8 +174,8 @@ public class SalaryAccountUtil implements Serializable {
cellValueStr = getStringValByObject(cellValueObj); cellValueStr = getStringValByObject(cellValueObj);
if (!StringUtils.isNotBlank(cellValueStr)) { if (!StringUtils.isNotBlank(cellValueStr)) {
errorFlag = false; errorFlag = false;
error = "第" + (i + 2) + "行:" + entry.getKey() + "列_不识别对象类型"; error = "第" + (i + dataRow) + "行:" + entry.getKey() + "列_不识别对象类型";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
dbFiedName = scs.getDbFiedName(); dbFiedName = scs.getDbFiedName();
...@@ -184,8 +189,8 @@ public class SalaryAccountUtil implements Serializable { ...@@ -184,8 +189,8 @@ public class SalaryAccountUtil implements Serializable {
phoneSubsidyMoney = NumberUtils.createBigDecimal(cellValueStr); phoneSubsidyMoney = NumberUtils.createBigDecimal(cellValueStr);
if(phoneSubsidyMoney.compareTo(new BigDecimal("300")) > 0) { if(phoneSubsidyMoney.compareTo(new BigDecimal("300")) > 0) {
errorFlag = false; errorFlag = false;
error = "第" + (i + 2) + "行:本次发放"+cellValueStr+"元,超出300元的限制,禁止导入"; error = "第" + (i + dataRow) + "行:本次发放"+cellValueStr+"元,超出300元的限制,禁止导入";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
} }
...@@ -208,8 +213,8 @@ public class SalaryAccountUtil implements Serializable { ...@@ -208,8 +213,8 @@ public class SalaryAccountUtil implements Serializable {
saiList.add(sai); saiList.add(sai);
} catch (Exception e) { } catch (Exception e) {
errorFlag = false; errorFlag = false;
error = "第" + (i + 2) + "行:应发工资:'" + cellValueStr + "'错误,请检查数据"; error = "第" + (i + dataRow) + "行:应发工资:'" + cellValueStr + "'错误,请检查数据";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
} }
...@@ -224,8 +229,8 @@ public class SalaryAccountUtil implements Serializable { ...@@ -224,8 +229,8 @@ public class SalaryAccountUtil implements Serializable {
saiList.add(sai); saiList.add(sai);
} catch (Exception e) { } catch (Exception e) {
errorFlag = false; errorFlag = false;
error = "第" + (i + 2) + "行:通讯补贴:'" + cellValueStr + "'错误,请检查数据"; error = "第" + (i + dataRow) + "行:通讯补贴:'" + cellValueStr + "'错误,请检查数据";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
} }
...@@ -235,8 +240,8 @@ public class SalaryAccountUtil implements Serializable { ...@@ -235,8 +240,8 @@ public class SalaryAccountUtil implements Serializable {
entity.setActualSalary(actualSalarySum); entity.setActualSalary(actualSalarySum);
} catch (Exception e) { } catch (Exception e) {
errorFlag = false; errorFlag = false;
error = "第" + (i + 2) + "行:实发工资:'" + cellValueStr + "'错误,请检查数据"; error = "第" + (i + dataRow) + "行:实发工资:'" + cellValueStr + "'错误,请检查数据";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
} }
...@@ -249,8 +254,8 @@ public class SalaryAccountUtil implements Serializable { ...@@ -249,8 +254,8 @@ public class SalaryAccountUtil implements Serializable {
new BigDecimal(cellValueStr.replace(",", "")); new BigDecimal(cellValueStr.replace(",", ""));
} catch (Exception ex) { } catch (Exception ex) {
errorFlag = false; errorFlag = false;
error = "第" + (i + 2) + "行:代扣、企业年金,只能是金额!"; error = "第" + (i + dataRow) + "行:代扣、企业年金,只能是金额!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
} }
...@@ -269,11 +274,11 @@ public class SalaryAccountUtil implements Serializable { ...@@ -269,11 +274,11 @@ public class SalaryAccountUtil implements Serializable {
} }
if (SalaryConstants.ID_NUMBER.equals(dbFiedName)) { if (SalaryConstants.ID_NUMBER.equals(dbFiedName)) {
if (checkIdNumberMap.get(cellValueStr) == null) { if (checkIdNumberMap.get(cellValueStr) == null) {
checkIdNumberMap.put(cellValueStr, (i + 2)); checkIdNumberMap.put(cellValueStr, (i + dataRow));
} else { } else {
errorFlag = false; errorFlag = false;
error = "第" + (i + 2) + "行与第:" + checkIdNumberMap.get(cellValueStr) + "行身份证重复:" + cellValueStr; error = "第" + (i + dataRow) + "行与第:" + checkIdNumberMap.get(cellValueStr) + "行身份证重复:" + cellValueStr;
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
break; break;
} }
if (cellValueStr.contains("x")) { if (cellValueStr.contains("x")) {
...@@ -305,7 +310,7 @@ public class SalaryAccountUtil implements Serializable { ...@@ -305,7 +310,7 @@ public class SalaryAccountUtil implements Serializable {
if (cellValueBig.toString().length() > 11) { if (cellValueBig.toString().length() > 11) {
if (cellValueBig.toString().length() > 500) { if (cellValueBig.toString().length() > 500) {
errorFlag = false; errorFlag = false;
errorList.add(new ErrorMessage((i + 2), "文本超长!")); errorList.add(new ErrorMessage((i + dataRow), "文本超长!"));
continue; continue;
} }
sai.setTextValue(cellValueBig.toString()); sai.setTextValue(cellValueBig.toString());
...@@ -315,7 +320,7 @@ public class SalaryAccountUtil implements Serializable { ...@@ -315,7 +320,7 @@ public class SalaryAccountUtil implements Serializable {
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
if (cellValueStr.length() > 500) { if (cellValueStr.length() > 500) {
errorFlag = false; errorFlag = false;
errorList.add(new ErrorMessage((i + 2), "文本超长!")); errorList.add(new ErrorMessage((i + dataRow), "文本超长!"));
continue; continue;
} }
sai.setTextValue(cellValueStr); sai.setTextValue(cellValueStr);
...@@ -331,7 +336,7 @@ public class SalaryAccountUtil implements Serializable { ...@@ -331,7 +336,7 @@ public class SalaryAccountUtil implements Serializable {
&& !SalaryConstants.SALARY_GIVE_TIME.equals(cellValueStr) && !SalaryConstants.SALARY_GIVE_TIME.equals(cellValueStr)
&& !SalaryConstants.SALARY_GIVE_TIME_TWO.equals(cellValueStr)) { && !SalaryConstants.SALARY_GIVE_TIME_TWO.equals(cellValueStr)) {
errorFlag = false; errorFlag = false;
errorList.add(new ErrorMessage((i + 2), "请注意:工资发放时间,只能是【立即发】或【暂停发】!你的内容:【"+cellValueStr+"】")); errorList.add(new ErrorMessage((i + dataRow), "请注意:工资发放时间,只能是【立即发】或【暂停发】!你的内容:【"+cellValueStr+"】"));
continue; continue;
} }
...@@ -342,16 +347,16 @@ public class SalaryAccountUtil implements Serializable { ...@@ -342,16 +347,16 @@ public class SalaryAccountUtil implements Serializable {
&& !SalaryConstants.IS_PERSON_OTHER.equals(cellValueStr) && !SalaryConstants.IS_PERSON_OTHER.equals(cellValueStr)
&& !SalaryConstants.IS_PERSON.equals(cellValueStr)) { && !SalaryConstants.IS_PERSON.equals(cellValueStr)) {
errorFlag = false; errorFlag = false;
errorList.add(new ErrorMessage((i + 2), "请注意:是否个人承担部分税费,只能是【" errorList.add(new ErrorMessage((i + dataRow), "请注意:是否个人承担部分税费,只能是【"
+SalaryConstants.IS_COMPANY+"】或【"+SalaryConstants.IS_PERSON_OTHER+"】或【" +SalaryConstants.IS_COMPANY+"】或【"+SalaryConstants.IS_PERSON_OTHER+"】或【"
+SalaryConstants.IS_PERSON+"】!你的内容:【"+cellValueStr+"】")); +SalaryConstants.IS_PERSON+"】!你的内容:【"+cellValueStr+"】"));
continue; continue;
} }
setFields(field, cellValueStr, attr, fieldType, entity); setFields(field, cellValueStr, attr, fieldType, entity);
error = validateUtil(cellValueStr, attr, (i + 2)); error = validateUtil(cellValueStr, attr, (i + dataRow));
if (null != error) { if (null != error) {
errorFlag = false; errorFlag = false;
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
} }
} }
} }
...@@ -368,44 +373,44 @@ public class SalaryAccountUtil implements Serializable { ...@@ -368,44 +373,44 @@ public class SalaryAccountUtil implements Serializable {
} }
} }
if (Common.isNotNull(must)) { if (Common.isNotNull(must)) {
error = "第" + (i + 2) + "行:" + must + "列_不可缺少"; error = "第" + (i + dataRow) + "行:" + must + "列_不可缺少";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
if (Common.isNotNull(phoneSubsidy)) { if (Common.isNotNull(phoneSubsidy)) {
phoneSubsidyItem = tSalaryEmployeeService.selectByIdcard(newEmp.getEmpIdcard(), nowMonth); phoneSubsidyItem = tSalaryEmployeeService.selectByIdcard(newEmp.getEmpIdcard(), nowMonth);
if (phoneSubsidyItem != null && Common.isNotNull(phoneSubsidyItem.getSalaryMoney()) if (phoneSubsidyItem != null && Common.isNotNull(phoneSubsidyItem.getSalaryMoney())
&& (phoneSubsidyItem.getSalaryMoney().add(phoneSubsidy)).compareTo(new BigDecimal("300")) > 0) { && (phoneSubsidyItem.getSalaryMoney().add(phoneSubsidy)).compareTo(new BigDecimal("300")) > 0) {
error = "第" + (i + 2) + "行:当月已发" + phoneSubsidyItem.getSalaryMoney() + "元,本次发放" + phoneSubsidy + "元,累计超出300元限制,禁止发放!"; error = "第" + (i + dataRow) + "行:当月已发" + phoneSubsidyItem.getSalaryMoney() + "元,本次发放" + phoneSubsidy + "元,累计超出300元限制,禁止发放!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
} }
if (annualBonusFlag && Common.isEmpty(entity.getAnnualBonusType())) { if (annualBonusFlag && Common.isEmpty(entity.getAnnualBonusType())) {
error = "第" + (i + 2) + "行:年终奖有值,【年终奖扣税方式】需填写【单独】/【合并】"; error = "第" + (i + dataRow) + "行:年终奖有值,【年终奖扣税方式】需填写【单独】/【合并】";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
if ("3".equals(salaryType) && actualSalarySum == null) { if ("3".equals(salaryType) && actualSalarySum == null) {
error = "第" + (i + 2) + "行:【劳务费】列_不可缺少"; error = "第" + (i + dataRow) + "行:【劳务费】列_不可缺少";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
if ("3".equals(salaryType) && Common.isEmpty(entity.getIsPersonTax())) { if ("3".equals(salaryType) && Common.isEmpty(entity.getIsPersonTax())) {
error = "第" + (i + 2) + "行:【是否个人承担部分税费】列_不可为空"; error = "第" + (i + dataRow) + "行:【是否个人承担部分税费】列_不可为空";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
if ("4".equals(salaryType) && actualSalarySum == null) { if ("4".equals(salaryType) && actualSalarySum == null) {
error = "第" + (i + 2) + "行:【稿酬】列_不可缺少"; error = "第" + (i + dataRow) + "行:【稿酬】列_不可缺少";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
// 应发、实发、实发劳务费不可都为空 // 应发、实发、实发劳务费不可都为空
if (relaySalary == null && actualSalarySum == null) { if (relaySalary == null && actualSalarySum == null) {
error = "第" + (i + 2) + "行:【应发工资】列_不可缺少"; error = "第" + (i + dataRow) + "行:【应发工资】列_不可缺少";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
// 版本2.6.6判重:对同一“项目”、同一“结算月份”、同一“报表类型”、同一“工资月份”、同一“身份证号”、同一“应发金额”进行校验 // 版本2.6.6判重:对同一“项目”、同一“结算月份”、同一“报表类型”、同一“工资月份”、同一“身份证号”、同一“应发金额”进行校验
...@@ -448,7 +453,7 @@ public class SalaryAccountUtil implements Serializable { ...@@ -448,7 +453,7 @@ public class SalaryAccountUtil implements Serializable {
newEmp.setIssueStatus(isIssue); newEmp.setIssueStatus(isIssue);
// 劳务费要使用人员信息 // 劳务费要使用人员信息
if (!notLabour) { if (!notLabour) {
R<TSalaryEmployee> eR = this.getNewEmp(newEmp, i, errorList, notLabour, entity, salaryType, dept, user R<TSalaryEmployee> eR = this.getNewEmp(newEmp, i + dataRow, errorList, notLabour, entity, salaryType, dept, user
, salaryStyle, salaryGiveTimeFlag, invoiceTitle, tSalaryAccountService , salaryStyle, salaryGiveTimeFlag, invoiceTitle, tSalaryAccountService
, tSalaryEmployeeService, bankMap); , tSalaryEmployeeService, bankMap);
if (eR.getCode() != 200) { if (eR.getCode() != 200) {
...@@ -465,7 +470,7 @@ public class SalaryAccountUtil implements Serializable { ...@@ -465,7 +470,7 @@ public class SalaryAccountUtil implements Serializable {
if (emp != null) { if (emp != null) {
if (setEntityByEmpInfo(dept, ownEmployeeMap, ownDeptMap, salaryType, isIssue, errorList if (setEntityByEmpInfo(dept, ownEmployeeMap, ownDeptMap, salaryType, isIssue, errorList
, entity, emp, saiList, salaryGiveTimeFlag, isNewEmployee, empName, salaryStyle , entity, emp, saiList, salaryGiveTimeFlag, isNewEmployee, empName, salaryStyle
, nowMonth, updateEmpList, checkBankInfoEmpList, i, bankMap)) , nowMonth, updateEmpList, checkBankInfoEmpList, i + dataRow, bankMap))
continue; continue;
} }
if (saiList != null && !saiList.isEmpty()) { if (saiList != null && !saiList.isEmpty()) {
...@@ -480,8 +485,8 @@ public class SalaryAccountUtil implements Serializable { ...@@ -480,8 +485,8 @@ public class SalaryAccountUtil implements Serializable {
if ("3".equals(salaryType)) { if ("3".equals(salaryType)) {
if (CommonConstants.dingleDigitStrArray[1].equals(entity.getIsDeductSocial()) if (CommonConstants.dingleDigitStrArray[1].equals(entity.getIsDeductSocial())
|| CommonConstants.dingleDigitStrArray[1].equals(entity.getIsDeductFund())) { || CommonConstants.dingleDigitStrArray[1].equals(entity.getIsDeductFund())) {
error = "第" + (i + 2) + "行:劳务费不可扣社保、公积金,请去除【是否扣除社保】列,或写【否】"; error = "第" + (i + dataRow) + "行:劳务费不可扣社保、公积金,请去除【是否扣除社保】列,或写【否】";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} else { } else {
entity.setIsDeductSocial("0"); entity.setIsDeductSocial("0");
...@@ -494,13 +499,13 @@ public class SalaryAccountUtil implements Serializable { ...@@ -494,13 +499,13 @@ public class SalaryAccountUtil implements Serializable {
//验证扣社保以及扣公积金时的关联关系 //验证扣社保以及扣公积金时的关联关系
if (CommonConstants.dingleDigitStrArray[1].equals(entity.getIsDeductSocial()) && Common.isEmpty(entity.getDeduSocialMonth())) { if (CommonConstants.dingleDigitStrArray[1].equals(entity.getIsDeductSocial()) && Common.isEmpty(entity.getDeduSocialMonth())) {
error = "第" + (i + 2) + "行:扣社保无社保扣缴月份"; error = "第" + (i + dataRow) + "行:扣社保无社保扣缴月份";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
if (CommonConstants.dingleDigitStrArray[1].equals(entity.getIsDeductFund()) && Common.isEmpty(entity.getDeduProvidentMonth())) { if (CommonConstants.dingleDigitStrArray[1].equals(entity.getIsDeductFund()) && Common.isEmpty(entity.getDeduProvidentMonth())) {
error = "第" + (i + 2) + "行:扣公积金无公积金扣缴月份"; error = "第" + (i + dataRow) + "行:扣公积金无公积金扣缴月份";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage((i + dataRow), error));
continue; continue;
} }
entity.setInvoiceTitle(invoiceTitle); entity.setInvoiceTitle(invoiceTitle);
...@@ -534,7 +539,7 @@ public class SalaryAccountUtil implements Serializable { ...@@ -534,7 +539,7 @@ public class SalaryAccountUtil implements Serializable {
otherEmp = otherEmpMap.get(newEmps.getEmpIdcard()); otherEmp = otherEmpMap.get(newEmps.getEmpIdcard());
if (otherEmp == null) { if (otherEmp == null) {
if (CommonConstants.ONE_STRING.equals(entity.getIsNewEmployee())) { if (CommonConstants.ONE_STRING.equals(entity.getIsNewEmployee())) {
if (!this.setNewEmpBase(newEmps, newEmps.getLineNums(), errorList, notLabour if (!this.setNewEmpBase(newEmps, newEmps.getLineNums() + dataRow, errorList, notLabour
, entity, salaryType, dept, user, entity.getSalaryStyle() , entity, salaryType, dept, user, entity.getSalaryStyle()
, CommonConstants.ZERO_STRING.equals(entity.getSalaryGiveTime()), invoiceTitle , CommonConstants.ZERO_STRING.equals(entity.getSalaryGiveTime()), invoiceTitle
, entity.getSaiList(), bankMap)) { , entity.getSaiList(), bankMap)) {
...@@ -546,11 +551,11 @@ public class SalaryAccountUtil implements Serializable { ...@@ -546,11 +551,11 @@ public class SalaryAccountUtil implements Serializable {
checkTaxMonthList.add(newEmps.getEmpIdcard()); checkTaxMonthList.add(newEmps.getEmpIdcard());
} else { } else {
if ("3".equals(salaryType) || "4".equals(salaryType)) { if ("3".equals(salaryType) || "4".equals(salaryType)) {
error = "第" + (newEmps.getLineNums() + 2) + "行:薪酬人员查询菜单无此员工,请添加<是否新员工>列,并录入身份证号、开户行总行、开户行省、开户行市、银行卡号、手机号码!"; error = "第" + (newEmps.getLineNums() + dataRow) + "行:薪酬人员查询菜单无此员工,请添加<是否新员工>列,并录入身份证号、开户行总行、开户行省、开户行市、银行卡号、手机号码!";
errorList.add(new ErrorMessage((newEmps.getLineNums() + 2), error)); errorList.add(new ErrorMessage((newEmps.getLineNums() + dataRow), error));
} else { } else {
error = "第" + (newEmps.getLineNums() + 2) + "行:薪酬人员查询菜单无此员工,请添加<是否新员工(默认否)>列,并录入身份证号、开户行总行、开户行省、开户行市、银行卡号、计税月份、手机号码!"; error = "第" + (newEmps.getLineNums() + dataRow) + "行:薪酬人员查询菜单无此员工,请添加<是否新员工(默认否)>列,并录入身份证号、开户行总行、开户行省、开户行市、银行卡号、计税月份、手机号码!";
errorList.add(new ErrorMessage(newEmps.getLineNums() + 2, error)); errorList.add(new ErrorMessage(newEmps.getLineNums() + dataRow, error));
} }
isContinue = false; isContinue = false;
} }
...@@ -561,7 +566,7 @@ public class SalaryAccountUtil implements Serializable { ...@@ -561,7 +566,7 @@ public class SalaryAccountUtil implements Serializable {
, CommonConstants.ZERO_STRING.equals(entity.getSalaryGiveTime()) , CommonConstants.ZERO_STRING.equals(entity.getSalaryGiveTime())
, CommonConstants.ONE_STRING.equals(entity.getIsNewEmployee()) , CommonConstants.ONE_STRING.equals(entity.getIsNewEmployee())
, otherEmp.getEmpName(), entity.getSalaryStyle() , otherEmp.getEmpName(), entity.getSalaryStyle()
, nowMonth, updateEmpList, checkBankInfoEmpList, newEmps.getLineNums(), bankMap)) { , nowMonth, updateEmpList, checkBankInfoEmpList, newEmps.getLineNums() + dataRow, bankMap)) {
isContinue = false; isContinue = false;
} }
} }
...@@ -582,8 +587,8 @@ public class SalaryAccountUtil implements Serializable { ...@@ -582,8 +587,8 @@ public class SalaryAccountUtil implements Serializable {
minTaxMonth = minTaxMonthMap.get(saveNewEmp.getEmpIdcard()); minTaxMonth = minTaxMonthMap.get(saveNewEmp.getEmpIdcard());
if (Common.isNotNull(minTaxMonth) if (Common.isNotNull(minTaxMonth)
&& !minTaxMonth.equals(entity.getTaxMonth())) { && !minTaxMonth.equals(entity.getTaxMonth())) {
error = "第" + (saveNewEmp.getLineNums() + 2) + "行:该员工已有发薪记录,计税月份请填写:【" + minTaxMonth + "】" + ",你填写了计税月:【" + entity.getTaxMonth() + "】"; error = "第" + (saveNewEmp.getLineNums() + dataRow) + "行:该员工已有发薪记录,计税月份请填写:【" + minTaxMonth + "】" + ",你填写了计税月:【" + entity.getTaxMonth() + "】";
errorList.add(new ErrorMessage((saveNewEmp.getLineNums() + 2), error)); errorList.add(new ErrorMessage((saveNewEmp.getLineNums() + dataRow), error));
canSave = false; canSave = false;
} }
} }
...@@ -612,25 +617,25 @@ public class SalaryAccountUtil implements Serializable { ...@@ -612,25 +617,25 @@ public class SalaryAccountUtil implements Serializable {
TSalaryAccountItemVo sai; TSalaryAccountItemVo sai;
String error; String error;
if (Common.isEmpty(emp.getEmpName())) { if (Common.isEmpty(emp.getEmpName())) {
error = "第" + (i + 2) + "行:薪酬人员查询处-员工姓名-为空,请去薪酬人员查询处更新!"; error = "第" + i + "行:薪酬人员查询处-员工姓名-为空,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} else if (Common.isEmpty(empName)) { } else if (Common.isEmpty(empName)) {
error = "第" + (i + 2) + "行:模板-员工姓名-为空,请添加员工姓名列!"; error = "第" + i + "行:模板-员工姓名-为空,请添加员工姓名列!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} else if (!empName.equals(emp.getEmpName())) { } else if (!empName.equals(emp.getEmpName())) {
error = "第" + (i + 2) + "行:员工-姓名与身份证-不匹配,请确认薪酬人员查询处信息!"; error = "第" + i + "行:员工-姓名与身份证-不匹配,请确认薪酬人员查询处信息!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} }
if (Common.isEmpty(emp.getEmpPhone())) { if (Common.isEmpty(emp.getEmpPhone())) {
error = "第" + (i + 2) + "行:薪酬人员查询处-手机号码-为空,请去薪酬人员查询处更新!"; error = "第" + i + "行:薪酬人员查询处-手机号码-为空,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} else if (!ValidityUtil.validateEmpPhone(emp.getEmpPhone())) { } else if (!ValidityUtil.validateEmpPhone(emp.getEmpPhone())) {
error = "第" + (i + 2) + "行:薪酬人员查询处-手机号码格式错误,请去薪酬人员查询处更新:" + emp.getEmpPhone(); error = "第" + i + "行:薪酬人员查询处-手机号码格式错误,请去薪酬人员查询处更新:" + emp.getEmpPhone();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} }
if (Common.isEmpty(emp.getTaxMonth()) && !"3".equals(salaryType) && !"4".equals(salaryType)) { if (Common.isEmpty(emp.getTaxMonth()) && !"3".equals(salaryType) && !"4".equals(salaryType)) {
...@@ -638,20 +643,20 @@ public class SalaryAccountUtil implements Serializable { ...@@ -638,20 +643,20 @@ public class SalaryAccountUtil implements Serializable {
if (entity.getTaxMonth().length() > CommonConstants.dingleDigitIntArray[6]) { if (entity.getTaxMonth().length() > CommonConstants.dingleDigitIntArray[6]) {
entity.setTaxMonth(emp.getTaxMonth().substring(0, 6)); entity.setTaxMonth(emp.getTaxMonth().substring(0, 6));
} else if (entity.getTaxMonth().length() < CommonConstants.dingleDigitIntArray[6]) { } else if (entity.getTaxMonth().length() < CommonConstants.dingleDigitIntArray[6]) {
error = "第" + (i + 2) + "行:工资模板里-计税月份-长度小于6:" + entity.getTaxMonth() + ",请在工资模板修改!"; error = "第" + i + "行:工资模板里-计税月份-长度小于6:" + entity.getTaxMonth() + ",请在工资模板修改!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} }
if (DateUtil.compareYearMonth(entity.getTaxMonth(), nowMonth)) { if (DateUtil.compareYearMonth(entity.getTaxMonth(), nowMonth)) {
error = "第" + (i + 2) + "行:工资模板里-计税月份-大于当前年月或错误,请调整:" + entity.getTaxMonth(); error = "第" + i + "行:工资模板里-计税月份-大于当前年月或错误,请调整:" + entity.getTaxMonth();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} }
emp.setTaxMonth(entity.getTaxMonth()); emp.setTaxMonth(entity.getTaxMonth());
updateEmpList.add(emp); updateEmpList.add(emp);
} else { } else {
error = "第" + (i + 2) + "行:薪酬人员查询处-计税月份-为空,请在工资模板填写-计税月份-列的内容!"; error = "第" + i + "行:薪酬人员查询处-计税月份-为空,请在工资模板填写-计税月份-列的内容!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} }
} }
...@@ -680,28 +685,28 @@ public class SalaryAccountUtil implements Serializable { ...@@ -680,28 +685,28 @@ public class SalaryAccountUtil implements Serializable {
entity.setEmpPhone(emp.getEmpPhone()); entity.setEmpPhone(emp.getEmpPhone());
if (SalaryConstants.SALARY_STYLE_BANK.equals(salaryStyle) && salaryGiveTimeFlag) { if (SalaryConstants.SALARY_STYLE_BANK.equals(salaryStyle) && salaryGiveTimeFlag) {
if (Common.isEmpty(emp.getBankName())) { if (Common.isEmpty(emp.getBankName())) {
error = "第" + (i + 2) + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行-为空,请去薪酬人员查询处更新!"; error = "第" + i + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行-为空,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} }
if (Common.isEmpty(emp.getBankNo())) { if (Common.isEmpty(emp.getBankNo())) {
error = "第" + (i + 2) + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-银行卡号-为空,请去薪酬人员查询处更新!"; error = "第" + i + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-银行卡号-为空,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} }
if (Common.isEmpty(emp.getBankProvince())) { if (Common.isEmpty(emp.getBankProvince())) {
error = "第" + (i + 2) + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行省-为空,请去薪酬人员查询处更新!"; error = "第" + i + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行省-为空,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} }
if (Common.isEmpty(emp.getBankCity())) { if (Common.isEmpty(emp.getBankCity())) {
error = "第" + (i + 2) + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行市-为空,请去薪酬人员查询处更新!"; error = "第" + i + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行市-为空,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} }
if (bankMap.get(emp.getBankName()) == null) { if (bankMap.get(emp.getBankName()) == null) {
error = "第" + (i + 2) + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行总行-不符合财务要求,请去薪酬人员查询处更新!"; error = "第" + i + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行总行-不符合财务要求,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} }
entity.setBankName(emp.getBankName()); entity.setBankName(emp.getBankName());
...@@ -712,8 +717,8 @@ public class SalaryAccountUtil implements Serializable { ...@@ -712,8 +717,8 @@ public class SalaryAccountUtil implements Serializable {
} else { } else {
if (Common.isNotNull(emp.getBankName())) { if (Common.isNotNull(emp.getBankName())) {
if (bankMap.get(emp.getBankName()) == null) { if (bankMap.get(emp.getBankName()) == null) {
error = "第" + (i + 2) + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行总行-不符合财务要求,请去薪酬人员查询处更新!"; error = "第" + i + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行总行-不符合财务要求,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} }
entity.setBankName(emp.getBankName()); entity.setBankName(emp.getBankName());
...@@ -745,15 +750,15 @@ public class SalaryAccountUtil implements Serializable { ...@@ -745,15 +750,15 @@ public class SalaryAccountUtil implements Serializable {
if (emp.getTaxMonth().length() > CommonConstants.dingleDigitIntArray[6]) { if (emp.getTaxMonth().length() > CommonConstants.dingleDigitIntArray[6]) {
entity.setTaxMonth(emp.getTaxMonth().substring(0, 6)); entity.setTaxMonth(emp.getTaxMonth().substring(0, 6));
} else if (emp.getTaxMonth().length() < CommonConstants.dingleDigitIntArray[6]) { } else if (emp.getTaxMonth().length() < CommonConstants.dingleDigitIntArray[6]) {
error = "第" + (i + 2) + "行:薪酬人员查询处-计税月份-长度小于6:" + entity.getTaxMonth() + ",请去薪酬人员查询处更新!在工资模板修改无效!"; error = "第" + i + "行:薪酬人员查询处-计税月份-长度小于6:" + entity.getTaxMonth() + ",请去薪酬人员查询处更新!在工资模板修改无效!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} else { } else {
entity.setTaxMonth(emp.getTaxMonth()); entity.setTaxMonth(emp.getTaxMonth());
} }
if (DateUtil.compareYearMonth(entity.getTaxMonth(), nowMonth)) { if (DateUtil.compareYearMonth(entity.getTaxMonth(), nowMonth)) {
error = "第" + (i + 2) + "行:薪酬人员查询处-计税月份-大于当前年月或错误,请调整:" + entity.getTaxMonth(); error = "第" + i + "行:薪酬人员查询处-计税月份-大于当前年月或错误,请调整:" + entity.getTaxMonth();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return true; return true;
} }
sai = new TSalaryAccountItemVo(); sai = new TSalaryAccountItemVo();
...@@ -785,24 +790,24 @@ public class SalaryAccountUtil implements Serializable { ...@@ -785,24 +790,24 @@ public class SalaryAccountUtil implements Serializable {
//增加工资人员档案:(临时使用) //增加工资人员档案:(临时使用)
if (newEmp != null) { if (newEmp != null) {
if (Common.isEmpty(newEmp.getEmpName())) { if (Common.isEmpty(newEmp.getEmpName())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-姓名-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-姓名-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} }
if (Common.isEmpty(newEmp.getEmpIdcard())) { if (Common.isEmpty(newEmp.getEmpIdcard())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-身份证号-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-身份证号-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} }
// 2021-8-31 hgw2.6.5新增手机号校验 // 2021-8-31 hgw2.6.5新增手机号校验
if (Common.isEmpty(newEmp.getEmpPhone())) { if (Common.isEmpty(newEmp.getEmpPhone())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-手机号码-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-手机号码-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} else if (!ValidityUtil.validateEmpPhone(newEmp.getEmpPhone())) { } else if (!ValidityUtil.validateEmpPhone(newEmp.getEmpPhone())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-手机号码格式错误:" + newEmp.getEmpPhone(); error = "第" + i + "行:" + newEmpStr + "-手机号码格式错误:" + newEmp.getEmpPhone();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} }
} else { } else {
...@@ -811,16 +816,16 @@ public class SalaryAccountUtil implements Serializable { ...@@ -811,16 +816,16 @@ public class SalaryAccountUtil implements Serializable {
if (entity != null) { if (entity != null) {
if (!"3".equals(salaryType) && !"4".equals(salaryType)) { if (!"3".equals(salaryType) && !"4".equals(salaryType)) {
if (Common.isEmpty(entity.getTaxMonth())) { if (Common.isEmpty(entity.getTaxMonth())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-计税月份-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-计税月份-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} else if (entity.getTaxMonth().length() < CommonConstants.dingleDigitIntArray[6]) { } else if (entity.getTaxMonth().length() < CommonConstants.dingleDigitIntArray[6]) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-计税月份-长度小于6:" + entity.getTaxMonth(); error = "第" + i + "行:" + newEmpStr + "-计税月份-长度小于6:" + entity.getTaxMonth();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} else if (DateUtil.compareYearMonth(entity.getTaxMonth(), nowMonth)) { } else if (DateUtil.compareYearMonth(entity.getTaxMonth(), nowMonth)) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-计税月份-大于当前年月或错误,请调整:" + entity.getTaxMonth(); error = "第" + i + "行:" + newEmpStr + "-计税月份-大于当前年月或错误,请调整:" + entity.getTaxMonth();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} else { } else {
newEmp.setTaxMonth(entity.getTaxMonth()); newEmp.setTaxMonth(entity.getTaxMonth());
...@@ -831,28 +836,28 @@ public class SalaryAccountUtil implements Serializable { ...@@ -831,28 +836,28 @@ public class SalaryAccountUtil implements Serializable {
String areaStr; String areaStr;
if (SalaryConstants.SALARY_STYLE_BANK.equals(salaryStyle) && salaryGiveTimeFlag) { if (SalaryConstants.SALARY_STYLE_BANK.equals(salaryStyle) && salaryGiveTimeFlag) {
if (Common.isEmpty(entity.getBankName())) { if (Common.isEmpty(entity.getBankName())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行总行-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-开户行总行-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} else { } else {
if (bankMap.get(entity.getBankName()) == null) { if (bankMap.get(entity.getBankName()) == null) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行总行-不符合财务要求,请去【开户行配置】菜单查询!"; error = "第" + i + "行:" + newEmpStr + "-开户行总行-不符合财务要求,请去【开户行配置】菜单查询!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} }
newEmp.setBankName(entity.getBankName()); newEmp.setBankName(entity.getBankName());
} }
if (Common.isEmpty(entity.getBankProvince()) || Common.isEmpty(entity.getBankCity())) { if (Common.isEmpty(entity.getBankProvince()) || Common.isEmpty(entity.getBankCity())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行省、市-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-开户行省、市-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} else { } else {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + entity.getBankProvince().trim()); areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + entity.getBankProvince().trim());
if (Common.isNotNull(areaStr)) { if (Common.isNotNull(areaStr)) {
newEmp.setBankProvince(areaStr); newEmp.setBankProvince(areaStr);
} else { } else {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行省错误:" + entity.getBankProvince(); error = "第" + i + "行:" + newEmpStr + "-开户行省错误:" + entity.getBankProvince();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} }
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + entity.getBankCity().trim() areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + entity.getBankCity().trim()
...@@ -860,14 +865,14 @@ public class SalaryAccountUtil implements Serializable { ...@@ -860,14 +865,14 @@ public class SalaryAccountUtil implements Serializable {
if (Common.isNotNull(areaStr)) { if (Common.isNotNull(areaStr)) {
newEmp.setBankCity(areaStr); newEmp.setBankCity(areaStr);
} else { } else {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行市错误:" + entity.getBankCity(); error = "第" + i + "行:" + newEmpStr + "-开户行市错误:" + entity.getBankCity();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} }
} }
if (Common.isEmpty(entity.getBankNo())) { if (Common.isEmpty(entity.getBankNo())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-银行卡号-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-银行卡号-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} else { } else {
newEmp.setBankNo(entity.getBankNo()); newEmp.setBankNo(entity.getBankNo());
...@@ -878,8 +883,8 @@ public class SalaryAccountUtil implements Serializable { ...@@ -878,8 +883,8 @@ public class SalaryAccountUtil implements Serializable {
} else { } else {
if (Common.isNotNull(entity.getBankName())) { if (Common.isNotNull(entity.getBankName())) {
if (bankMap.get(entity.getBankName()) == null) { if (bankMap.get(entity.getBankName()) == null) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行总行-不符合财务要求,请去【开户行配置】菜单查询!"; error = "第" + i + "行:" + newEmpStr + "-开户行总行-不符合财务要求,请去【开户行配置】菜单查询!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} }
newEmp.setBankName(entity.getBankName()); newEmp.setBankName(entity.getBankName());
...@@ -920,15 +925,15 @@ public class SalaryAccountUtil implements Serializable { ...@@ -920,15 +925,15 @@ public class SalaryAccountUtil implements Serializable {
String minTaxMonth = tSalaryAccountService.getMinTaxMonthByNowYear(newEmp.getEmpIdcard(), nowYear); String minTaxMonth = tSalaryAccountService.getMinTaxMonthByNowYear(newEmp.getEmpIdcard(), nowYear);
if (Common.isNotNull(minTaxMonth) if (Common.isNotNull(minTaxMonth)
&& !minTaxMonth.equals(entity.getTaxMonth())) { && !minTaxMonth.equals(entity.getTaxMonth())) {
error = "第" + (i + 2) + "行:该员工已有发薪记录,计税月份请填写:【" + minTaxMonth + "】" + ",你填写了计税月:【" + entity.getTaxMonth() + "】"; error = "第" + i + "行:该员工已有发薪记录,计税月份请填写:【" + minTaxMonth + "】" + ",你填写了计税月:【" + entity.getTaxMonth() + "】";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} }
} }
String saveNewEmpReturn = tSalaryEmployeeService.saveNewSalaryEmployee(notLabour, newEmp); String saveNewEmpReturn = tSalaryEmployeeService.saveNewSalaryEmployee(notLabour, newEmp);
if (Common.isNotNull(saveNewEmpReturn)) { if (Common.isNotNull(saveNewEmpReturn)) {
error = "第" + (i + 2) + "行:该员工新建失败:【" + saveNewEmpReturn + "】"; error = "第" + i + "行:该员工新建失败:【" + saveNewEmpReturn + "】";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return R.failed(); return R.failed();
} }
return R.ok(newEmp); return R.ok(newEmp);
...@@ -947,24 +952,24 @@ public class SalaryAccountUtil implements Serializable { ...@@ -947,24 +952,24 @@ public class SalaryAccountUtil implements Serializable {
if (newEmp != null) { if (newEmp != null) {
newEmp.setLineNums(i); newEmp.setLineNums(i);
if (Common.isEmpty(newEmp.getEmpName())) { if (Common.isEmpty(newEmp.getEmpName())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-姓名-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-姓名-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} }
if (Common.isEmpty(newEmp.getEmpIdcard())) { if (Common.isEmpty(newEmp.getEmpIdcard())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-身份证号-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-身份证号-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} }
// 2021-8-31 hgw2.6.5新增手机号校验 // 2021-8-31 hgw2.6.5新增手机号校验
if (Common.isEmpty(newEmp.getEmpPhone())) { if (Common.isEmpty(newEmp.getEmpPhone())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-手机号码-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-手机号码-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} else if (!ValidityUtil.validateEmpPhone(newEmp.getEmpPhone())) { } else if (!ValidityUtil.validateEmpPhone(newEmp.getEmpPhone())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-手机号码格式错误:" + newEmp.getEmpPhone(); error = "第" + i + "行:" + newEmpStr + "-手机号码格式错误:" + newEmp.getEmpPhone();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} }
} else { } else {
...@@ -973,16 +978,16 @@ public class SalaryAccountUtil implements Serializable { ...@@ -973,16 +978,16 @@ public class SalaryAccountUtil implements Serializable {
if (entity != null) { if (entity != null) {
if (!"3".equals(salaryType) && !"4".equals(salaryType)) { if (!"3".equals(salaryType) && !"4".equals(salaryType)) {
if (Common.isEmpty(entity.getTaxMonth())) { if (Common.isEmpty(entity.getTaxMonth())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-计税月份-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-计税月份-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} else if (entity.getTaxMonth().length() < CommonConstants.dingleDigitIntArray[6]) { } else if (entity.getTaxMonth().length() < CommonConstants.dingleDigitIntArray[6]) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-计税月份-长度小于6:" + entity.getTaxMonth(); error = "第" + i + "行:" + newEmpStr + "-计税月份-长度小于6:" + entity.getTaxMonth();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} else if (DateUtil.compareYearMonth(entity.getTaxMonth(), nowMonth)) { } else if (DateUtil.compareYearMonth(entity.getTaxMonth(), nowMonth)) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-计税月份-大于当前年月或错误,请调整:" + entity.getTaxMonth(); error = "第" + i + "行:" + newEmpStr + "-计税月份-大于当前年月或错误,请调整:" + entity.getTaxMonth();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} else { } else {
TSalaryAccountItemVo sai = new TSalaryAccountItemVo(); TSalaryAccountItemVo sai = new TSalaryAccountItemVo();
...@@ -999,28 +1004,28 @@ public class SalaryAccountUtil implements Serializable { ...@@ -999,28 +1004,28 @@ public class SalaryAccountUtil implements Serializable {
String areaStr; String areaStr;
if (SalaryConstants.SALARY_STYLE_BANK.equals(salaryStyle) && salaryGiveTimeFlag) { if (SalaryConstants.SALARY_STYLE_BANK.equals(salaryStyle) && salaryGiveTimeFlag) {
if (Common.isEmpty(entity.getBankName())) { if (Common.isEmpty(entity.getBankName())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行总行-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-开户行总行-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} else { } else {
if (bankMap.get(entity.getBankName()) == null) { if (bankMap.get(entity.getBankName()) == null) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行总行-不符合财务要求,请去【开户行配置】菜单查询!"; error = "第" + i + "行:" + newEmpStr + "-开户行总行-不符合财务要求,请去【开户行配置】菜单查询!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} }
newEmp.setBankName(entity.getBankName()); newEmp.setBankName(entity.getBankName());
} }
if (Common.isEmpty(entity.getBankProvince()) || Common.isEmpty(entity.getBankCity())) { if (Common.isEmpty(entity.getBankProvince()) || Common.isEmpty(entity.getBankCity())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行省、市-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-开户行省、市-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} else { } else {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + entity.getBankProvince().trim()); areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + entity.getBankProvince().trim());
if (Common.isNotNull(areaStr)) { if (Common.isNotNull(areaStr)) {
newEmp.setBankProvince(areaStr); newEmp.setBankProvince(areaStr);
} else { } else {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行省错误:" + entity.getBankProvince(); error = "第" + i + "行:" + newEmpStr + "-开户行省错误:" + entity.getBankProvince();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} }
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + entity.getBankCity().trim() areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + entity.getBankCity().trim()
...@@ -1028,14 +1033,14 @@ public class SalaryAccountUtil implements Serializable { ...@@ -1028,14 +1033,14 @@ public class SalaryAccountUtil implements Serializable {
if (Common.isNotNull(areaStr)) { if (Common.isNotNull(areaStr)) {
newEmp.setBankCity(areaStr); newEmp.setBankCity(areaStr);
} else { } else {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行市错误:" + entity.getBankCity(); error = "第" + i + "行:" + newEmpStr + "-开户行市错误:" + entity.getBankCity();
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} }
} }
if (Common.isEmpty(entity.getBankNo())) { if (Common.isEmpty(entity.getBankNo())) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-银行卡号-不可为空!"; error = "第" + i + "行:" + newEmpStr + "-银行卡号-不可为空!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} else { } else {
newEmp.setBankNo(entity.getBankNo()); newEmp.setBankNo(entity.getBankNo());
...@@ -1046,8 +1051,8 @@ public class SalaryAccountUtil implements Serializable { ...@@ -1046,8 +1051,8 @@ public class SalaryAccountUtil implements Serializable {
} else { } else {
if (Common.isNotNull(entity.getBankName())) { if (Common.isNotNull(entity.getBankName())) {
if (bankMap.get(entity.getBankName()) == null) { if (bankMap.get(entity.getBankName()) == null) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行总行-不符合财务要求,请去【开户行配置】菜单查询!"; error = "第" + i + "行:" + newEmpStr + "-开户行总行-不符合财务要求,请去【开户行配置】菜单查询!";
errorList.add(new ErrorMessage((i + 2), error)); errorList.add(new ErrorMessage(i, error));
return false; return false;
} }
newEmp.setBankName(entity.getBankName()); newEmp.setBankName(entity.getBankName());
...@@ -1209,7 +1214,7 @@ public class SalaryAccountUtil implements Serializable { ...@@ -1209,7 +1214,7 @@ public class SalaryAccountUtil implements Serializable {
return errorInfo(attr, "_小于最小值", i); return errorInfo(attr, "_小于最小值", i);
} }
} else { } else {
return "第" + (i + 2) + "行:" + "_必须为数字"; return "第" + i + "行:" + "_必须为数字";
} }
} }
} }
......
...@@ -39,7 +39,8 @@ public class SalaryConstants { ...@@ -39,7 +39,8 @@ public class SalaryConstants {
//模板列必填 //模板列必填
public static final String IS_MUST = "1"; public static final String IS_MUST = "1";
public static final String EMP_NAME = "姓名"; public static final String EMP_NAME = "姓名";
public static final String IF_NEW_EMPLOYEE = "是否新员工(默认否)"; public static final String EMP_NAME2 = "员工姓名";
public static final String IF_NEW_EMPLOYEE = "是否新员工(默认否)";
public static final String IS_NEW_EMPLOYEE = "是否新员工"; public static final String IS_NEW_EMPLOYEE = "是否新员工";
public static final String IS_NEW = "是"; public static final String IS_NEW = "是";
public static final String ID_NUMBER = "身份证号"; public static final String ID_NUMBER = "身份证号";
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryStandardOriginalDetailMapper">
<resultMap id="TSalaryStandardOriginalDetailMap" type="com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginalDetail">
<id property="id" column="ID"/>
<result property="originalId" column="ORIGINAL_ID"/>
<result property="columnNo" column="COLUMN_NO"/>
<result property="excelName" column="EXCEL_NAME"/>
<result property="modelName" column="MODEL_NAME"/>
<result property="flag" column="FLAG"/>
<result property="formulaNo" column="FORMULA_NO"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
a.ORIGINAL_ID,
a.COLUMN_NO,
a.EXCEL_NAME,
a.MODEL_NAME,
a.FLAG,
a.FORMULA_NO
</sql>
<sql id="TSalaryStandardOriginalDetail_where">
<if test="tSalaryStandardOriginalDetail != null">
<if test="tSalaryStandardOriginalDetail.id != null and tSalaryStandardOriginalDetail.id.trim() != ''">
AND a.ID = #{tSalaryStandardOriginalDetail.id}
</if>
<if test="tSalaryStandardOriginalDetail.originalId != null and tSalaryStandardOriginalDetail.originalId.trim() != ''">
AND a.ORIGINAL_ID = #{tSalaryStandardOriginalDetail.originalId}
</if>
<if test="tSalaryStandardOriginalDetail.columnNo != null and tSalaryStandardOriginalDetail.columnNo.trim() != ''">
AND a.COLUMN_NO = #{tSalaryStandardOriginalDetail.columnNo}
</if>
<if test="tSalaryStandardOriginalDetail.excelName != null and tSalaryStandardOriginalDetail.excelName.trim() != ''">
AND a.EXCEL_NAME = #{tSalaryStandardOriginalDetail.excelName}
</if>
<if test="tSalaryStandardOriginalDetail.modelName != null and tSalaryStandardOriginalDetail.modelName.trim() != ''">
AND a.MODEL_NAME = #{tSalaryStandardOriginalDetail.modelName}
</if>
</if>
</sql>
<!--TSalaryStandardOriginalDetail简单分页查询-->
<select id="getTSalaryStandardOriginalDetailPage" resultMap="TSalaryStandardOriginalDetailMap">
SELECT
<include refid="Base_Column_List"/>
FROM
t_salary_standard_original_detail a
<where> 1=1
<include refid="TSalaryStandardOriginalDetail_where"/>
</where>
ORDER BY a.COLUMN_NO asc
</select>
<!--获取详情-->
<select id="getTSalaryStandardOriginalDetailByOrgId" resultMap="TSalaryStandardOriginalDetailMap">
SELECT
<include refid="Base_Column_List"/>
FROM
t_salary_standard_original_detail a
where a.ORIGINAL_ID = #{originalId}
ORDER BY a.COLUMN_NO asc
</select>
<!--删除关系-->
<delete id="deleteByOrgId" >
DELETE FROM t_salary_standard_original_detail WHERE ORIGINAL_ID = #{originalId}
</delete>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryStandardOriginalMapper">
<resultMap id="TSalaryStandardOriginalMap" type="com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal">
<id property="id" column="ID"/>
<result property="deptId" column="DEPT_ID"/>
<result property="deptName" column="DEPT_NAME"/>
<result property="deptNo" column="DEPT_NO"/>
<result property="createBy" column="CREATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="updateTime" column="UPDATE_TIME"/>
<result property="setName" column="SET_NAME"/>
<result property="sheetName" column="SHEET_NAME"/>
<result property="attaName" column="ATTA_NAME"/>
<result property="attaSrc" column="ATTA_SRC"/>
<result property="attaUrl" column="ATTA_URL"/>
<result property="attaSize" column="ATTA_SIZE"/>
<result property="attaType" column="ATTA_TYPE"/>
<result property="dateNum" column="DATE_NUM"/>
<result property="deleteFlag" column="DELETE_FLAG"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
a.DEPT_ID,
a.DEPT_NAME,
a.DEPT_NO,
a.CREATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
a.UPDATE_BY,
a.UPDATE_TIME,
a.SET_NAME,
a.SHEET_NAME,
a.ATTA_NAME,
a.ATTA_SRC,
a.ATTA_URL,
a.ATTA_SIZE,
a.ATTA_TYPE,
a.DATE_NUM,
a.DELETE_FLAG
</sql>
<sql id="TSalaryStandardOriginal_where">
<if test="tSalaryStandardOriginal != null">
<if test="tSalaryStandardOriginal.id != null and tSalaryStandardOriginal.id.trim() != ''">
AND a.ID != #{tSalaryStandardOriginal.id}
</if>
<if test="tSalaryStandardOriginal.deptId != null and tSalaryStandardOriginal.deptId.trim() != ''">
AND a.DEPT_ID = #{tSalaryStandardOriginal.deptId}
</if>
<if test="tSalaryStandardOriginal.deptName != null and tSalaryStandardOriginal.deptName.trim() != ''">
AND a.DEPT_NAME like concat('%',#{tSalaryStandardOriginal.deptName},'%')
</if>
<if test="tSalaryStandardOriginal.deptNo != null and tSalaryStandardOriginal.deptNo.trim() != ''">
AND a.DEPT_NO = #{tSalaryStandardOriginal.deptNo}
</if>
<if test="tSalaryStandardOriginal.setName != null and tSalaryStandardOriginal.setName.trim() != ''">
AND a.SET_NAME like concat('%',#{tSalaryStandardOriginal.setName},'%')
</if>
<if test="tSalaryStandardOriginal.sheetName != null and tSalaryStandardOriginal.sheetName.trim() != ''">
AND a.SHEET_NAME like concat('%',#{tSalaryStandardOriginal.sheetName},'%')
</if>
<if test="tSalaryStandardOriginal.attaName != null and tSalaryStandardOriginal.attaName.trim() != ''">
AND ATTA_NAME = #{tSalaryStandardOriginal.attaName}
</if>
<if test="tSalaryStandardOriginal.attaSrc != null and tSalaryStandardOriginal.attaSrc.trim() != ''">
AND ATTA_SRC = #{tSalaryStandardOriginal.attaSrc}
</if>
<if test="tSalaryStandardOriginal.attaUrl != null and tSalaryStandardOriginal.attaUrl.trim() != ''">
AND ATTA_URL = #{tSalaryStandardOriginal.attaUrl}
</if>
<if test="tSalaryStandardOriginal.attaSize != null and tSalaryStandardOriginal.attaSize.trim() != ''">
AND ATTA_SIZE = #{tSalaryStandardOriginal.attaSize}
</if>
<if test="tSalaryStandardOriginal.attaType != null and tSalaryStandardOriginal.attaType.trim() != ''">
AND ATTA_TYPE = #{tSalaryStandardOriginal.attaType}
</if>
</if>
</sql>
<!--TSalaryStandardOriginal简单分页查询-->
<select id="getTSalaryStandardOriginalPage" resultMap="TSalaryStandardOriginalMap">
SELECT
<include refid="Base_Column_List"/>
FROM
t_salary_standard_original a
<where> a.DELETE_FLAG = 0
<include refid="TSalaryStandardOriginal_where"/>
</where>
ORDER BY a.CREATE_TIME desc
</select>
<!--导入工资时的获取识别配置列表-->
<select id="getTSalaryStandardOriginalList" resultMap="TSalaryStandardOriginalMap">
SELECT
<include refid="Base_Column_List"/>
FROM
t_salary_standard_original a
<where> a.DELETE_FLAG = 0
<if test="tSalaryStandardOriginal != null">
<if test="tSalaryStandardOriginal.id != null and tSalaryStandardOriginal.id.trim() != ''">
AND a.ID != #{tSalaryStandardOriginal.id}
</if>
<if test="tSalaryStandardOriginal.deptId != null and tSalaryStandardOriginal.deptId.trim() != ''">
AND a.DEPT_ID = #{tSalaryStandardOriginal.deptId}
</if>
<if test="tSalaryStandardOriginal.deptName != null and tSalaryStandardOriginal.deptName.trim() != ''">
AND a.DEPT_NAME = #{tSalaryStandardOriginal.deptName}
</if>
<if test="tSalaryStandardOriginal.deptNo != null and tSalaryStandardOriginal.deptNo.trim() != ''">
AND a.DEPT_NO = #{tSalaryStandardOriginal.deptNo}
</if>
<if test="tSalaryStandardOriginal.setName != null and tSalaryStandardOriginal.setName.trim() != ''">
AND a.SET_NAME = #{tSalaryStandardOriginal.setName}
</if>
</if>
</where>
ORDER BY a.CREATE_TIME asc
</select>
<!-- 特殊身份证允许识别为数据行 -->
<select id="getSpecialIdCardList" resultType="java.lang.String">
SELECT a.ID_CARD FROM t_salary_standard_original_special_idcard a
</select>
</mapper>
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