1.财务共享功能开发

This commit is contained in:
zhangzhiguo 2025-02-19 17:03:28 +08:00
parent a722ae200b
commit 65caf1c583
5 changed files with 1338 additions and 0 deletions

View File

@ -0,0 +1,89 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.LocaleString;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.field.ComboEdit;
import kd.bos.form.field.ComboItem;
import kd.sdk.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
/**
* 单据界面插件
* 支出/收入合同公共插件
*/
public class ContractPublicBillRevisionPlugin extends AbstractBillPlugIn implements Plugin {
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String name = e.getProperty().getName();
if(name.equals("zcgj_jtnw")){
Object zcgj_jtnw = this.getModel().getValue("zcgj_jtnw");
if(zcgj_jtnw!=null && zcgj_jtnw!=""){
List<ComboItem> comboList = new ArrayList<>();
if(zcgj_jtnw.toString().equals("jtn")){
comboList.add(new ComboItem(new LocaleString("中材矿山"), "1"));
comboList.add(new ComboItem(new LocaleString("中材国际"), "2"));
comboList.add(new ComboItem(new LocaleString("中联水泥"), "3"));
comboList.add(new ComboItem(new LocaleString("中联同力"), "4"));
comboList.add(new ComboItem(new LocaleString("南方水泥"), "5"));
comboList.add(new ComboItem(new LocaleString("浙江水泥"), "6"));
comboList.add(new ComboItem(new LocaleString("江西水泥"), "7"));
comboList.add(new ComboItem(new LocaleString("中南水泥"), "8"));
comboList.add(new ComboItem(new LocaleString("西南水泥"), "9"));
comboList.add(new ComboItem(new LocaleString("云南水泥"), "10"));
comboList.add(new ComboItem(new LocaleString("贵州水泥"), "11"));
comboList.add(new ComboItem(new LocaleString("新疆水泥"), "12"));
comboList.add(new ComboItem(new LocaleString("三狮材料"), "13"));
comboList.add(new ComboItem(new LocaleString("华南材料"), "14"));
comboList.add(new ComboItem(new LocaleString("华东材料"), "15"));
comboList.add(new ComboItem(new LocaleString("中材水泥"), "16"));
comboList.add(new ComboItem(new LocaleString("北方水泥"), "17"));
comboList.add(new ComboItem(new LocaleString("宁夏建材"), "18"));
// comboList.add(new ComboItem(new LocaleString("祁连山"), "19"));
comboList.add(new ComboItem(new LocaleString("中材科技"), "20"));
comboList.add(new ComboItem(new LocaleString("中建投"), "21"));
comboList.add(new ComboItem(new LocaleString("地勘"), "22"));
comboList.add(new ComboItem(new LocaleString("资产管理公司"), "23"));
}else{
comboList.add(new ComboItem(new LocaleString("山水"), "24"));
// comboList.add(new ComboItem(new LocaleString(""), "25"));
comboList.add(new ComboItem(new LocaleString("华新"), "26"));
comboList.add(new ComboItem(new LocaleString("华润"), "27"));
comboList.add(new ComboItem(new LocaleString("红狮"), "28"));
comboList.add(new ComboItem(new LocaleString("亚泰"), "29"));
comboList.add(new ComboItem(new LocaleString("金隅"), "30"));
comboList.add(new ComboItem(new LocaleString("昆钢"), "31"));
comboList.add(new ComboItem(new LocaleString("台泥"), "32"));
comboList.add(new ComboItem(new LocaleString("万年青"), "33"));
comboList.add(new ComboItem(new LocaleString("其他未列明第三方"), "34"));
}
ComboEdit comboEdit = getView().getControl("zcgj_belongingsector");
comboEdit.setComboItems(comboList);
}
}else if (name.equals("contracttype")) {//收入合同字段值改变
String direction = ((DynamicObject)this.getModel().getValue("contract")).getString("paydirection");
if("out".equals(direction)){
ChangeData changeData = e.getChangeSet()[0];
DynamicObject contractType = (DynamicObject)changeData.getNewValue();
String number = contractType.getString("number");
List<ComboItem> comboList = new ArrayList<>();
if(number.equals("sbzl")){
comboList.add(new ComboItem(new LocaleString("全部租赁"), "C"));
comboList.add(new ComboItem(new LocaleString("部分租赁"), "D"));
comboList.add(new ComboItem(new LocaleString("零星租赁"), "F"));
}else{
comboList.add(new ComboItem(new LocaleString("全面合作"), "A"));
comboList.add(new ComboItem(new LocaleString("局部合作"), "B"));
}
ComboEdit comboEdit = getView().getControl("zcgj_cooperatemode");
comboEdit.setComboItems(comboList);
}
}
}
}

View File

@ -0,0 +1,482 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.cache.CacheFactory;
import kd.bos.cache.TempFileCache;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.fileservice.FileService;
import kd.bos.fileservice.FileServiceFactory;
import kd.bos.form.control.AttachmentPanel;
import kd.bos.form.field.ComboEdit;
import kd.bos.form.field.events.BeforeF7SelectListener;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.AttachmentDto;
import kd.bos.servicehelper.AttachmentServiceHelper;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.ec.contract.formplugin.AbstractContBillPlugin;
import java.io.*;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.security.SecureRandom;
import java.util.*;
import java.util.stream.Collectors;
public class ContractRevisionEditUIPlugin extends AbstractContBillPlugin{
private static final FileService fileService = FileServiceFactory.getAttachmentFileService();
private static final TempFileCache tempFileCache = CacheFactory.getCommonCacheFactory().getTempFileCache();
@Override
public void afterBindData(EventObject e) {
super.afterBindData(e);
Object contractId = this.getView().getFormShowParameter().getCustomParam("contractId");
Object paydirection = this.getView().getFormShowParameter().getCustomParam("paydirection");
String operateType = (String)this.getView().getFormShowParameter().getCustomParam("operateType");
DynamicObject contract;
//收入/支出合同-合同修订
if (contractId != null && "edit".equals(operateType)) {
contract = new DynamicObject();
if ("out".equals(paydirection)) {
contract = BusinessDataServiceHelper.loadSingle(contractId, "ec_out_contract");
} else if ("in".equals(paydirection)) {
contract = BusinessDataServiceHelper.loadSingle(contractId, "ec_in_contract");
}
if ("out".equals(paydirection)) {
this.loadHeadFields(contract, true);
} else if ("in".equals(paydirection)) {
this.loadHeadFields(contract, false);
}
} else {
//修订历史
//获取收支类型
String direction = ((DynamicObject)this.getModel().getValue("contract")).getString("paydirection");
if (paydirection == null || paydirection == "") {
paydirection = direction;
}
//获取合同id
Object contracPk = ((DynamicObject)this.getModel().getValue("contract")).getPkValue();
QFilter filter = new QFilter("contract", "=", contracPk);
QFilter filter1 = new QFilter("versionnumber", "<", this.getModel().getValue("versionnumber"));
String inSelecttors = "id,contract,versionnumber,contractno,contractname,payrate,incontpayplanentry,incontpayplanentry.incometype,incontpayplanentry.incomemethod,incontpayplanentry.incomepercent,incontpayplanentry.incomeamount,incontpayplanentry.planincometime,incontpayplanentry.incomedescription,incontpayplanentry.insourceid,riskentry,riskentry.risktype,riskentry.riskname,riskentry.riskdesc,riskentry.measures,riskentry.islegalrisk,riskentry.risksourceid,contracttype.name,ismultirate,signdate,isonlist,incontract,description";
String outSelectors = "id,contract,versionnumber,contractno,contractname,payrate,outcontpayplanentry,outcontpayplanentry.paytype,outcontpayplanentry.paymethod,outcontpayplanentry.paypercent,outcontpayplanentry.payamount,outcontpayplanentry.planpaytime,outcontpayplanentry.paydescription,outcontpayplanentry.paysourceid,riskentry,riskentry.risktype,riskentry.riskname,riskentry.riskdesc,riskentry.measures,riskentry.islegalrisk,riskentry.risksourceid,incontract,contracttype.name,ismultirate,signdate,isonlist,incontract,description";
inSelecttors+=",zcgj_startdate,zcgj_enddate,zcgj_cooperatemode,zcgj_jnjw,zcgj_customerclass,zcgj_project,zcgj_settlementdeadline,zcgj_follow,zcgj_priceadjustment,zcgj_paymode,zcgj_guaranteemethod,zcgj_belongingsector,zcgj_sngl,zcgj_guaramount,zcgj_guaranteeyear";
inSelecttors+=",zcgj_bnyjhshte,zcgj_bnyjbhshte,zcgj_bnyjse,zcgj_pjnhhshte,zcgj_pjnhbhshte,zcgj_pjnhse,zcgj_sjcn,zcgj_yjbnyxcn,zcgj_contractprocess.FBasedataId,zcgj_hshtdj,zcgj_bhshtdj";
outSelectors+=",zcgj_startdate,zcgj_enddate,zcgj_cooperatemode,zcgj_jnjw,zcgj_customerclass,zcgj_project,zcgj_settlementdeadline,zcgj_priceadjustment,zcgj_paymode,zcgj_guaranteemethod,zcgj_jtnw,zcgj_guaramount,zcgj_guaranteeyear";
new DynamicObjectCollection();
DynamicObjectCollection lastVersion = QueryServiceHelper.query("ec_contract_revision", "id,contract,versionnumber,contractno,contractname,payrate", new QFilter[]{filter, filter1}, "versionnumber desc");
if (lastVersion.size() > 0) {
DynamicObject cont = new DynamicObject();
if ("in".equals(direction)) {
cont = BusinessDataServiceHelper.loadSingle(((DynamicObject)lastVersion.get(0)).get("id"), "ec_contract_revision", inSelecttors);
} else if ("out".equals(direction)) {
cont = BusinessDataServiceHelper.loadSingle(((DynamicObject)lastVersion.get(0)).get("id"), "ec_contract_revision", outSelectors);
}
HashMap<String, Object> styleMap = new HashMap();
styleMap.put("fc", "#009966");
//设置境内外的颜色(修正过的)
String jnjw = (String)this.getModel().getValue("zcgj_jnjw");
if (jnjw != null && !jnjw.equals(cont.getString("zcgj_jnjw"))) {
this.getView().updateControlMetadata("zcgj_jnjw", styleMap);
}
Date zcgjStartdate = (Date)this.getModel().getValue("zcgj_startdate");
if (zcgjStartdate != null && !zcgjStartdate.equals(cont.getDate("zcgj_startdate"))) {
this.getView().updateControlMetadata("zcgj_startdate", styleMap);
}
Date zcgjEnddate = (Date)this.getModel().getValue("zcgj_enddate");
if (zcgjEnddate != null && !zcgjEnddate.equals(cont.getDate("zcgj_enddate"))) {
this.getView().updateControlMetadata("zcgj_enddate", styleMap);
}
String cooperatemode = (String)this.getModel().getValue("zcgj_cooperatemode");
if (cooperatemode != null && !cooperatemode.equals(cont.getString("zcgj_cooperatemode"))) {
this.getView().updateControlMetadata("zcgj_cooperatemode", styleMap);
}
String customerclass = (String)this.getModel().getValue("zcgj_customerclass");
if (customerclass != null && !customerclass.equals(cont.getString("zcgj_customerclass"))) {
this.getView().updateControlMetadata("zcgj_customerclass", styleMap);
}
DynamicObject projectObj = (DynamicObject)this.getModel().getValue("zcgj_project");
if (projectObj != null ) {
DynamicObject project = cont.getDynamicObject("zcgj_project");
String num = "";
if(project!=null){
num = project.getString("number");
}
if(!projectObj.getString("number").equals(num)){
this.getView().updateControlMetadata("zcgj_project", styleMap);
}
}
String settlementdeadline = (String)this.getModel().getValue("zcgj_settlementdeadline");
if (settlementdeadline != null && !settlementdeadline.equals(cont.getString("zcgj_settlementdeadline"))) {
this.getView().updateControlMetadata("zcgj_settlementdeadline", styleMap);
}
String paymode = (String)this.getModel().getValue("zcgj_paymode");
if (paymode != null && !paymode.equals(cont.getString("zcgj_paymode"))) {
this.getView().updateControlMetadata("zcgj_paymode", styleMap);
}
String guaranteemethod = (String)this.getModel().getValue("zcgj_guaranteemethod");
if (guaranteemethod != null && !guaranteemethod.equals(cont.getString("zcgj_guaranteemethod"))) {
this.getView().updateControlMetadata("zcgj_guaranteemethod", styleMap);
}
BigDecimal guaramount = (BigDecimal)this.getModel().getValue("zcgj_guaramount");
if (guaramount != null && guaramount.compareTo(cont.getBigDecimal("zcgj_guaramount")) != 0) {
this.getView().updateControlMetadata("zcgj_guaramount", styleMap);
}
String guaranteeyear = String.valueOf(this.getModel().getValue("zcgj_guaranteeyear"));
if (guaranteeyear != null && !guaranteeyear.equals(cont.getString("zcgj_guaranteeyear"))) {
this.getView().updateControlMetadata("zcgj_guaranteeyear", styleMap);
}
String priceadjustment = (String)this.getModel().getValue("zcgj_priceadjustment");
if (priceadjustment != null && !priceadjustment.equals(cont.getString("zcgj_priceadjustment"))) {
this.getView().updateControlMetadata("zcgj_priceadjustment", styleMap);
}
if("out".equals(direction)){
String jtnw = (String)this.getModel().getValue("zcgj_jtnw");
if (jtnw != null && !jtnw.equals(cont.getString("zcgj_jtnw"))) {
this.getView().updateControlMetadata("zcgj_jtnw", styleMap);
}
}else{
String belongingsector = (String)this.getModel().getValue("zcgj_belongingsector");
if (belongingsector != null && !belongingsector.equals(cont.getString("zcgj_belongingsector"))) {
this.getView().updateControlMetadata("zcgj_belongingsector", styleMap);
}
String sngl = (String)this.getModel().getValue("zcgj_sngl");
if (sngl != null && !sngl.equals(cont.getString("zcgj_sngl"))) {
this.getView().updateControlMetadata("zcgj_sngl", styleMap);
}
String follow = (String)this.getModel().getValue("zcgj_follow");
if (follow != null && !follow.equals(cont.getString("zcgj_follow"))) {
this.getView().updateControlMetadata("zcgj_follow", styleMap);
}
BigDecimal originaloftaxamount = (BigDecimal)this.getModel().getValue("zcgj_originaloftaxamount");
if (originaloftaxamount != null && originaloftaxamount.compareTo(cont.getBigDecimal("zcgj_originaloftaxamount")) != 0) {
this.getView().updateControlMetadata("zcgj_originaloftaxamount", styleMap);
}
BigDecimal originalamount = (BigDecimal)this.getModel().getValue("zcgj_originalamount");
if (originalamount != null && originalamount.compareTo(cont.getBigDecimal("zcgj_originalamount")) != 0) {
this.getView().updateControlMetadata("zcgj_originalamount", styleMap);
}
BigDecimal taxamount = (BigDecimal)this.getModel().getValue("zcgj_taxamount");
if (taxamount != null && taxamount.compareTo(cont.getBigDecimal("zcgj_taxamount")) != 0) {
this.getView().updateControlMetadata("zcgj_taxamount", styleMap);
}
BigDecimal bnyjhshte = (BigDecimal)this.getModel().getValue("zcgj_bnyjhshte");
if (bnyjhshte != null && bnyjhshte.compareTo(cont.getBigDecimal("zcgj_bnyjhshte")) != 0) {
this.getView().updateControlMetadata("zcgj_bnyjhshte", styleMap);
}
BigDecimal bnyjbhshte = (BigDecimal)this.getModel().getValue("zcgj_bnyjbhshte");
if (bnyjbhshte != null && bnyjbhshte.compareTo(cont.getBigDecimal("zcgj_bnyjbhshte")) != 0) {
this.getView().updateControlMetadata("zcgj_bnyjbhshte", styleMap);
}
BigDecimal bnyjse = (BigDecimal)this.getModel().getValue("zcgj_bnyjse");
if (bnyjse != null && bnyjse.compareTo(cont.getBigDecimal("zcgj_bnyjse")) != 0) {
this.getView().updateControlMetadata("zcgj_bnyjse", styleMap);
}
BigDecimal pjnhhshte = (BigDecimal)this.getModel().getValue("zcgj_pjnhhshte");
if (pjnhhshte != null && pjnhhshte.compareTo(cont.getBigDecimal("zcgj_pjnhhshte")) != 0) {
this.getView().updateControlMetadata("zcgj_pjnhhshte", styleMap);
}
BigDecimal pjnhbhshte = (BigDecimal)this.getModel().getValue("zcgj_pjnhbhshte");
if (pjnhbhshte != null && pjnhbhshte.compareTo(cont.getBigDecimal("zcgj_pjnhbhshte")) != 0) {
this.getView().updateControlMetadata("zcgj_pjnhbhshte", styleMap);
}
BigDecimal pjnhse = (BigDecimal)this.getModel().getValue("zcgj_pjnhse");
if (pjnhse != null && pjnhse.compareTo(cont.getBigDecimal("zcgj_pjnhse")) != 0) {
this.getView().updateControlMetadata("zcgj_pjnhse", styleMap);
}
BigDecimal sjcn = (BigDecimal)this.getModel().getValue("zcgj_sjcn");
if (sjcn != null && sjcn.compareTo(cont.getBigDecimal("zcgj_sjcn")) != 0) {
this.getView().updateControlMetadata("zcgj_sjcn", styleMap);
}
BigDecimal yjbnyxcn = (BigDecimal)this.getModel().getValue("zcgj_yjbnyxcn");
if (yjbnyxcn != null && yjbnyxcn.compareTo(cont.getBigDecimal("zcgj_yjbnyxcn")) != 0) {
this.getView().updateControlMetadata("zcgj_yjbnyxcn", styleMap);
}
//zcgj_contractprocess
DynamicObjectCollection contractprocessObj = (DynamicObjectCollection)this.getModel().getValue("zcgj_contractprocess");
if (contractprocessObj != null ) {
Set<Long> ids = new HashSet<>();
for (DynamicObject dynamicObject : contractprocessObj) {
Long id = Long.parseLong(((DynamicObject)dynamicObject.get("FBasedataId")).getPkValue()+"");
ids.add(id);//((DynamicObject)contractprocessObj.get(0).get("FBasedataId")).getPkValue()
}
DynamicObjectCollection contractprocess = cont.getDynamicObjectCollection("zcgj_contractprocess");
Set<Long> idSet= new HashSet<>();
if(contractprocess!=null){
for (DynamicObject dynamicObject : contractprocess) {
if(dynamicObject.get("FBasedataId")!=null){
idSet.add(Long.parseLong(((DynamicObject)dynamicObject.get("FBasedataId")).getPkValue()+""));
}
}
if(!ids.equals(idSet)){
this.getView().updateControlMetadata("zcgj_contractprocess", styleMap);
}
}else{
this.getView().updateControlMetadata("zcgj_contractprocess", styleMap);
}
}
//zcgj_hshtdj
BigDecimal hshtdj = (BigDecimal)this.getModel().getValue("zcgj_hshtdj");
if (hshtdj != null && hshtdj.compareTo(cont.getBigDecimal("zcgj_hshtdj")) != 0) {
this.getView().updateControlMetadata("zcgj_hshtdj", styleMap);
}
//zcgj_bhshtdj
BigDecimal bhshtdj = (BigDecimal)this.getModel().getValue("zcgj_bhshtdj");
if (bhshtdj != null && bhshtdj.compareTo(cont.getBigDecimal("zcgj_bhshtdj")) != 0) {
this.getView().updateControlMetadata("zcgj_bhshtdj", styleMap);
}
}
}
}
this.getView().setVisible(false, new String[]{"zcgj_project"});//项目
if ("out".equals(paydirection)) {
//支出合同隐藏收入合同的字段
this.getView().setVisible(false, new String[]{"zcgj_belongingsector"});//所属板块
this.getView().setVisible(false, new String[]{"zcgj_sngl"});//水泥骨料
this.getView().setVisible(false, new String[]{"zcgj_follow"});//流程
} else if ("in".equals(paydirection)) {
//收入合同隐藏支出合同的字段
//this.getView().setVisible(false, new String[]{"outcompload"});
this.getView().setVisible(false, new String[]{"zcgj_cooperatemode"});//合作类型
//this.getView().setVisible(false, new String[]{"zcgj_jtnw"});//集团内外
}
}
private void loadRiskEntry(DynamicObject contract) {
this.getModel().deleteEntryData("riskentry");
DynamicObjectCollection riskentry = contract.getDynamicObjectCollection("riskentry");
for(int i = 0; i < riskentry.size(); ++i) {
DynamicObject o = (DynamicObject)riskentry.get(i);
int rowIndex = this.getModel().createNewEntryRow("riskentry");
this.getModel().setValue("risktype", o.get("risktype"), rowIndex);
this.getModel().setValue("riskname", o.get("riskname"), rowIndex);
this.getModel().setValue("riskdesc", o.get("riskdesc"), rowIndex);
this.getModel().setValue("risksourceid", o.getPkValue(), rowIndex);
this.getModel().setValue("measures", o.get("measures"), rowIndex);
this.getModel().setValue("islegalrisk", o.get("islegalrisk"), rowIndex);
}
}
private void loadSpecEntry(DynamicObject contract) {
DynamicObjectCollection specEntry = contract.getDynamicObjectCollection("specentry");
Iterator var3 = specEntry.iterator();
while(var3.hasNext()) {
DynamicObject specObj = (DynamicObject)var3.next();
int rowIndex = this.getModel().createNewEntryRow("specentry");
this.getModel().setValue("propname", specObj.get("propname"), rowIndex);
this.getModel().setValue("fieldname", specObj.get("fieldname"), rowIndex);
this.getModel().setValue("value", specObj.get("value"), rowIndex);
this.getModel().setValue("specsourceid", specObj.getPkValue(), rowIndex);
}
}
private void loadHeadFields(DynamicObject contract, boolean isOutContract) {
//通用字段
//合同起始日期
this.getModel().setValue("zcgj_startdate", contract.get("zcgj_startdate"));
//合同终止日期
this.getModel().setValue("zcgj_enddate", contract.get("zcgj_enddate"));
//合作类型 zcgj_cooperationmode
//境内外
this.getModel().setValue("zcgj_jnjw", contract.get("zcgj_jnjw"));
//客商分类
this.getModel().setValue("zcgj_customerclass", contract.get("zcgj_customerclass"));
//项目
this.getModel().setValue("zcgj_project", contract.get("project"));
//结算时限
this.getModel().setValue("zcgj_settlementdeadline", contract.get("zcgj_settlementdeadline"));
//付款方式
this.getModel().setValue("zcgj_paymode", contract.get("zcgj_paymode"));
//担保方式
this.getModel().setValue("zcgj_guaranteemethod", contract.get("zcgj_guaranteemethod"));
//价格调整条款
this.getModel().setValue("zcgj_priceadjustment", contract.get("zcgj_priceadjustment"));
this.getModel().setValue("zcgj_guaramount", contract.get("zcgj_guaramount"));
this.getModel().setValue("zcgj_guaranteeyear", contract.get("zcgj_guaranteeyear"));
//集团内外
this.getModel().setValue("zcgj_jtnw", contract.get("zcgj_jtnw"));
if (isOutContract) {
//支出合同
//合作类型
this.getModel().setValue("zcgj_cooperatemode", contract.get("zcgj_cooperatemode"));
//List<Map<String, Object>> atts = AttachmentServiceHelper.getAttachments("ec_out_contract", contract.getPkValue().toString(), "attachmentpanel");
} else {
//合作类型
this.getModel().setValue("zcgj_cooperatemode", contract.get("zcgj_cooperationmode"));
//收入合同字段
this.getModel().setValue("zcgj_belongingsector", contract.get("zcgj_belongingsector"));//所属板块
this.getModel().setValue("zcgj_sngl", contract.get("zcgj_sngl"));//水泥骨料
//流程
this.getModel().setValue("zcgj_follow", contract.get("zcgj_follow"));
this.getModel().setValue("zcgj_bnyjhshte", contract.get("zcgj_bnyjhshte"));
this.getModel().setValue("zcgj_bnyjbhshte", contract.get("zcgj_bnyjbhshte"));
this.getModel().setValue("zcgj_bnyjse", contract.get("zcgj_bnyjse"));
this.getModel().setValue("zcgj_pjnhhshte", contract.get("zcgj_pjnhhshte"));
this.getModel().setValue("zcgj_pjnhbhshte", contract.get("zcgj_pjnhbhshte"));
this.getModel().setValue("zcgj_pjnhse", contract.get("zcgj_pjnhse"));
this.getModel().setValue("zcgj_sjcn", contract.get("zcgj_sjcn"));
this.getModel().setValue("zcgj_yjbnyxcn", contract.get("zcgj_yjbnyxcn"));
DynamicObjectCollection dynamicObjectCollection = contract.getDynamicObjectCollection("zcgj_contractprocess");
boolean ok = true;
boolean hasNull = dynamicObjectCollection.stream().anyMatch(element -> element.get("FBasedataId") == null);
if(!hasNull){
this.getModel().setValue("zcgj_contractprocess", contract.get("zcgj_contractprocess"));
}
// }
this.getModel().setValue("zcgj_hshtdj", contract.get("zcgj_hshtdj"));
this.getModel().setValue("zcgj_bhshtdj", contract.get("zcgj_bhshtdj"));
this.getModel().setValue("zcgj_originaloftaxamount", contract.get("originaloftaxamount"));
this.getModel().setValue("zcgj_originalamount", contract.get("originalamount"));
this.getModel().setValue("zcgj_taxamount", contract.get("taxamount"));
//this.getModel().setValue("zcgj_attachmentpanel", contract.get("attachmentpanel"));
/*AttachmentPanel panel = this.getView().getControl("zcgj_attachmentpanel");
List<Map<String, Object>> atts = AttachmentServiceHelper.getAttachments("ec_in_contract", contract.getPkValue().toString(), "attachmentpanel");
List<Map<String, Object>> newAttachments = new ArrayList<>(atts.size());
for (Map<String, Object> att : atts) {
String tempUrl = saveAsTempFile(att);
Map<String, Object> newAttachment = new HashMap<>(16);
String name = (String) att.get("name");
//将url关联的文件服务器文件存储成临时文件
newAttachment.put("url", tempUrl);
// 重新设置uid附件唯一标识
newAttachment.put("uid", "rc-upload-" + System.currentTimeMillis() + "-" + new SecureRandom().nextInt(100));
newAttachment.put("name", name);
newAttachment.put("size", att.get("size"));
newAttachment.put("status", att.get("status"));
//目标单formId
newAttachment.put("entityNum", "ec_contract_revision");
//目标单pkId此时还未生成传入'0'
newAttachment.put("billPkId", "0");
newAttachments.add(newAttachment);
}
panel.bindData(newAttachments);
panel.upload(newAttachments);*/
}
}
/**
* 将url关联的文件服务器文件存储成临时文件
* 未保存状态下单据的附件必须是临时文件
* @return
*/
private String saveAsTempFile(Map<String, Object> att ) {
AttachmentDto attachmentDto = AttachmentServiceHelper.getAttachmentInfoByAttPk(att.get("attPkId"));
String fileUrl = attachmentDto.getResourcePath();
String filename = attachmentDto.getFilename();
ByteArrayOutputStream out = new ByteArrayOutputStream();
FileServiceFactory.getAttachmentFileService().download(fileUrl,out,null);
InputStream inputStream = new ByteArrayInputStream(out.toByteArray());
//保存文件流返回
String tempUrl = tempFileCache.saveAsUrl(filename, inputStream, 2 * 60 * 60);
String address = RequestContext.get().getClientFullContextPath();
if (!address.endsWith("/")) {
address = address + "/";
}
tempUrl = address + tempUrl;
return tempUrl;
}
private void loadOutContPlanentry(DynamicObject contract) {
this.getModel().deleteEntryData("outcontpayplanentry");
DynamicObjectCollection outcontpayplanentry = contract.getDynamicObjectCollection("outcontpayplanentry");
DynamicObjectCollection entryEntity = this.getModel().getEntryEntity("outcontpayplanentry");
for(int i = 0; i < outcontpayplanentry.size(); ++i) {
DynamicObject o = (DynamicObject)outcontpayplanentry.get(i);
DynamicObject pay = entryEntity.addNew();
pay.set("paytype", o.get("paytype"));
pay.set("paymethod", o.get("paymethod"));
pay.set("paypercent", o.get("paypercent"));
pay.set("payamount", o.get("payamount"));
pay.set("planpaytime", o.get("planpaytime"));
pay.set("paysourceid", o.getPkValue());
pay.set("paydescription", o.get("remarks"));
pay.set("paynode", o.get("paynode"));
pay.set("totalpaypercent", o.get("totalpaypercent"));
pay.set("paynodetext", o.get("paynodetext"));
pay.set("nodedate", o.get("nodedate"));
pay.set("isdeduction", o.get("isdeduction"));
}
this.getView().updateView("outcontpayplanentry");
}
private void loadIncomePlanEntry(DynamicObject contract) {
this.getModel().deleteEntryData("incontpayplanentry");
DynamicObjectCollection outcontpayplanentry = contract.getDynamicObjectCollection("incontpayplanentry");
for(int i = 0; i < outcontpayplanentry.size(); ++i) {
DynamicObject o = (DynamicObject)outcontpayplanentry.get(i);
this.getModel().createNewEntryRow("incontpayplanentry");
this.getModel().setValue("incometype", o.get("paytype"), i);
this.getModel().setValue("incomemethod", o.get("paymethod"), i);
this.getModel().setValue("incomepercent", o.get("paypercent"), i);
this.getModel().setValue("incomeamount", o.get("payamount"), i);
this.getModel().setValue("planincometime", o.get("planpaytime"), i);
this.getModel().setValue("insourceid", o.getPkValue(), i);
this.getModel().setValue("incomedescription", o.get("remarks"), i);
this.getModel().setValue("incomenode", o.get("paynode"), i);
this.getModel().setValue("totalincomepercent", o.get("totalpaypercent"), i);
}
Object[] ids = outcontpayplanentry.stream().map((ox) -> {
return ox.getPkValue();
}).toArray();
QFilter filter = new QFilter("contentryentity.sourceid", "in", ids);
DynamicObjectCollection query = QueryServiceHelper.query("ec_in_contfundplan", "id,billno,contentryentity.sourceid", new QFilter[]{filter});
if (query.size() > 0) {
this.getView().getControl("advconap").getView().setEnable(false, new String[0]);
}
this.getView().setVisible(false, new String[]{"advconap1"});
}
}

View File

@ -0,0 +1,151 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import java.math.BigDecimal;
import java.util.EventObject;
/**
* 收入合同单据界面插件
*/
public class EcContractRevisionFromPlugin extends AbstractBillPlugIn implements Plugin {
@Override
public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e);
}
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String name = e.getProperty().getName();
if(name.equals("zcgj_pjnhhshte") || name.equals("zcgj_pjnhbhshte") || name.equals("zcgj_yjhshtsr")||
name.equals("zcgj_yjbhshtsr")||name.equals("zcgj_hshtdj")||name.equals("zcgj_bnyjhshte")||name.equals("zcgj_bnyjbhshte")){
ChangeData changeData = e.getChangeSet()[0];
DynamicObject contract = ((DynamicObject)this.getModel().getValue("contract"));
DynamicObject taxrateInfo = contract.getDynamicObject("taxrate");
QFilter filter = new QFilter("id", "=", taxrateInfo.getPkValue());
DynamicObject taxtRateObj = BusinessDataServiceHelper.loadSingle("bd_taxrate", "id,taxrate", new QFilter[]{filter});
//bd_taxrate
if (taxtRateObj != null) {
BigDecimal trate = taxtRateObj.getBigDecimal("taxrate");
BigDecimal pRate = trate.divide(new BigDecimal(100)).add(new BigDecimal(1));
BigDecimal amount = new BigDecimal(0);
BigDecimal ofamount = new BigDecimal(0);
BigDecimal rate = new BigDecimal(0);
DynamicObject dataEntity = this.getModel().getDataEntity(true);
if (name.equals("zcgj_pjnhhshte")) {
Object zcgjPjnhbhshte = this.getModel().getValue("zcgj_pjnhhshte");
System.out.println();
if (zcgjPjnhbhshte != null) {
ofamount = new BigDecimal(zcgjPjnhbhshte.toString());
}
amount = ofamount.divide(pRate, 6, BigDecimal.ROUND_HALF_UP);
rate = ofamount.subtract(amount);
dataEntity.set("zcgj_pjnhbhshte", amount);
dataEntity.set("zcgj_pjnhse", rate);
// this.getModel().setValue("zcgj_pjnhbhshte", amount);
// this.getModel().setValue("zcgj_pjnhse", rate);
this.getView().updateView("zcgj_pjnhbhshte");
this.getView().updateView("zcgj_pjnhse");
} else if (name.equals("zcgj_pjnhbhshte")) {
// Object zcgjPjnhhshte = this.getModel().getValue("zcgj_pjnhbhshte");
Object zcgjPjnhhshte = changeData.getNewValue();
System.out.println();
if (zcgjPjnhhshte != null) {
amount = new BigDecimal(zcgjPjnhhshte.toString());
}
ofamount = amount.multiply(pRate);
rate = ofamount.subtract(amount);
// this.getModel().setValue("zcgj_pjnhhshte", ofamount);
// this.getModel().setValue("zcgj_pjnhse", rate);
dataEntity.set("zcgj_pjnhbhshte", amount);
dataEntity.set("zcgj_pjnhhshte", ofamount);
dataEntity.set("zcgj_pjnhse", rate);
this.getView().updateView("zcgj_pjnhbhshte");
this.getView().updateView("zcgj_pjnhhshte");
this.getView().updateView("zcgj_pjnhse");
}else if (name.equals("zcgj_yjhshtsr")) {
Object zcgjyjhshtsr = this.getModel().getValue("zcgj_yjhshtsr");
System.out.println();
if (zcgjyjhshtsr != null) {
ofamount = new BigDecimal(zcgjyjhshtsr.toString());
}
amount = ofamount.divide(pRate, 6, BigDecimal.ROUND_HALF_UP);
rate = ofamount.subtract(amount);
// this.getModel().setValue("zcgj_yjbhshtsr", amount);
// this.getModel().setValue("zcgj_yjzse", rate);
dataEntity.set("zcgj_yjbhshtsr", amount);
dataEntity.set("zcgj_yjzse", rate);
this.getView().updateView("zcgj_yjbhshtsr");
this.getView().updateView("zcgj_yjzse");
} else if (name.equals("zcgj_yjbhshtsr")) {
Object zcgjyjbhshtsr = this.getModel().getValue("zcgj_yjbhshtsr");
System.out.println();
if (zcgjyjbhshtsr != null) {
amount = new BigDecimal(zcgjyjbhshtsr.toString());
}
ofamount = amount.multiply(pRate);
rate = ofamount.subtract(amount);
// this.getModel().setValue("zcgj_yjhshtsr", ofamount);
// this.getModel().setValue("zcgj_yjzse", rate);
dataEntity.set("zcgj_yjhshtsr", ofamount);
dataEntity.set("zcgj_yjzse", rate);
this.getView().updateView("zcgj_yjhshtsr");
this.getView().updateView("zcgj_yjzse");
}else if (name.equals("zcgj_hshtdj")) {
Object zcgjhshtdj = this.getModel().getValue("zcgj_hshtdj");
if (zcgjhshtdj != null) {
ofamount = new BigDecimal(zcgjhshtdj.toString());
}
amount = ofamount.divide(pRate,6, BigDecimal.ROUND_HALF_UP);
dataEntity.set("zcgj_bhshtdj", amount);
// this.getModel().setValue("zcgj_bhshtdj", ofamount);
this.getView().updateView("zcgj_bhshtdj");
}else if (name.equals("zcgj_bhshtdj")) {
Object zcgjbhshtdj = this.getModel().getValue("zcgj_bhshtdj");
if (zcgjbhshtdj != null) {
amount = new BigDecimal(zcgjbhshtdj.toString());
}
ofamount = amount.multiply(pRate);
dataEntity.set("zcgj_hshtdj", ofamount);
// this.getModel().setValue("zcgj_hshtdj", ofamount);
this.getView().updateView("zcgj_hshtdj");
} else if (name.equals("zcgj_bnyjhshte")) {
Object zcgjbnyjbhshte = this.getModel().getValue("zcgj_bnyjhshte");
if (zcgjbnyjbhshte != null) {
ofamount = new BigDecimal(zcgjbnyjbhshte.toString());
}
amount = ofamount.divide(pRate, 6, BigDecimal.ROUND_HALF_UP);
rate = ofamount.subtract(amount);
dataEntity.set("zcgj_bnyjbhshte", amount);
dataEntity.set("zcgj_bnyjse", rate);
this.getView().updateView("zcgj_bnyjbhshte");
this.getView().updateView("zcgj_bnyjse");
} else if (name.equals("zcgj_bnyjbhshte")) {
Object zcgjbnyjhshte = this.getModel().getValue("zcgj_bnyjbhshte");
if (zcgjbnyjhshte != null) {
amount = new BigDecimal(zcgjbnyjhshte.toString());
}
ofamount = amount.multiply(pRate);
rate = ofamount.subtract(amount);
dataEntity.set("zcgj_bnyjhshte", ofamount);
dataEntity.set("zcgj_bnyjse", rate);
this.getView().updateView("zcgj_bnyjhshte");
this.getView().updateView("zcgj_bnyjse");
}
}
}
}
}

View File

@ -0,0 +1,302 @@
package zcgj.zcdev.zcdev.pr.plugin.operate;
import kd.bos.cache.CacheFactory;
import kd.bos.cache.TempFileCache;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.resource.ResManager;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.args.BeforeOperationArgs;
import kd.bos.fileservice.FileServiceFactory;
import kd.bos.servicehelper.AttachmentDto;
import kd.bos.servicehelper.AttachmentServiceHelper;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class ContractBeforeRevisionOp extends AbstractOperationServicePlugIn {
private static final TempFileCache tempFileCache = CacheFactory.getCommonCacheFactory().getTempFileCache();
public void onPreparePropertys(PreparePropertysEventArgs e) {
e.getFieldKeys().add("contract");
e.getFieldKeys().add("contractname");
e.getFieldKeys().add("contractno");
e.getFieldKeys().add("payrate");
e.getFieldKeys().add("paydirection");
e.getFieldKeys().add("incontpayplanentry");
e.getFieldKeys().add("incometype");
e.getFieldKeys().add("incomemethod");
e.getFieldKeys().add("incomepercent");
e.getFieldKeys().add("incomeamount");
e.getFieldKeys().add("planincometime");
e.getFieldKeys().add("incomedescription");
e.getFieldKeys().add("riskentry");
e.getFieldKeys().add("riskname");
e.getFieldKeys().add("risktype");
e.getFieldKeys().add("measures");
e.getFieldKeys().add("riskdesc");
e.getFieldKeys().add("islegalrisk");
e.getFieldKeys().add("outcontpayplanentry");
e.getFieldKeys().add("paytype");
e.getFieldKeys().add("paymethod");
e.getFieldKeys().add("payamount");
e.getFieldKeys().add("paypercent");
e.getFieldKeys().add("planpaytime");
e.getFieldKeys().add("paydescription");
e.getFieldKeys().add("insourceid");
e.getFieldKeys().add("paysourceid");
e.getFieldKeys().add("risksourceid");
e.getFieldKeys().add("versionnumber");
e.getFieldKeys().add("propname");
e.getFieldKeys().add("value");
e.getFieldKeys().add("fieldname");
e.getFieldKeys().add("specsourceid");
e.getFieldKeys().add("contracttype");
e.getFieldKeys().add("signdate");
e.getFieldKeys().add("payrate");
e.getFieldKeys().add("description");
e.getFieldKeys().add("incontract");
e.getFieldKeys().add("bizstatus");
e.getFieldKeys().add("isincomebytasknode");
e.getFieldKeys().add("ispaybytasknode");
e.getFieldKeys().add("incomenode");
e.getFieldKeys().add("totalincomepercent");
e.getFieldKeys().add("paynode");
e.getFieldKeys().add("paynodetext");
e.getFieldKeys().add("nodedate");
e.getFieldKeys().add("isreltask");
e.getFieldKeys().add("totalpaypercent");
e.getFieldKeys().add("ispayentry");
e.getFieldKeys().add("iscontrolrate");
e.getFieldKeys().add("changerate");
e.getFieldKeys().add("visarate");
e.getFieldKeys().add("claimrate");
e.getFieldKeys().add("performrate");
e.getFieldKeys().add("settlemethod");
e.getFieldKeys().add("ispaybymonth");
e.getFieldKeys().add("isdeduction");
e.getFieldKeys().add("zcgj_jnjw");
e.getFieldKeys().add("zcgj_startdate");
e.getFieldKeys().add("zcgj_enddate");
e.getFieldKeys().add("zcgj_cooperatemode");
e.getFieldKeys().add("zcgj_jnjw");
e.getFieldKeys().add("zcgj_customerclass");
e.getFieldKeys().add("zcgj_project");
e.getFieldKeys().add("zcgj_settlementdeadline");
e.getFieldKeys().add("zcgj_paymode");
e.getFieldKeys().add("zcgj_guaranteemethod");
e.getFieldKeys().add("zcgj_priceadjustment");
e.getFieldKeys().add("zcgj_jtnw");
e.getFieldKeys().add("zcgj_belongingsector");
e.getFieldKeys().add("zcgj_sngl");
e.getFieldKeys().add("zcgj_follow");
e.getFieldKeys().add("zcgj_guaramount");
e.getFieldKeys().add("zcgj_guaranteeyear");
e.getFieldKeys().add("zcgj_bnyjhshte");
e.getFieldKeys().add("zcgj_bnyjbhshte");
e.getFieldKeys().add("zcgj_bnyjse");
e.getFieldKeys().add("zcgj_pjnhhshte");
e.getFieldKeys().add("zcgj_pjnhbhshte");
e.getFieldKeys().add("zcgj_pjnhse");
e.getFieldKeys().add("zcgj_sjcn");
e.getFieldKeys().add("zcgj_yjbnyxcn");
e.getFieldKeys().add("zcgj_originaloftaxamount");
e.getFieldKeys().add("zcgj_originalamount");
e.getFieldKeys().add("zcgj_taxamount");
e.getFieldKeys().add("zcgj_contractprocess");
e.getFieldKeys().add("zcgj_hshtdj");
e.getFieldKeys().add("zcgj_bhshtdj");
//e.getFieldKeys().add("zcgj_attachmentpanel");
}
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
String operationKey = e.getOperationKey();
DynamicObject[] dataEntities = e.getDataEntities();
DynamicObject obj;
DynamicObject firstEdit;
String formatText;
switch (operationKey) {
case "audit":
ArrayList<DynamicObject> outContList = new ArrayList();
ArrayList<DynamicObject> inContList = new ArrayList();
DynamicObject[] var22 = dataEntities;
int var24 = dataEntities.length;
for(int var26 = 0; var26 < var24; ++var26) {
obj = var22[var26];
DynamicObject contract;
boolean isOutContract = false;
if ("out".equals(obj.getDynamicObject("contract").getString("paydirection"))) {
contract = BusinessDataServiceHelper.loadSingle(obj.getDynamicObject("contract").getPkValue(), "ec_out_contract");
//this.updateHeadFields(obj, contract, true);
// outContList.add(contract);
isOutContract = true;
} else {
if (!"in".equals(obj.getDynamicObject("contract").getString("paydirection"))) {
formatText = String.format(ResManager.loadKDString("单据编号:%s关联的修订合同既不是支出合同也不是收入合同类型无法审核。", "ContractRevisionOp_0", "ec-contract-opplugin", new Object[0]), obj.getString("billno"));
e.setCancelMessage(formatText);
e.cancel = true;
break;
}
contract = BusinessDataServiceHelper.loadSingle(obj.getDynamicObject("contract").getPkValue(), "ec_in_contract");
//this.updateHeadFields(obj, contract, false);
// inContList.add(contract);
}
//如果版本号是2的情况下把版本号1的字段补充完整
BigDecimal versionNumber = obj.getBigDecimal("versionnumber");
if (new BigDecimal(2).compareTo(versionNumber) == 0){
BigDecimal preVersionNumber = versionNumber.subtract(BigDecimal.ONE);
DynamicObject contractObj = obj.getDynamicObject("contract");
long contractId = contractObj.getLong("id");
DynamicObject revisonContract
=BusinessDataServiceHelper.newDynamicObject("zcgj_ec_contract_rev_temp");
if (revisonContract != null) {
revisonContract.set("contract", contractId);
revisonContract.set("zcgj_startdate", contract.get("zcgj_startdate"));
revisonContract.set("zcgj_enddate", contract.get("zcgj_enddate"));
revisonContract.set("zcgj_jnjw", contract.get("zcgj_jnjw"));
revisonContract.set("zcgj_customerclass", contract.get("zcgj_customerclass"));
revisonContract.set("zcgj_project", contract.get("project"));
revisonContract.set("zcgj_settlementdeadline", contract.get("zcgj_settlementdeadline"));
revisonContract.set("zcgj_paymode", contract.get("zcgj_paymode"));
revisonContract.set("zcgj_guaranteemethod", contract.get("zcgj_guaranteemethod"));
revisonContract.set("zcgj_priceadjustment", contract.get("zcgj_priceadjustment"));
revisonContract.set("zcgj_guaranteeyear", contract.get("zcgj_guaranteeyear"));
revisonContract.set("zcgj_guaramount", contract.get("zcgj_guaramount"));
revisonContract.set("versionnumber", preVersionNumber);
//revisonContract.set("zcgj_attachmentpanel", contract.get("attachmentpanel"));
//List<Map<String, Object>> atts = AttachmentServiceHelper.getAttachments("ec_in_contract", contract.getPkValue().toString(), "attachmentpanel");
//DynamicObjectCollection attCollection = revisonContract.getDynamicObjectCollection("zcgj_attachmentpanel");
//for (Map<String, Object> att : atts) {
// attCollection.addNew().set("fbasedataid",att.get("attPkId"));
//}
//AttachmentServiceHelper.upload("zcgj_ec_contract_rev_temp" ,contract.getPkValue(), "zcgj_attachmentpanel", atts);
if (isOutContract) {
revisonContract.set("zcgj_jtnw", contract.get("zcgj_jtnw"));
revisonContract.set("zcgj_cooperatemode", contract.get("zcgj_cooperatemode"));
} else {
revisonContract.set("zcgj_cooperatemode", contract.get("zcgj_cooperationmode"));
revisonContract.set("zcgj_belongingsector", contract.get("zcgj_belongingsector"));
revisonContract.set("zcgj_sngl", contract.get("zcgj_sngl"));
revisonContract.set("zcgj_follow", contract.get("zcgj_follow"));
revisonContract.set("zcgj_bnyjhshte", contract.get("zcgj_bnyjhshte"));
revisonContract.set("zcgj_bnyjbhshte", contract.get("zcgj_bnyjbhshte"));
revisonContract.set("zcgj_bnyjse", contract.get("zcgj_bnyjse"));
revisonContract.set("zcgj_pjnhhshte", contract.get("zcgj_pjnhhshte"));
revisonContract.set("zcgj_pjnhbhshte", contract.get("zcgj_pjnhbhshte"));
revisonContract.set("zcgj_pjnhse", contract.get("zcgj_pjnhse"));
revisonContract.set("zcgj_sjcn", contract.get("zcgj_sjcn"));
revisonContract.set("zcgj_yjbnyxcn", contract.get("zcgj_yjbnyxcn"));//2147319228447850496
DynamicObjectCollection oldContractprocess = contract.getDynamicObjectCollection("zcgj_contractprocess");
DynamicObjectCollection newContractprocess = revisonContract.getDynamicObjectCollection("zcgj_contractprocess");
if(newContractprocess!=null){
newContractprocess.clear();
}
for (DynamicObject contractprocess : oldContractprocess) {
DynamicObject newObj = new DynamicObject(newContractprocess.getDynamicObjectType());
DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(contractprocess.getLong(2), "ec_ecbd_pro_cbs");
newObj.set("FBasedataId",dynamicObject1);
newContractprocess.add(newObj);
}
revisonContract.set("zcgj_contractprocess", newContractprocess);
revisonContract.set("zcgj_hshtdj", contract.get("zcgj_hshtdj"));
revisonContract.set("zcgj_bhshtdj", contract.get("zcgj_bhshtdj"));
revisonContract.set("zcgj_originaloftaxamount", contract.get("originaloftaxamount"));
revisonContract.set("zcgj_originalamount", contract.get("originalamount"));
revisonContract.set("zcgj_taxamount", contract.get("taxamount"));
}
SaveServiceHelper.save(new DynamicObject[]{revisonContract});
}
}
}
}
}
private void updateHeadFields(DynamicObject obj, DynamicObject contract, boolean isOutContract) {
contract.set("zcgj_startdate", obj.get("zcgj_startdate"));
contract.set("zcgj_enddate", obj.get("zcgj_enddate"));
contract.set("zcgj_cooperatemode", obj.get("zcgj_cooperatemode"));
contract.set("zcgj_jnjw", obj.get("zcgj_jnjw"));
contract.set("zcgj_customerclass", obj.get("zcgj_customerclass"));
contract.set("project", obj.get("zcgj_project"));
contract.set("zcgj_settlementdeadline", obj.get("zcgj_settlementdeadline"));
contract.set("zcgj_paymode", obj.get("zcgj_paymode"));
contract.set("zcgj_guaranteemethod", obj.get("zcgj_guaranteemethod"));
contract.set("zcgj_priceadjustment", obj.get("zcgj_priceadjustment"));
contract.set("zcgj_guaramount", obj.get("zcgj_guaramount"));
contract.set("zcgj_guaranteeyear", obj.get("zcgj_guaranteeyear"));
//contract.set("zcgj_attachmentpanel", obj.get("zcgj_attachmentpanel"));
contract.set("zcgj_jtnw", obj.get("zcgj_jtnw"));
if (isOutContract) {
} else {
contract.set("zcgj_belongingsector", obj.get("zcgj_belongingsector"));
contract.set("zcgj_sngl", obj.get("zcgj_sngl"));
contract.set("zcgj_follow", obj.get("zcgj_follow"));
contract.set("zcgj_bnyjhshte", obj.get("zcgj_bnyjhshte"));
contract.set("zcgj_bnyjbhshte", obj.get("zcgj_bnyjbhshte"));
contract.set("zcgj_bnyjse", obj.get("zcgj_bnyjse"));
contract.set("zcgj_pjnhhshte", obj.get("zcgj_pjnhhshte"));
contract.set("zcgj_pjnhbhshte", obj.get("zcgj_pjnhbhshte"));
contract.set("zcgj_pjnhse", obj.get("zcgj_pjnhse"));
contract.set("zcgj_sjcn", obj.get("zcgj_sjcn"));
contract.set("zcgj_yjbnyxcn", obj.get("zcgj_yjbnyxcn"));
contract.set("zcgj_contractprocess", obj.get("zcgj_contractprocess"));
contract.set("zcgj_hshtdj", obj.get("zcgj_hshtdj"));
contract.set("zcgj_bhshtdj", obj.get("zcgj_bhshtdj"));
contract.set("zcgj_originaloftaxamount", obj.get("zcgj_originaloftaxamount"));
contract.set("zcgj_originalamount", obj.get("zcgj_originalamount"));
contract.set("zcgj_taxamount", obj.get("zcgj_taxamount"));
}
}
/**
* 将url关联的文件服务器文件存储成临时文件
* 未保存状态下单据的附件必须是临时文件
* @return
*/
private String saveAsTempFile(Map<String, Object> att ) {
AttachmentDto attachmentDto = AttachmentServiceHelper.getAttachmentInfoByAttPk(att.get("attPkId"));
String fileUrl = attachmentDto.getResourcePath();
String filename = attachmentDto.getFilename();
ByteArrayOutputStream out = new ByteArrayOutputStream();
FileServiceFactory.getAttachmentFileService().download(fileUrl,out,null);
InputStream inputStream = new ByteArrayInputStream(out.toByteArray());
//保存文件流返回
String tempUrl = tempFileCache.saveAsUrl(filename, inputStream, 2 * 60 * 60);
String address = RequestContext.get().getClientFullContextPath();
if (!address.endsWith("/")) {
address = address + "/";
}
tempUrl = address + tempUrl;
return tempUrl;
}
}

View File

@ -0,0 +1,314 @@
package zcgj.zcdev.zcdev.pr.plugin.operate;
import kd.bos.cache.CacheFactory;
import kd.bos.cache.TempFileCache;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.resource.ResManager;
import kd.bos.entity.EntityMetadataCache;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.args.BeforeOperationArgs;
import kd.bos.fileservice.FileServiceFactory;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.AttachmentDto;
import kd.bos.servicehelper.AttachmentServiceHelper;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Map;
public class ContractRevisionOp extends AbstractOperationServicePlugIn {
private static final TempFileCache tempFileCache = CacheFactory.getCommonCacheFactory().getTempFileCache();
public void onPreparePropertys(PreparePropertysEventArgs e) {
e.getFieldKeys().add("contract");
e.getFieldKeys().add("contractname");
e.getFieldKeys().add("contractno");
e.getFieldKeys().add("payrate");
e.getFieldKeys().add("paydirection");
e.getFieldKeys().add("incontpayplanentry");
e.getFieldKeys().add("incometype");
e.getFieldKeys().add("incomemethod");
e.getFieldKeys().add("incomepercent");
e.getFieldKeys().add("incomeamount");
e.getFieldKeys().add("planincometime");
e.getFieldKeys().add("incomedescription");
e.getFieldKeys().add("riskentry");
e.getFieldKeys().add("riskname");
e.getFieldKeys().add("risktype");
e.getFieldKeys().add("measures");
e.getFieldKeys().add("riskdesc");
e.getFieldKeys().add("islegalrisk");
e.getFieldKeys().add("outcontpayplanentry");
e.getFieldKeys().add("paytype");
e.getFieldKeys().add("paymethod");
e.getFieldKeys().add("payamount");
e.getFieldKeys().add("paypercent");
e.getFieldKeys().add("planpaytime");
e.getFieldKeys().add("paydescription");
e.getFieldKeys().add("insourceid");
e.getFieldKeys().add("paysourceid");
e.getFieldKeys().add("risksourceid");
e.getFieldKeys().add("versionnumber");
e.getFieldKeys().add("propname");
e.getFieldKeys().add("value");
e.getFieldKeys().add("fieldname");
e.getFieldKeys().add("specsourceid");
e.getFieldKeys().add("contracttype");
e.getFieldKeys().add("signdate");
e.getFieldKeys().add("payrate");
e.getFieldKeys().add("description");
e.getFieldKeys().add("incontract");
e.getFieldKeys().add("bizstatus");
e.getFieldKeys().add("isincomebytasknode");
e.getFieldKeys().add("ispaybytasknode");
e.getFieldKeys().add("incomenode");
e.getFieldKeys().add("totalincomepercent");
e.getFieldKeys().add("paynode");
e.getFieldKeys().add("paynodetext");
e.getFieldKeys().add("nodedate");
e.getFieldKeys().add("isreltask");
e.getFieldKeys().add("totalpaypercent");
e.getFieldKeys().add("ispayentry");
e.getFieldKeys().add("iscontrolrate");
e.getFieldKeys().add("changerate");
e.getFieldKeys().add("visarate");
e.getFieldKeys().add("claimrate");
e.getFieldKeys().add("performrate");
e.getFieldKeys().add("settlemethod");
e.getFieldKeys().add("ispaybymonth");
e.getFieldKeys().add("isdeduction");
e.getFieldKeys().add("zcgj_jnjw");
e.getFieldKeys().add("zcgj_startdate");
e.getFieldKeys().add("zcgj_enddate");
e.getFieldKeys().add("zcgj_cooperatemode");
e.getFieldKeys().add("zcgj_jnjw");
e.getFieldKeys().add("zcgj_customerclass");
e.getFieldKeys().add("zcgj_project");
e.getFieldKeys().add("zcgj_settlementdeadline");
e.getFieldKeys().add("zcgj_paymode");
e.getFieldKeys().add("zcgj_guaranteemethod");
e.getFieldKeys().add("zcgj_priceadjustment");
e.getFieldKeys().add("zcgj_jtnw");
e.getFieldKeys().add("zcgj_belongingsector");
e.getFieldKeys().add("zcgj_sngl");
e.getFieldKeys().add("zcgj_follow");
e.getFieldKeys().add("zcgj_guaramount");
e.getFieldKeys().add("zcgj_guaranteeyear");
e.getFieldKeys().add("zcgj_bnyjhshte");
e.getFieldKeys().add("zcgj_bnyjbhshte");
e.getFieldKeys().add("zcgj_bnyjse");
e.getFieldKeys().add("zcgj_pjnhhshte");
e.getFieldKeys().add("zcgj_pjnhbhshte");
e.getFieldKeys().add("zcgj_pjnhse");
e.getFieldKeys().add("zcgj_sjcn");
e.getFieldKeys().add("zcgj_yjbnyxcn");
e.getFieldKeys().add("zcgj_originaloftaxamount");
e.getFieldKeys().add("zcgj_originalamount");
e.getFieldKeys().add("zcgj_taxamount");
e.getFieldKeys().add("zcgj_contractprocess");
e.getFieldKeys().add("zcgj_hshtdj");
e.getFieldKeys().add("zcgj_bhshtdj");
//e.getFieldKeys().add("zcgj_attachmentpanel");
}
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
String operationKey = e.getOperationKey();
DynamicObject[] dataEntities = e.getDataEntities();
DynamicObject obj;
DynamicObject firstEdit;
String formatText;
switch (operationKey) {
case "audit":
ArrayList<DynamicObject> outContList = new ArrayList();
ArrayList<DynamicObject> inContList = new ArrayList();
DynamicObject[] var22 = dataEntities;
int var24 = dataEntities.length;
for(int var26 = 0; var26 < var24; ++var26) {
obj = var22[var26];
DynamicObject contract;
boolean isOutContract = false;
if ("out".equals(obj.getDynamicObject("contract").getString("paydirection"))) {
contract = BusinessDataServiceHelper.loadSingle(obj.getDynamicObject("contract").getPkValue(), "ec_out_contract");
this.updateHeadFields(obj, contract, true);
outContList.add(contract);
isOutContract = true;
} else {
if (!"in".equals(obj.getDynamicObject("contract").getString("paydirection"))) {
formatText = String.format(ResManager.loadKDString("单据编号:%s关联的修订合同既不是支出合同也不是收入合同类型无法审核。", "ContractRevisionOp_0", "ec-contract-opplugin", new Object[0]), obj.getString("billno"));
e.setCancelMessage(formatText);
e.cancel = true;
break;
}
contract = BusinessDataServiceHelper.loadSingle(obj.getDynamicObject("contract").getPkValue(), "ec_in_contract");
this.updateHeadFields(obj, contract, false);
inContList.add(contract);
}
//如果版本号是2的情况下把版本号1的字段补充完整
BigDecimal versionNumber = obj.getBigDecimal("versionnumber");
if (new BigDecimal(2).compareTo(versionNumber) == 0){
BigDecimal preVersionNumber = versionNumber.subtract(BigDecimal.ONE);
DynamicObject contractObj = obj.getDynamicObject("contract");
long contractId = contractObj.getLong("id");
QFilter verionFilter = new QFilter("versionnumber", "=", preVersionNumber);
QFilter contractFilter = new QFilter("contract", "=", contractId);
String selectProperties = "id,zcgj_startdate,zcgj_enddate,zcgj_cooperatemode,zcgj_jnjw,zcgj_customerclass,zcgj_project,zcgj_settlementdeadline,zcgj_paymode," +
"zcgj_guaranteemethod,zcgj_priceadjustment,zcgj_originaloftaxamount,zcgj_originalamount,zcgj_taxamount,zcgj_jtnw,zcgj_belongingsector,zcgj_sngl,zcgj_follow,zcgj_guaranteeyear,zcgj_guaramount,";
selectProperties+=",zcgj_bnyjhshte,zcgj_bnyjbhshte,zcgj_bnyjse,zcgj_pjnhhshte,zcgj_pjnhbhshte,zcgj_pjnhse,zcgj_sjcn,zcgj_yjbnyxcn,zcgj_contractprocess,zcgj_hshtdj,zcgj_bhshtdj";
DynamicObject revisonContract = BusinessDataServiceHelper.loadSingle("ec_contract_revision", selectProperties, new QFilter[]{verionFilter, contractFilter});
SaveServiceHelper.save(new DynamicObject[]{obj});
//DynamicObject revisonContract
// =BusinessDataServiceHelper.newDynamicObject("ec_contract_revision");
if (revisonContract != null) {
DynamicObject revisonContractBak = BusinessDataServiceHelper.loadSingle("zcgj_ec_contract_rev_temp", selectProperties, new QFilter[]{verionFilter, contractFilter});
if(revisonContractBak!=null){
revisonContract.set("zcgj_startdate", revisonContractBak.get("zcgj_startdate"));
revisonContract.set("zcgj_enddate", revisonContractBak.get("zcgj_enddate"));
revisonContract.set("zcgj_cooperatemode", revisonContractBak.get("zcgj_cooperatemode"));
revisonContract.set("zcgj_jnjw", revisonContractBak.get("zcgj_jnjw"));
revisonContract.set("zcgj_customerclass", revisonContractBak.get("zcgj_customerclass"));
revisonContract.set("zcgj_project", revisonContractBak.get("zcgj_project"));
revisonContract.set("zcgj_settlementdeadline", revisonContractBak.get("zcgj_settlementdeadline"));
revisonContract.set("zcgj_paymode", revisonContractBak.get("zcgj_paymode"));
revisonContract.set("zcgj_guaranteemethod", revisonContractBak.get("zcgj_guaranteemethod"));
revisonContract.set("zcgj_priceadjustment", revisonContractBak.get("zcgj_priceadjustment"));
revisonContract.set("zcgj_guaranteeyear", revisonContractBak.get("zcgj_guaranteeyear"));
revisonContract.set("zcgj_guaramount", revisonContractBak.get("zcgj_guaramount"));
// revisonContract.set("zcgj_attachmentpanel", contract.get("zcgj_attachmentpanel"));
revisonContract.set("zcgj_jtnw", revisonContractBak.get("zcgj_jtnw"));
if (isOutContract) {
} else {
revisonContract.set("zcgj_belongingsector", revisonContractBak.get("zcgj_belongingsector"));
revisonContract.set("zcgj_sngl", revisonContractBak.get("zcgj_sngl"));
revisonContract.set("zcgj_follow", revisonContractBak.get("zcgj_follow"));
revisonContract.set("zcgj_bnyjhshte", revisonContractBak.get("zcgj_bnyjhshte"));
revisonContract.set("zcgj_bnyjbhshte", revisonContractBak.get("zcgj_bnyjbhshte"));
revisonContract.set("zcgj_bnyjse", revisonContractBak.get("zcgj_bnyjse"));
revisonContract.set("zcgj_pjnhhshte", revisonContractBak.get("zcgj_pjnhhshte"));
revisonContract.set("zcgj_pjnhbhshte", revisonContractBak.get("zcgj_pjnhbhshte"));
revisonContract.set("zcgj_pjnhse", revisonContractBak.get("zcgj_pjnhse"));
revisonContract.set("zcgj_sjcn", revisonContractBak.get("zcgj_sjcn"));
revisonContract.set("zcgj_yjbnyxcn", revisonContractBak.get("zcgj_yjbnyxcn"));
//revisonContract.set("zcgj_contractprocess", revisonContractBak.get("zcgj_contractprocess"));
DynamicObjectCollection oldContractprocess = revisonContractBak.getDynamicObjectCollection("zcgj_contractprocess");
DynamicObjectCollection newContractprocess = revisonContract.getDynamicObjectCollection("zcgj_contractprocess");
for (DynamicObject contractprocess : oldContractprocess) {
DynamicObject newObj = new DynamicObject(newContractprocess.getDynamicObjectType());
DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(contractprocess.getLong(2), "ec_ecbd_pro_cbs");
newObj.set("FBasedataId",dynamicObject1);
newContractprocess.add(newObj);
}
revisonContract.set("zcgj_contractprocess", newContractprocess);
revisonContract.set("zcgj_hshtdj", revisonContractBak.get("zcgj_hshtdj"));
revisonContract.set("zcgj_bhshtdj", revisonContractBak.get("zcgj_bhshtdj"));
revisonContract.set("zcgj_originaloftaxamount", revisonContractBak.get("zcgj_originaloftaxamount"));
revisonContract.set("zcgj_originalamount", revisonContractBak.get("zcgj_originalamount"));
revisonContract.set("zcgj_taxamount", revisonContractBak.get("zcgj_taxamount"));
}
SaveServiceHelper.save(new DynamicObject[]{revisonContract});
}
}
}
}
SaveServiceHelper.save(EntityMetadataCache.getDataEntityType("ec_out_contract"), outContList.toArray());
SaveServiceHelper.save(EntityMetadataCache.getDataEntityType("ec_in_contract"), inContList.toArray());
}
}
private void updateHeadFields(DynamicObject obj, DynamicObject contract, boolean isOutContract) {
contract.set("zcgj_startdate", obj.get("zcgj_startdate"));
contract.set("zcgj_enddate", obj.get("zcgj_enddate"));
contract.set("zcgj_jnjw", obj.get("zcgj_jnjw"));
contract.set("zcgj_customerclass", obj.get("zcgj_customerclass"));
contract.set("project", obj.get("zcgj_project"));
contract.set("zcgj_settlementdeadline", obj.get("zcgj_settlementdeadline"));
contract.set("zcgj_paymode", obj.get("zcgj_paymode"));
contract.set("zcgj_guaranteemethod", obj.get("zcgj_guaranteemethod"));
contract.set("zcgj_priceadjustment", obj.get("zcgj_priceadjustment"));
contract.set("zcgj_guaramount", obj.get("zcgj_guaramount"));
contract.set("zcgj_guaranteeyear", obj.get("zcgj_guaranteeyear"));
//contract.set("zcgj_attachmentpanel", obj.get("zcgj_attachmentpanel"));
contract.set("zcgj_jtnw", obj.get("zcgj_jtnw"));
if (isOutContract) {
contract.set("zcgj_cooperatemode", obj.get("zcgj_cooperatemode"));
} else {
contract.set("zcgj_cooperationmode", obj.get("zcgj_cooperatemode"));
contract.set("zcgj_belongingsector", obj.get("zcgj_belongingsector"));
contract.set("zcgj_sngl", obj.get("zcgj_sngl"));
contract.set("zcgj_follow", obj.get("zcgj_follow"));
contract.set("zcgj_bnyjhshte", obj.get("zcgj_bnyjhshte"));
contract.set("zcgj_bnyjbhshte", obj.get("zcgj_bnyjbhshte"));
contract.set("zcgj_bnyjse", obj.get("zcgj_bnyjse"));
contract.set("zcgj_pjnhhshte", obj.get("zcgj_pjnhhshte"));
contract.set("zcgj_pjnhbhshte", obj.get("zcgj_pjnhbhshte"));
contract.set("zcgj_pjnhse", obj.get("zcgj_pjnhse"));
contract.set("zcgj_sjcn", obj.get("zcgj_sjcn"));
contract.set("zcgj_yjbnyxcn", obj.get("zcgj_yjbnyxcn"));
DynamicObjectCollection oldContractprocess = obj.getDynamicObjectCollection("zcgj_contractprocess");
DynamicObjectCollection newContractprocess = contract.getDynamicObjectCollection("zcgj_contractprocess");
if(newContractprocess!=null){
newContractprocess.clear();
}
for (DynamicObject contractprocess : oldContractprocess) {
DynamicObject newObj = new DynamicObject(newContractprocess.getDynamicObjectType());
DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(contractprocess.getLong(2), "ec_ecbd_pro_cbs");
newObj.set("FBasedataId",dynamicObject1);
newContractprocess.add(newObj);
}
contract.set("zcgj_contractprocess", newContractprocess);
contract.set("zcgj_hshtdj", obj.get("zcgj_hshtdj"));
contract.set("zcgj_bhshtdj", obj.get("zcgj_bhshtdj"));
contract.set("originaloftaxamount", obj.get("zcgj_originaloftaxamount"));
contract.set("originalamount", obj.get("zcgj_originalamount"));
contract.set("taxamount", obj.get("zcgj_taxamount"));
}
}
/**
* 将url关联的文件服务器文件存储成临时文件
* 未保存状态下单据的附件必须是临时文件
* @return
*/
private String saveAsTempFile(Map<String, Object> att ) {
AttachmentDto attachmentDto = AttachmentServiceHelper.getAttachmentInfoByAttPk(att.get("attPkId"));
String fileUrl = attachmentDto.getResourcePath();
String filename = attachmentDto.getFilename();
ByteArrayOutputStream out = new ByteArrayOutputStream();
FileServiceFactory.getAttachmentFileService().download(fileUrl,out,null);
InputStream inputStream = new ByteArrayInputStream(out.toByteArray());
//保存文件流返回
String tempUrl = tempFileCache.saveAsUrl(filename, inputStream, 2 * 60 * 60);
String address = RequestContext.get().getClientFullContextPath();
if (!address.endsWith("/")) {
address = address + "/";
}
tempUrl = address + tempUrl;
return tempUrl;
}
}