Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
xiaoshi 2024-12-19 16:00:06 +08:00
commit ecbd06b147
3 changed files with 175 additions and 120 deletions

View File

@ -0,0 +1,86 @@
package zcgj.zcdev.zcdev.fs.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.entity.operate.Submit;
import kd.bos.form.FormShowParameter;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.field.BasedataEdit;
import kd.bos.form.field.events.BeforeF7SelectEvent;
import kd.bos.form.field.events.BeforeF7SelectListener;
import kd.bos.list.ListShowParameter;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP;
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 OverseaStaysLimitPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener {
private static final Log log = LogFactory.getLog(OverseaStaysLimitPlugin.class);
//开发商标识
private static final String prefix ="zcgj";
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
BasedataEdit fieldEdit = this.getView().getControl("zcgj_district_f7");
fieldEdit.addBeforeF7SelectListener(this);
}
@Override
public void beforeF7Select(BeforeF7SelectEvent f7) {
String name = f7.getProperty().getName();
if (name.equals("zcgj_district_f7")){
DynamicObject zcgjCountry = (DynamicObject)this.getModel().getValue("zcgj_country");
long countryId = zcgjCountry.getLong("id");
ListShowParameter showParameter = (ListShowParameter) f7.getFormShowParameter();
showParameter.getListFilterParameter().getQFilters().add(new QFilter("country", QCP.equals,countryId));
}
}
/*@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String name = e.getProperty().getName();
if("zcgj_district_f7".equals(name)){
IDataModel model = this.getModel();
ChangeData[] changeSet = e.getChangeSet();
DynamicObject newValue = (DynamicObject)changeSet[0].getNewValue();
long id = newValue.getLong("id");
//获取地域详细信息
//bd_admindivision
DynamicObject cityObj = BusinessDataServiceHelper.loadSingle("bd_admindivision", "country",
new QFilter[]{new QFilter("id", QCP.equals,id)});
if(cityObj!=null){
DynamicObject country = cityObj.getDynamicObject("country");
long countryId = country.getLong("id");
//获取所属国家
//bd_country
DynamicObject countryObj = BusinessDataServiceHelper.loadSingle("bd_country", "number,name,twocountrycode",
new QFilter[]{new QFilter("id", QCP.equals,countryId)});
if(countryObj!=null){
String twocountrycode = countryObj.getString("twocountrycode");
String countname = countryObj.getString("name");
if(!"CN".equals(twocountrycode)){
//保存国家id
// this.getModel().setValue("zcgj_countryid",countryId);
}
}
}
}
}*/
}

View File

@ -0,0 +1,89 @@
package zcgj.zcdev.zcdev.fs.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map;
/**
* 差旅报销单国外住宿标准提醒插件
*/
public class TripreimbursebillAbroadAlertedPlugin extends AbstractBillPlugIn implements Plugin {
//private static final Log log = LogFactory.getLog(TripreimbursebillPlugin.class);
//开发商标识
private static final String prefix ="zcgj";
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String name = e.getProperty().getName();
//目的地变更
if("to".equals(name)){
IDataModel model = this.getModel();
ChangeData[] changeSet = e.getChangeSet();
DynamicObject newValue = (DynamicObject)changeSet[0].getNewValue();
long id = newValue.getLong("id");
//获取地域详细信息
//bd_admindivision
DynamicObject cityObj = BusinessDataServiceHelper.loadSingle("bd_admindivision", "country",
new QFilter[]{new QFilter("id", QCP.equals,id)});
if(cityObj!=null){
DynamicObject country = cityObj.getDynamicObject("country");
long countryId = country.getLong("id");
//获取所属国家
//bd_country
DynamicObject countryObj = BusinessDataServiceHelper.loadSingle("bd_country", "number,name,twocountrycode",
new QFilter[]{new QFilter("id", QCP.equals,countryId)});
if(countryObj!=null){
String twocountrycode = countryObj.getString("twocountrycode");
String countname = countryObj.getString("name");
if(!"CN".equals(twocountrycode)){
DynamicObject[] load = BusinessDataServiceHelper.load("zcgj_oversea_stays_limit",
"zcgj_district_f7,zcgj_country,zcgj_currency,zcgj_stays_criteria,zcgj_rate"
, new QFilter[]{new QFilter("zcgj_country", QCP.equals, countryId)});
BigDecimal otherAmount = BigDecimal.ZERO;
BigDecimal cirtyAmount = BigDecimal.ZERO;
String currencyName = "";
String currencySign = "";
if(load == null || load.length<1){
// this.getView().showTipNotification("当前出差国家为:"+countname+",未设置住宿标准!");
}else{
Map<String,Object> map = new HashMap<>();
for (DynamicObject dynamicObject : load) {
DynamicObject zcgjCountry = dynamicObject.getDynamicObject("zcgj_country");
DynamicObject zcgjDistrictF7 = dynamicObject.getDynamicObject("zcgj_district_f7");
DynamicObject zcgjCurrency = dynamicObject.getDynamicObject("zcgj_currency");
BigDecimal zcgjStaysCriteria = dynamicObject.getBigDecimal("zcgj_stays_criteria");
BigDecimal zcgjRate = dynamicObject.getBigDecimal("zcgj_rate");
currencyName = zcgjCurrency.getString("name");
if(zcgjDistrictF7 ==null ){
otherAmount = zcgjStaysCriteria.multiply(zcgjRate);
}else if(countryId == zcgjDistrictF7.getLong("id")){
cirtyAmount = zcgjStaysCriteria.multiply(zcgjRate);
}
}
if(!BigDecimal.ZERO.equals(otherAmount) && BigDecimal.ZERO.equals(cirtyAmount) ){
//this.getView().showTipNotification("当前出差国家为:"+countname+",币别为:"+currencyName+",住宿标准为:"+otherAmount.setScale(2, RoundingMode.HALF_UP));
this.getView().showTipNotification("当前出差国家为:"+countname+",住宿标准为(人民币)"+otherAmount.setScale(2, RoundingMode.HALF_UP)+"");
}else if(BigDecimal.ZERO.equals(otherAmount) && !BigDecimal.ZERO.equals(cirtyAmount) ){
//this.getView().showTipNotification("当前出差国家为:"+countname+",币别为:"+currencyName+",住宿标准为:"+cirtyAmount.setScale(2, RoundingMode.HALF_UP));
this.getView().showTipNotification("当前出差国家为:"+countname+",住宿标准为(人民币)"+cirtyAmount.setScale(2, RoundingMode.HALF_UP)+"");
}
}
}
}
}
}
}
}

View File

@ -1,120 +0,0 @@
package zcgj.zcdev.zcdev.fs.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.entity.operate.Submit;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.sdk.plugin.Plugin;
import java.math.BigDecimal;
/**
* 差旅报销单插件
*/
@Deprecated
public class TripreimbursebillPlugin extends AbstractBillPlugIn implements Plugin {
private static final Log log = LogFactory.getLog(TripreimbursebillPlugin.class);
//开发商标识
private static final String prefix ="zcgj";
@Override
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
if((args.getSource() instanceof Submit) ){
Submit source = (Submit)args.getSource();
if(source.getOperateKey().equals("submit") ){
//highseasontripstdshow
//提交时校验附件是否必填
IDataModel model = this.getModel();
String zsKey = String.valueOf(model.getValue("zcgj_zs_key"));
boolean isfloating20 = Boolean.parseBoolean(model.getValue("zcgj_isfloating20")+"");
//获取当前费用为住宿的
DynamicObjectCollection tripentryCollection = model.getEntryEntity("tripentry");
//tripentry.get(0).getDynamicObjectCollection("entryentity").get(2).getDynamicObject("expenseitem").getString("number");
for (DynamicObject tripentry : tripentryCollection) {
DynamicObjectCollection entryentityCollection = tripentry.getDynamicObjectCollection("entryentity");
for (DynamicObject entryentity : entryentityCollection) {
DynamicObject expenseitem = entryentity.getDynamicObject("expenseitem");
String zsNumber = expenseitem.getString("number");
if(zsKey.equals(zsNumber)){
BigDecimal orientryamount = entryentity.getBigDecimal("orientryamount");//报销金额
BigDecimal tripstandardamount = entryentity.getBigDecimal("tripstandardamount");//差旅标准金额
Integer caldaycount = entryentity.getInt("caldaycount");//标准天数
//如果选择了上浮20%则按照上浮20%进行判断
if(isfloating20){
//BigDecimal multiply = tripstandardamount.multiply(new BigDecimal("1.2")).multiply(new BigDecimal(caldaycount));
BigDecimal multiply = tripstandardamount.multiply(new BigDecimal(caldaycount));
//-1表示小于0是等于1是大于
if(orientryamount.compareTo(multiply) > 0){
this.getView().showTipNotification("报销住宿超出标准上浮20%");
//取消提交操作
args.setCancel(true);
}
}else{
BigDecimal multiply = tripstandardamount.multiply(new BigDecimal(caldaycount));
//-1表示小于0是等于1是大于
if(orientryamount.compareTo(multiply) > 0){
this.getView().showTipNotification("报销住宿超出标准!");
//取消提交操作
args.setCancel(true);
}
}
}
}
}
//获取当前差旅标准
/* Object value = model.getValue("tripstandardamount");
this.getView().showTipNotification(value+"");*/
}
}
}
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String name = e.getProperty().getName();
/*if(name.equals("zcgj_isfloating20")){
IDataModel model = this.getModel();
ChangeData[] changeSet = e.getChangeSet();
Boolean isfloating20 = (Boolean)changeSet[0].getNewValue();
String zsKey = String.valueOf(model.getValue("zcgj_zs_key"));
//获取当前费用为住宿的
DynamicObjectCollection tripentryCollection = model.getEntryEntity("tripentry");
//tripentry.get(0).getDynamicObjectCollection("entryentity").get(2).getDynamicObject("expenseitem").getString("number");
for (DynamicObject tripentry : tripentryCollection) {
DynamicObjectCollection entryentityCollection = tripentry.getDynamicObjectCollection("entryentity");
for (DynamicObject entryentity : entryentityCollection) {
DynamicObject expenseitem = entryentity.getDynamicObject("expenseitem");
String zsNumber = expenseitem.getString("number");
if(zsKey.equals(zsNumber)){
BigDecimal orientryamount = entryentity.getBigDecimal("orientryamount");//报销金额
BigDecimal tripstandardamount = entryentity.getBigDecimal("tripstandardamount");//差旅标准金额
BigDecimal tripstandardamountOld = tripstandardamount;//差旅标准金额
Integer caldaycount = entryentity.getInt("caldaycount");//标准天数
//如果选择了上浮20%则按照上浮20%进行判断
if(isfloating20){
BigDecimal multiply = tripstandardamount.multiply(new BigDecimal("1.2"));
entryentity.set("tripstandardamount",multiply);
}else{
entryentity.set("tripstandardamount",tripstandardamountOld);
}
this.getView().updateView("entryentity");
//this.getView().showTipNotification(tripstandardamount+" "+tripstandardamountOld);
}
}
}
}*/
}
}