Commit ff2715fd authored by hongguangwu's avatar hongguangwu

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

parent aecf5217
......@@ -32,38 +32,46 @@ public class EkpQiwiChuchai {
@Schema(description = "审批编号")
@NotBlank(message = "审批编号不能为空")
private String spNo;
private String fdSpNo;
@Schema(description = "申请人姓名")
@NotBlank(message = "申请人姓名不能为空")
private String applyUserName;
private String fdApplyUserName;
@Schema(description = "申请人部门")
@NotBlank(message = "申请人部门不能为空")
private String applyUserDept;
private String fdApplyUserDept;
@Schema(description = "申请日期")
@NotNull(message = "申请日期不能为空")
private LocalDateTime applyDate;
private LocalDateTime fdApplyDate;
@Schema(description = "开始日期")
private LocalDate newBegin;
private LocalDate fdNewBegin;
@Schema(description = "结束日期")
private LocalDate newEnd;
private LocalDate fdNewEnd;
@Schema(description = "出差事由")
private String reason;
private String fdReason;
@Schema(description = "随行人员")
private String person;
private String fdPerson;
@Schema(description = "出差地点")
private String address;
private String fdAddress;
@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已结算;
@Schema(description = "结算状态")
private String status;
private String fdStatus;
@Schema(description = "关联结算ID")
private String settleFormId;
private String fdSettleFormId;
@Schema(description = "创建时间")
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;
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;
......@@ -23,6 +24,8 @@ public interface EkpQiweiChuchaiMapper extends BaseMapper<EkpQiwiChuchai> {
* @return: java.util.List<com.yifu.cloud.v1.hrms.api.entity.salary.TStatisticsProjectReimburse>
**/
List<EkpQiwiChuchai> getAllInfo(@Param("status") String status);
List<QiWeiUserVo> getQiYeWeiXinUserList();
}
......
......@@ -6,18 +6,22 @@
<resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai">
<id property="fdId" column="fd_ID" />
<result property="spNo" column="FD_SP_NO"/>
<result property="applyUserName" column="FD_APPLY_USER_NAME"/>
<result property="applyUserDept" column="FD_APPLY_USER_DEPT"/>
<result property="applyDate" column="FD_APPLY_DATE"/>
<result property="newBegin" column="FD_NEW_BEGIN"/>
<result property="newEnd" column="FD_NEW_END"/>
<result property="reason" column="FD_REASON"/>
<result property="person" column="FD_PERSON"/>
<result property="address" column="FD_ADDRESS"/>
<result property="tools" column="FD_TOOLS"/>
<result property="status" column="FD_STATUS"/>
<result property="settleFormId" column="FD_SETTLE_FORM_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="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>
......@@ -33,6 +37,10 @@
a.FD_PERSON,
a.FD_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
......@@ -50,4 +58,9 @@
</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>
......@@ -51,9 +51,8 @@ public class TSalaryStandardOriginalDetail {
/**
* 原表表头
*/
@NotBlank(message = "原表表头不能为空")
@Length(max = 50, message = "原表表头不能超过50个字符")
@ExcelAttribute(name = "原表表头", isNotEmpty = true, errorInfo = "原表表头不能为空", maxLength = 50)
@ExcelAttribute(name = "原表表头", maxLength = 50)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "原表表头")
private String excelName;
......
......@@ -122,13 +122,19 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
if (!(filename.endsWith(".xls") || filename.endsWith(".xlsx"))) {
return R.failed("文件名称格式有误,请重新上传!" + filename);
}
ExcelSheetVo vo;
R<ExcelSheetVo> voR;
ExcelSheetVo vo = null;
InputStream inputStream = file.getInputStream();
//根据文件格式 对应不同的api解析
if (filename.endsWith(".xlsx")) {
vo = readXlsx(inputStream, specialIdCardList, true, sheetName);
voR = readXlsx(inputStream, specialIdCardList, true, sheetName);
} 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())) {
......@@ -137,7 +143,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
return R.ok(vo);
} catch (IOException e) {
e.printStackTrace();
log.error("解析表头失败!"+ e.getMessage());
log.error("解析表头失败!" + e.getMessage());
}
return R.failed("解析表头失败");
}
......@@ -151,7 +157,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
* @Date: 2024/4/8 17:02
* @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 {
HSSFWorkbook sheets = null;
ExcelSheetVo sheetVo = new ExcelSheetVo();
......@@ -223,13 +229,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
} else if (CellType.BOOLEAN == cell.getCellType()) {
cellValue = String.valueOf(row.getCell(cellNum).getBooleanCellValue());
} else {
cell.setCellType(CellType.STRING);
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))
......@@ -257,14 +262,20 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
titleList = new ArrayList<>(columnList);
}
}
if (rowNum >= 50 && dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!");
}
if (titleFlag && !dataRowFlag) {
break;
}
}
if (dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!!");
}
sheetVo.setDataNum(dataRow);
sheetVo.setTitleList(titleList);
sheetVo.setContentList(contentList);
return sheetVo;
return R.ok(sheetVo);
}
}
} catch (IOException e) {
......@@ -277,7 +288,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
sheets.close();
}
}
return sheetVo;
return R.ok(sheetVo);
}
/**
......@@ -289,7 +300,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
* @Date: 2024/4/8 17:02
* @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 {
XSSFWorkbook sheets = null;
ExcelSheetVo sheetVo = new ExcelSheetVo();
......@@ -370,9 +381,9 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
//return sheetVo;
}
if (Common.isNotNull(cellValue) && dataRowFlag
&& (((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue))
// 特殊身份证允许识别
|| regSpecialIdCard(cellValue, specialIdCardList))) {
&& (((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue))
// 特殊身份证允许识别
|| regSpecialIdCard(cellValue, specialIdCardList))) {
dataRow = rowNum;
dataRowFlag = false;
}
......@@ -395,14 +406,20 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
titleList = new ArrayList<>(columnList);
}
}
if (rowNum >= 50 && dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!");
}
if (titleFlag && !dataRowFlag) {
break;
}
}
if (dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!!");
}
sheetVo.setDataNum(dataRow);
sheetVo.setTitleList(titleList);
sheetVo.setContentList(contentList);
return sheetVo;
return R.ok(sheetVo);
}
}
} catch (IOException e) {
......@@ -415,7 +432,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
sheets.close();
}
}
return sheetVo;
return R.ok(sheetVo);
}
/**
......@@ -526,21 +543,28 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
}
String jsonString = null;
InputStream inputStream = file.getInputStream();
ExcelSheetVo vo;
R<ExcelSheetVo> voR;
ExcelSheetVo vo = null;
//根据文件格式 对应不同的api解析
if (filename.endsWith(".xlsx")) {
vo = readXlsx(inputStream, specialIdCardList, false, sheetName);
voR = readXlsx(inputStream, specialIdCardList, false, sheetName);
} 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()) {
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);
if (detailMap.get(String.valueOf(title.getLineNum())) == null) {
return R.failed("表头与导入的不一致,第"+title.getLineNum()+"列表头【"+title.getContent()+"】未找到配置,请先配置表头!");
} else if (!title.getContent().equals(detailMap.get(String.valueOf(title.getLineNum())).getExcelName())
&& (!"是否新员工(默认否)".equals(title.getContent())
if (Common.isNotNull(title.getContent())) {
if (detailMap.get(String.valueOf(title.getLineNum())) == null) {
return R.failed("表头与导入的不一致,第" + title.getLineNum() + "列表头【" + 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())
......@@ -549,7 +573,10 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
|| !"手机号码".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 {
......
......@@ -118,7 +118,23 @@
FROM
t_salary_standard_original a
<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>
ORDER BY a.CREATE_TIME asc
</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