异常项添加人员重复
This commit is contained in:
parent
4ed7a06bcd
commit
c0171e6c03
|
|
@ -369,7 +369,7 @@ public class OCRSwingArea extends JFrame {
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL; // 水平填充
|
gbc.fill = GridBagConstraints.HORIZONTAL; // 水平填充
|
||||||
gbc.weightx = 1; // 水平权重
|
gbc.weightx = 1; // 水平权重
|
||||||
parentContentPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // 设置内边距
|
parentContentPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // 设置内边距
|
||||||
String[] columnNames = {"姓名", "Excel表格实发工资", "PDF实发工资"};
|
String[] columnNames = {"姓名", "Excel表格实发工资", "PDF实发工资","异常项"};
|
||||||
for (int i = 0; i < errorDataList.size(); i++) {
|
for (int i = 0; i < errorDataList.size(); i++) {
|
||||||
Map<String, Object> map = errorDataList.get(i);
|
Map<String, Object> map = errorDataList.get(i);
|
||||||
JPanel childContentPanel = new JPanel();
|
JPanel childContentPanel = new JPanel();
|
||||||
|
|
@ -393,11 +393,13 @@ public class OCRSwingArea extends JFrame {
|
||||||
errorTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
errorTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||||
errorTable.setRowHeight(25); // 设置行高
|
errorTable.setRowHeight(25); // 设置行高
|
||||||
TableColumn cellColumn = errorTable.getColumn("姓名");
|
TableColumn cellColumn = errorTable.getColumn("姓名");
|
||||||
cellColumn.setPreferredWidth(200);
|
cellColumn.setPreferredWidth(100);
|
||||||
TableColumn cellColumn2 = errorTable.getColumn("Excel表格实发工资");
|
TableColumn cellColumn2 = errorTable.getColumn("Excel表格实发工资");
|
||||||
cellColumn2.setPreferredWidth(200);
|
cellColumn2.setPreferredWidth(150);
|
||||||
TableColumn cellColumn3 = errorTable.getColumn("PDF实发工资");
|
TableColumn cellColumn3 = errorTable.getColumn("PDF实发工资");
|
||||||
cellColumn3.setPreferredWidth(200);
|
cellColumn3.setPreferredWidth(150);
|
||||||
|
TableColumn cellColumn4 = errorTable.getColumn("异常项");
|
||||||
|
cellColumn4.setPreferredWidth(200);
|
||||||
JScrollPane jScrollPane = new JScrollPane(errorTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
JScrollPane jScrollPane = new JScrollPane(errorTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
JPanel panel2 = new JPanel();
|
JPanel panel2 = new JPanel();
|
||||||
panel2.setLayout(new BoxLayout(panel2, BoxLayout.Y_AXIS)); // 垂直排列
|
panel2.setLayout(new BoxLayout(panel2, BoxLayout.Y_AXIS)); // 垂直排列
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public class ErrorTableModel extends DefaultTableModel{
|
||||||
|
|
||||||
private void loadData() {
|
private void loadData() {
|
||||||
for (UserErrorVo userErrorVo : data) {
|
for (UserErrorVo userErrorVo : data) {
|
||||||
Object[] row = {userErrorVo.getName(), userErrorVo.getWage(), userErrorVo.getPdfWage()};
|
Object[] row = {userErrorVo.getName(), userErrorVo.getWage(), userErrorVo.getPdfWage(),userErrorVo.getErrorData()};
|
||||||
addRow(row); // 添加行数据
|
addRow(row); // 添加行数据
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,10 +115,13 @@ public class HandleDataUtil {
|
||||||
List<UserErrorVo> userErrorVos2 = CompareDataUtil.compareData2(excelList, pdfList);
|
List<UserErrorVo> userErrorVos2 = CompareDataUtil.compareData2(excelList, pdfList);
|
||||||
// 5.比较pdf和excel中人员的实发工资不一致的数据
|
// 5.比较pdf和excel中人员的实发工资不一致的数据
|
||||||
List<UserErrorVo> userErrorVos3 = CompareDataUtil.compareData3(excelList, pdfList);
|
List<UserErrorVo> userErrorVos3 = CompareDataUtil.compareData3(excelList, pdfList);
|
||||||
|
// 6.人员重复
|
||||||
|
List<UserErrorVo> userErrorVos4 = CompareDataUtil.compareData4(excelList, pdfList);
|
||||||
// 合并数据
|
// 合并数据
|
||||||
dataList.addAll(userErrorVos);
|
dataList.addAll(userErrorVos);
|
||||||
dataList.addAll(userErrorVos2);
|
dataList.addAll(userErrorVos2);
|
||||||
dataList.addAll(userErrorVos3);
|
dataList.addAll(userErrorVos3);
|
||||||
|
dataList.addAll(userErrorVos4);
|
||||||
dataMap.put("fileName", fileName.substring(0, fileName.lastIndexOf(".")));
|
dataMap.put("fileName", fileName.substring(0, fileName.lastIndexOf(".")));
|
||||||
dataMap.put("errorList", dataList);
|
dataMap.put("errorList", dataList);
|
||||||
return dataMap;
|
return dataMap;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ public class CompareDataUtil {
|
||||||
for (UserVo userVo : difference) {
|
for (UserVo userVo : difference) {
|
||||||
UserErrorVo userErrorVo = new UserErrorVo();
|
UserErrorVo userErrorVo = new UserErrorVo();
|
||||||
BeanUtil.copyProperties(userVo, userErrorVo);
|
BeanUtil.copyProperties(userVo, userErrorVo);
|
||||||
|
userErrorVo.setErrorData("pdf中人员不存在");
|
||||||
dataList.add(userErrorVo);
|
dataList.add(userErrorVo);
|
||||||
}
|
}
|
||||||
return dataList;
|
return dataList;
|
||||||
|
|
@ -57,6 +58,7 @@ public class CompareDataUtil {
|
||||||
for (UserVo userVo : difference) {
|
for (UserVo userVo : difference) {
|
||||||
UserErrorVo userErrorVo = new UserErrorVo();
|
UserErrorVo userErrorVo = new UserErrorVo();
|
||||||
userErrorVo.setName(userVo.getName());
|
userErrorVo.setName(userVo.getName());
|
||||||
|
userErrorVo.setErrorData("excel中人员不存在");
|
||||||
userErrorVo.setPdfWage(userVo.getWage());
|
userErrorVo.setPdfWage(userVo.getWage());
|
||||||
dataList.add(userErrorVo);
|
dataList.add(userErrorVo);
|
||||||
}
|
}
|
||||||
|
|
@ -77,6 +79,23 @@ public class CompareDataUtil {
|
||||||
return dataList;
|
return dataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pdf和excel中姓名重复数据
|
||||||
|
* @param excelList
|
||||||
|
* @param pdfList
|
||||||
|
* @return List<UserErrorVo>
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2025/3/17 13:50
|
||||||
|
*/
|
||||||
|
public static List<UserErrorVo> compareData4(List<UserVo> excelList, List<UserVo> pdfList) {
|
||||||
|
List<UserErrorVo> dataList = new ArrayList<>();
|
||||||
|
List<UserErrorVo> excelAlikeList = findAlikeData(excelList,1);
|
||||||
|
List<UserErrorVo> pdfAlikeList = findAlikeData(excelList,2);
|
||||||
|
dataList.addAll(excelAlikeList);
|
||||||
|
dataList.addAll(pdfAlikeList);
|
||||||
|
return dataList;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<UserErrorVo> findDifferentSalaries(List<UserVo> listA, List<UserVo> listB) {
|
public static List<UserErrorVo> findDifferentSalaries(List<UserVo> listA, List<UserVo> listB) {
|
||||||
List<UserErrorVo> result = new ArrayList<>();
|
List<UserErrorVo> result = new ArrayList<>();
|
||||||
// 将集合 B 转换为 Map,key 为姓名,value 为 Employee 对象
|
// 将集合 B 转换为 Map,key 为姓名,value 为 Employee 对象
|
||||||
|
|
@ -92,9 +111,31 @@ public class CompareDataUtil {
|
||||||
userErrorVo.setName(empA.getName());
|
userErrorVo.setName(empA.getName());
|
||||||
userErrorVo.setWage(empA.getWage());
|
userErrorVo.setWage(empA.getWage());
|
||||||
userErrorVo.setPdfWage(empB.getWage());
|
userErrorVo.setPdfWage(empB.getWage());
|
||||||
|
userErrorVo.setErrorData("实发工资不一致");
|
||||||
result.add(userErrorVo);
|
result.add(userErrorVo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<UserErrorVo> findAlikeData(List<UserVo> list,int type) {
|
||||||
|
List<UserErrorVo> result = new ArrayList<>();
|
||||||
|
// 使用Stream API查找重复的姓名
|
||||||
|
Map<String, List<UserVo>> nameGroups = list.stream()
|
||||||
|
.collect(Collectors.groupingBy(UserVo::getName));
|
||||||
|
|
||||||
|
// 过滤出重复的姓名,并只保留一条记录
|
||||||
|
List<UserVo> duplicatePeople = nameGroups.entrySet().stream()
|
||||||
|
.filter(entry -> entry.getValue().size() > 1) // 过滤出重复的姓名
|
||||||
|
.map(entry -> entry.getValue().get(0)) // 只取第一条记录
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 遍历集合
|
||||||
|
for (UserVo userVo : duplicatePeople) {
|
||||||
|
UserErrorVo userErrorVo = new UserErrorVo();
|
||||||
|
userErrorVo.setName(userVo.getName());
|
||||||
|
userErrorVo.setErrorData(type == 1 ? "excel中姓名重复" : "pdf中姓名重复");
|
||||||
|
result.add(userErrorVo);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,10 @@ public class UserErrorVo {
|
||||||
private Double wage;
|
private Double wage;
|
||||||
/**pdf-实发工资*/
|
/**pdf-实发工资*/
|
||||||
private Double pdfWage;
|
private Double pdfWage;
|
||||||
|
|
||||||
|
/**异常项*/
|
||||||
|
private String errorData;
|
||||||
|
|
||||||
public UserErrorVo() {
|
public UserErrorVo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,12 +46,21 @@ public class UserErrorVo {
|
||||||
this.pdfWage = pdfWage;
|
this.pdfWage = pdfWage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getErrorData() {
|
||||||
|
return errorData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorData(String errorData) {
|
||||||
|
this.errorData = errorData;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "UserErrorVo{" +
|
return "UserErrorVo{" +
|
||||||
"name='" + name + '\'' +
|
"name='" + name + '\'' +
|
||||||
", wage=" + wage +
|
", wage=" + wage +
|
||||||
", pdfWage=" + pdfWage +
|
", pdfWage=" + pdfWage +
|
||||||
|
", errorData='" + errorData + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue