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

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;
@ -102,48 +104,80 @@ public class ContractListDateFilterPlugin extends AbstractBillPlugIn implements
if (contractEntries.isEmpty()) { if (contractEntries.isEmpty()) {
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();
Date signDate = contract.getDate("sign_date");// 签约日期 ChangeData changeData = e.getChangeSet()[0];
Calendar calendar = Calendar.getInstance(); int rowIndex = changeData.getRowIndex();
calendar.setTime(signDate); DynamicObject eyContract = (DynamicObject) model.getValue("ey_contract", rowIndex);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
signDate = calendar.getTime();
model.setValue("qeug_sign_date", signDate, i);
String evalTypeNum = contractEntry.getString("ey_eval_type.number");// 评估类型 if (eyContract == null) {
if (!"007".equals(evalTypeNum)) continue; 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");// 签约日期
Calendar calendar = Calendar.getInstance();
calendar.setTime(signDate);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
signDate = calendar.getTime();
model.setValue("qeug_sign_date", signDate, rowIndex);
DynamicObject contractSettle; String evalType = "";
boolean isMainContract = contract.getBoolean("ismaincontract"); List<DynamicObject> evalTypeList = this.getEvalTypeByContract(contract);
DynamicObject mainContract = contract.getDynamicObject("maincontract");// 关联主合同 if (!evalTypeList.isEmpty()) {
if (!isMainContract && mainContract != null) { DynamicObject dynamicObject = evalTypeList.get(0);
mainContract = BusinessDataServiceHelper.loadSingle(mainContract.getPkValue(), "resm_contract_book", "id,sign_date,contract"); if (dynamicObject != null) evalType = dynamicObject.getString("number");
Long contractId = mainContract.getLong("contract"); }
QFilter idQF = new QFilter("contractbill", QCP.equals, contractId);
contractSettle = BusinessDataServiceHelper.loadSingle("recon_consettlebill", "id,bizdate", idQF.toArray());// 合同结算 if (!"007".equals(evalType)) return;
} else {
Long contractId = contract.getLong("contract"); DynamicObject contractSettle;
QFilter idQF = new QFilter("contractbill", QCP.equals, contractId); boolean isMainContract = contract.getBoolean("ismaincontract");
contractSettle = BusinessDataServiceHelper.loadSingle("recon_consettlebill", "id,bizdate", idQF.toArray());// 合同结算 DynamicObject mainContract = contract.getDynamicObject("maincontract");// 关联主合同
} if (!isMainContract && mainContract != null) {
if (contractSettle != null) { mainContract = BusinessDataServiceHelper.loadSingle(mainContract.getPkValue(), "resm_contract_book", "id,sign_date,contract");
Date bizDate = contractSettle.getDate("bizdate");// 结算日期 Long contractId = mainContract.getLong("contract");
model.setValue("qeug_bizdate", bizDate, i); QFilter idQF = new QFilter("contractbill", QCP.equals, contractId);
} contractSettle = BusinessDataServiceHelper.loadSingle("recon_consettlebill", "id,bizdate", idQF.toArray());// 合同结算
} else {
Long contractId = contract.getLong("contract");
QFilter idQF = new QFilter("contractbill", QCP.equals, contractId);
contractSettle = BusinessDataServiceHelper.loadSingle("recon_consettlebill", "id,bizdate", idQF.toArray());// 合同结算
}
if (contractSettle != null) {
Date bizDate = contractSettle.getDate("bizdate");// 结算日期
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;
}
} }