|
|
@@ -43,17 +43,19 @@ public class ImportTaskGuideImportService {
|
|
|
private Long sinsurTplId;
|
|
|
private Long welfarepayerId;
|
|
|
private Long periodId;
|
|
|
+ private String periodNumber;
|
|
|
private String url;
|
|
|
private static final long DATE_TYPE_ID = 1050L;
|
|
|
private static final long NUMBER_TYPE_ID = 1010L;
|
|
|
private static final long DECIMAL_TYPE_ID = 1020L;
|
|
|
private static final String DATE_FORMAT = "yyyy-MM-dd";
|
|
|
|
|
|
- public ImportTaskGuideImportService(String url, Long importTaskId, Long sinsurTplId, Long periodId, Long welfarepayerId) {
|
|
|
+ public ImportTaskGuideImportService(String url, Long importTaskId, Long sinsurTplId, Long periodId, String periodNumber, Long welfarepayerId) {
|
|
|
this.url = url;
|
|
|
this.importTaskId = importTaskId;
|
|
|
this.sinsurTplId = sinsurTplId;
|
|
|
this.periodId = periodId;
|
|
|
+ this.periodNumber = periodNumber;
|
|
|
this.welfarepayerId = welfarepayerId;
|
|
|
}
|
|
|
|
|
|
@@ -114,6 +116,7 @@ public class ImportTaskGuideImportService {
|
|
|
if (!this.isCancel(cacheKey)) {
|
|
|
boolean hasWorkStartDate = tplFixItemMap.containsKey(11);
|
|
|
Map<Integer, List<Map<String, String>>> columnIndexMap = this.getColumnIndexMap();
|
|
|
+ Map<Integer, List<Map<String, String>>> commonColumnIndexMap = this.getCommonColumnIndexMap();
|
|
|
int defaultSize = 500;
|
|
|
List<List<Map<Integer, String>>> splitDataList = SWCListUtils.split(dataRowList, defaultSize);
|
|
|
int lineIndex = 0;
|
|
|
@@ -123,7 +126,7 @@ public class ImportTaskGuideImportService {
|
|
|
for(int size = splitDataList.size(); index < size; ++index) {
|
|
|
tempList = (List)splitDataList.get(index);
|
|
|
lineIndex = index * defaultSize;
|
|
|
- this.checkImportData(tempList, errDataList, columnIndexMap, lineIndex, cacheKey, writeTaskType, orgId, hasWorkStartDate, false);
|
|
|
+ this.checkImportData(tempList, errDataList, commonColumnIndexMap, columnIndexMap, lineIndex, cacheKey, writeTaskType, orgId, hasWorkStartDate, false);
|
|
|
}
|
|
|
|
|
|
if (!this.isCancel(cacheKey)) {
|
|
|
@@ -145,7 +148,7 @@ public class ImportTaskGuideImportService {
|
|
|
}
|
|
|
|
|
|
// TODO 校验导入数据
|
|
|
- private void checkImportData(List<Map<Integer, String>> dataRowList, List<Map<String, String>> allErrDataList, Map<Integer, List<Map<String, String>>> columnIndexMap, int lineIndex, String cacheKey, String writeTaskType, Long orgId, boolean hasWorkStartDate, boolean isMulTimeOnePeriod) {
|
|
|
+ private void checkImportData(List<Map<Integer, String>> dataRowList, List<Map<String, String>> allErrDataList, Map<Integer, List<Map<String, String>>> commonColumnIndexMap, Map<Integer, List<Map<String, String>>> columnIndexMap, int lineIndex, String cacheKey, String writeTaskType, Long orgId, boolean hasWorkStartDate, boolean isMulTimeOnePeriod) {
|
|
|
Map<Integer, Map<Integer, Object>> passDataRowMap = new HashMap(16);
|
|
|
int lineIndexVer = lineIndex;
|
|
|
List<Map<String, String>> errDataList = new ArrayList(10);
|
|
|
@@ -158,7 +161,7 @@ public class ImportTaskGuideImportService {
|
|
|
while(it.hasNext()) {
|
|
|
Map<Integer, Object> passRowMap = new HashMap(16);
|
|
|
Map<Integer, String> rowMap = (Map)it.next();
|
|
|
- isSuccess = this.checkFieldRequriedForCommon(rowMap, errDataList, lineIndex, passRowMap);
|
|
|
+ isSuccess = this.checkFieldRequriedForCommon(commonColumnIndexMap, rowMap, errDataList, lineIndex, passRowMap);
|
|
|
if(!isSuccess) {
|
|
|
++lineIndex;
|
|
|
} else if (!this.checkItemValue(columnIndexMap, passRowMap, errDataList, lineIndex, rowMap)) {
|
|
|
@@ -172,7 +175,7 @@ public class ImportTaskGuideImportService {
|
|
|
}
|
|
|
|
|
|
if (!this.isCancel(cacheKey)) {
|
|
|
- this.saveData(passDataRowMap, columnIndexMap);
|
|
|
+ this.saveData(passDataRowMap, commonColumnIndexMap, columnIndexMap);
|
|
|
successCount = passDataRowMap.size();
|
|
|
failCount = dataRowList.size() - successCount;
|
|
|
return;
|
|
|
@@ -191,7 +194,7 @@ public class ImportTaskGuideImportService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void saveData(Map<Integer, Map<Integer, Object>> passDataRowMap, Map<Integer, List<Map<String, String>>> columnIndexMap) {
|
|
|
+ private void saveData(Map<Integer, Map<Integer, Object>> passDataRowMap, Map<Integer, List<Map<String, String>>> commonColumnIndexMap, Map<Integer, List<Map<String, String>>> columnIndexMap) {
|
|
|
if (passDataRowMap != null && passDataRowMap.size() != 0) {
|
|
|
DynamicObjectCollection result = new DynamicObjectCollection();
|
|
|
MainEntityType type = EntityMetadataCache.getDataEntityType("nckd_sinsurtempdata");
|
|
|
@@ -204,7 +207,7 @@ public class ImportTaskGuideImportService {
|
|
|
temporary = (DynamicObject)type.createInstance();
|
|
|
rowMap = (Map)entry.getValue();
|
|
|
temporary.set("nckd_datastatus", "0");
|
|
|
- ImportTaskUtils.setTemporaryValueForCommon(temporary, rowMap);
|
|
|
+ ImportTaskUtils.setTemporaryValueForCommon(commonColumnIndexMap, temporary, rowMap, periodNumber);
|
|
|
temporary.set("nckd_importtask", this.importTaskId);
|
|
|
temporary.set("creator", RequestContext.get().getCurrUserId());
|
|
|
temporary.set("createtime", new Date());
|
|
|
@@ -283,35 +286,23 @@ public class ImportTaskGuideImportService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private boolean checkFieldRequriedForCommon(Map<Integer, String> rowMap, List<Map<String, String>> errDataList, int lineIndex, Map<Integer, Object> passRowMap) {
|
|
|
+ private boolean checkFieldRequriedForCommon(Map<Integer, List<Map<String, String>>> commonColumnIndexMap, Map<Integer, String> rowMap, List<Map<String, String>> errDataList, int lineIndex, Map<Integer, Object> passRowMap) {
|
|
|
String msg = ResManager.loadKDString("请填写“{0}”。", "ImportTaskGuideImportService_2", "swc-hsas-business", new Object[0]);
|
|
|
- if (SWCStringUtils.isEmpty((String)rowMap.get(0))) {
|
|
|
- errDataList.add(this.assembleErrMap(lineIndex, false, MessageFormat.format(msg, SinsurPresetItemEnum.CALPERIOD.getItemName())));
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- passRowMap.put(0, rowMap.get(0));
|
|
|
- if (SWCStringUtils.isEmpty((String)rowMap.get(1))) {
|
|
|
- errDataList.add(this.assembleErrMap(lineIndex, false, MessageFormat.format(msg, SinsurPresetItemEnum.EMP_IDCARD.getItemName())));
|
|
|
+
|
|
|
+ for (Map.Entry<Integer, List<Map<String, String>>> columnEntry : commonColumnIndexMap.entrySet()) {
|
|
|
+ Integer columnIndex = columnEntry.getKey();
|
|
|
+ String itemValue = rowMap.get(columnIndex);
|
|
|
+
|
|
|
+ if (SWCStringUtils.isEmpty(itemValue)) {
|
|
|
+ errDataList.add(this.assembleErrMap(lineIndex, false, MessageFormat.format(msg, columnEntry.getValue().get(0).get("name"))));
|
|
|
return false;
|
|
|
- } else {
|
|
|
- passRowMap.put(1, rowMap.get(1));
|
|
|
- if (SWCStringUtils.isEmpty((String)rowMap.get(2))) {
|
|
|
- errDataList.add(this.assembleErrMap(lineIndex, false, MessageFormat.format(msg, SinsurPresetItemEnum.EMP_NAME.getItemName())));
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- passRowMap.put(2, rowMap.get(2));
|
|
|
- passRowMap.put(3, rowMap.get(3));
|
|
|
- return true;
|
|
|
-// if (SWCStringUtils.isEmpty((String)rowMap.get(3))) {
|
|
|
-// errDataList.add(this.assembleErrMap(lineIndex, false, MessageFormat.format(msg, SinsurPresetItemEnum.EMP_NUMBER.getItemName())));
|
|
|
-// return false;
|
|
|
-// } else {
|
|
|
-// passRowMap.put(3, rowMap.get(3));
|
|
|
-// return true;
|
|
|
-// }
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Map<String, String> itemMap : columnEntry.getValue()) {
|
|
|
+ passRowMap.put(columnIndex, itemValue);
|
|
|
}
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
private Map<Integer, List<Map<String, String>>> getColumnIndexMap() {
|
|
|
@@ -323,19 +314,44 @@ public class ImportTaskGuideImportService {
|
|
|
while(var4.hasNext()) {
|
|
|
Map<String, String> obj = (Map)var4.next();
|
|
|
if (!"0".equals(obj.get("itemType"))) {
|
|
|
- tempMapList = (List)columnIndexMap.get(Integer.valueOf((String)obj.get("columnIndex")));
|
|
|
+ tempMapList = (List) columnIndexMap.get(Integer.valueOf((String) obj.get("columnIndex")));
|
|
|
if (tempMapList == null) {
|
|
|
tempMapList = new ArrayList(10);
|
|
|
- columnIndexMap.put(Integer.valueOf((String)obj.get("columnIndex")), tempMapList);
|
|
|
+ columnIndexMap.put(Integer.valueOf((String) obj.get("columnIndex")), tempMapList);
|
|
|
}
|
|
|
+ ((List) tempMapList).add(obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- ((List)tempMapList).add(obj);
|
|
|
+ return columnIndexMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取默认项目Map
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<Integer, List<Map<String, String>>> getCommonColumnIndexMap() {
|
|
|
+ List<Map<String, String>> columnHeadList = ImportTaskUtils.getColumnHeadList(this.sinsurTplId, this.importTaskId);
|
|
|
+ Map<Integer, List<Map<String, String>>> columnIndexMap = new HashMap(columnHeadList.size());
|
|
|
+ List<Map<String, String>> tempMapList = null;
|
|
|
+ Iterator var4 = columnHeadList.iterator();
|
|
|
+
|
|
|
+ while(var4.hasNext()) {
|
|
|
+ Map<String, String> obj = (Map)var4.next();
|
|
|
+ if ("0".equals(obj.get("itemType"))) {
|
|
|
+ tempMapList = (List) columnIndexMap.get(Integer.valueOf((String) obj.get("columnIndex")));
|
|
|
+ if (tempMapList == null) {
|
|
|
+ tempMapList = new ArrayList(10);
|
|
|
+ columnIndexMap.put(Integer.valueOf((String) obj.get("columnIndex")), tempMapList);
|
|
|
+ }
|
|
|
+ ((List) tempMapList).add(obj);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return columnIndexMap;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private Map<String, String> assembleErrMap(int dataIndex, boolean isAll, String msg) {
|
|
|
Map<String, String> errMap = new HashMap(4);
|
|
|
errMap.put("errMsg", msg);
|
|
|
@@ -361,7 +377,12 @@ public class ImportTaskGuideImportService {
|
|
|
}
|
|
|
tplName.append(((SinsurPresetItemEnum)entry.getValue()).getImportColumnName());
|
|
|
if (!excelName.equals(tplName.toString())) {
|
|
|
- errDataList.add(((SinsurPresetItemEnum)entry.getValue()).getImportColumnName());
|
|
|
+ // 系统导出来的模板列名有*,线下的模板可能不会加*号,这里再判断一下,如果有*号,去掉*号再匹配一下
|
|
|
+ if(tplName.toString().startsWith("*")) {
|
|
|
+ if(!excelName.equals(tplName.toString().substring(1, tplName.toString().length()))) {
|
|
|
+ errDataList.add(((SinsurPresetItemEnum)entry.getValue()).getImportColumnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|