调整获取日期逻辑,修复日期数据不显示问题

This commit is contained in:
ggxl 2024-11-18 10:05:41 +08:00
parent 76695471a5
commit a18dd70de7
1 changed files with 69 additions and 35 deletions

View File

@ -8,6 +8,8 @@ import kd.bos.dataentity.resource.ResManager;
import kd.bos.dataentity.utils.StringUtils; import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.EntityMetadataCache; import kd.bos.entity.EntityMetadataCache;
import kd.bos.entity.datamodel.IDataModel; import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.container.Tab; import kd.bos.form.container.Tab;
import kd.bos.form.control.Control; import kd.bos.form.control.Control;
import kd.bos.orm.query.QCP; import kd.bos.orm.query.QCP;
@ -104,14 +106,24 @@ public class ContractListDateFilterPlugin extends AbstractBillPlugIn implements
this.getView().showTipNotification(ResManager.loadKDString("没有符合条件的合同,请检查。", "EvalPlanEdit_13", "repc-resm-formplugin", new Object[0])); this.getView().showTipNotification(ResManager.loadKDString("没有符合条件的合同,请检查。", "EvalPlanEdit_13", "repc-resm-formplugin", new Object[0]));
Tab tabap = (Tab) this.getView().getControl("tabap"); Tab tabap = (Tab) this.getView().getControl("tabap");
tabap.activeTab("tab_info"); tabap.activeTab("tab_info");
return; }
}
} }
for (int i = 0; i < contractEntries.size(); i++) { @Override
DynamicObject contractEntry = contractEntries.get(i); public void propertyChanged(PropertyChangedArgs e) {
DynamicObject eyContract = contractEntry.getDynamicObject("ey_contract"); String name = e.getProperty().getName();
if (eyContract != null) { if ("ey_contract".equals(name)) {
DynamicObject contract = BusinessDataServiceHelper.loadSingle(eyContract.getPkValue(), "resm_contract_book", "id,sign_date,contract,ismaincontract,maincontract"); IDataModel model = this.getModel();
ChangeData changeData = e.getChangeSet()[0];
int rowIndex = changeData.getRowIndex();
DynamicObject eyContract = (DynamicObject) model.getValue("ey_contract", rowIndex);
if (eyContract == null) {
model.setValue("qeug_sign_date", null, rowIndex);
model.setValue("qeug_bizdate", null, rowIndex);
} else {
DynamicObject contract = BusinessDataServiceHelper.loadSingle(eyContract.getPkValue(), "resm_contract_book", "id,sign_date,contract,ismaincontract,maincontract,bizstatus");
Date signDate = contract.getDate("sign_date");// 签约日期 Date signDate = contract.getDate("sign_date");// 签约日期
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(signDate); calendar.setTime(signDate);
@ -120,10 +132,16 @@ public class ContractListDateFilterPlugin extends AbstractBillPlugIn implements
calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.MILLISECOND, 0);
signDate = calendar.getTime(); signDate = calendar.getTime();
model.setValue("qeug_sign_date", signDate, i); model.setValue("qeug_sign_date", signDate, rowIndex);
String evalTypeNum = contractEntry.getString("ey_eval_type.number");// 评估类型 String evalType = "";
if (!"007".equals(evalTypeNum)) continue; List<DynamicObject> evalTypeList = this.getEvalTypeByContract(contract);
if (!evalTypeList.isEmpty()) {
DynamicObject dynamicObject = evalTypeList.get(0);
if (dynamicObject != null) evalType = dynamicObject.getString("number");
}
if (!"007".equals(evalType)) return;
DynamicObject contractSettle; DynamicObject contractSettle;
boolean isMainContract = contract.getBoolean("ismaincontract"); boolean isMainContract = contract.getBoolean("ismaincontract");
@ -140,10 +158,26 @@ public class ContractListDateFilterPlugin extends AbstractBillPlugIn implements
} }
if (contractSettle != null) { if (contractSettle != null) {
Date bizDate = contractSettle.getDate("bizdate");// 结算日期 Date bizDate = contractSettle.getDate("bizdate");// 结算日期
model.setValue("qeug_bizdate", bizDate, i); model.setValue("qeug_bizdate", bizDate, rowIndex);
} }
} }
} }
} }
protected List<DynamicObject> getEvalTypeByContract(DynamicObject contract) {
String bizStatus = contract.getString("bizstatus");
QFilter qFilter = new QFilter("enable", "=", true);
qFilter.and("stage", "=", "2");
DynamicObject[] evalTypeArr = BusinessDataServiceHelper.load("resm_evaltype", "stage,bizstatus", qFilter.toArray(), "number");
List<DynamicObject> evalTypeList = (List)Arrays.stream(evalTypeArr).filter((item) -> {
return item.getString("bizstatus").contains(bizStatus);
}).collect(Collectors.toList());
if (evalTypeList.isEmpty()) {
evalTypeList = (List)Arrays.stream(evalTypeArr).filter((item) -> {
return StringUtils.isEmpty(item.getString("bizstatus"));
}).collect(Collectors.toList());
}
return evalTypeList;
} }
} }