Compare commits

...

2 Commits

Author SHA1 Message Date
陈绍鑫 0fbeb48387 Merge remote-tracking branch 'origin/main' into main 2024-11-18 17:04:10 +08:00
陈绍鑫 a3000e2047 代码提交
提交人:陈绍鑫
时间:2024/11/18  17:00
内容:成本测算插件
2024-11-18 17:04:00 +08:00
4 changed files with 121 additions and 14 deletions

View File

@ -0,0 +1,77 @@
package shkd.repc.recos.formplugin;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.form.control.EntryGrid;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.operate.FormOperate;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MeasureciFormPlugin extends AbstractFormPlugin {
@Override
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
super.beforeDoOperation(args);
FormOperate source = (FormOperate) args.getSource();
String operateKey = source.getOperateKey();
if ("qeug_tbgcl".equals(operateKey)){
Object producttypeid = this.getModel().getValue("producttypeid");//产品类型ID
Object measurecostid = this.getModel().getValue("measurecostid");//成本测算ID
DynamicObject measurecost = BusinessDataServiceHelper.loadSingle(measurecostid,"recos_measurecost");
DynamicObject project = measurecost.getDynamicObject("project");
String number = project.getString("number");//项目编码
QFilter filter = new QFilter("qeug_cpmc.id", QCP.equals, producttypeid).
and(new QFilter("qeug_xmnumber", QCP.equals, number));
DynamicObject queryone = QueryServiceHelper.queryOne("qeug_gcl", "id", filter.toArray());
if (queryone==null){
this.getView().showSuccessNotification("请维护项目面积数据");
return;
}
Map<String, BigDecimal> result = new HashMap<>();
DynamicObject gcl = BusinessDataServiceHelper.loadSingle(queryone.get("id"),"qeug_gcl");
DynamicObjectCollection qeug_entryentity = gcl.getDynamicObjectCollection("qeug_entryentity");//面积
for (int i = 0; i <qeug_entryentity.size() ; i++) {
DynamicObject dynamicObject = qeug_entryentity.get(i);
BigDecimal sum = dynamicObject.getBigDecimal("qeug_b2f").
add(dynamicObject.getBigDecimal("qeug_b1f")).
add(dynamicObject.getBigDecimal("qeug_1f")).
add(dynamicObject.getBigDecimal("qeug_2f")).
add(dynamicObject.getBigDecimal("qeug_3f")).
add(dynamicObject.getBigDecimal("qeug_4f")).
add(dynamicObject.getBigDecimal("qeug_5f")).
add(dynamicObject.getBigDecimal("qeug_6f")).
add(dynamicObject.getBigDecimal("qeug_7f")).
add(dynamicObject.getBigDecimal("qeug_8f"));
result.put(dynamicObject.getString("qeug_kmname"),sum);
}
EntryGrid cientry = this.getControl("cientry");
int[] selectRows = cientry.getSelectRows();
if (selectRows.length==0){
this.getView().showSuccessNotification("请选择要同步的行");
return;
}
List<DynamicObject> myList = new ArrayList<>();
for (int i = 0; i < selectRows.length; i++) {
DynamicObject cientrydata = this.getModel().getEntryRowEntity("cientry", selectRows[i]);
myList.add(cientrydata);
}
result.forEach((key, value) -> {
for (DynamicObject dynamicObject : myList) {
if (dynamicObject.getString("entry_accountname").equals(key)){
this.getModel().setValue("entry_workload",value,(int)dynamicObject.get("seq")-1);//工程量
}
}
});
this.getView().showSuccessNotification("功能失败:");
}
}
}

View File

@ -80,7 +80,12 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
for (DynamicObject queryOne : query) { for (DynamicObject queryOne : query) {
List list=new ArrayList(); List list=new ArrayList();
List listcaption=new ArrayList(); List listcaption=new ArrayList();
listcaption.add("科目长名称"); // listcaption.add("科目长名称");
listcaption.add("一级分类");
listcaption.add("二级分类");
listcaption.add("三级分类");
listcaption.add("四级分类");
listcaption.add("五级分类");
listcaption.add("科目编码"); listcaption.add("科目编码");
listcaption.add("科目名称"); listcaption.add("科目名称");
listcaption.add("工程量单位"); listcaption.add("工程量单位");
@ -97,7 +102,20 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
DynamicObject entry_costaccount = dynamicObject.getDynamicObject("entry_costaccount");//科目 DynamicObject entry_costaccount = dynamicObject.getDynamicObject("entry_costaccount");//科目
if (entry_costaccount.getBoolean("isleaf")){ if (entry_costaccount.getBoolean("isleaf")){
List listvalue=new ArrayList(); List listvalue=new ArrayList();
listvalue.add(entry_costaccount.getString("fullname"));//科目长名称 // listvalue.add(entry_costaccount.getString("fullname"));//科目长名称
String fullname = entry_costaccount.getString("fullname");
String[] parts = fullname.split("_");
String[] partsWithoutLast = Arrays.copyOf(parts, parts.length - 1);
for (int i = 0; i < 5; i++) {
try {
String s = partsWithoutLast[i];
listvalue.add(s);
} catch (Exception e) {
listvalue.add("");
}
}
listvalue.add(dynamicObject.getString("entry_longnumber"));//科目编码 listvalue.add(dynamicObject.getString("entry_longnumber"));//科目编码
listvalue.add(dynamicObject.getString("entry_accountname"));//科目名称 listvalue.add(dynamicObject.getString("entry_accountname"));//科目名称
DynamicObject entry_workloadunit = dynamicObject.getDynamicObject("entry_workloadunit"); DynamicObject entry_workloadunit = dynamicObject.getDynamicObject("entry_workloadunit");

View File

@ -51,7 +51,8 @@ public class ProjectBillPlugin extends AbstractFormPlugin implements BeforeQuick
showParameter.setCustomParam("billno",billno); showParameter.setCustomParam("billno",billno);
showParameter.setCustomParam("billname",zh_cn); showParameter.setCustomParam("billname",zh_cn);
showParameter.setCustomParam("productentry_producttype",productentry_producttype.getPkValue().toString()); showParameter.setCustomParam("productentry_producttype",productentry_producttype.getPkValue().toString());
showParameter.setCustomParam("versionnum",this.getModel().getValue("versionnum")); showParameter.setCustomParam("operateKey",operateKey);
} }
} }

View File

@ -2,6 +2,7 @@ package shkd.repc.repmd.formplugin;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.events.BizDataEventArgs;
import kd.bos.entity.operate.Save; import kd.bos.entity.operate.Save;
import kd.bos.form.events.AfterDoOperationEventArgs; import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.events.BeforeDoOperationEventArgs; import kd.bos.form.events.BeforeDoOperationEventArgs;
@ -14,28 +15,38 @@ import kd.bos.servicehelper.QueryServiceHelper;
import java.util.EventObject; import java.util.EventObject;
public class WorkQuantityPlugin extends AbstractFormPlugin { public class WorkQuantityPlugin extends AbstractFormPlugin {
@Override
public void createNewData(BizDataEventArgs e) {
super.createNewData(e);
}
@Override @Override
public void afterBindData(EventObject e) { public void afterBindData(EventObject e) {
super.afterBindData(e); super.afterBindData(e);
String operateKey = this.getView().getFormShowParameter().getCustomParam("operateKey");
if ("工程量".equals(operateKey)){
String billno = this.getView().getFormShowParameter().getCustomParam("billno"); String billno = this.getView().getFormShowParameter().getCustomParam("billno");
String billname = this.getView().getFormShowParameter().getCustomParam("billname"); String billname = this.getView().getFormShowParameter().getCustomParam("billname");
String versionnum = this.getView().getFormShowParameter().getCustomParam("versionnum");
String productentry_producttype = this.getView().getFormShowParameter().getCustomParam("productentry_producttype"); String productentry_producttype = this.getView().getFormShowParameter().getCustomParam("productentry_producttype");
this.getModel().setValue("qeug_xmnumber",billno); this.getModel().setValue("qeug_xmnumber",billno);
this.getModel().setValue("name",billname); this.getModel().setValue("name",billname);
this.getModel().setValue("qeug_cpmc",productentry_producttype); this.getModel().setValue("qeug_cpmc",productentry_producttype);
this.getModel().setValue("qeug_bbh",versionnum); }
} }
@Override @Override
public void beforeDoOperation(BeforeDoOperationEventArgs args) { public void beforeDoOperation(BeforeDoOperationEventArgs args) {
if (args.getSource() instanceof Save){ if (args.getSource() instanceof Save){
String qeug_xmnumber = (String) this.getModel().getValue("qeug_xmnumber"); String qeug_xmnumber = (String) this.getModel().getValue("qeug_xmnumber");
String qeug_bbh = (String) this.getModel().getValue("qeug_bbh"); DynamicObject qeug_cpmc = (DynamicObject) this.getModel().getValue("qeug_cpmc");
QFilter filter = new QFilter("qeug_xmnumber", QCP.equals, qeug_xmnumber).and(new QFilter("qeug_bbh", QCP.equals, qeug_bbh)); Object pkValue = qeug_cpmc.getPkValue();
QFilter filter = new QFilter("qeug_xmnumber", QCP.equals, qeug_xmnumber)
.and(new QFilter("qeug_cpmc.id", QCP.equals, pkValue));
DynamicObjectCollection query = QueryServiceHelper.query("qeug_gcl", "id", filter.toArray()); DynamicObjectCollection query = QueryServiceHelper.query("qeug_gcl", "id", filter.toArray());
if (query.size()!=0){ if (query.size()!=0){
this.getView().showSuccessNotification("已存在当前版本号的项目数据,不允许保存"); this.getView().showSuccessNotification("已存在此项目,不允许保存");
args.setCancel(true); args.setCancel(true);
} }
} }