供应商考察汇总表单取数、表单插件
This commit is contained in:
parent
c087558b27
commit
ad35787615
|
@ -0,0 +1,161 @@
|
||||||
|
package shkd.repc.resm.report.data;
|
||||||
|
|
||||||
|
import kd.bos.algo.*;
|
||||||
|
import kd.bos.algo.input.CollectionInput;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.entity.report.AbstractReportListDataPlugin;
|
||||||
|
import kd.bos.entity.report.FilterInfo;
|
||||||
|
import kd.bos.entity.report.FilterItemInfo;
|
||||||
|
import kd.bos.entity.report.ReportQueryParam;
|
||||||
|
import kd.bos.orm.query.QCP;
|
||||||
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.org.OrgUnitServiceHelper;
|
||||||
|
import kd.bos.servicehelper.user.UserServiceHelper;
|
||||||
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报表取数插件
|
||||||
|
*/
|
||||||
|
public class SupInspectSumReportDataPlugin extends AbstractReportListDataPlugin implements Plugin {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSet query(ReportQueryParam reportQueryParam, Object o) throws Throwable {
|
||||||
|
|
||||||
|
String[] fileNames = {"qeug_org","qeug_suppliername","qeug_datetime","qeug_usagetext","qeug_examscore","qeug_goodreason",
|
||||||
|
"qeug_badreason","qeug_dept","qeug_user"};//字段标识数组
|
||||||
|
DataType[] dataTypes = {DataType.LongType,DataType.StringType,DataType.DateType,DataType.StringType,DataType.BigDecimalType,DataType.StringType,
|
||||||
|
DataType.StringType,DataType.LongType,DataType.LongType};//字段类型数组
|
||||||
|
|
||||||
|
|
||||||
|
//todo:设置过滤条件
|
||||||
|
QFilter qFilter = new QFilter("billstatus", QCP.equals, "B");//提交评分状态为已提交
|
||||||
|
QFilter examTaskFilter = this.getExamTaskFilter(reportQueryParam, qFilter);//根据界面过滤条件,重新调整过滤条件
|
||||||
|
|
||||||
|
//todo:整合数据集合
|
||||||
|
Collection<Object[]> firmParams = this.addFirmParams(examTaskFilter);
|
||||||
|
|
||||||
|
//todo:加载结果集
|
||||||
|
RowMeta row = RowMetaFactory.createRowMeta(fileNames, dataTypes);
|
||||||
|
CollectionInput inputs = new CollectionInput(row, firmParams);
|
||||||
|
DataSet resultDataSet = Algo.create(this.getClass().getName()).createDataSet(inputs);
|
||||||
|
return resultDataSet.orderBy(new String[]{"qeug_datetime desc"});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取界面过滤条件,返回过滤条件集合
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected Map<String, Object> transQueryParam(ReportQueryParam param) {
|
||||||
|
Map<String, Object> paramMap = new HashMap(param.getFilter().getFilterItems().size());
|
||||||
|
Iterator var3 = param.getFilter().getFilterItems().iterator();
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
FilterItemInfo filterItem = (FilterItemInfo)var3.next();
|
||||||
|
paramMap.put(filterItem.getPropName(), filterItem.getValue());
|
||||||
|
}
|
||||||
|
return paramMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据界面条件重新构建过滤条件
|
||||||
|
* @param reportQueryParam
|
||||||
|
* @param qFilter
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public QFilter getExamTaskFilter(ReportQueryParam reportQueryParam,QFilter qFilter){
|
||||||
|
Map<String, Object> paramMap = this.transQueryParam(reportQueryParam);//获取查询参数集合
|
||||||
|
DynamicObjectCollection orges = (DynamicObjectCollection) paramMap.get("qeug_orgfilter");//所属组织集合
|
||||||
|
DynamicObjectCollection regSupplies = (DynamicObjectCollection) paramMap.get("qeug_evalsupplierfilter");//潜在供应商集合
|
||||||
|
DynamicObjectCollection offSupplies = (DynamicObjectCollection) paramMap.get("qeug_evaloffsuppliefilter");//正式供应商集合
|
||||||
|
DynamicObjectCollection supplierGroups = (DynamicObjectCollection) paramMap.get("qeug_suppliergroupfilter");//供应商分类集合
|
||||||
|
//todo:设置所属组织过滤条件
|
||||||
|
if (orges != null && orges.size() > 0){
|
||||||
|
ArrayList<Long> orgIdList = new ArrayList<>();
|
||||||
|
for (DynamicObject org : orges) {
|
||||||
|
orgIdList.add(org.getLong("id"));
|
||||||
|
}
|
||||||
|
qFilter.and("org.id",QCP.in,orgIdList);
|
||||||
|
}
|
||||||
|
//todo:设置供应商过滤条件
|
||||||
|
if (regSupplies != null || offSupplies != null){
|
||||||
|
if (regSupplies != null && regSupplies.size() > 0){//潜在供应商
|
||||||
|
ArrayList<Long> regSupplyIdList = new ArrayList<>();
|
||||||
|
for (DynamicObject regSupply : regSupplies) {
|
||||||
|
regSupplyIdList.add(regSupply.getLong("id"));//填充潜在供应商主键
|
||||||
|
}
|
||||||
|
qFilter.and("evalsupplier.id",QCP.in,regSupplyIdList);
|
||||||
|
}
|
||||||
|
if (offSupplies != null && offSupplies.size() > 0){//正式供应商
|
||||||
|
ArrayList<Long> offSupplyIdList = new ArrayList<>();
|
||||||
|
for (DynamicObject offSupply : offSupplies) {
|
||||||
|
offSupplyIdList.add(offSupply.getLong("id"));//填充正式供应商主键
|
||||||
|
}
|
||||||
|
qFilter.and("evaloffsupplier.id",QCP.in,offSupplyIdList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//todo:设置供应商分类过滤条件
|
||||||
|
if (supplierGroups != null && supplierGroups.size() > 0){
|
||||||
|
ArrayList<Long> supplierGroupIdList = new ArrayList<>();//供应商分类集合
|
||||||
|
for (DynamicObject supplierGroup : supplierGroups) {
|
||||||
|
supplierGroupIdList.add(supplierGroup.getLong("id"));//填充供应商分类主键
|
||||||
|
}
|
||||||
|
qFilter.and("multisuppliertype.fbasedataid.id",QCP.in,supplierGroupIdList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return qFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建数据集合
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Collection<Object[]> addFirmParams(QFilter examTaskFilter){
|
||||||
|
Collection<Object[]> firmParams = null ;
|
||||||
|
DynamicObject[] resm_myexams = BusinessDataServiceHelper.load("resm_myexam", "id,name,org,examsuppliername,modifytime,evalscore,creator,entry_evalscore,entry_evalscore.qeug_scoredesc,entry_evalscore.scoredesc", examTaskFilter.toArray());//加载数据源
|
||||||
|
if (resm_myexams != null && resm_myexams.length > 0){
|
||||||
|
firmParams = new ArrayList<Object[]>(resm_myexams.length);//初始化考察任务数据集合
|
||||||
|
for (int i = 0; i < resm_myexams.length; i++) {
|
||||||
|
Object[] firmParam = new Object[9];//创建行数据
|
||||||
|
DynamicObject resm_myexam = resm_myexams[i];//单个考察任务数据
|
||||||
|
//todo:根据加载出的考察任务数据,渲染报表行数据
|
||||||
|
DynamicObject org = resm_myexam.getDynamicObject("org");
|
||||||
|
firmParam[0] = org.getPkValue();//考察组织
|
||||||
|
String examsuppliername = resm_myexam.getString("examsuppliername");
|
||||||
|
firmParam[1] = examsuppliername;//供应商名称
|
||||||
|
Date modifytime = resm_myexam.getDate("modifytime");
|
||||||
|
firmParam[2] = modifytime;//考察日期
|
||||||
|
firmParam[3] = null;//用途
|
||||||
|
BigDecimal evalscore = resm_myexam.getBigDecimal("evalscore");
|
||||||
|
firmParam[4] = evalscore;//评分数(满分100分)
|
||||||
|
DynamicObjectCollection entry_evalscore = resm_myexam.getDynamicObjectCollection("entry_evalscore");
|
||||||
|
String goodStr = "";
|
||||||
|
String badStr = "";
|
||||||
|
for (DynamicObject dy : entry_evalscore) {
|
||||||
|
String qeug_scoredesc = dy.getString("qeug_scoredesc");
|
||||||
|
String scoredesc = dy.getString("scoredesc");
|
||||||
|
goodStr = goodStr + qeug_scoredesc + "\n";
|
||||||
|
badStr = badStr + scoredesc + "\n";
|
||||||
|
}
|
||||||
|
firmParam[5] = goodStr;//评分原因(优)
|
||||||
|
firmParam[6] = badStr;//评分原因(劣)
|
||||||
|
DynamicObject creator = resm_myexam.getDynamicObject("creator");
|
||||||
|
long userId = creator.getLong("id");
|
||||||
|
long orgId = UserServiceHelper.getUserMainOrgId(creator.getLong("id"));
|
||||||
|
firmParam[7] = orgId;//考察人员所属部门
|
||||||
|
firmParam[8] = userId;//考察人员姓名
|
||||||
|
firmParams.add(firmParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return firmParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package shkd.repc.resm.report.form;
|
||||||
|
|
||||||
|
import kd.bos.dataentity.metadata.IDataEntityProperty;
|
||||||
|
import kd.bos.entity.datamodel.events.ChangeData;
|
||||||
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||||
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||||
|
import kd.bos.report.plugin.AbstractReportFormPlugin;
|
||||||
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.EventObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 供应商考察汇总表单插件
|
||||||
|
*/
|
||||||
|
public class SupInspectSumReportFormPlugin extends AbstractReportFormPlugin implements Plugin {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单据更新初始化
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void afterCreateNewData(EventObject e) {
|
||||||
|
super.afterCreateNewData(e);
|
||||||
|
String qeug_suppliertypefilter = (String) this.getModel().getValue("qeug_suppliertypefilter");
|
||||||
|
if ("A".equals(qeug_suppliertypefilter)){
|
||||||
|
this.getView().setVisible(false,"qeug_evaloffsuppliefilter");
|
||||||
|
}else {
|
||||||
|
this.getView().setVisible(false,"qeug_evalsupplierfilter");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 常用过滤条件界面控制
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void propertyChanged(PropertyChangedArgs e) {
|
||||||
|
super.propertyChanged(e);
|
||||||
|
String name = e.getProperty().getName();
|
||||||
|
if ("qeug_suppliertypefilter".equals(name)){
|
||||||
|
ChangeData[] changeSet = e.getChangeSet();
|
||||||
|
Object newValue = changeSet[0].getNewValue();
|
||||||
|
if ("A".equals(newValue)){
|
||||||
|
this.getModel().setValue("qeug_evaloffsuppliefilter",null);
|
||||||
|
this.getView().setVisible(false,"qeug_evaloffsuppliefilter");
|
||||||
|
this.getView().setVisible(true,"qeug_evalsupplierfilter");
|
||||||
|
}else {
|
||||||
|
this.getModel().setValue("qeug_evalsupplierfilter",null);
|
||||||
|
this.getView().setVisible(false,"qeug_evalsupplierfilter");
|
||||||
|
this.getView().setVisible(true,"qeug_evaloffsuppliefilter");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue