diff --git a/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java b/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java index 0c02fbd..12176f8 100644 --- a/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java +++ b/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java @@ -4,9 +4,15 @@ import com.google.common.collect.Lists; import kd.bos.bill.OperationStatus; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.entity.ILocaleString; +import kd.bos.dataentity.metadata.IDataEntityProperty; +import kd.bos.entity.BasedataEntityType; import kd.bos.entity.datamodel.IDataModel; import kd.bos.entity.datamodel.events.BeforeDeleteEntryEventArgs; +import kd.bos.entity.datamodel.events.IDataModelChangeListener; +import kd.bos.entity.property.BasedataProp; import kd.bos.entity.property.EntryProp; +import kd.bos.entity.property.MulBasedataProp; import kd.bos.form.*; import kd.bos.form.control.AttachmentPanel; import kd.bos.form.control.EntryGrid; @@ -14,6 +20,9 @@ import kd.bos.form.control.events.UploadEvent; import kd.bos.form.control.events.UploadListener; import kd.bos.form.events.AfterDoOperationEventArgs; import kd.bos.form.events.BeforeDoOperationEventArgs; +import kd.bos.form.field.BasedataEdit; +import kd.bos.form.field.events.AfterBindingDataEvent; +import kd.bos.form.field.events.BasedataEditListener; import kd.bos.form.operate.FormOperate; import kd.bos.form.plugin.AbstractFormPlugin; import kd.bos.list.ListFilterParameter; @@ -49,7 +58,86 @@ import java.util.regex.Pattern; * qeug_recon_supplyconb_ext 补充合同 * qeug_recon_temptofixb_ext 暂转固 */ -public class ContractFormPlugin extends AbstractFormPlugin implements UploadListener { +public class ContractFormPlugin extends AbstractFormPlugin implements UploadListener, BasedataEditListener, IDataModelChangeListener { + + + + private static final String BASEDATA_FIELD = "multitypepartya"; + + + + @Override + public void initialize() { + super.initialize(); + this.getModel().addDataModelChangeListener(this); + BasedataEdit mulEdit = this.getControl(BASEDATA_FIELD); + mulEdit.addBasedataEditListener(this); + } + + @Override + public void afterBindingData(AfterBindingDataEvent afterBindingDataEvent) { + BasedataEdit edit = (BasedataEdit) afterBindingDataEvent.getSource(); + DynamicObject dataEntity = this.getModel().getDataEntity(true); + DynamicObject basedata_field = dataEntity.getDynamicObject(BASEDATA_FIELD); + if (!basedata_field.getDynamicObjectType().getName().equals("bos_org")){ + return; + } + Object v = afterBindingDataEvent.getDataEntity(); + Object displayProp = ""; + + if (v == null) { + return; + } + + BasedataEntityType dt; + if (((DynamicObject) v).getDataEntityType() instanceof BasedataEntityType) { + dt = (BasedataEntityType) ((DynamicObject) v).getDataEntityType(); + } else { + dt = (BasedataEntityType) ((BasedataProp) edit.getProperty()).getComplexType(); + } + + //获取数据包中的名称字段值 + String nameKey = dt.getNameProperty(); + IDataEntityProperty p2 = dt.findProperty(nameKey); + if (p2 != null) { + displayProp = p2.getValueFast(v); + if (displayProp instanceof ILocaleString) { + displayProp = displayProp.toString(); + } + } + if (BASEDATA_FIELD.equals(edit.getKey())) { + nameKey = "ffirmname"; + } + + //动态修改基础资料的显示属性为公司名称 + Object pkValue = basedata_field.getPkValue(); + String name = dt.getName(); + DynamicObject single = BusinessDataServiceHelper.loadSingle(pkValue, name); + if (!single.getString(nameKey).isEmpty()){ + displayProp = String.format("%s", single.getString(nameKey)); + } + //设置显示属性 + afterBindingDataEvent.setDisplayProp(displayProp.toString()); + } + + /** + * 获取配置的编辑显示属性 + * + * @param property + * @return + */ + private String getEditSearchProp(IDataEntityProperty property) { + BasedataProp basedataProp = null; + + if ((property instanceof BasedataProp)) { + basedataProp = (BasedataProp) property; + } else if (property instanceof MulBasedataProp) { + basedataProp = (BasedataProp) ((MulBasedataProp) property).getRefBaseProp(); + } + + return basedataProp.getEditSearchProp(); + } + @Override public void registerListener(EventObject e) { super.registerListener(e); @@ -466,6 +554,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadList this.getView().showForm(parameter); } + } // case "newentry1": diff --git a/main/java/shkd/repc/recon/listplugin/ContractSummaryListPlugin.java b/main/java/shkd/repc/recon/listplugin/ContractSummaryListPlugin.java index a5221f7..df08f34 100644 --- a/main/java/shkd/repc/recon/listplugin/ContractSummaryListPlugin.java +++ b/main/java/shkd/repc/recon/listplugin/ContractSummaryListPlugin.java @@ -2,23 +2,46 @@ package shkd.repc.recon.listplugin; import kd.bos.form.events.ExportFileEvent; import kd.bos.form.events.FlexBeforeClosedEvent; +import kd.bos.list.plugin.AbstractListPlugin; import kd.bos.list.plugin.IListPlugin; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; /** * 合同明细清单列表插件 * qeug_contractsummarylist */ -public class ContractSummaryListPlugin implements IListPlugin { - +public class ContractSummaryListPlugin extends AbstractListPlugin implements IListPlugin { /** 导出文件后事件,可以用来修改导出的文件内容,比如修改excel数据、格式、加密等 */ public void afterExportFile(ExportFileEvent e) { File file = e.getFile(); - +// if (file != null) { +// try (FileInputStream fis = new FileInputStream(file);) { +// Workbook wb = new XSSFWorkbook(fis); +// Sheet sheet = wb.getSheetAt(0); +// // 修改背景颜色(示例写死,自行修改) +// for (int i = 0; i < 3; i++) { +// CellStyle cs = wb.createCellStyle(); +// cs.setFillForegroundColor(IndexedColors.RED.getIndex()); +// cs.setFillPattern(FillPatternType.SOLID_FOREGROUND); +// cs.setLocked(true); +// sheet.getRow(i).getCell(1).setCellStyle(cs); +// } +// // 保存 +// FileOutputStream out = new FileOutputStream(file); +// wb.write(out); +// wb.close(); +// out.close(); +// } catch (Throwable ex) { +// ex.printStackTrace(); +// } +// } } - @Override public String getPluginName() { return null; diff --git a/main/java/shkd/repc/recon/opplugin/IntroduceContractPlugin.java b/main/java/shkd/repc/recon/opplugin/IntroduceContractPlugin.java new file mode 100644 index 0000000..ffa4cf9 --- /dev/null +++ b/main/java/shkd/repc/recon/opplugin/IntroduceContractPlugin.java @@ -0,0 +1,37 @@ +package shkd.repc.recon.opplugin; + +import com.alibaba.fastjson.JSONObject; +import kd.bos.entity.api.ApiResult; +import kd.bos.entity.plugin.ImportLogger; +import kd.bos.form.plugin.impt.BatchImportPlugin; +import kd.bos.form.plugin.impt.ImportBillData; + +import java.util.Iterator; +import java.util.List; + +public class IntroduceContractPlugin extends BatchImportPlugin { + @Override + protected ApiResult save(List rowdatas, ImportLogger logger) { + Iterator iterator = rowdatas.iterator(); + while (iterator.hasNext()){ + ImportBillData importBillData = iterator.next(); + JSONObject data = importBillData.getData(); + String qeug_bcdecimalqty = (String) data.get("qeug_bcdecimalqty");//本次完工量 + String qeug_decimalqty = (String) data.get("qeug_decimalqty");//工程量 + double bcdecimalqty = 0; + double decimalqty =0; + try { + bcdecimalqty = Double.parseDouble(qeug_bcdecimalqty); + decimalqty = Double.parseDouble(qeug_decimalqty); + } catch (NumberFormatException e) { + logger.log(importBillData.getStartIndex(),"工程量数据格式有误").fail(); + iterator.remove(); + } + if (bcdecimalqty>decimalqty){ + logger.log(importBillData.getStartIndex(),"本次完工量不能大于工程量").fail(); + iterator.remove(); + } + } + return super.save(rowdatas, logger); + } +} diff --git a/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java b/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java index e612f6f..c5b3843 100644 --- a/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java +++ b/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java @@ -94,7 +94,7 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl } String res = updateRecosMeasurecos(arrayList, sheetName); if (!"success".equals(res)){ - this.getView().showSuccessNotification("功能失败"); + this.getView().showSuccessNotification("功能失败:"+res); return; } } diff --git a/main/java/shkd/repc/resm/formplugin/TycQzSupplierFormPlugin.java b/main/java/shkd/repc/resm/formplugin/TycQzSupplierFormPlugin.java index c7a0a3e..9579b04 100644 --- a/main/java/shkd/repc/resm/formplugin/TycQzSupplierFormPlugin.java +++ b/main/java/shkd/repc/resm/formplugin/TycQzSupplierFormPlugin.java @@ -146,7 +146,7 @@ public class TycQzSupplierFormPlugin extends AbstractFormPlugin { } else { DynamicObjectCollection dynamicObjects=new DynamicObjectCollection(); dynamicObjects.add(this.getModel().getDataEntity(true)); - ListSelectedRowCollection listSelectedData = args.getListSelectedData(); +// ListSelectedRowCollection listSelectedData = args.getListSelectedData(); // Set selectRowSet = (Set)listSelectedData.stream().map((item) -> { // return item.getPrimaryKeyValue(); // }).collect(Collectors.toSet());