123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- package fi.em.FormPlugin;
- import kd.bos.exception.KDBizException;
- import kd.bos.form.plugin.AbstractFormPlugin;
- import kd.sdk.plugin.Plugin;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import kd.bos.context.RequestContext;
- import kd.bos.dataentity.entity.DynamicObject;
- import kd.bos.dataentity.serialization.SerializationUtils;
- import kd.bos.form.control.Control;
- import kd.bos.form.control.EntryGrid;
- import kd.bos.form.events.AfterDoOperationEventArgs;
- import kd.bos.orm.query.QCP;
- import kd.bos.orm.query.QFilter;
- import kd.bos.servicehelper.BusinessDataServiceHelper;
- import org.apache.commons.lang3.StringUtils;
- import java.math.BigDecimal;
- import java.util.*;
- public class PostModalFormPlugin extends AbstractFormPlugin implements Plugin {
- private final static String KEY_OK = "btnok";
- //页面取消按钮标识
- private final static String KEY_CANCEL = "btncancel";
- //页面取消按钮标识
- private final static String KEY_SEARCH = "search";
- private final static String FORMID_ENTRY = "ztjg_entryentity";
- private final static String FORMID = "ztjg_postcertifynotice";
- private static String FORMID_USER = "bos_user";
- private static String nckd_agentparameter = "nckd_agentparameter";
- /**
- * 页面点击事件
- *
- * @param evt
- */
- @Override
- public void click(EventObject evt) {
- super.click(evt);
- //获取被点击的控件对象
- Control source = (Control) evt.getSource();
- String pageId = this.getView().getPageId();
- if (StringUtils.equals(source.getKey(), KEY_OK)) {
- String listStr = this.getPageCache().get(pageId);
- if (StringUtils.isNotBlank(listStr)){
- JSONArray reJa = new JSONArray();
- EntryGrid entryGrid = this.getView().getControl(FORMID_ENTRY);
- int[] selectRows = entryGrid.getSelectRows();
- if (selectRows.length<=0){
- this.getView().showMessage("请先选择一条数据!");
- return;
- }
- JSONArray infoJa = SerializationUtils.fromJsonString(listStr, JSONArray.class);
- for(int i=0;i<selectRows.length;i++){
- JSONObject reJo = infoJa.getJSONObject(selectRows[i]);
- reJa.add(reJo);
- }
- HashMap<String, String> map = new HashMap<>();
- map.put("reJaStr", reJa.toJSONString());
- this.getView().returnDataToParent(map);
- }
- this.getView().close();
- } else if (StringUtils.equals(source.getKey(), KEY_CANCEL)) {
- //被点击控件为取消则设置返回值为空并关闭页面(在页面关闭回调方法中必须验证返回值不为空,否则会报空指针)
- this.getView().returnDataToParent(null);
- this.getView().close();
- } else {
- this.getView().returnDataToParent(null);
- this.getView().close();
- }
- }
- @Override
- public void registerListener(EventObject e) {
- super.registerListener(e);
- //页面确认按钮和取消按钮添加监听
- this.addClickListeners(KEY_OK, KEY_CANCEL);
- }
- @Override
- public void afterCreateNewData(EventObject e) {
- super.afterBindData(e);
- DynamicObject period = (DynamicObject) this.getModel().getValue("nckd_agentparameter");
- //获取父页面传入数据
- Map<String, Object> customParams = this.getView().getFormShowParameter().getCustomParams();
- String orgnumber = (String) customParams.get("orgnumber");
- if (orgnumber == null){
- throw new KDBizException("付费承担公司为空!");
- }
- QFilter nckd_orgamountFilter = new QFilter("nckd_unappliedorg.number", QCP.equals,orgnumber);
- if(period !=null){
- String nckd_sole = period.getString("nckd_sole");
- if(nckd_sole!=null && !nckd_sole.isEmpty()){
- nckd_orgamountFilter.and("nckd_typeagent.nckd_sole", QCP.equals,"A");
- }
- }
- nckd_orgamountFilter.and("enable", QCP.equals,"1");
- DynamicObject[] nckd_orgamountaccount = BusinessDataServiceHelper.load(nckd_agentparameter,"id",new QFilter[] {nckd_orgamountFilter});
- for (int c=0;c<nckd_orgamountaccount.length;c++){
- DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(nckd_orgamountaccount[c].getPkValue(), nckd_orgamountaccount[c].getDynamicObjectType().getName());
- for (DynamicObject entryentity : dynamicObject.getDynamicObjectCollection("nckd_sharemessage")) {
- DynamicObject nckdShareorg = entryentity.getDynamicObject("nckd_shareorg");
- BigDecimal nckdAgentvalue = entryentity.getBigDecimal("nckd_agentvalue");
- }
- }
- //initTable(isInform,isForce,startDate,endDate,null);
- }
- @Override
- public void afterDoOperation(AfterDoOperationEventArgs e) {
- if (KEY_SEARCH.equals(e.getOperateKey())) {
- Date startDate = (Date) this.getModel().getValue("ztjg_startdate");
- Date endDate = (Date) this.getModel().getValue("ztjg_enddate");
- Boolean isForce = (Boolean) this.getModel().getValue("ztjg_isforce");
- Boolean isInform = (Boolean) this.getModel().getValue("ztjg_isinform");
- String likeName = (String) this.getModel().getValue("ztjg_likename");
- if (isForce == null){
- isForce = false;
- }
- if (isInform == null){
- isInform = false;
- }
- if (startDate == null){
- this.getView().showMessage("请选择开始日期!");
- return;
- }else if (endDate == null){
- this.getView().showMessage("请选择结束日期!");
- return;
- }
- initTable(isInform,isForce,startDate,endDate,likeName);
- }
- }
- public void initTable(Boolean isInform,Boolean isForce,Date startdate,Date etartdate,String likeName){
- //历史数据清除
- this.getModel().deleteEntryData(FORMID_ENTRY);
- JSONArray reJa = getInitData(isInform,isForce,startdate,etartdate,likeName);
- for (int i=0;i<reJa.size();i++){
- JSONObject processJo = reJa.getJSONObject(i);
- int rowIndex = this.getModel().createNewEntryRow(FORMID_ENTRY);
- this.getModel().setValue("ztjg_id", processJo.getString("ztjg_id"), rowIndex);
- this.getModel().setValue("ztjg_noticeno", processJo.getString("ztjg_noticeno"), rowIndex);
- this.getModel().setValue("ztjg_noticedate", processJo.getDate("ztjg_noticedate"), rowIndex);
- this.getModel().setValue("ztjg_org", processJo.getObject("ztjg_org", DynamicObject.class), rowIndex);
- this.getModel().setValue("ztjg_dept", processJo.getObject("ztjg_dept",DynamicObject.class), rowIndex);
- this.getModel().setValue("ztjg_postname", processJo.getString("ztjg_postname"), rowIndex);
- this.getModel().setValue("ztjg_postdate", processJo.getDate("ztjg_postdate"), rowIndex);
- this.getModel().setValue("ztjg_address", processJo.getString("ztjg_address"), rowIndex);
- this.getModel().setValue("ztjg_postcontent", processJo.getString("ztjg_postcontent"), rowIndex);
- this.getModel().setValue("ztjg_demand", processJo.getString("ztjg_demand"), rowIndex);
- this.getModel().setValue("ztjg_mainnotice", processJo.getString("ztjg_mainnotice"), rowIndex);
- this.getModel().setValue("ztjg_integralitem", processJo.getObject("ztjg_integralitem",DynamicObject.class), rowIndex);
- this.getModel().setValue("ztjg_retakes", processJo.getBoolean("ztjg_retakes"), rowIndex);
- this.getModel().setValue("ztjg_datastr", processJo.getString("ztjg_datastr"), rowIndex);
- this.getModel().setValue("ztjg_customize1", processJo.getString("ztjg_customize1"), rowIndex);
- this.getModel().setValue("ztjg_customize2", processJo.getString("ztjg_customize2"), rowIndex);
- this.getModel().setValue("ztjg_customize3", processJo.getString("ztjg_customize3"), rowIndex);
- this.getModel().setValue("ztjg_postnamestr", processJo.getString("ztjg_postnamestr"), rowIndex);
- }
- String pageId = this.getView().getPageId();
- String listStr = SerializationUtils.toJsonString(reJa);
- this.getPageCache().put(pageId,listStr);
- }
- public static JSONArray getInitData(Boolean isInform,Boolean isForce, Date startdate,Date enddate,String likeName){
- JSONArray reJa = new JSONArray();
- DynamicObject userInfo = BusinessDataServiceHelper.loadSingle(RequestContext.get().getCurrUserId(),FORMID_USER);
- QFilter[] filters = null;
- QFilter personQFilter = null;
- QFilter statusQFilter = null;
- if (isForce){
- personQFilter = new QFilter("entryentity.ztjg_posteename.id", QCP.equals, userInfo.getPkValue());
- statusQFilter = new QFilter("entryentity.ztjg_ispushforce", QCP.equals, false);
- }else {
- personQFilter = new QFilter("ztjg_entryentity.ztjg_canposteename.id", QCP.equals, userInfo.getPkValue());
- statusQFilter = new QFilter("ztjg_entryentity.ztjg_ispushcan", QCP.equals, false);
- }
- QFilter qFilter1 = new QFilter("billstatus", QCP.equals, "C");
- QFilter qFilter2 = new QFilter("ztjg_bizdate", QCP.large_equals, startdate);
- QFilter qFilter3 = new QFilter("ztjg_bizdate", QCP.less_equals, enddate);
- QFilter qFilter4 = new QFilter("ztjg_postname", QCP.like, "%"+likeName+"%");
- if (!isInform){
- if (StringUtils.isNotBlank(likeName)){
- filters = new QFilter[]{personQFilter,statusQFilter,qFilter1,qFilter2,qFilter3,qFilter4};
- }else {
- filters = new QFilter[]{personQFilter,statusQFilter,qFilter1,qFilter2,qFilter3};
- }
- }
- DynamicObject[] conObjects = BusinessDataServiceHelper.load(FORMID,"id,billno,ztjg_bizdate,ztjg_org,ztjg_dept,ztjg_postname,ztjg_postdate,ztjg_address,ztjg_postcontent,ztjg_demand,ztjg_mainnotice,ztjg_integralitem,ztjg_retakes,ztjg_postnamestr,ztjg_datastr,ztjg_customize1,ztjg_customize2,ztjg_customize3",filters);
- for (DynamicObject obj:conObjects){
- JSONObject itemJo = new JSONObject();
- itemJo.put("ztjg_id",obj.getPkValue().toString());
- itemJo.put("ztjg_noticeno",obj.getString("billno"));
- itemJo.put("ztjg_noticedate",obj.getDate("ztjg_bizdate"));
- itemJo.put("ztjg_org",obj.getDynamicObject("ztjg_org"));
- itemJo.put("ztjg_dept",obj.getDynamicObject("ztjg_dept"));
- itemJo.put("ztjg_postname",obj.getString("ztjg_postname"));
- itemJo.put("ztjg_postdate",obj.getDate("ztjg_postdate"));
- itemJo.put("ztjg_address",obj.getString("ztjg_address"));
- itemJo.put("ztjg_postcontent",obj.getString("ztjg_postcontent"));
- itemJo.put("ztjg_demand",obj.getString("ztjg_demand"));
- itemJo.put("ztjg_mainnotice",obj.getString("ztjg_mainnotice"));
- itemJo.put("ztjg_integralitem",obj.getDynamicObject("ztjg_integralitem"));
- itemJo.put("ztjg_retakes",obj.getBoolean("ztjg_retakes"));
- itemJo.put("ztjg_postnamestr",obj.getString("ztjg_postnamestr"));
- itemJo.put("ztjg_datastr",obj.getString("ztjg_datastr"));
- itemJo.put("ztjg_customize1",obj.getString("ztjg_customize1"));
- itemJo.put("ztjg_customize2",obj.getString("ztjg_customize2"));
- itemJo.put("ztjg_customize3",obj.getString("ztjg_customize3"));
- reJa.add(itemJo);
- }
- return reJa;
- }
- }
|