Commit ff2715fd authored by hongguangwu's avatar hongguangwu

MVP1.6.2-工资原表识别-优化

parent aecf5217
...@@ -32,38 +32,46 @@ public class EkpQiwiChuchai { ...@@ -32,38 +32,46 @@ public class EkpQiwiChuchai {
@Schema(description = "审批编号") @Schema(description = "审批编号")
@NotBlank(message = "审批编号不能为空") @NotBlank(message = "审批编号不能为空")
private String spNo; private String fdSpNo;
@Schema(description = "申请人姓名") @Schema(description = "申请人姓名")
@NotBlank(message = "申请人姓名不能为空") @NotBlank(message = "申请人姓名不能为空")
private String applyUserName; private String fdApplyUserName;
@Schema(description = "申请人部门") @Schema(description = "申请人部门")
@NotBlank(message = "申请人部门不能为空") @NotBlank(message = "申请人部门不能为空")
private String applyUserDept; private String fdApplyUserDept;
@Schema(description = "申请日期") @Schema(description = "申请日期")
@NotNull(message = "申请日期不能为空") @NotNull(message = "申请日期不能为空")
private LocalDateTime applyDate; private LocalDateTime fdApplyDate;
@Schema(description = "开始日期") @Schema(description = "开始日期")
private LocalDate newBegin; private LocalDate fdNewBegin;
@Schema(description = "结束日期") @Schema(description = "结束日期")
private LocalDate newEnd; private LocalDate fdNewEnd;
@Schema(description = "出差事由") @Schema(description = "出差事由")
private String reason; private String fdReason;
@Schema(description = "随行人员") @Schema(description = "随行人员")
private String person; private String fdPerson;
@Schema(description = "出差地点") @Schema(description = "出差地点")
private String address; private String fdAddress;
@Schema(description = "出行工具") @Schema(description = "出行工具")
private String tools; 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已结算; // status 0 初始;1已结算;
@Schema(description = "结算状态") @Schema(description = "结算状态")
private String status; private String fdStatus;
@Schema(description = "关联结算ID") @Schema(description = "关联结算ID")
private String settleFormId; private String fdSettleFormId;
@Schema(description = "创建时间") @Schema(description = "创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
......
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;
}
...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.permission.mapper; ...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.permission.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; 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.entity.EkpQiwiChuchai;
import com.yifu.cloud.plus.v1.yifu.permission.vo.QiWeiUserVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -23,6 +24,8 @@ public interface EkpQiweiChuchaiMapper extends BaseMapper<EkpQiwiChuchai> { ...@@ -23,6 +24,8 @@ public interface EkpQiweiChuchaiMapper extends BaseMapper<EkpQiwiChuchai> {
* @return: java.util.List<com.yifu.cloud.v1.hrms.api.entity.salary.TStatisticsProjectReimburse> * @return: java.util.List<com.yifu.cloud.v1.hrms.api.entity.salary.TStatisticsProjectReimburse>
**/ **/
List<EkpQiwiChuchai> getAllInfo(@Param("status") String status); List<EkpQiwiChuchai> getAllInfo(@Param("status") String status);
List<QiWeiUserVo> getQiYeWeiXinUserList();
} }
......
...@@ -12,6 +12,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants; ...@@ -12,6 +12,7 @@ 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.Common;
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.permission.entity.EkpQiwiChuchai; import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai;
import com.yifu.cloud.plus.v1.yifu.permission.vo.QiWeiUserVo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
...@@ -75,6 +76,8 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -75,6 +76,8 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
// 已被拉取的Map // 已被拉取的Map
Map<String, String> cpMap = this.getAllMap(); Map<String, String> cpMap = this.getAllMap();
// 企微姓名Map
Map<String, String> userMap = this.getUserMap();
// 一个月的全量数据 // 一个月的全量数据
List<EkpQiwiChuchai> cpAllList = new ArrayList<>(); List<EkpQiwiChuchai> cpAllList = new ArrayList<>();
List<EkpQiwiChuchai> returnCpList = new ArrayList<>(); List<EkpQiwiChuchai> returnCpList = new ArrayList<>();
...@@ -82,21 +85,30 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -82,21 +85,30 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
this.getCostPaymentListByMonth(startTime, endTime, cpAllList); this.getCostPaymentListByMonth(startTime, endTime, cpAllList);
if (!cpAllList.isEmpty()) { if (!cpAllList.isEmpty()) {
for (EkpQiwiChuchai cp : cpAllList) { for (EkpQiwiChuchai cp : cpAllList) {
if (cpMap.get(cp.getSpNo()) == null) { if (cpMap.get(cp.getFdSpNo()) == null) {
returnCpList.add(cp); returnCpList.add(cp);
} }
} }
} }
returnCpList = new ArrayList<>();
EkpQiwiChuchai cp = new EkpQiwiChuchai();
cp.setFdSpNo("202404160069");
returnCpList.add(cp);
cp = new EkpQiwiChuchai();
cp.setFdSpNo("202404160075");
returnCpList.add(cp);
// 填充详情 // 填充详情
if (!returnCpList.isEmpty()) { if (!returnCpList.isEmpty()) {
log.error("拉取企业微信出差数据:"+returnCpList.size()+" 条,开始循环拉取明细!"); log.error("拉取企业微信出差数据:"+returnCpList.size()+" 条,开始循环拉取明细!");
this.getTStatisticsProjectReimburseDetail(returnCpList); this.getTStatisticsProjectReimburseDetail(returnCpList, userMap);
log.error("拉取企业微信出差数据结束"); log.error("拉取企业微信出差数据结束");
} }
// 填充基础数据并保存: // 填充基础数据并保存:
if (!returnCpList.isEmpty()) { if (!returnCpList.isEmpty()) {
this.saveBatch(returnCpList); this.saveBatch(returnCpList);
} }
cpMap.clear();
userMap.clear();
return new R<>(returnCpList); return new R<>(returnCpList);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -188,7 +200,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -188,7 +200,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
* @Date: 2024-4-12 16:55:00 * @Date: 2024-4-12 16:55:00
* @return: java.util.List<com.yifu.cloud.v1.hrms.api.entity.TStatisticsProjectReimburse> * @return: java.util.List<com.yifu.cloud.v1.hrms.api.entity.TStatisticsProjectReimburse>
**/ **/
private R<List<EkpQiwiChuchai>> getTStatisticsProjectReimburseDetail(List<EkpQiwiChuchai> list) { private R<List<EkpQiwiChuchai>> getTStatisticsProjectReimburseDetail(List<EkpQiwiChuchai> list, Map<String, String> userMap) {
String accessToken = wxConfig.getReimbursementToken(restTemplate); String accessToken = wxConfig.getReimbursementToken(restTemplate);
int i = 1; int i = 1;
JSONObject jsonDetail; JSONObject jsonDetail;
...@@ -205,7 +217,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -205,7 +217,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
for (EkpQiwiChuchai r : list) { for (EkpQiwiChuchai r : list) {
log.error("企业微信出差【"+i+"/"+""+list.size()+"】条"); log.error("企业微信出差【"+i+"/"+""+list.size()+"】条");
jsonDetail = new JSONObject(); jsonDetail = new JSONObject();
jsonDetail.put("sp_no", r.getSpNo()); jsonDetail.put("sp_no", r.getFdSpNo());
formEntityDetail = new HttpEntity<>(jsonDetail.toString(), headers); formEntityDetail = new HttpEntity<>(jsonDetail.toString(), headers);
dataResultDetail = restTemplate.postForEntity(SecurityConstants.WX_GET_APPROVAL_DETAIL, formEntityDetail, String.class, accessToken).getBody(); dataResultDetail = restTemplate.postForEntity(SecurityConstants.WX_GET_APPROVAL_DETAIL, formEntityDetail, String.class, accessToken).getBody();
if (Common.isEmpty(dataResultDetail)) { if (Common.isEmpty(dataResultDetail)) {
...@@ -219,7 +231,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -219,7 +231,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
} }
// 详细信息 // 详细信息
info = jsonObject.getString("info"); info = jsonObject.getString("info");
this.setTStatisticsProjectReimburseDetail(info, r); this.setTStatisticsProjectReimburseDetail(info, r, userMap);
if (i++ >= 600) { if (i++ >= 600) {
// 企业微信频率限制:接口频率限制 600次/分钟 // 企业微信频率限制:接口频率限制 600次/分钟
try { try {
...@@ -242,11 +254,20 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -242,11 +254,20 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
List<EkpQiwiChuchai> cpHistoryList = baseMapper.getAllInfo(null); List<EkpQiwiChuchai> cpHistoryList = baseMapper.getAllInfo(null);
Map<String, String> cpMap = new HashMap<>(); Map<String, String> cpMap = new HashMap<>();
for (EkpQiwiChuchai cpHis : cpHistoryList) { for (EkpQiwiChuchai cpHis : cpHistoryList) {
cpMap.put(cpHis.getSpNo(), "0"); cpMap.put(cpHis.getFdSpNo(), "0");
} }
return cpMap; 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 jsonObject
* @param cpList * @param cpList
...@@ -262,10 +283,10 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -262,10 +283,10 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
List<String> dataList = JSON.parseArray(data, String.class); List<String> dataList = JSON.parseArray(data, String.class);
for (String datas : dataList) { for (String datas : dataList) {
cp = new EkpQiwiChuchai(); cp = new EkpQiwiChuchai();
cp.setApplyDate(LocalDateTime.now()); cp.setFdApplyDate(LocalDateTime.now());
cp.setApplyUserName("张三"); cp.setFdApplyUserName("张三");
cp.setSpNo(datas); cp.setFdSpNo(datas);
cp.setStatus(CommonConstants.ZERO_STRING); cp.setFdStatus(CommonConstants.ZERO_STRING);
cpList.add(cp); cpList.add(cp);
} }
} }
...@@ -278,14 +299,19 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -278,14 +299,19 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
* @Date: 2024-4-12 17:01:35 * @Date: 2024-4-12 17:01:35
* @return: void * @return: void
**/ **/
private void setTStatisticsProjectReimburseDetail(String info, EkpQiwiChuchai reimburse) { private void setTStatisticsProjectReimburseDetail(String info, EkpQiwiChuchai reimburse, Map<String, String> userMap) {
JSONObject jsonObject = JSON.parseObject(info); JSONObject jsonObject = JSON.parseObject(info);
if (Common.isNotNull(info)) { if (Common.isNotNull(info)) {
reimburse.setCreateTime(LocalDateTime.now()); reimburse.setCreateTime(LocalDateTime.now());
reimburse.setApplyUserName(((JSONObject) jsonObject.get("applyer")).getString("userid")); String userId = ((JSONObject) jsonObject.get("applyer")).getString("userid");
reimburse.setApplyUserDept(((JSONObject) jsonObject.get("applyer")).getString("partyid")); if (Common.isNotNull(userId) && userMap.get(userId) != null) {
reimburse.setSpNo(jsonObject.getString("sp_no")); reimburse.setFdApplyUserName(userMap.get(userId));
reimburse.setApplyDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(Long.parseLong(String.valueOf(jsonObject.get("apply_time")))), ZoneId.systemDefault())); } 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"); JSONObject applyData = (JSONObject) jsonObject.get("apply_data");
String contents = applyData.getString("contents"); String contents = applyData.getString("contents");
...@@ -294,16 +320,23 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -294,16 +320,23 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
JSONObject value; JSONObject value;
JSONObject attendance; JSONObject attendance;
JSONObject dateRange; JSONObject dateRange;
//JSONObject selector; JSONObject selector;
//JSONArray options; JSONArray options;
JSONObject options0;
JSONArray options0value;
JSONObject options0value0;
// 开始时间 // 开始时间
LocalDate newBegin = null; LocalDate newBegin = null;
// 结束时间 // 结束时间
LocalDate newEnd = null; LocalDate newEnd = null;
// 出差时长 // 出差时长
//String newDuration; //String newDuration;
// 岗位级别 // 出差地点级别
//String post; String addressLevel= null;
// 交通补助
String jiaoTong= null;
// 餐饮补助
String canYin= null;
// 业务条线归属 // 业务条线归属
//String lineType; //String lineType;
// 出差事由 // 出差事由
...@@ -313,7 +346,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -313,7 +346,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
// 出差地点 // 出差地点
String address = null; String address = null;
// 出行工具 // 出行工具
String tools = null; String tools = "";
for (HashMap content : contentList) { for (HashMap content : contentList) {
title = (JSONArray) content.get("title"); title = (JSONArray) content.get("title");
if ("出差".equals(((JSONObject) title.get(0)).get("text"))) { if ("出差".equals(((JSONObject) title.get(0)).get("text"))) {
...@@ -346,17 +379,57 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -346,17 +379,57 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
} else if ("出差地点".equals(((JSONObject) title.get(0)).get("text"))) { } else if ("出差地点".equals(((JSONObject) title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR); value = (JSONObject) content.get(VALUESTR);
address = value.getString("text"); address = value.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");
options0 = (JSONObject) options.get(0);
options0value = (JSONArray) options0.get(VALUESTR);
options0value0 = (JSONObject) options0value.get(0);
addressLevel = options0value0.getString("text");
} else if (((JSONObject) title.get(0)).getString("text").contains("交通补助")) {
value = (JSONObject) content.get(VALUESTR);
if (Common.isNotNull(value.getString("text"))) {
jiaoTong = value.getString("text");
}
} else if (((JSONObject) title.get(0)).getString("text").contains("餐饮补助")) {
value = (JSONObject) content.get(VALUESTR);
if (Common.isNotNull(value.getString("text"))) {
canYin = value.getString("text");
}
} else if ("出行工具".equals(((JSONObject) title.get(0)).get("text"))) { } else if ("出行工具".equals(((JSONObject) title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR); value = (JSONObject) content.get(VALUESTR);
tools = value.getString("text"); selector = (JSONObject) value.get("selector");
options = (JSONArray) selector.get("options");
for (int j=0;j<options.size();j++) {
options0 = (JSONObject) options.get(j);
options0value = (JSONArray) options0.get(VALUESTR);
options0value0 = (JSONObject) options0value.get(0);
addressLevel = options0value0.getString("text");
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.setNewBegin(newBegin); reimburse.setFdRenShu(renShu);
reimburse.setNewEnd(newEnd); reimburse.setFdPerson(person);
reimburse.setReason(reason); reimburse.setFdAddress(address);
reimburse.setPerson(person); reimburse.setFdTools(tools);
reimburse.setAddress(address); reimburse.setFdAddressLevel(addressLevel);
reimburse.setTools(tools); reimburse.setFdJiaoTong(jiaoTong);
reimburse.setFdCanYin(canYin);
} }
} }
......
...@@ -6,18 +6,22 @@ ...@@ -6,18 +6,22 @@
<resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai"> <resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai">
<id property="fdId" column="fd_ID" /> <id property="fdId" column="fd_ID" />
<result property="spNo" column="FD_SP_NO"/> <result property="fdSpNo" column="FD_SP_NO"/>
<result property="applyUserName" column="FD_APPLY_USER_NAME"/> <result property="fdApplyUserName" column="FD_APPLY_USER_NAME"/>
<result property="applyUserDept" column="FD_APPLY_USER_DEPT"/> <result property="fdApplyUserDept" column="FD_APPLY_USER_DEPT"/>
<result property="applyDate" column="FD_APPLY_DATE"/> <result property="fdApplyDate" column="FD_APPLY_DATE"/>
<result property="newBegin" column="FD_NEW_BEGIN"/> <result property="fdNewBegin" column="FD_NEW_BEGIN"/>
<result property="newEnd" column="FD_NEW_END"/> <result property="fdNewEnd" column="FD_NEW_END"/>
<result property="reason" column="FD_REASON"/> <result property="fdReason" column="FD_REASON"/>
<result property="person" column="FD_PERSON"/> <result property="fdPerson" column="FD_PERSON"/>
<result property="address" column="FD_ADDRESS"/> <result property="fdAddress" column="FD_ADDRESS"/>
<result property="tools" column="FD_TOOLS"/> <result property="fdTools" column="FD_TOOLS"/>
<result property="status" column="FD_STATUS"/> <result property="fdAddressLevel" column="FD_ADDRESS_LEVEL"/>
<result property="settleFormId" column="FD_SETTLE_FORM_ID"/> <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"/> <result property="createTime" column="create_time"/>
</resultMap> </resultMap>
...@@ -33,6 +37,10 @@ ...@@ -33,6 +37,10 @@
a.FD_PERSON, a.FD_PERSON,
a.FD_ADDRESS, a.FD_ADDRESS,
a.FD_TOOLS, a.FD_TOOLS,
a.FD_ADDRESS_LEVEL,
a.FD_JIAO_TONG,
a.FD_CAN_YIN,
a.FD_REN_SHU,
a.FD_STATUS, a.FD_STATUS,
a.FD_SETTLE_FORM_ID, a.FD_SETTLE_FORM_ID,
a.create_time a.create_time
...@@ -50,4 +58,9 @@ ...@@ -50,4 +58,9 @@
</where> </where>
</select> </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> </mapper>
...@@ -51,9 +51,8 @@ public class TSalaryStandardOriginalDetail { ...@@ -51,9 +51,8 @@ public class TSalaryStandardOriginalDetail {
/** /**
* 原表表头 * 原表表头
*/ */
@NotBlank(message = "原表表头不能为空")
@Length(max = 50, message = "原表表头不能超过50个字符") @Length(max = 50, message = "原表表头不能超过50个字符")
@ExcelAttribute(name = "原表表头", isNotEmpty = true, errorInfo = "原表表头不能为空", maxLength = 50) @ExcelAttribute(name = "原表表头", maxLength = 50)
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "原表表头") @ExcelProperty(value = "原表表头")
private String excelName; private String excelName;
......
...@@ -122,13 +122,19 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -122,13 +122,19 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
if (!(filename.endsWith(".xls") || filename.endsWith(".xlsx"))) { if (!(filename.endsWith(".xls") || filename.endsWith(".xlsx"))) {
return R.failed("文件名称格式有误,请重新上传!" + filename); return R.failed("文件名称格式有误,请重新上传!" + filename);
} }
ExcelSheetVo vo; R<ExcelSheetVo> voR;
ExcelSheetVo vo = null;
InputStream inputStream = file.getInputStream(); InputStream inputStream = file.getInputStream();
//根据文件格式 对应不同的api解析 //根据文件格式 对应不同的api解析
if (filename.endsWith(".xlsx")) { if (filename.endsWith(".xlsx")) {
vo = readXlsx(inputStream, specialIdCardList, true, sheetName); voR = readXlsx(inputStream, specialIdCardList, true, sheetName);
} else { } else {
vo = readXls(inputStream, specialIdCardList, true, sheetName); 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())) { if (Common.isNotNull(vo.getErrorInfo())) {
...@@ -137,7 +143,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -137,7 +143,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
return R.ok(vo); return R.ok(vo);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
log.error("解析表头失败!"+ e.getMessage()); log.error("解析表头失败!" + e.getMessage());
} }
return R.failed("解析表头失败"); return R.failed("解析表头失败");
} }
...@@ -151,7 +157,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -151,7 +157,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
* @Date: 2024/4/8 17:02 * @Date: 2024/4/8 17:02
* @return: com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelVo * @return: com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelVo
**/ **/
private ExcelSheetVo readXls(InputStream inputStream, List<String> specialIdCardList, boolean titleFlag private R<ExcelSheetVo> readXls(InputStream inputStream, List<String> specialIdCardList, boolean titleFlag
, String sheetName) throws IOException { , String sheetName) throws IOException {
HSSFWorkbook sheets = null; HSSFWorkbook sheets = null;
ExcelSheetVo sheetVo = new ExcelSheetVo(); ExcelSheetVo sheetVo = new ExcelSheetVo();
...@@ -223,13 +229,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -223,13 +229,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
} else if (CellType.BOOLEAN == cell.getCellType()) { } else if (CellType.BOOLEAN == cell.getCellType()) {
cellValue = String.valueOf(row.getCell(cellNum).getBooleanCellValue()); cellValue = String.valueOf(row.getCell(cellNum).getBooleanCellValue());
} else { } else {
cell.setCellType(CellType.STRING);
cellValue = row.getCell(cellNum).getStringCellValue(); cellValue = row.getCell(cellNum).getStringCellValue();
} }
} }
} catch (Exception e) { } catch (Exception e) {
cellValue = ""; cellValue = "";
//sheetVo.setErrorInfo("请注意单元格格式,第" + (i + 1) + "个sheet,第" + (rowNum + 1) + "行第" + (cellNum + 1) + "列。" + e.getMessage());
//return sheetVo;
} }
if (Common.isNotNull(cellValue) && dataRowFlag if (Common.isNotNull(cellValue) && dataRowFlag
&& (((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue)) && (((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue))
...@@ -257,14 +262,20 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -257,14 +262,20 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
titleList = new ArrayList<>(columnList); titleList = new ArrayList<>(columnList);
} }
} }
if (rowNum >= 50 && dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!");
}
if (titleFlag && !dataRowFlag) { if (titleFlag && !dataRowFlag) {
break; break;
} }
} }
if (dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!!");
}
sheetVo.setDataNum(dataRow); sheetVo.setDataNum(dataRow);
sheetVo.setTitleList(titleList); sheetVo.setTitleList(titleList);
sheetVo.setContentList(contentList); sheetVo.setContentList(contentList);
return sheetVo; return R.ok(sheetVo);
} }
} }
} catch (IOException e) { } catch (IOException e) {
...@@ -277,7 +288,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -277,7 +288,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
sheets.close(); sheets.close();
} }
} }
return sheetVo; return R.ok(sheetVo);
} }
/** /**
...@@ -289,7 +300,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -289,7 +300,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
* @Date: 2024/4/8 17:02 * @Date: 2024/4/8 17:02
* @return: com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelVo * @return: com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelVo
**/ **/
private ExcelSheetVo readXlsx(InputStream inputStream, List<String> specialIdCardList, boolean titleFlag private R<ExcelSheetVo> readXlsx(InputStream inputStream, List<String> specialIdCardList, boolean titleFlag
, String sheetName) throws IOException { , String sheetName) throws IOException {
XSSFWorkbook sheets = null; XSSFWorkbook sheets = null;
ExcelSheetVo sheetVo = new ExcelSheetVo(); ExcelSheetVo sheetVo = new ExcelSheetVo();
...@@ -370,9 +381,9 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -370,9 +381,9 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
//return sheetVo; //return sheetVo;
} }
if (Common.isNotNull(cellValue) && dataRowFlag if (Common.isNotNull(cellValue) && dataRowFlag
&& (((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue)) && (((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue))
// 特殊身份证允许识别 // 特殊身份证允许识别
|| regSpecialIdCard(cellValue, specialIdCardList))) { || regSpecialIdCard(cellValue, specialIdCardList))) {
dataRow = rowNum; dataRow = rowNum;
dataRowFlag = false; dataRowFlag = false;
} }
...@@ -395,14 +406,20 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -395,14 +406,20 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
titleList = new ArrayList<>(columnList); titleList = new ArrayList<>(columnList);
} }
} }
if (rowNum >= 50 && dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!");
}
if (titleFlag && !dataRowFlag) { if (titleFlag && !dataRowFlag) {
break; break;
} }
} }
if (dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!!");
}
sheetVo.setDataNum(dataRow); sheetVo.setDataNum(dataRow);
sheetVo.setTitleList(titleList); sheetVo.setTitleList(titleList);
sheetVo.setContentList(contentList); sheetVo.setContentList(contentList);
return sheetVo; return R.ok(sheetVo);
} }
} }
} catch (IOException e) { } catch (IOException e) {
...@@ -415,7 +432,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -415,7 +432,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
sheets.close(); sheets.close();
} }
} }
return sheetVo; return R.ok(sheetVo);
} }
/** /**
...@@ -526,21 +543,28 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -526,21 +543,28 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
} }
String jsonString = null; String jsonString = null;
InputStream inputStream = file.getInputStream(); InputStream inputStream = file.getInputStream();
ExcelSheetVo vo; R<ExcelSheetVo> voR;
ExcelSheetVo vo = null;
//根据文件格式 对应不同的api解析 //根据文件格式 对应不同的api解析
if (filename.endsWith(".xlsx")) { if (filename.endsWith(".xlsx")) {
vo = readXlsx(inputStream, specialIdCardList, false, sheetName); voR = readXlsx(inputStream, specialIdCardList, false, sheetName);
} else { } else {
vo = readXls(inputStream, specialIdCardList, false, sheetName); 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()) { if (vo.getTitleList() != null && !vo.getTitleList().isEmpty()) {
ExcelColumnVo title; ExcelColumnVo title;
for (int i=0;i<vo.getTitleList().size();i++) { for (int i = 0; i < vo.getTitleList().size(); i++) {
title = vo.getTitleList().get(i); title = vo.getTitleList().get(i);
if (detailMap.get(String.valueOf(title.getLineNum())) == null) { if (Common.isNotNull(title.getContent())) {
return R.failed("表头与导入的不一致,第"+title.getLineNum()+"列表头【"+title.getContent()+"】未找到配置,请先配置表头!"); if (detailMap.get(String.valueOf(title.getLineNum())) == null) {
} else if (!title.getContent().equals(detailMap.get(String.valueOf(title.getLineNum())).getExcelName()) return R.failed("表头与导入的不一致,第" + title.getLineNum() + "列表头【" + title.getContent() + "】未找到配置,请先配置表头!");
&& (!"是否新员工(默认否)".equals(title.getContent()) } 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())
...@@ -549,7 +573,10 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -549,7 +573,10 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
|| !"手机号码".equals(title.getContent()) || !"手机号码".equals(title.getContent())
|| !"计税月份".equals(title.getContent())) || !"计税月份".equals(title.getContent()))
) { ) {
return R.failed("表头与导入的不一致,第"+(i+1)+"列应为【"+detailMap.get(String.valueOf(title.getLineNum())).getExcelName()+"】,实际为【"+title.getContent()+"】"); 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("表头与导入的不一致,第" + (i + 1) + "列应为【" + detailMap.get(String.valueOf(title.getLineNum())).getExcelName() + "】,实际为空!");
} }
} }
} else { } else {
......
...@@ -118,7 +118,23 @@ ...@@ -118,7 +118,23 @@
FROM FROM
t_salary_standard_original a t_salary_standard_original a
<where> a.DELETE_FLAG = 0 <where> a.DELETE_FLAG = 0
<include refid="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 = #{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> </where>
ORDER BY a.CREATE_TIME asc ORDER BY a.CREATE_TIME asc
</select> </select>
......
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