|  | @@ -0,0 +1,109 @@
 | 
											
												
													
														|  | 
 |  | +package fi.gl.formplugin;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +import kd.bos.bill.AbstractBillPlugIn;
 | 
											
												
													
														|  | 
 |  | +import kd.bos.dataentity.OperateOption;
 | 
											
												
													
														|  | 
 |  | +import kd.bos.dataentity.entity.DynamicObject;
 | 
											
												
													
														|  | 
 |  | +import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
											
												
													
														|  | 
 |  | +import kd.bos.form.control.Control;
 | 
											
												
													
														|  | 
 |  | +import kd.bos.orm.query.QCP;
 | 
											
												
													
														|  | 
 |  | +import kd.bos.orm.query.QFilter;
 | 
											
												
													
														|  | 
 |  | +import kd.bos.servicehelper.BusinessDataServiceHelper;
 | 
											
												
													
														|  | 
 |  | +import kd.bos.servicehelper.operation.OperationServiceHelper;
 | 
											
												
													
														|  | 
 |  | +import org.apache.commons.lang3.StringUtils;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +import java.util.Date;
 | 
											
												
													
														|  | 
 |  | +import java.util.EventObject;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +/**
 | 
											
												
													
														|  | 
 |  | + * 动态表单操作
 | 
											
												
													
														|  | 
 |  | + * 日结执行界面插件
 | 
											
												
													
														|  | 
 |  | + * 2024-06-28 wangj
 | 
											
												
													
														|  | 
 |  | + * 主要功能:日结执行按钮逻辑
 | 
											
												
													
														|  | 
 |  | + */
 | 
											
												
													
														|  | 
 |  | +public class DailyexcuteFormPlugin extends AbstractBillPlugIn {
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private final static String KEY_DAILY = "nckd_daily";
 | 
											
												
													
														|  | 
 |  | +    //页面取消按钮标识
 | 
											
												
													
														|  | 
 |  | +    private final static String KEY_UNDAILY = "nckd_undaily";
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +//    @Override
 | 
											
												
													
														|  | 
 |  | +//    public void registerListener(EventObject e) {
 | 
											
												
													
														|  | 
 |  | +//        super.registerListener(e);
 | 
											
												
													
														|  | 
 |  | +//        this.addClickListeners(KEY_DAILY, KEY_UNDAILY);
 | 
											
												
													
														|  | 
 |  | +//    }
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//    @Override
 | 
											
												
													
														|  | 
 |  | +//    public void click(EventObject evt) {
 | 
											
												
													
														|  | 
 |  | +//        super.click(evt);
 | 
											
												
													
														|  | 
 |  | +//        //获取被点击的控件对象
 | 
											
												
													
														|  | 
 |  | +//        Control source = (Control) evt.getSource();
 | 
											
												
													
														|  | 
 |  | +//        if (StringUtils.equals(source.getKey(), KEY_DAILY)) {
 | 
											
												
													
														|  | 
 |  | +//            DynamicObjectCollection orgCol = (DynamicObjectCollection) this.getModel().getValue("nckd_org");
 | 
											
												
													
														|  | 
 |  | +//            if(orgCol==null || orgCol.size()==0){
 | 
											
												
													
														|  | 
 |  | +//                this.getView().showMessage("请先选择组织");
 | 
											
												
													
														|  | 
 |  | +//                return;
 | 
											
												
													
														|  | 
 |  | +//            }
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//            Date dailydate = (Date) this.getModel().getValue("nckd_dailydate");
 | 
											
												
													
														|  | 
 |  | +//            if(dailydate==null || "".equals(dailydate)){
 | 
											
												
													
														|  | 
 |  | +//                this.getView().showMessage("请先选择日期");
 | 
											
												
													
														|  | 
 |  | +//                return;
 | 
											
												
													
														|  | 
 |  | +//            }
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//            String message = dailyData(orgCol,dailydate);
 | 
											
												
													
														|  | 
 |  | +//            this.getView().showMessage(message);
 | 
											
												
													
														|  | 
 |  | +//        }else if (StringUtils.equals(source.getKey(), KEY_UNDAILY)) {
 | 
											
												
													
														|  | 
 |  | +//            this.getView().showMessage("反日结成功");
 | 
											
												
													
														|  | 
 |  | +//        }
 | 
											
												
													
														|  | 
 |  | +//    }
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//    /*
 | 
											
												
													
														|  | 
 |  | +//    * 查询凭证,符合条件的组织插入日结记录,不符合条件的显示在表格中
 | 
											
												
													
														|  | 
 |  | +//     */
 | 
											
												
													
														|  | 
 |  | +//    private String dailyData(DynamicObjectCollection orgCol, Date dailydate) {
 | 
											
												
													
														|  | 
 |  | +//        String returnMessage = "";
 | 
											
												
													
														|  | 
 |  | +//        for(DynamicObject orgObj : orgCol){
 | 
											
												
													
														|  | 
 |  | +//            boolean isCan = true;
 | 
											
												
													
														|  | 
 |  | +//            QFilter qFilter_org = new QFilter("org", QCP.equals,orgObj.getPkValue());
 | 
											
												
													
														|  | 
 |  | +//            QFilter qFilter_bizdate = new QFilter("bizdate",QCP.equals,dailydate);
 | 
											
												
													
														|  | 
 |  | +//            DynamicObject[] voucherCol = BusinessDataServiceHelper.load("gl_voucher","id,ispost,billno,bizdate,org,billstatus",
 | 
											
												
													
														|  | 
 |  | +//                    new QFilter[]{qFilter_org,qFilter_bizdate});
 | 
											
												
													
														|  | 
 |  | +//            for(DynamicObject voucherObj : voucherCol){
 | 
											
												
													
														|  | 
 |  | +//                boolean ispost = voucherObj.getBoolean("ispost");
 | 
											
												
													
														|  | 
 |  | +//                if(ispost!=true){//是否过账等于否
 | 
											
												
													
														|  | 
 |  | +//                    isCan = false;
 | 
											
												
													
														|  | 
 |  | +//                    int rowid = this.getModel().createNewEntryRow("nckd_entryentity");
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//                    this.getModel().setValue("nckd_voucherorg",orgObj,rowid);//设置组织
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//                    String voucherid = voucherObj.getString("id");
 | 
											
												
													
														|  | 
 |  | +//                    this.getModel().setValue("nckd_vouherid",voucherid,rowid);//设置凭证id
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//                    String billno = voucherObj.getString("billno");
 | 
											
												
													
														|  | 
 |  | +//                    this.getModel().setValue("nckd_vouhernumber",billno,rowid);//设置凭证号
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//                    Date bizdate = voucherObj.getDate("bizdate");
 | 
											
												
													
														|  | 
 |  | +//                    this.getModel().setValue("nckd_voucherdate",bizdate,rowid);//设置凭证日期
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//                    String billstatus = voucherObj.getString("billstatus");
 | 
											
												
													
														|  | 
 |  | +//                    this.getModel().setValue("nckd_voucherstatus",billstatus,rowid);//设置凭证状态
 | 
											
												
													
														|  | 
 |  | +//                }
 | 
											
												
													
														|  | 
 |  | +//            }
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//            //写入日结记录
 | 
											
												
													
														|  | 
 |  | +//            writeDailybill(isCan,orgObj,dailydate);
 | 
											
												
													
														|  | 
 |  | +//        }
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//        return returnMessage;
 | 
											
												
													
														|  | 
 |  | +//    }
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//    private void writeDailybill(boolean isCan, DynamicObject orgObj, Date dailydate) {
 | 
											
												
													
														|  | 
 |  | +//        if(isCan==true){
 | 
											
												
													
														|  | 
 |  | +//            DynamicObject dailybillObj = BusinessDataServiceHelper.newDynamicObject("nckd_gl_dailybill");
 | 
											
												
													
														|  | 
 |  | +//            dailybillObj.set("nckd_org",orgObj);
 | 
											
												
													
														|  | 
 |  | +//            dailybillObj.set("nckd_dailydate",dailydate);
 | 
											
												
													
														|  | 
 |  | +//            DynamicObject[] datalist = new DynamicObject[]{dailybillObj};
 | 
											
												
													
														|  | 
 |  | +//            OperationServiceHelper.executeOperate("save","nckd_gl_dailybill",datalist, OperateOption.create());
 | 
											
												
													
														|  | 
 |  | +//        }
 | 
											
												
													
														|  | 
 |  | +//    }
 | 
											
												
													
														|  | 
 |  | +}
 |