项目-面积数据导入改造

This commit is contained in:
李贵强 2025-02-25 18:06:37 +08:00
parent 49146f3849
commit ebaf2edff2
1 changed files with 47 additions and 68 deletions

View File

@ -197,19 +197,21 @@ public class TotalAssignmentPlugin extends AbstractFormPlugin implements RowClic
for (int i = 0; i < productEntry.size(); i++) {
if (productEntry.get(i).getBigDecimal("productentry_buildingarea").compareTo(BigDecimal.ZERO) == 0) {
DynamicObjectCollection collections = productEntry.get(i).getDynamicObjectCollection(SUB_ENTRY);
this.setProductEntryValue(productEntry,collections,productEntry.get(0).getLong("id"));
//防水面积赋值
BigDecimal waterproofArea = collections.stream()
.filter(collection -> "防水".equals(collection.getString("qeug_fl"))) // 排除 "防水" 类型
.map(collection -> {
BigDecimal hjs = collection.getBigDecimal("qeug_hjs");
BigDecimal tzz = collection.getBigDecimal("qeug_tzz");
return hjs.add(tzz);
})
.reduce(BigDecimal.ZERO, BigDecimal::add);
this.getModel().setValue("qeug_waterproofarea",waterproofArea,i);
// BigDecimal waterproofArea = collections.stream()
// .filter(collection -> "防水".equals(collection.getString("qeug_fl"))) // 排除 "防水" 类型
// .map(collection -> {
// BigDecimal hjs = collection.getBigDecimal("qeug_hjs");
// BigDecimal tzz = collection.getBigDecimal("qeug_tzz");
// return hjs.add(tzz);
// })
// .reduce(BigDecimal.ZERO, BigDecimal::add);
// this.getModel().setValue("qeug_waterproofarea",waterproofArea,i);
//指标信息赋值
Long typeId = productEntry.get(i).getLong("productentry_producttype.id");
this.updateMetricInfo(collections, typeId, pkValue);
}
}
Tab tab = this.getView().getControl("tabap");
@ -353,6 +355,8 @@ public class TotalAssignmentPlugin extends AbstractFormPlugin implements RowClic
watertight = watertight.add(value);
break;
case "非标":
case "总面积":
case "可出租面积":
break;
default:
this.getView().showMessage("无效的分类: " + type + ", 请重新选择!");
@ -385,8 +389,11 @@ public class TotalAssignmentPlugin extends AbstractFormPlugin implements RowClic
* @param pkValue 表单id
*/
private void updateMetricInfo(DynamicObjectCollection collections, Long productTypeId, Object pkValue) {
// 获取地下面积汇总值
//获取总面积分类的总面积
BigDecimal allArea=areaSummary(collections,"总面积");
// 获取总面积分类的地下面积汇总值
BigDecimal groundFloorSummary = collections.stream()
.filter(collection -> "总面积".equals(collection.getString("qeug_fl")))
.map(collection -> {
// 获取两个 BigDecimal 如果为 null则使用 BigDecimal.ZERO
BigDecimal b1f = collection.getBigDecimal("qeug_b1f") != null ? collection.getBigDecimal("qeug_b1f") : BigDecimal.ZERO;
@ -395,39 +402,11 @@ public class TotalAssignmentPlugin extends AbstractFormPlugin implements RowClic
})
.reduce(BigDecimal.ZERO, BigDecimal::add); // 累加所有的和
// 获取地上面积汇总值
BigDecimal allArea = collections.stream()
.map(collection -> {
// 获取 BigDecimal 如果为 null则使用 BigDecimal.ZERO
BigDecimal hjs = collection.getBigDecimal("qeug_hjs") != null ? collection.getBigDecimal("qeug_hjs") : BigDecimal.ZERO;
BigDecimal tzz = collection.getBigDecimal("qeug_tzz") != null ? collection.getBigDecimal("qeug_tzz") : BigDecimal.ZERO;
return hjs.add(tzz);
})
.reduce(BigDecimal.ZERO, BigDecimal::add); // 累加所有的面积
//获取防水面积
BigDecimal waterproofArea = collections.stream()
.filter(collection -> "防水".equals(collection.getString("qeug_fl"))) // 排除 "防水" 类型
.map(collection -> {
BigDecimal hjs = collection.getBigDecimal("qeug_hjs");
BigDecimal tzz = collection.getBigDecimal("qeug_tzz");
return hjs.add(tzz);
})
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 获取地上面积 - 地下面积 - 防水面积
BigDecimal groundSummary = allArea.subtract(groundFloorSummary).subtract(waterproofArea);
BigDecimal groundSummary = allArea.subtract(groundFloorSummary);
// 获取精装面积汇总值
BigDecimal hardcoverSummary = collections.stream()
.filter(collection -> "套内".equals(collection.getString("qeug_fl"))) // 筛选 "套内" 类型
.map(collection -> {
// 获取 BigDecimal 如果为 null则使用 BigDecimal.ZERO
BigDecimal hjs = collection.getBigDecimal("qeug_hjs") != null ? collection.getBigDecimal("qeug_hjs") : BigDecimal.ZERO;
BigDecimal tzz = collection.getBigDecimal("qeug_tzz") != null ? collection.getBigDecimal("qeug_tzz") : BigDecimal.ZERO;
return hjs.add(tzz);
})
.reduce(BigDecimal.ZERO, BigDecimal::add); // 累加所有的 "套内" 面积
BigDecimal hardcoverSummary = areaSummary(collections,"套内");
QFilter qFilter = new QFilter("mainprojectid", QCP.equals, pkValue);
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("repmd_index_products", qFilter.toArray());
@ -457,47 +436,47 @@ public class TotalAssignmentPlugin extends AbstractFormPlugin implements RowClic
*/
private void setProductEntryValue(DynamicObjectCollection productEntry, DynamicObjectCollection collections, Long id) {
//公区面积汇总
BigDecimal publicArea = collections.stream()
.filter(collection -> "公区".equals(collection.getString("qeug_fl"))) // 排除 "防水" 类型
.map(collection -> {
BigDecimal hjs = collection.getBigDecimal("qeug_hjs");
BigDecimal tzz = collection.getBigDecimal("qeug_tzz");
return hjs.add(tzz);
})
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal publicArea = areaSummary(collections,"公区");
//套内面积汇总
BigDecimal hardcoverArea = collections.stream()
.filter(collection -> "套内".equals(collection.getString("qeug_fl"))) // 排除 "防水" 类型
.map(collection -> {
BigDecimal hjs = collection.getBigDecimal("qeug_hjs");
BigDecimal tzz = collection.getBigDecimal("qeug_tzz");
return hjs.add(tzz);
})
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal hardcoverArea = areaSummary(collections,"套内");
//防水面积汇总
BigDecimal waterproofArea = collections.stream()
.filter(collection -> "防水".equals(collection.getString("qeug_fl"))) // 排除 "防水" 类型
.map(collection -> {
BigDecimal hjs = collection.getBigDecimal("qeug_hjs");
BigDecimal tzz = collection.getBigDecimal("qeug_tzz");
return hjs.add(tzz);
})
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal waterproofArea = areaSummary(collections,"防水");
//可出租面积
BigDecimal hireArea = areaSummary(collections,"可出租面积");
for (int i = 0; i < productEntry.size(); i++) {
DynamicObject dynamicObject = productEntry.get(i);
Long id1 = dynamicObject.getLong("id");
if (id1.compareTo(id) == 0) {
dynamicObject.set("productentry_buildingarea", publicArea.add(hardcoverArea));
//实际装修面积=公区+套内
dynamicObject.set("qeug_actualarea", publicArea.add(hardcoverArea));
//防水面积
dynamicObject.set("qeug_waterproofarea",waterproofArea);
this.getView().updateView("productentry_buildingarea",i);
this.getView().updateView("qeug_waterproofarea",i);
//改建后可出租面积
dynamicObject.set("qeug_productentry_saleare",hireArea);
break;
}
}
this.getView().updateView("productentry");
// 更新控件显示
updateLabel(publicAmountLabel, publicArea);
updateLabel(watertightAmountLabel, waterproofArea);
updateLabel(hardcoverAmountLabel, hardcoverArea);
}
/**
* 面积分类汇总
* @param collections
* @param type
* @return
*/
private BigDecimal areaSummary(DynamicObjectCollection collections,String type){
return collections.stream()
.filter(collection -> type.equals(collection.getString("qeug_fl")))
.map(collection -> {
BigDecimal hjs = collection.getBigDecimal("qeug_hjs");
BigDecimal tzz = collection.getBigDecimal("qeug_tzz");
return hjs.add(tzz);
})
.reduce(BigDecimal.ZERO, BigDecimal::add);
}
}