代码提交

提交人:陈绍鑫
时间:2024/11/19  17:00
内容:成本测算插件
This commit is contained in:
陈绍鑫 2024-11-19 18:04:56 +08:00
parent 53b839e0ac
commit 0c14f00de9
4 changed files with 94 additions and 31 deletions

View File

@ -26,9 +26,13 @@ public class Calculation {
//工程量 //工程量
Double entry_workload; Double entry_workload;
//估算口径
String entry_measureplanidx;
//备注
String entry_description;
public Calculation(String entry_longnumber, String entry_accountname, String entry_workloadunit, Double entry_adjustcoefficient, Double entry_amount,Double entry_price,Double entry_workload) { public Calculation(String entry_longnumber, String entry_accountname, String entry_workloadunit, Double entry_adjustcoefficient, Double entry_amount,Double entry_price,Double entry_workload,String entry_measureplanidx,String entry_description) {
this.entry_longnumber = entry_longnumber; this.entry_longnumber = entry_longnumber;
this.entry_accountname = entry_accountname; this.entry_accountname = entry_accountname;
this.entry_workloadunit = entry_workloadunit; this.entry_workloadunit = entry_workloadunit;
@ -36,6 +40,8 @@ public class Calculation {
this.entry_amount = entry_amount; this.entry_amount = entry_amount;
this.entry_price = entry_price; this.entry_price = entry_price;
this.entry_workload = entry_workload; this.entry_workload = entry_workload;
this.entry_measureplanidx = entry_measureplanidx;
this.entry_description = entry_description;
} }
public String getEntry_longnumber() { public String getEntry_longnumber() {
@ -95,6 +101,22 @@ public class Calculation {
this.entry_workload = entry_workload; this.entry_workload = entry_workload;
} }
public String getEntry_measureplanidx() {
return entry_measureplanidx;
}
public void setEntry_measureplanidx(String entry_measureplanidx) {
this.entry_measureplanidx = entry_measureplanidx;
}
public String getEntry_description() {
return entry_description;
}
public void setEntry_description(String entry_description) {
this.entry_description = entry_description;
}
public Calculation() { public Calculation() {
} }
} }

View File

@ -41,16 +41,7 @@ public class MeasureciFormPlugin extends AbstractFormPlugin {
DynamicObjectCollection qeug_entryentity = gcl.getDynamicObjectCollection("qeug_entryentity");//面积 DynamicObjectCollection qeug_entryentity = gcl.getDynamicObjectCollection("qeug_entryentity");//面积
for (int i = 0; i <qeug_entryentity.size() ; i++) { for (int i = 0; i <qeug_entryentity.size() ; i++) {
DynamicObject dynamicObject = qeug_entryentity.get(i); DynamicObject dynamicObject = qeug_entryentity.get(i);
BigDecimal sum = dynamicObject.getBigDecimal("qeug_b2f"). BigDecimal sum = dynamicObject.getBigDecimal("qeug_hjs");
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); result.put(dynamicObject.getString("qeug_kmname"),sum);
} }
EntryGrid cientry = this.getControl("cientry"); EntryGrid cientry = this.getControl("cientry");

View File

@ -80,7 +80,7 @@ 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("三级分类");
@ -88,12 +88,16 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
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("调整系数"); listcaption.add("调整系数");
listcaption.add("单价"); listcaption.add("含调差指标单价");
listcaption.add("合价(含税)"); listcaption.add("合价(含税)");
listcaption.add("备注");
list.add(listcaption); list.add(listcaption);
int sum=1;
Object fid = queryOne.get("id"); Object fid = queryOne.get("id");
DynamicObject single = BusinessDataServiceHelper.loadSingle(fid,"recos_measureci"); DynamicObject single = BusinessDataServiceHelper.loadSingle(fid,"recos_measureci");
DynamicObjectCollection cientry = single.getDynamicObjectCollection("cientry"); DynamicObjectCollection cientry = single.getDynamicObjectCollection("cientry");
@ -102,11 +106,10 @@ 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(new BigDecimal(sum++));//科目长名称
String fullname = entry_costaccount.getString("fullname"); String fullname = entry_costaccount.getString("fullname");
String[] parts = fullname.split("_"); String[] parts = fullname.split("_");
String[] partsWithoutLast = Arrays.copyOf(parts, parts.length - 1); String[] partsWithoutLast = Arrays.copyOf(parts, parts.length - 1);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
try { try {
String s = partsWithoutLast[i]; String s = partsWithoutLast[i];
@ -118,6 +121,8 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
listvalue.add(dynamicObject.getString("entry_longnumber"));//科目编码 listvalue.add(dynamicObject.getString("entry_longnumber"));//科目编码
listvalue.add(dynamicObject.getString("entry_accountname"));//科目名称 listvalue.add(dynamicObject.getString("entry_accountname"));//科目名称
listvalue.add("");//财务预算分类
listvalue.add(dynamicObject.getString("entry_measureplanidx.name"));//估算口径
DynamicObject entry_workloadunit = dynamicObject.getDynamicObject("entry_workloadunit"); DynamicObject entry_workloadunit = dynamicObject.getDynamicObject("entry_workloadunit");
if (entry_workloadunit!=null){ if (entry_workloadunit!=null){
listvalue.add(dynamicObject.getDynamicObject("entry_workloadunit").getString("name"));//单位 listvalue.add(dynamicObject.getDynamicObject("entry_workloadunit").getString("name"));//单位
@ -125,11 +130,11 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
listvalue.add(""); listvalue.add("");
} }
listvalue.add(dynamicObject.getBigDecimal("entry_workload"));//工程量 listvalue.add(dynamicObject.getBigDecimal("entry_workload"));//工程量
BigDecimal entry_adjustcoefficient = dynamicObject.getBigDecimal("entry_adjustcoefficient").multiply(new BigDecimal(100)); BigDecimal entry_adjustcoefficient = dynamicObject.getBigDecimal("entry_adjustcoefficient");
listvalue.add(entry_adjustcoefficient.toString()+"%");//调整系数 listvalue.add(entry_adjustcoefficient);//调整系数
listvalue.add(dynamicObject.getBigDecimal("entry_price"));//单价 listvalue.add(dynamicObject.getBigDecimal("entry_price"));//单价
listvalue.add(dynamicObject.getBigDecimal("entry_amount"));//合价(含税) listvalue.add(dynamicObject.getBigDecimal("entry_amount"));//合价(含税)
listvalue.add(dynamicObject.getLocaleString("entry_description").getLocaleValue_zh_CN());//备注
list.add(listvalue); list.add(listvalue);
} }
} }
@ -182,6 +187,10 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
// 单据列表数据风格样式设置字体为黑体字号15 // 单据列表数据风格样式设置字体为黑体字号15
XSSFCellStyle billStyle = workbook.createCellStyle(); XSSFCellStyle billStyle = workbook.createCellStyle();
// 设置水平居中
billStyle.setAlignment(HorizontalAlignment.CENTER);
// 设置垂直居中
billStyle.setVerticalAlignment(VerticalAlignment.CENTER);
XSSFFont billFont = workbook.createFont(); XSSFFont billFont = workbook.createFont();
billFont.setFontName("黑体"); billFont.setFontName("黑体");
billFont.setFontHeight(15); billFont.setFontHeight(15);
@ -190,6 +199,13 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
for (int i = 0; i < excel.size(); i++) { for (int i = 0; i < excel.size(); i++) {
// i+1是因为前面第1行加了一个标题单据列表数据是从Excel的第2行开始的所以要+1 // i+1是因为前面第1行加了一个标题单据列表数据是从Excel的第2行开始的所以要+1
XSSFRow nrow = sheet.createRow(i+1); XSSFRow nrow = sheet.createRow(i+1);
// if (i==0){
// XSSFCellStyle style = workbook.createCellStyle();
// style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
// XSSFColor grayColor = new XSSFColor(new java.awt.Color(128, 128, 128), new DefaultIndexedColorMap());
// style.setFillForegroundColor(grayColor);
// nrow.setRowStyle(style);
// }
for (int u=0;u<excel.get(i).size();u++){ for (int u=0;u<excel.get(i).size();u++){
XSSFCell ncell = nrow.createCell(u); XSSFCell ncell = nrow.createCell(u);
ncell.setCellStyle(billStyle); ncell.setCellStyle(billStyle);
@ -275,8 +291,6 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
} }
Object attPkId = att.getAttachmentData().get(0).get("attPkId"); Object attPkId = att.getAttachmentData().get(0).get("attPkId");
if (null == attPkId) { if (null == attPkId) {
// attPk = false;
// this.getView().invokeOperation("save");//调用保存
this.getView().showSuccessNotification("请先保存"); this.getView().showSuccessNotification("请先保存");
return; return;
} }
@ -310,14 +324,15 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
for (int j = rowNum; j <= rowCountsheet - 2; j++){//序号行至最后一行总计前一行 for (int j = rowNum; j <= rowCountsheet - 2; j++){//序号行至最后一行总计前一行
Row row = sheet.getRow(j); Row row = sheet.getRow(j);
Calculation calculation = new Calculation( Calculation calculation = new Calculation(
row.getCell(5).toString(),//科目编码 row.getCell(6).getStringCellValue(),//科目编码
row.getCell(6).toString(),//科目名称 row.getCell(7).getStringCellValue(),//科目名称
row.getCell(9).getStringCellValue(),//单位 row.getCell(10).getStringCellValue(),//单位
//Double.parseDouble(row.getCell(12).getStringCellValue().replace("%", ""))/100.0, row.getCell(12).getNumericCellValue(),// 调整系数
Double.parseDouble(row.getCell(12).toString()),// 调整系数 row.getCell(14).getNumericCellValue(),//合价含税
row.getCell(17).getNumericCellValue(),//合价含税 row.getCell(13).getNumericCellValue(),//单价
row.getCell(16).getNumericCellValue(),//单价 row.getCell(11).getNumericCellValue(),//工程量
row.getCell(13).getNumericCellValue()//工程量 row.getCell(9).getStringCellValue(),//估算口径
row.getCell(15).getStringCellValue()//备注
); );
arrayList.add(calculation); arrayList.add(calculation);
} }
@ -382,8 +397,12 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
String entry_workloadunit = value.getEntry_workloadunit(); String entry_workloadunit = value.getEntry_workloadunit();
DynamicObject unit = QueryServiceHelper.queryOne("bd_measureunits", "id,name,number", new QFilter("name", QCP.equals, entry_workloadunit).toArray()); DynamicObject unit = QueryServiceHelper.queryOne("bd_measureunits", "id,name,number", new QFilter("name", QCP.equals, entry_workloadunit).toArray());
if (unit==null){
sheetNameView.getModel().setValue("entry_workloadunit",null,key);//单位
}else {
DynamicObject single = BusinessDataServiceHelper.loadSingle(unit.getString("id"),"bd_measureunits"); DynamicObject single = BusinessDataServiceHelper.loadSingle(unit.getString("id"),"bd_measureunits");
sheetNameView.getModel().setValue("entry_workloadunit",single,key);//单位 sheetNameView.getModel().setValue("entry_workloadunit",single,key);//单位
}
sheetNameView.getModel().setValue("entry_adjustcoefficient",value.getEntry_adjustcoefficient(),key);//调整系数 sheetNameView.getModel().setValue("entry_adjustcoefficient",value.getEntry_adjustcoefficient(),key);//调整系数
@ -393,6 +412,16 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
sheetNameView.getModel().setValue("entry_amount",value.getEntry_amount(),key);//合价(含税) sheetNameView.getModel().setValue("entry_amount",value.getEntry_amount(),key);//合价(含税)
DynamicObject measureidxexp = QueryServiceHelper.queryOne("recos_measureidxexp", "id,name,number", new QFilter("name", QCP.equals, value.getEntry_measureplanidx()).toArray());
if (measureidxexp==null){
sheetNameView.getModel().setValue("entry_measureplanidx",null,key);//单位
}else {
DynamicObject recos_measureidxexp = BusinessDataServiceHelper.loadSingle(measureidxexp.getString("id"),"recos_measureidxexp");
sheetNameView.getModel().setValue("entry_measureplanidx",recos_measureidxexp,key);//估算口径
}
sheetNameView.getModel().setValue("entry_description",value.getEntry_description(),key);//备注
}); });
getView().sendFormAction(sheetNameView); getView().sendFormAction(sheetNameView);

View File

@ -1,15 +1,18 @@
package shkd.repc.repmd.formplugin; package shkd.repc.repmd.formplugin;
import kd.bos.bill.BillShowParameter;
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.datamodel.events.BizDataEventArgs;
import kd.bos.entity.operate.Save; import kd.bos.entity.operate.Save;
import kd.bos.form.ShowType;
import kd.bos.form.events.AfterDoOperationEventArgs; import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.events.BeforeDoOperationEventArgs; import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.operate.FormOperate; import kd.bos.form.operate.FormOperate;
import kd.bos.form.plugin.AbstractFormPlugin; import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QCP; import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.service.operation.Submit;
import kd.bos.servicehelper.QueryServiceHelper; import kd.bos.servicehelper.QueryServiceHelper;
import java.util.EventObject; import java.util.EventObject;
@ -41,20 +44,34 @@ public class WorkQuantityPlugin extends AbstractFormPlugin {
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");
DynamicObject qeug_cpmc = (DynamicObject) this.getModel().getValue("qeug_cpmc"); DynamicObject qeug_cpmc = (DynamicObject) this.getModel().getValue("qeug_cpmc");
if(qeug_cpmc==null){
this.getView().showSuccessNotification("请填写产品");
args.setCancel(true);
return;
}
Object pkValue = qeug_cpmc.getPkValue(); Object pkValue = qeug_cpmc.getPkValue();
QFilter filter = new QFilter("qeug_xmnumber", QCP.equals, qeug_xmnumber) QFilter filter = new QFilter("qeug_xmnumber", QCP.equals, qeug_xmnumber)
.and(new QFilter("qeug_cpmc.id", QCP.equals, pkValue)); .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){
if (query.get(0).get("id").equals(this.getModel().getValue("id"))){ if (query.get(0).get("id").equals(this.getModel().getValue("id"))){
}else { }else {
this.getView().showSuccessNotification("已存在此项目,不允许保存"); this.getView().showSuccessNotification("已存在此项目,不允许保存");
args.setCancel(true); args.setCancel(true);
return;
} }
} }
} }
// FormOperate source = (FormOperate) args.getSource();
// String operateKey = source.getOperateKey();
// if (operateKey.equals("donothing")){
// BillShowParameter billShowParameter = new BillShowParameter();
// billShowParameter.setFormId("recos_conplan");// 合约规划
// billShowParameter.getOpenStyle().setShowType(ShowType.Modal);
// billShowParameter.getOpenStyle().setTargetKey("tabap");
// this.getView().showForm(billShowParameter);
// }
} }
@Override @Override
@ -63,5 +80,9 @@ public class WorkQuantityPlugin extends AbstractFormPlugin {
this.getView().invokeOperation("submit"); this.getView().invokeOperation("submit");
this.getView().invokeOperation("audit"); this.getView().invokeOperation("audit");
} }
if (afterDoOperationEventArgs.getSource() instanceof Submit){
afterDoOperationEventArgs.getOperationResult().setShowMessage(false);
} }
} }
}