|
@@ -185,7 +185,7 @@ public class OutTempDataViewBillListPlugin extends AbstractListPlugin implements
|
|
|
String name = (String)tempMap.get("name");
|
|
String name = (String)tempMap.get("name");
|
|
|
key = (String)tempMap.get("key");
|
|
key = (String)tempMap.get("key");
|
|
|
itemType = (String)tempMap.get("itemType");
|
|
itemType = (String)tempMap.get("itemType");
|
|
|
- if ("0".equals(itemType)) {
|
|
|
|
|
|
|
+ if ("999".equals(itemType)) {
|
|
|
if (!COMMONCOLUMNSET.contains(key)) {
|
|
if (!COMMONCOLUMNSET.contains(key)) {
|
|
|
IListColumn tempColumn = (IListColumn)otherFixColumnMap.get(key);
|
|
IListColumn tempColumn = (IListColumn)otherFixColumnMap.get(key);
|
|
|
if (tempColumn != null) {
|
|
if (tempColumn != null) {
|
|
@@ -238,40 +238,40 @@ public class OutTempDataViewBillListPlugin extends AbstractListPlugin implements
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void addItemProp(DynamicObjectType mainEntityType, List<Map<String, String>> columnHeadList) {
|
|
private void addItemProp(DynamicObjectType mainEntityType, List<Map<String, String>> columnHeadList) {
|
|
|
- String key = null;
|
|
|
|
|
- Long dataTypeId = null;
|
|
|
|
|
- String name = null;
|
|
|
|
|
- String itemType = null;
|
|
|
|
|
- Iterator it = columnHeadList.iterator();
|
|
|
|
|
-
|
|
|
|
|
- while(true) {
|
|
|
|
|
- while(true) {
|
|
|
|
|
- Map temMap;
|
|
|
|
|
- do {
|
|
|
|
|
- if (!it.hasNext()) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- temMap = (Map)it.next();
|
|
|
|
|
- key = (String)temMap.get("key");
|
|
|
|
|
- itemType = (String)temMap.get("itemType");
|
|
|
|
|
- } while("0".equals(itemType));
|
|
|
|
|
-
|
|
|
|
|
- dataTypeId = Long.valueOf((String)temMap.get("datatypeid"));
|
|
|
|
|
- name = (String)temMap.get("name");
|
|
|
|
|
- if (1030L != dataTypeId && 1010L != dataTypeId && 1020L != dataTypeId) {
|
|
|
|
|
- if (1050L == dataTypeId) {
|
|
|
|
|
- DateProp property = new DateProp();
|
|
|
|
|
- property.setName(key);
|
|
|
|
|
- property.setDisplayName(new LocaleString(name));
|
|
|
|
|
- mainEntityType.addProperty(property);
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- TextProp property = new TextProp();
|
|
|
|
|
- property.setName(key);
|
|
|
|
|
- property.setDisplayName(new LocaleString(name));
|
|
|
|
|
- property.setMaxLenth(200);
|
|
|
|
|
- mainEntityType.addProperty(property);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 遍历所有列定义
|
|
|
|
|
+ for (Map<String, String> columnDef : columnHeadList) {
|
|
|
|
|
+ String key = columnDef.get("key");
|
|
|
|
|
+ String itemType = columnDef.get("itemType");
|
|
|
|
|
+
|
|
|
|
|
+ // 只处理非固定列(itemType != "0")
|
|
|
|
|
+// if ("0".equals(itemType)) {
|
|
|
|
|
+// continue;
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ Long dataTypeId = Long.valueOf(columnDef.get("datatypeid"));
|
|
|
|
|
+ String name = columnDef.get("name");
|
|
|
|
|
+
|
|
|
|
|
+ // 根据数据类型创建相应属性
|
|
|
|
|
+ if (dataTypeId == 1050L) {
|
|
|
|
|
+ // 日期类型属性
|
|
|
|
|
+ DateProp dateProperty = new DateProp();
|
|
|
|
|
+ dateProperty.setName(key);
|
|
|
|
|
+ dateProperty.setDisplayName(new LocaleString(name));
|
|
|
|
|
+ mainEntityType.addProperty(dateProperty);
|
|
|
|
|
+ } else if (dataTypeId == 1010L || dataTypeId == 1020L || dataTypeId == 1030L) {
|
|
|
|
|
+ // 文本类型属性(包括数值)
|
|
|
|
|
+ TextProp textProperty = new TextProp();
|
|
|
|
|
+ textProperty.setName(key);
|
|
|
|
|
+ textProperty.setDisplayName(new LocaleString(name));
|
|
|
|
|
+ textProperty.setMaxLenth(200);
|
|
|
|
|
+ mainEntityType.addProperty(textProperty);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 其他文本类型属性
|
|
|
|
|
+ TextProp otherProperty = new TextProp();
|
|
|
|
|
+ otherProperty.setName(key);
|
|
|
|
|
+ otherProperty.setDisplayName(new LocaleString(name));
|
|
|
|
|
+ otherProperty.setMaxLenth(200);
|
|
|
|
|
+ mainEntityType.addProperty(otherProperty);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -283,111 +283,118 @@ public class OutTempDataViewBillListPlugin extends AbstractListPlugin implements
|
|
|
@Override
|
|
@Override
|
|
|
public DynamicObjectCollection getData(int start, int limit) {
|
|
public DynamicObjectCollection getData(int start, int limit) {
|
|
|
DynamicObjectCollection list = super.getData(start, limit);
|
|
DynamicObjectCollection list = super.getData(start, limit);
|
|
|
|
|
+
|
|
|
|
|
+ // 如果是全选操作,直接返回基础数据
|
|
|
if (this.getQueryBuilder().isSelectedAllRows()) {
|
|
if (this.getQueryBuilder().isSelectedAllRows()) {
|
|
|
return list;
|
|
return list;
|
|
|
- } else {
|
|
|
|
|
- List<Map<String, String>> columnHeadList = OutTempDataViewBillListPlugin.this.getColumnHeadList();
|
|
|
|
|
- if (SWCHelper.isEmpty(columnHeadList)) {
|
|
|
|
|
- return list;
|
|
|
|
|
- } else {
|
|
|
|
|
- OutTempDataViewBillListPlugin.this.addItemProp(list.getDynamicObjectType(), columnHeadList);
|
|
|
|
|
- List<Long> idList = (List)list.stream().map((objx) -> {
|
|
|
|
|
- return objx.getLong("id");
|
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
|
- Map<Long, Map<String, Object>> itemDataMap = this.getItemDataMap(idList);
|
|
|
|
|
- if (itemDataMap.size() == 0) {
|
|
|
|
|
- return list;
|
|
|
|
|
- } else {
|
|
|
|
|
- Map<String, Object> tempMap = null;
|
|
|
|
|
- Iterator it = list.iterator();
|
|
|
|
|
- while(true) {
|
|
|
|
|
- DynamicObject obj;
|
|
|
|
|
- do {
|
|
|
|
|
- do {
|
|
|
|
|
- if (!it.hasNext()) {
|
|
|
|
|
- return list;
|
|
|
|
|
- }
|
|
|
|
|
- obj = (DynamicObject)it.next();
|
|
|
|
|
- tempMap = (Map)itemDataMap.get(obj.getLong("id"));
|
|
|
|
|
- } while(tempMap == null);
|
|
|
|
|
- } while(tempMap.size() == 0);
|
|
|
|
|
-
|
|
|
|
|
- Iterator it1 = tempMap.entrySet().iterator();
|
|
|
|
|
-
|
|
|
|
|
- while(it1.hasNext()) {
|
|
|
|
|
- Map.Entry<String, Object> entry = (Map.Entry)it1.next();
|
|
|
|
|
- obj.set((String)entry.getKey(), entry.getValue());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, String>> columnHeadList = OutTempDataViewBillListPlugin.this.getColumnHeadList();
|
|
|
|
|
+ if (SWCHelper.isEmpty(columnHeadList)) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 添加动态属性到实体类型
|
|
|
|
|
+ OutTempDataViewBillListPlugin.this.addItemProp(list.getDynamicObjectType(), columnHeadList);
|
|
|
|
|
+
|
|
|
|
|
+ // 提取ID列表用于查询
|
|
|
|
|
+ List<Long> idList = list.stream()
|
|
|
|
|
+ .map(obj -> obj.getLong("id"))
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ if (idList.isEmpty()) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 获取详细数据映射
|
|
|
|
|
+ Map<Long, Map<String, Object>> itemDataMap = this.getItemDataMap(idList);
|
|
|
|
|
+ if (itemDataMap.isEmpty()) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 将详细数据填充到主列表中
|
|
|
|
|
+ for (DynamicObject obj : list) {
|
|
|
|
|
+ Long id = obj.getLong("id");
|
|
|
|
|
+ Map<String, Object> detailData = itemDataMap.get(id);
|
|
|
|
|
+ if (detailData != null && !detailData.isEmpty()) {
|
|
|
|
|
+ for (Map.Entry<String, Object> entry : detailData.entrySet()) {
|
|
|
|
|
+ obj.set(entry.getKey(), entry.getValue());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ return list;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private Map<Long, Map<String, Object>> getItemDataMap(List<Long> idList) {
|
|
private Map<Long, Map<String, Object>> getItemDataMap(List<Long> idList) {
|
|
|
- Map<Long, Map<String, Object>> itemDataMap = new HashMap(16);
|
|
|
|
|
|
|
+ Map<Long, Map<String, Object>> itemDataMap = new HashMap<>(16);
|
|
|
HRBaseServiceHelper helper = new HRBaseServiceHelper("nckd_outtempdata");
|
|
HRBaseServiceHelper helper = new HRBaseServiceHelper("nckd_outtempdata");
|
|
|
String fields = "id,entryentity.nckd_itemtype,entryentity.nckd_itemid,entryentity.nckd_datatype,entryentity.nckd_itemvalue";
|
|
String fields = "id,entryentity.nckd_itemtype,entryentity.nckd_itemid,entryentity.nckd_datatype,entryentity.nckd_itemvalue";
|
|
|
QFilter qFilter = new QFilter("id", "in", idList);
|
|
QFilter qFilter = new QFilter("id", "in", idList);
|
|
|
DynamicObjectCollection itemData = helper.queryOriginalCollection(fields, new QFilter[]{qFilter});
|
|
DynamicObjectCollection itemData = helper.queryOriginalCollection(fields, new QFilter[]{qFilter});
|
|
|
- if (itemData.size() == 0) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (itemData.isEmpty()) {
|
|
|
return itemDataMap;
|
|
return itemDataMap;
|
|
|
- } else {
|
|
|
|
|
- Map<String, Object> tempMap = null;
|
|
|
|
|
- long dataTypeId = 0L;
|
|
|
|
|
- String itemValue = null;
|
|
|
|
|
- String columnKey = null;
|
|
|
|
|
- Iterator var12 = itemData.iterator();
|
|
|
|
|
-
|
|
|
|
|
- while(true) {
|
|
|
|
|
- while(true) {
|
|
|
|
|
- DynamicObject obj;
|
|
|
|
|
- do {
|
|
|
|
|
- if (!var12.hasNext()) {
|
|
|
|
|
- return itemDataMap;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- obj = (DynamicObject)var12.next();
|
|
|
|
|
- tempMap = (Map)itemDataMap.get(obj.getLong("id"));
|
|
|
|
|
- if (tempMap == null) {
|
|
|
|
|
- tempMap = new HashMap(16);
|
|
|
|
|
- itemDataMap.put(obj.getLong("id"), tempMap);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- dataTypeId = obj.getLong("entryentity.nckd_itemtype");
|
|
|
|
|
- itemValue = obj.getString("entryentity.nckd_itemvalue");
|
|
|
|
|
- } while(itemValue == null);
|
|
|
|
|
-
|
|
|
|
|
- columnKey = this.getColumnKey(obj.getString("entryentity.nckd_itemtype"), obj.getLong("entryentity.nckd_itemid"));
|
|
|
|
|
- if (1020L != dataTypeId && 1010L != dataTypeId) {
|
|
|
|
|
- if (1050L == dataTypeId) {
|
|
|
|
|
- try {
|
|
|
|
|
- ((Map)tempMap).put(columnKey, DateTimeUtils.parseDate(itemValue, "yyyy-MM-dd"));
|
|
|
|
|
- } catch (ParseException var15) {
|
|
|
|
|
- OutTempDataViewBillListPlugin.logger.error("parse itemValue error", var15);
|
|
|
|
|
- throw new KDBizException(ExceptionUtils.getFullStackTrace(var15));
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- ((Map)tempMap).put(columnKey, itemValue);
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- ((Map)tempMap).put(columnKey, new BigDecimal(itemValue));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (DynamicObject obj : itemData) {
|
|
|
|
|
+ Long objectId = obj.getLong("id");
|
|
|
|
|
+ String itemValue = obj.getString("entryentity.nckd_itemvalue");
|
|
|
|
|
+
|
|
|
|
|
+ // 跳过空值记录
|
|
|
|
|
+ if (itemValue == null) {
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 获取或创建该对象的属性映射
|
|
|
|
|
+ Map<String, Object> objectProperties = itemDataMap.computeIfAbsent(objectId, k -> new HashMap<>(16));
|
|
|
|
|
+
|
|
|
|
|
+ // 获取列键和数据类型
|
|
|
|
|
+ String itemType = obj.getString("entryentity.nckd_itemtype");
|
|
|
|
|
+ Long itemId = obj.getLong("entryentity.nckd_itemid");
|
|
|
|
|
+ String columnKey = this.getColumnKey(itemType, itemId);
|
|
|
|
|
+ Long dataTypeId = obj.getLong("entryentity.nckd_datatype");
|
|
|
|
|
+
|
|
|
|
|
+ // 根据数据类型处理值
|
|
|
|
|
+ try {
|
|
|
|
|
+ Object processedValue = this.processValueByDataType(dataTypeId, itemValue);
|
|
|
|
|
+ objectProperties.put(columnKey, processedValue);
|
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
|
+ OutTempDataViewBillListPlugin.logger.error("parse itemValue error", e);
|
|
|
|
|
+ throw new KDBizException(ExceptionUtils.getFullStackTrace(e));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return itemDataMap;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据数据类型处理值
|
|
|
|
|
+ * @param dataTypeId 数据类型ID
|
|
|
|
|
+ * @param itemValue 原始值
|
|
|
|
|
+ * @return 处理后的值
|
|
|
|
|
+ * @throws ParseException 解析异常
|
|
|
|
|
+ */
|
|
|
|
|
+ private Object processValueByDataType(Long dataTypeId, String itemValue) throws ParseException {
|
|
|
|
|
+ if (dataTypeId == null) {
|
|
|
|
|
+ return itemValue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (dataTypeId == 1050L) {
|
|
|
|
|
+ // 日期类型
|
|
|
|
|
+ return DateTimeUtils.parseDate(itemValue, "yyyy-MM-dd");
|
|
|
|
|
+ } else if (dataTypeId == 1010L || dataTypeId == 1020L) {
|
|
|
|
|
+ // 数值类型
|
|
|
|
|
+ return new BigDecimal(itemValue);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 其他类型作为字符串处理
|
|
|
|
|
+ return itemValue;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private String getColumnKey(String itemType, long itemId) {
|
|
private String getColumnKey(String itemType, long itemId) {
|
|
|
String columnKey = "";
|
|
String columnKey = "";
|
|
|
- if ("4".equals(itemType)) {
|
|
|
|
|
- columnKey = "ft" + itemId;
|
|
|
|
|
|
|
+ if ("0".equals(itemType)) {
|
|
|
|
|
+ columnKey = "fix" + itemId;
|
|
|
} else if ("1".equals(itemType)) {
|
|
} else if ("1".equals(itemType)) {
|
|
|
columnKey = "ii" + itemId;
|
|
columnKey = "ii" + itemId;
|
|
|
- } else if ("3".equals(itemType)) {
|
|
|
|
|
- columnKey = "bs" + itemId;
|
|
|
|
|
- } else if ("2".equals(itemType)) {
|
|
|
|
|
- columnKey = "sp" + itemId;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return columnKey;
|
|
return columnKey;
|