|
|
|
@ -2,28 +2,29 @@ package shkd.repc.recos.formplugin;
|
|
|
|
|
|
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
|
|
import kd.bos.form.IFormView;
|
|
|
|
|
import kd.bos.form.control.AttachmentPanel;
|
|
|
|
|
import kd.bos.form.control.events.UploadListener;
|
|
|
|
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
|
|
|
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
|
|
|
|
import kd.bos.form.operate.FormOperate;
|
|
|
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
|
|
|
import kd.bos.mvc.bill.BillView;
|
|
|
|
|
import kd.bos.orm.query.QCP;
|
|
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
|
|
import kd.bos.servicehelper.AttachmentDto;
|
|
|
|
|
import kd.bos.servicehelper.AttachmentServiceHelper;
|
|
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
|
import kd.bos.servicehelper.QueryServiceHelper;
|
|
|
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
import shkd.repc.recos.domain.Calculation;
|
|
|
|
|
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.EventObject;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements UploadListener {
|
|
|
|
|
|
|
|
|
@ -45,6 +46,19 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|
|
|
|
case "qeug_test":
|
|
|
|
|
Long id = (Long) this.getModel().getValue("id");//获取单据id
|
|
|
|
|
|
|
|
|
|
Map<String, String> result = new HashMap<>();
|
|
|
|
|
//获取不同楼对应标签得pageid
|
|
|
|
|
Map<String, String> all = this.getPageCache().getAll();
|
|
|
|
|
for (Map.Entry<String, String> entry : all.entrySet()) {
|
|
|
|
|
if (entry.getKey().startsWith("tab_measureci")) {//建安测算
|
|
|
|
|
IFormView view = this.getView().getView(entry.getValue());//标签里面的页面
|
|
|
|
|
Long producttypeid = (Long) view.getModel().getValue("producttypeid");//产品类型id
|
|
|
|
|
DynamicObject single = BusinessDataServiceHelper.loadSingle(producttypeid,"repmd_producttypes");
|
|
|
|
|
String fullname = single.getString("fullname");
|
|
|
|
|
result.put(fullname, entry.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//遍历附件前校验
|
|
|
|
|
AttachmentPanel att = this.getView().getControl("attachmentpanelap");
|
|
|
|
|
if (att.getAttachmentData().size()==0){
|
|
|
|
@ -88,11 +102,13 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|
|
|
|
row.getCell(9).getStringCellValue(),//单位
|
|
|
|
|
//Double.parseDouble(row.getCell(12).getStringCellValue().replace("%", ""))/100.0,
|
|
|
|
|
Double.parseDouble(row.getCell(12).toString()),// 调整系数
|
|
|
|
|
row.getCell(17).getNumericCellValue()//合价(含税)
|
|
|
|
|
row.getCell(17).getNumericCellValue(),//合价(含税)
|
|
|
|
|
row.getCell(16).getNumericCellValue(),//单价
|
|
|
|
|
row.getCell(13).getNumericCellValue()//工程量
|
|
|
|
|
);
|
|
|
|
|
arrayList.add(calculation);
|
|
|
|
|
}
|
|
|
|
|
String res = updateRecosMeasurecos(arrayList, sheetName);
|
|
|
|
|
String res = updateRecosMeasurecos(arrayList, sheetName,result);
|
|
|
|
|
if (!"success".equals(res)){
|
|
|
|
|
this.getView().showSuccessNotification("功能失败:"+res);
|
|
|
|
|
return;
|
|
|
|
@ -102,6 +118,8 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.getView().showSuccessNotification("功能成功");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -120,19 +138,45 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|
|
|
|
/*
|
|
|
|
|
* 根据入参信息修改成本测算方法
|
|
|
|
|
* */
|
|
|
|
|
public String updateRecosMeasurecos(List<Calculation> arrayList,String sheetName) {
|
|
|
|
|
public String updateRecosMeasurecos(List<Calculation> arrayList,String sheetName,Map<String, String> result) {
|
|
|
|
|
try {
|
|
|
|
|
//处理
|
|
|
|
|
System.out.println(arrayList);
|
|
|
|
|
System.out.println(sheetName);
|
|
|
|
|
// QFilter filter = new QFilter("measurecostid", QCP.equals, (Long) this.getModel().getValue("id"));
|
|
|
|
|
// DynamicObject[] DynamicObjects = BusinessDataServiceHelper.load("recos_measureci", "id,status,cientry", filter.toArray());
|
|
|
|
|
// Long fid = (Long) DynamicObjects[0].get("id");
|
|
|
|
|
// DynamicObject loadSingle = BusinessDataServiceHelper.loadSingle(fid,"recos_measureci");
|
|
|
|
|
// DynamicObjectCollection cientry = loadSingle.getDynamicObjectCollection("cientry");
|
|
|
|
|
// cientry.get(4).set("entry_amount",666);
|
|
|
|
|
// Object[] save = SaveServiceHelper.save(new DynamicObject[]{loadSingle});
|
|
|
|
|
// System.out.println(save);
|
|
|
|
|
List<String> numberStrings = arrayList.stream()
|
|
|
|
|
.map(calculation -> String.valueOf(calculation.getEntry_longnumber()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
String sheetNamepage = result.get(sheetName);
|
|
|
|
|
BillView sheetNameView = (BillView) this.getView().getView(sheetNamepage);
|
|
|
|
|
DynamicObject dataEntity = sheetNameView.getModel().getDataEntity(true);
|
|
|
|
|
DynamicObjectCollection cientry = dataEntity.getDynamicObjectCollection("cientry");
|
|
|
|
|
|
|
|
|
|
Map<Integer, Calculation> hashMap = new HashMap<>();//存储修改的数据和下标
|
|
|
|
|
for (DynamicObject dynamicObject : cientry) {
|
|
|
|
|
if (numberStrings.contains(dynamicObject.getString("entry_longnumber"))){
|
|
|
|
|
Calculation res = arrayList.stream()
|
|
|
|
|
.filter(calculation -> dynamicObject.getString("entry_longnumber").equals(calculation.getEntry_longnumber()))
|
|
|
|
|
.findFirst() // 获取第一个匹配的元素
|
|
|
|
|
.orElse(null);
|
|
|
|
|
hashMap.put((int) dynamicObject.get("seq")-1,res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
hashMap.forEach((key, value) -> {
|
|
|
|
|
|
|
|
|
|
String entry_workloadunit = value.getEntry_workloadunit();
|
|
|
|
|
DynamicObject unit = QueryServiceHelper.queryOne("bd_measureunits", "id,name,number", new QFilter("name", QCP.equals, entry_workloadunit).toArray());
|
|
|
|
|
DynamicObject single = BusinessDataServiceHelper.loadSingle(unit.getString("id"),"bd_measureunits");
|
|
|
|
|
sheetNameView.getModel().setValue("entry_workloadunit",single,key);//单位
|
|
|
|
|
|
|
|
|
|
sheetNameView.getModel().setValue("entry_adjustcoefficient",value.getEntry_adjustcoefficient(),key);//调整系数
|
|
|
|
|
|
|
|
|
|
sheetNameView.getModel().setValue("entry_price",value.getEntry_price(),key);//单价
|
|
|
|
|
|
|
|
|
|
sheetNameView.getModel().setValue("entry_workload",value.getEntry_workload(),key);//工程量
|
|
|
|
|
|
|
|
|
|
sheetNameView.getModel().setValue("entry_amount",value.getEntry_amount(),key);//合价(含税)
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
getView().sendFormAction(sheetNameView);
|
|
|
|
|
return "success";
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return e.getMessage();
|
|
|
|
|