493 lines
		
	
	
		
			30 KiB
		
	
	
	
		
			Java
		
	
	
	
			
		
		
	
	
			493 lines
		
	
	
		
			30 KiB
		
	
	
	
		
			Java
		
	
	
	
| package tqq9.lc123.cloud.app.plugin.form.pm;
 | |
| 
 | |
| import com.alibaba.fastjson.JSONArray;
 | |
| import com.alibaba.fastjson.JSONObject;
 | |
| import com.google.gson.Gson;
 | |
| import kd.bos.bill.AbstractBillPlugIn;
 | |
| import kd.bos.dataentity.entity.DynamicObject;
 | |
| import kd.bos.dataentity.entity.DynamicObjectCollection;
 | |
| import kd.bos.dataentity.utils.StringUtils;
 | |
| import kd.bos.entity.datamodel.IDataModel;
 | |
| import kd.bos.entity.datamodel.events.ChangeData;
 | |
| import kd.bos.entity.datamodel.events.PropertyChangedArgs;
 | |
| import kd.bos.form.FormShowParameter;
 | |
| import kd.bos.form.IFormView;
 | |
| import kd.bos.orm.query.QCP;
 | |
| import kd.bos.orm.query.QFilter;
 | |
| import kd.bos.servicehelper.BusinessDataServiceHelper;
 | |
| import kd.bos.servicehelper.user.UserServiceHelper;
 | |
| import kd.sdk.plugin.Plugin;
 | |
| import org.springframework.http.ResponseEntity;
 | |
| import tqq9.lc123.cloud.app.api.utils.Constants;
 | |
| import tqq9.lc123.cloud.app.api.utils.HttpClient;
 | |
| import tqq9.lc123.cloud.app.plugin.utils.EntryFieldRefresher;
 | |
| import tqq9.lc123.cloud.app.plugin.utils.HttpRequestUtils;
 | |
| 
 | |
| import java.io.IOException;
 | |
| import java.math.BigDecimal;
 | |
| import java.net.ConnectException;
 | |
| import java.util.*;
 | |
| 
 | |
| /**
 | |
|  * 单据界面插件
 | |
|  */
 | |
| public class PurApplyBillPlugin extends AbstractBillPlugIn implements Plugin {
 | |
|     private static String URL;
 | |
|     private static DynamicObject BILLTYPE;
 | |
|     private static DynamicObject BIZTYPE;
 | |
|     private static DynamicObject LINETYPE;
 | |
| 
 | |
|     static {
 | |
|         DynamicObject url = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
 | |
|                 new QFilter[]{new QFilter("number", QCP.equals, "FLXT_Balance_Url")});
 | |
|         URL = url != null ? url.getString("name") : null;
 | |
|         // 申请单
 | |
|         DynamicObject billtype = BusinessDataServiceHelper.loadSingle("bos_billtype", new QFilter[]{new QFilter("number", QCP.equals, "pm_PurApplyBill_STD_BT_S")});
 | |
|         BILLTYPE = billtype;
 | |
|         DynamicObject biztype = BusinessDataServiceHelper.loadSingle("bd_biztype", new QFilter[]{new QFilter("number", QCP.equals, "110")});
 | |
|         BIZTYPE = biztype;
 | |
|         DynamicObject linetype = BusinessDataServiceHelper.loadSingle("bd_linetype", new QFilter[]{new QFilter("number", QCP.equals, "010")});
 | |
|         LINETYPE = linetype;
 | |
|     }
 | |
| 
 | |
|     private final static String ENTRYENTITY = "billentry";
 | |
| 
 | |
|     private final static String SH_ORGNUMBER = "SHLC";
 | |
| 
 | |
|     private final static String BJ_ORGNUMBER = "BJLC";
 | |
| 
 | |
|     private final static String GZ_ORGNUMBER = "GZLC";
 | |
| 
 | |
|     private final static HashMap<String, String> tokenMap = new HashMap<String, String>() {{
 | |
|         put("Authorization", "Bearer b96dad1eb4f84c41bae651162aeacdd3");
 | |
|     }};
 | |
| 
 | |
| 
 | |
|     @Override
 | |
|     public void propertyChanged(PropertyChangedArgs e) {
 | |
|         super.propertyChanged(e);
 | |
|         String name = e.getProperty().getName();
 | |
|         DynamicObject dataEntity = this.getModel().getDataEntity(true);
 | |
|         IDataModel model = this.getModel();
 | |
|         IFormView view = this.getView();
 | |
|         //--------------上海------------------
 | |
|         //集采供应商
 | |
|         if (StringUtils.equals("tqq9_sup_sh", name)) {
 | |
|             DynamicObject tqq9_sup_sh = (DynamicObject) model.getValue("tqq9_sup_sh");//供应商
 | |
|             DynamicObject org = BusinessDataServiceHelper.loadSingle("bos_org", new QFilter[]{new QFilter("number", QCP.equals, SH_ORGNUMBER)});
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateDynamicObjectByOrg(SH_ORGNUMBER, "supplier", tqq9_sup_sh, model);
 | |
|             String tqq9_mulcombofield1 = tqq9_sup_sh.getString("tqq9_mulcombofield1");
 | |
|             model.setValue("tqq9_suparea_sh", tqq9_mulcombofield1);
 | |
|             HashMap<String, String> queryMap = new HashMap<>();
 | |
|             queryMap.put("supplierId", tqq9_sup_sh.getString("number"));
 | |
|             queryMap.put("companyId", org.getString("number"));
 | |
|             Gson gson = new Gson();
 | |
|             try {
 | |
|                 String bodyString = HttpRequestUtils.doGet(URL, queryMap, tokenMap);
 | |
|                 HashMap map = gson.fromJson(bodyString, HashMap.class);
 | |
|                 ArrayList<Map<String, Object>> data = (ArrayList) map.get("data");
 | |
|                 if (data != null) {
 | |
|                     for (Map datum : data) {
 | |
|                         Map<String, Object> dataMap = datum;
 | |
|                         String type = dataMap.get("type").toString();//类型
 | |
|                         BigDecimal totalMoney = new BigDecimal((Double) dataMap.get("totalMoney"));//剩余总金额
 | |
|                         BigDecimal totalMoneyAvailable = new BigDecimal((Double) dataMap.get("totalMoneyAvailable"));//可使用金额
 | |
|                         if (StringUtils.equals(type, "1.0")) {
 | |
|                             //货返
 | |
|                             model.setValue("tqq9_hshfzje_sh", totalMoney);//含税货返总金额
 | |
|                             model.setValue("tqq9_hshfkyje_sh", totalMoneyAvailable);//含税货返可用金额
 | |
|                         } else if (StringUtils.equals(type, "0.0")) {
 | |
|                             //现返
 | |
|                             model.setValue("tqq9_hsxfzje_sh", totalMoney);//含税现返总金额
 | |
|                             model.setValue("tqq9_hsxfkyje_sh", totalMoneyAvailable);//含税现返可用金额
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|             } catch (IOException ex) {
 | |
|                 throw new RuntimeException(ex);
 | |
|             }
 | |
|             view.updateView();
 | |
|         }
 | |
|         //收货仓库
 | |
|         if (StringUtils.equals("tqq9_rewares_sh", name)) {
 | |
|             DynamicObject tqq9_rewares_sh = (DynamicObject) model.getValue("tqq9_rewares_sh");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateDynamicObjectByOrg(SH_ORGNUMBER, "warehouse", tqq9_rewares_sh, model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //采购数量
 | |
|         if (StringUtils.equals("applyqty", name)) {
 | |
|             BigDecimal applyqty = (BigDecimal) model.getValue("applyqty");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.sumEntrByOrg(SH_ORGNUMBER, "applyqty", "tqq9_purqty_sh", model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //应付金额
 | |
|         if (StringUtils.equals("tqq9_yfje", name)) {
 | |
|             BigDecimal tqq9_yfje = (BigDecimal) model.getValue("tqq9_yfje");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.sumEntrByOrg(SH_ORGNUMBER, "tqq9_yfje", "tqq9_payamount_sh", model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //优惠金额_单头
 | |
|         if (StringUtils.equals("tqq9_discountamt_sh", name)) {
 | |
|             BigDecimal tqq9_discountamt_sh = (BigDecimal) model.getValue("tqq9_discountamt_sh");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_sh, model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //货返_单头
 | |
|         if (StringUtils.equals("tqq9_hshfsyje_sh", name)) {
 | |
|             BigDecimal tqq9_hshfsyje_sh = (BigDecimal) model.getValue("tqq9_hshfsyje_sh");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_sh, model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //现返_单头
 | |
|         if (StringUtils.equals("tqq9_hsxfsyje_sh", name)) {
 | |
|             BigDecimal tqq9_hsxfsyje_sh = (BigDecimal) model.getValue("tqq9_hsxfsyje_sh");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_sh, model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //--------------北京------------------
 | |
|         //集采供应商
 | |
|         if (StringUtils.equals("tqq9_sup_bj", name)) {
 | |
|             DynamicObject tqq9_sup_bj = (DynamicObject) model.getValue("tqq9_sup_bj");
 | |
|             DynamicObject org = BusinessDataServiceHelper.loadSingle("bos_org", new QFilter[]{new QFilter("number", QCP.equals, BJ_ORGNUMBER)});
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateDynamicObjectByOrg(BJ_ORGNUMBER, "supplier", tqq9_sup_bj, model);
 | |
|             String tqq9_mulcombofield1 = tqq9_sup_bj.getString("tqq9_mulcombofield1");
 | |
|             model.setValue("tqq9_suparea_bj", tqq9_mulcombofield1);
 | |
|             HashMap<String, String> queryMap = new HashMap<>();
 | |
|             queryMap.put("supplierId", tqq9_sup_bj.getString("number"));
 | |
|             queryMap.put("companyId", org.getString("number"));
 | |
|             Gson gson = new Gson();
 | |
|             try {
 | |
|                 String bodyString = HttpRequestUtils.doGet(URL, queryMap, tokenMap);
 | |
|                 HashMap map = gson.fromJson(bodyString, HashMap.class);
 | |
|                 ArrayList<Map<String, Object>> data = (ArrayList) map.get("data");
 | |
|                 if (data != null) {
 | |
|                     for (Map datum : data) {
 | |
|                         Map<String, Object> dataMap = datum;
 | |
|                         String type = dataMap.get("type").toString();//类型
 | |
|                         BigDecimal totalMoney = new BigDecimal((Double) dataMap.get("totalMoney"));//剩余总金额
 | |
|                         BigDecimal totalMoneyAvailable = new BigDecimal((Double) dataMap.get("totalMoneyAvailable"));//可使用金额
 | |
|                         if (StringUtils.equals(type, "1.0")) {
 | |
|                             //货返
 | |
|                             model.setValue("tqq9_hshfzje_bj", totalMoney);//含税货返总金额
 | |
|                             model.setValue("tqq9_hshfkyje_bj", totalMoneyAvailable);//含税货返可用金额
 | |
|                         } else if (StringUtils.equals(type, "0.0")) {
 | |
|                             //现返
 | |
|                             model.setValue("tqq9_hsxfzje_bj", totalMoney);//含税现返总金额
 | |
|                             model.setValue("tqq9_hsxfkyje_bj", totalMoneyAvailable);//含税现返可用金额
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|             } catch (IOException ex) {
 | |
|                 throw new RuntimeException(ex);
 | |
|             }
 | |
| 
 | |
| 
 | |
|             view.updateView();
 | |
|         }
 | |
|         //收货仓库
 | |
|         if (StringUtils.equals("tqq9_rewares_bj", name)) {
 | |
|             DynamicObject tqq9_rewares_bj = (DynamicObject) model.getValue("tqq9_rewares_bj");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateDynamicObjectByOrg(BJ_ORGNUMBER, "warehouse", tqq9_rewares_bj, model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //采购数量
 | |
|         if (StringUtils.equals("applyqty", name)) {
 | |
|             BigDecimal applyqty = (BigDecimal) model.getValue("applyqty");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.sumEntrByOrg(BJ_ORGNUMBER, "applyqty", "tqq9_purqty_bj", model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //应付金额
 | |
|         if (StringUtils.equals("tqq9_yfje", name)) {
 | |
|             BigDecimal tqq9_yfje = (BigDecimal) model.getValue("tqq9_yfje");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.sumEntrByOrg(BJ_ORGNUMBER, "tqq9_yfje", "tqq9_payamount_bj", model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //优惠金额_单头
 | |
|         if (StringUtils.equals("tqq9_discountamt_bj", name)) {
 | |
|             BigDecimal tqq9_discountamt_bj = (BigDecimal) model.getValue("tqq9_discountamt_bj");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateAmountByOrg(BJ_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_bj, model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //货返_单头
 | |
|         if (StringUtils.equals("tqq9_hshfsyje_bj", name)) {
 | |
|             BigDecimal tqq9_hshfsyje_bj = (BigDecimal) model.getValue("tqq9_hshfsyje_bj");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateAmountByOrg(BJ_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_bj, model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //现返_单头
 | |
|         if (StringUtils.equals("tqq9_hsxfsyje_bj", name)) {
 | |
|             BigDecimal tqq9_hsxfsyje_bj = (BigDecimal) model.getValue("tqq9_hsxfsyje_bj");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateAmountByOrg(BJ_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_bj, model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //--------------广州------------------
 | |
|         //集采供应商
 | |
|         if (StringUtils.equals("tqq9_sup_gz", name)) {
 | |
|             DynamicObject tqq9_sup_gz = (DynamicObject) model.getValue("tqq9_sup_gz");
 | |
|             DynamicObject org = BusinessDataServiceHelper.loadSingle("bos_org", new QFilter[]{new QFilter("number", QCP.equals, GZ_ORGNUMBER)});
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateDynamicObjectByOrg(GZ_ORGNUMBER, "supplier", tqq9_sup_gz, model);
 | |
|             String tqq9_mulcombofield1 = tqq9_sup_gz.getString("tqq9_mulcombofield1");
 | |
|             model.setValue("tqq9_suparea_gz", tqq9_mulcombofield1);
 | |
|             HashMap<String, String> queryMap = new HashMap<>();
 | |
|             queryMap.put("supplierId", tqq9_sup_gz.getString("number"));
 | |
|             queryMap.put("companyId", org.getString("number"));
 | |
|             Gson gson = new Gson();
 | |
|             try {
 | |
|                 String bodyString = HttpRequestUtils.doGet(URL, queryMap, tokenMap);
 | |
|                 HashMap map = gson.fromJson(bodyString, HashMap.class);
 | |
|                 ArrayList<Map<String, Object>> data = (ArrayList) map.get("data");
 | |
|                 if (data != null) {
 | |
|                     for (Map datum : data) {
 | |
|                         Map<String, Object> dataMap = datum;
 | |
|                         String type = dataMap.get("type").toString();//类型
 | |
|                         BigDecimal totalMoney = new BigDecimal((Double) dataMap.get("totalMoney"));//剩余总金额
 | |
|                         BigDecimal totalMoneyAvailable = new BigDecimal((Double) dataMap.get("totalMoneyAvailable"));//可使用金额
 | |
|                         if (StringUtils.equals(type, "1.0")) {
 | |
|                             //货返
 | |
|                             model.setValue("tqq9_hshfzje_gz", totalMoney);//含税货返总金额
 | |
|                             model.setValue("tqq9_hshfkyje_gz", totalMoneyAvailable);//含税货返可用金额
 | |
|                         } else if (StringUtils.equals(type, "0.0")) {
 | |
|                             //现返
 | |
|                             model.setValue("tqq9_hsxfzje_gz", totalMoney);//含税现返总金额
 | |
|                             model.setValue("tqq9_hsxfkyje_gz", totalMoneyAvailable);//含税现返可用金额
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|             } catch (IOException ex) {
 | |
|                 throw new RuntimeException(ex);
 | |
|             }
 | |
|             view.updateView();
 | |
|         }
 | |
|         //收货仓库
 | |
|         if (StringUtils.equals("tqq9_rewares_gz", name)) {
 | |
|             DynamicObject tqq9_rewares_gz = (DynamicObject) model.getValue("tqq9_rewares_gz");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateDynamicObjectByOrg(GZ_ORGNUMBER, "warehouse", tqq9_rewares_gz, model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //采购数量
 | |
|         if (StringUtils.equals("applyqty", name)) {
 | |
|             BigDecimal applyqty = (BigDecimal) model.getValue("applyqty");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.sumEntrByOrg(GZ_ORGNUMBER, "applyqty", "tqq9_purqty_gz", model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //应付金额
 | |
|         if (StringUtils.equals("tqq9_yfje", name)) {
 | |
|             BigDecimal tqq9_yfje = (BigDecimal) model.getValue("tqq9_yfje");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.sumEntrByOrg(GZ_ORGNUMBER, "tqq9_yfje", "tqq9_payamount_gz", model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //优惠金额_单头
 | |
|         if (StringUtils.equals("tqq9_discountamt_gz", name)) {
 | |
|             BigDecimal tqq9_discountamt_gz = (BigDecimal) model.getValue("tqq9_discountamt_gz");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateAmountByOrg(GZ_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_gz, model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //货返_单头
 | |
|         if (StringUtils.equals("tqq9_hshfsyje_gz", name)) {
 | |
|             BigDecimal tqq9_hshfsyje_gz = (BigDecimal) model.getValue("tqq9_hshfsyje_gz");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateAmountByOrg(GZ_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_gz, model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //现返_单头
 | |
|         if (StringUtils.equals("tqq9_hsxfsyje_gz", name)) {
 | |
|             BigDecimal tqq9_hsxfsyje_gz = (BigDecimal) model.getValue("tqq9_hsxfsyje_gz");
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             entryFieldRefresher.updateAmountByOrg(GZ_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_gz, model);
 | |
|             view.updateView();
 | |
|         }
 | |
|         //分录优惠金额,现返,货返金额分摊
 | |
|         if (StringUtils.equals("tqq9_amount", name)) {
 | |
|             EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
 | |
|             BigDecimal tqq9_discountamt_sh = (BigDecimal) model.getValue("tqq9_discountamt_sh");
 | |
|             entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_sh, model);
 | |
|             BigDecimal tqq9_hshfsyje_sh = (BigDecimal) model.getValue("tqq9_hshfsyje_sh");
 | |
|             entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_sh, model);
 | |
|             BigDecimal tqq9_hsxfsyje_sh = (BigDecimal) model.getValue("tqq9_hsxfsyje_sh");
 | |
|             entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_sh, model);
 | |
|             BigDecimal tqq9_discountamt_bj = (BigDecimal) model.getValue("tqq9_discountamt_bj");
 | |
|             entryFieldRefresher.updateAmountByOrg(BJ_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_bj, model);
 | |
|             BigDecimal tqq9_hshfsyje_bj = (BigDecimal) model.getValue("tqq9_hshfsyje_bj");
 | |
|             entryFieldRefresher.updateAmountByOrg(BJ_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_bj, model);
 | |
|             BigDecimal tqq9_hsxfsyje_bj = (BigDecimal) model.getValue("tqq9_hsxfsyje_bj");
 | |
|             entryFieldRefresher.updateAmountByOrg(BJ_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_bj, model);
 | |
|             BigDecimal tqq9_discountamt_gz = (BigDecimal) model.getValue("tqq9_discountamt_gz");
 | |
|             entryFieldRefresher.updateAmountByOrg(GZ_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_gz, model);
 | |
|             BigDecimal tqq9_hshfsyje_gz = (BigDecimal) model.getValue("tqq9_hshfsyje_gz");
 | |
|             entryFieldRefresher.updateAmountByOrg(GZ_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_gz, model);
 | |
|             BigDecimal tqq9_hsxfsyje_gz = (BigDecimal) model.getValue("tqq9_hsxfsyje_gz");
 | |
|             entryFieldRefresher.updateAmountByOrg(GZ_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_gz, model);
 | |
|         }
 | |
|         //物料带出最高限价
 | |
|         if (StringUtils.equals("material", name)) {
 | |
|             ChangeData changeData = e.getChangeSet()[0];
 | |
|             int rowIndex = changeData.getRowIndex();
 | |
|             DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection(ENTRYENTITY);
 | |
|             DynamicObject dynamicObject = dynamicObjectCollection.get(rowIndex);
 | |
|             DynamicObject material = dynamicObject.getDynamicObject("material");
 | |
|             DynamicObject masterid = material.getDynamicObject("masterid");
 | |
|             DynamicObject bd_material = BusinessDataServiceHelper.loadSingle(masterid.getLong("id"), "bd_material");
 | |
|             DynamicObject org = (DynamicObject) this.getModel().getValue("entryrecorg", rowIndex);
 | |
|             //上海
 | |
|             if (StringUtils.equals(SH_ORGNUMBER, org.getString("number"))) {
 | |
|                 BigDecimal tqq9_maxprice_sh = bd_material.getBigDecimal("tqq9_maxprice_sh");
 | |
|                 if (tqq9_maxprice_sh.compareTo(BigDecimal.ZERO) > 0) {
 | |
|                     getModel().setValue("priceandtax", tqq9_maxprice_sh, rowIndex);
 | |
|                     getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_sh, rowIndex);
 | |
|                 }
 | |
|                 //北京
 | |
|             } else if (StringUtils.equals(BJ_ORGNUMBER, org.getString("number"))) {
 | |
|                 BigDecimal tqq9_maxprice_bj = bd_material.getBigDecimal("tqq9_maxprice_bj");
 | |
|                 if (tqq9_maxprice_bj.compareTo(BigDecimal.ZERO) > 0) {
 | |
|                     getModel().setValue("priceandtax", tqq9_maxprice_bj, rowIndex);
 | |
|                     getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_bj, rowIndex);
 | |
|                 }
 | |
|                 //广州
 | |
|             } else if (StringUtils.equals(GZ_ORGNUMBER, org.getString("number"))) {
 | |
|                 BigDecimal tqq9_maxprice_gz = bd_material.getBigDecimal("tqq9_maxprice_gz");
 | |
|                 if (tqq9_maxprice_gz.compareTo(BigDecimal.ZERO) > 0) {
 | |
|                     getModel().setValue("priceandtax", tqq9_maxprice_gz, rowIndex);
 | |
|                     getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_gz, rowIndex);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         //校验含税单价和最高限价
 | |
|         if (StringUtils.equals("priceandtax", name)) {
 | |
|             ChangeData changeData = e.getChangeSet()[0];
 | |
|             int rowIndex = changeData.getRowIndex();
 | |
|             int seq = rowIndex;
 | |
|             BigDecimal newValue = (BigDecimal) changeData.getNewValue();
 | |
|             BigDecimal tqq9_zgcgxj = (BigDecimal) getModel().getValue("tqq9_zgcgxj", seq);
 | |
|             if (newValue.compareTo(tqq9_zgcgxj) > 0 && tqq9_zgcgxj.compareTo(BigDecimal.ZERO) > 0) {
 | |
|                 getModel().setValue("priceandtax", 0, seq);
 | |
|                 this.getView().showErrorNotification("物料明细分录行" + seq + "含税单价超过最高采购限价,请修改");
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override
 | |
|     public void afterCreateNewData(EventObject e) {
 | |
|         super.afterCreateNewData(e);
 | |
|         FormShowParameter formShowParameter = this.getView().getFormShowParameter();
 | |
|         JSONObject tqq9_pursuggestrpt = (JSONObject) formShowParameter.getCustomParam("pm_purapplybill");
 | |
|         if (tqq9_pursuggestrpt != null) {
 | |
|             IDataModel model = this.getModel();
 | |
|             DynamicObjectCollection billentry = model.getDataEntity(true).getDynamicObjectCollection("billentry");
 | |
|             billentry.clear();
 | |
|             //采购建议报表
 | |
|             JSONArray tqq9_pursuggestrptentry = tqq9_pursuggestrpt.getJSONArray("tqq9_pursuggestrptentry");
 | |
| 
 | |
|             long currentUserId = UserServiceHelper.getCurrentUserId();
 | |
|             DynamicObject user = BusinessDataServiceHelper.loadSingle("bos_user", new QFilter[]{new QFilter("id", QCP.equals, currentUserId)});
 | |
|             DynamicObjectCollection entryentity = user.getDynamicObjectCollection("entryentity");
 | |
|             DynamicObject dept = null;//部门
 | |
|             for (DynamicObject dynamicObject : entryentity) {
 | |
|                 boolean ispartjob = dynamicObject.getBoolean("ispartjob");
 | |
|                 if (!ispartjob) {
 | |
|                     dept = dynamicObject.getDynamicObject("dpt");
 | |
|                 }
 | |
|             }
 | |
|             DynamicObject LCJT = BusinessDataServiceHelper.loadSingle("bos_org", new QFilter[]{new QFilter("name", QCP.equals, "励齿集团")});
 | |
| 
 | |
|             DynamicObject currency = BusinessDataServiceHelper.loadSingle("bd_currency",
 | |
|                     new QFilter[]{new QFilter("number", QCP.equals, "CNY")});//币别
 | |
|             DynamicObject taxrate = BusinessDataServiceHelper.loadSingle("bd_taxrate",
 | |
|                     new QFilter[]{new QFilter("number", QCP.equals, "V13")});//税率
 | |
|             Date date = new Date();
 | |
|             int i = 0;
 | |
|             for (Object dynamicObject : tqq9_pursuggestrptentry) {
 | |
|                 JSONObject entry = (JSONObject) dynamicObject;
 | |
|                 if (entry.getBoolean("tqq9_ischange")) {
 | |
|                     billentry.addNew();
 | |
|                     if (i == 0) {
 | |
|                         model.setValue("org", LCJT);//申请组织
 | |
|                         model.setValue("dept", dept);//申请部门
 | |
|                         model.setValue("bizuser", user);//申请人
 | |
|                         model.setValue("currency", currency);//币别
 | |
|                         model.setValue("creator", user);//创建人
 | |
|                         model.setValue("lastupdateuser", user);//修改人
 | |
|                         model.setValue("lastupdatetime", date);//修改时间
 | |
|                         model.setValue("billtype", BILLTYPE);//单据类型
 | |
|                         model.setValue("biztype", BIZTYPE);//业务类型
 | |
|                         model.setValue("biztime", date);//申请日期
 | |
|                         model.setValue("billstatus", "A");//单据状态
 | |
|                         model.setValue("closestatus", "A");//关闭状态
 | |
|                         model.setValue("cancelstatus", "A");//作废状态
 | |
|                         model.setValue("changestatus", "A");//变更状态
 | |
|                         model.setValue("subversion", "1");//子版本号
 | |
|                         model.setValue("version", "1");//版本号
 | |
|                         model.setValue("tqq9_sfsyhf_sh", "false");//是否使用货返
 | |
|                         model.setValue("tqq9_hshfsysl_sh", taxrate);//含税货返使用税率
 | |
|                         model.setValue("tqq9_sfsyxf_sh", "false");//是否使用现返
 | |
|                         model.setValue("tqq9_hsxfsysl_sh", taxrate);//含税现返使用税率
 | |
|                         model.setValue("tqq9_sfsyhf_bj", "false");//是否使用货返
 | |
|                         model.setValue("tqq9_hshfsysl_bj", taxrate);//含税货返使用税率
 | |
|                         model.setValue("tqq9_sfsyxf_bj", "false");//是否使用现返
 | |
|                         model.setValue("tqq9_hsxfsysl_bj", taxrate);//含税现返使用税率
 | |
|                         model.setValue("tqq9_sfsyhf_gz", "false");//是否使用货返
 | |
|                         model.setValue("tqq9_hshfsysl_gz", taxrate);//含税货返使用税率
 | |
|                         model.setValue("tqq9_sfsyxf_gz", "false");//是否使用现返
 | |
|                         model.setValue("tqq9_hsxfsysl_gz", taxrate);//含税现返使用税率
 | |
|                     }
 | |
|                     JSONObject org = entry.getJSONObject("tqq9_org");
 | |
|                     DynamicObject tqq9_org = BusinessDataServiceHelper.loadSingle(org.getLong("id"), "bos_org");//组织
 | |
|                     JSONObject material = entry.getJSONObject("tqq9_material");//物料
 | |
|                     DynamicObject tqq9_material = BusinessDataServiceHelper.loadSingle(material.getLong("id"), "bd_material");//物料
 | |
|                     DynamicObject materialpurchaseinfo = BusinessDataServiceHelper.loadSingle("bd_materialpurchaseinfo", new QFilter[]{new QFilter("masterid", QCP.equals, tqq9_material.getLong("id"))});//物料采购信息
 | |
|                     BigDecimal tqq9_saledates = entry.getBigDecimal("tqq9_saledates");
 | |
|                     model.setValue("material", materialpurchaseinfo, i);//物料
 | |
|                     model.setValue("materialname", tqq9_material.getString("name"), i);//物料名称
 | |
|                     model.setValue("unit", tqq9_material.getDynamicObject("baseunit"), i);//计量单位
 | |
|                     model.setValue("baseunit", tqq9_material.getDynamicObject("baseunit"), i);//基本单位
 | |
|                     model.setValue("rowclosestatus", "A");//行关闭状态
 | |
|                     model.setValue("rowterminatestatus", "A");//行终止状态
 | |
|                     model.setValue("entryrecorg", tqq9_org, i);//收货组织
 | |
|                     model.setValue("entryreqorg", tqq9_org, i);//需求组织
 | |
|                     model.setValue("entryreqdept", dept, i);//需求部门
 | |
|                     model.setValue("reqdate", date, i);//需求日期
 | |
|                     model.setValue("purdate", date, i);//建议采购日期
 | |
|                     model.setValue("deliverdate", date, i);//交货日期
 | |
|                     model.setValue("bomtime", date, i);//展BOM时间
 | |
|                     model.setValue("linetype", LINETYPE, i);//行类型
 | |
|                     model.setValue("linetype", LINETYPE, i);//行类型
 | |
|                     model.setValue("entrychangetype", "B",i);//变更方式
 | |
|                     model.setValue("entrycreator", user, i);//创建人
 | |
|                     model.setValue("entryrecdept", tqq9_org, i);//收货部门
 | |
|                     model.setValue("entrypurdept", tqq9_org, i);//采购部门
 | |
|                     model.setValue("entryoperatorgroup", tqq9_org, i);//采购组
 | |
|                     model.setValue("tqq9_expectsaletime", tqq9_saledates, i);//预计销售时间(月)
 | |
|                     if (StringUtils.equals(tqq9_org.getString("number"), "SHLC")) {
 | |
|                         model.setValue("tqq9_zgcgxj", tqq9_material.getBigDecimal("tqq9_maxprice_sh"), i);//最高采购限价
 | |
|                         model.setValue("priceandtax", tqq9_material.getBigDecimal("tqq9_maxprice_sh"), i);//含税单价
 | |
|                     } else if (StringUtils.equals(tqq9_org.getString("number"), "BJLC")) {
 | |
|                         model.setValue("tqq9_zgcgxj", tqq9_material.getBigDecimal("tqq9_maxprice_bj"), i);//最高采购限价
 | |
|                         model.setValue("priceandtax", tqq9_material.getBigDecimal("tqq9_maxprice_bj"), i);//含税单价
 | |
|                     } else if (StringUtils.equals(tqq9_org.getString("number"), "GZLC")) {
 | |
|                         model.setValue("tqq9_zgcgxj", tqq9_material.getBigDecimal("tqq9_maxprice_gz"), i);//最高采购限价
 | |
|                         model.setValue("priceandtax", tqq9_material.getBigDecimal("tqq9_maxprice_gz"), i);//含税单价
 | |
|                     }
 | |
|                     i++;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| } |