【物料变更】处理变更内容
This commit is contained in:
parent
a3841451d2
commit
2d6d18e4d4
|
|
@ -37,6 +37,7 @@ public class MaterialBillPlugin extends AbstractBillPlugIn {
|
|||
if("submit".equals(operateKey)){
|
||||
//复制后修改数据在提交时记录修改的内容,如果修改内容为空,则不记录
|
||||
LinkedHashMap changeMap = new LinkedHashMap();
|
||||
StringBuilder changeContent = new StringBuilder();
|
||||
DynamicObject dataEntity = this.getModel().getDataEntity(true);
|
||||
String newName = dataEntity.getString("name");
|
||||
String srcNumber = null;
|
||||
|
|
@ -48,15 +49,20 @@ public class MaterialBillPlugin extends AbstractBillPlugIn {
|
|||
if(srcMaterialArr != null && srcMaterialArr.length > 0){
|
||||
DynamicObject srcMaterial = srcMaterialArr[0];
|
||||
srcMaterial = BusinessDataServiceHelper.loadSingle(srcMaterial.getPkValue(), "bd_material");
|
||||
|
||||
|
||||
//获取实体中所有变更的属性
|
||||
StringBuilder changeContent = new StringBuilder();
|
||||
|
||||
List<IDataEntityProperty> iDataEntityProperties = dataEntity.getDataEntityState().GetDirtyProperties();
|
||||
if(iDataEntityProperties.size()>0){
|
||||
for(IDataEntityProperty prop :iDataEntityProperties){
|
||||
String name = prop.getName();//字段标识
|
||||
String displayName = prop.getDisplayName().get("zh_CN");//字段名称
|
||||
if("name".equals(name) || "useorg".equals(name) || "modifytime".equals(name)){
|
||||
continue;
|
||||
}
|
||||
LocaleString displayNameLocaleStr = prop.getDisplayName();
|
||||
if(displayNameLocaleStr == null){
|
||||
continue;
|
||||
}
|
||||
String displayName = displayNameLocaleStr.get("zh_CN");//字段名称
|
||||
String propTypeName = prop.getPropertyType().getName();
|
||||
if("kd.bos.dataentity.entity.DynamicObject".equals(propTypeName)){
|
||||
DynamicObject dynamicObject = dataEntity.getDynamicObject(name);
|
||||
|
|
@ -69,12 +75,12 @@ public class MaterialBillPlugin extends AbstractBillPlugIn {
|
|||
changeContent.append("字段:"+displayName+"("+name+"),变更前:"+oldValue+",变更后:"+newValue+";");
|
||||
}
|
||||
}else{
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:null,变更后:"+newValue+";");
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:空,变更后:"+newValue+";");
|
||||
}
|
||||
}else{
|
||||
if(dynamicObject1 != null) {
|
||||
String oldValue = dynamicObject1.getString("name");
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:"+oldValue+",变更后:null;");
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:"+oldValue+",变更后:空;");
|
||||
}
|
||||
}
|
||||
}else if("java.util.Date".equals(propTypeName)){
|
||||
|
|
@ -86,11 +92,11 @@ public class MaterialBillPlugin extends AbstractBillPlugIn {
|
|||
changeContent.append("字段:"+displayName+"("+name+"),变更前:"+oldValue+",变更后:"+newValue+";");
|
||||
}
|
||||
}else{
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:null,变更后:"+newValue+";");
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:空,变更后:"+newValue+";");
|
||||
}
|
||||
}else{
|
||||
if(oldValue != null){
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:"+oldValue+",变更后:null;");
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:"+oldValue+",变更后:空;");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -115,11 +121,11 @@ public class MaterialBillPlugin extends AbstractBillPlugIn {
|
|||
changeContent.append("字段:"+displayName+"("+name+"),变更前:"+oldValue+",变更后:"+newValue+";");
|
||||
}
|
||||
}else{
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:null,变更后:"+newValue+";");
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:空,变更后:"+newValue+";");
|
||||
}
|
||||
}else {
|
||||
if(oldValue != null){
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:"+oldValue+",变更后:null;");
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:"+oldValue+",变更后:空;");
|
||||
}
|
||||
}
|
||||
}else if("boolean".equals(propTypeName)){
|
||||
|
|
@ -137,11 +143,11 @@ public class MaterialBillPlugin extends AbstractBillPlugIn {
|
|||
changeContent.append("字段:"+displayName+"("+name+"),变更前:"+oldValue+",变更后:"+newValue+";");
|
||||
}
|
||||
}else{
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:null,变更后:"+newValue+";");
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:空,变更后:"+newValue+";");
|
||||
}
|
||||
}else{
|
||||
if(StringUtils.isNotBlank(oldValue)) {
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:"+oldValue+",变更后:null;");
|
||||
changeContent.append("字段:"+displayName+"("+name+"),变更前:"+oldValue+",变更后:空;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -151,32 +157,40 @@ public class MaterialBillPlugin extends AbstractBillPlugIn {
|
|||
DynamicObjectCollection entryentity = dataEntity.getDynamicObjectCollection("entry_groupstandard");
|
||||
//获取单据体中已变更的属性
|
||||
for(int x = 0; x < entryentity.size(); x++){
|
||||
DynamicObject entry = entryentity.get(x);
|
||||
List<IDataEntityProperty> iDataEntityProperties1 = entryentity.get(x).getDataEntityState().GetDirtyProperties();
|
||||
for(IDataEntityProperty prop1 :iDataEntityProperties1){
|
||||
String name = prop1.getName();
|
||||
String propTypeName = prop1.getPropertyType().getName();
|
||||
// LocaleString displayName1 = prop1.getDisplayName();
|
||||
// changeMap.put("entry_groupstandard-"+(x+1)+":"+name,displayName1);
|
||||
// if("kd.bos.dataentity.entity.DynamicObject".equals(propTypeName)){
|
||||
// DynamicObject dynamicObject = dataEntity.getDynamicObject(name);
|
||||
// }else if("java.util.Date".equals(propTypeName)){
|
||||
// Date date = dataEntity.getDate(name);
|
||||
// }else if("java.lang.Integer".equals(propTypeName)){
|
||||
// int anInt = dataEntity.getInt(name);
|
||||
// }else if("java.lang.Long".equals(propTypeName)){
|
||||
// Long aLong = dataEntity.getLong(name);
|
||||
// }else if("java.math.BigDecimal".equals(propTypeName)){
|
||||
// BigDecimal bigDecimal = dataEntity.getBigDecimal(name);
|
||||
// }else if("boolean".equals(propTypeName)){
|
||||
// boolean aBoolean = dataEntity.getBoolean(name);
|
||||
// }else {
|
||||
// String string = dataEntity.getString(name);
|
||||
// }
|
||||
for(IDataEntityProperty prop :iDataEntityProperties1){
|
||||
String name = prop.getName();
|
||||
String propTypeName = prop.getPropertyType().getName();
|
||||
LocaleString displayNameLocaleStr = prop.getDisplayName();
|
||||
if(displayNameLocaleStr == null){
|
||||
continue;
|
||||
}
|
||||
LocaleString displayName1 = prop.getDisplayName();
|
||||
changeMap.put("entry_groupstandard-"+(x+1)+":"+name,displayName1);
|
||||
if("kd.bos.dataentity.entity.DynamicObject".equals(propTypeName)){
|
||||
DynamicObject dynamicObject = entry.getDynamicObject(name);
|
||||
}else if("java.util.Date".equals(propTypeName)){
|
||||
Date date = entry.getDate(name);
|
||||
}else if("java.lang.Integer".equals(propTypeName)){
|
||||
int anInt = entry.getInt(name);
|
||||
}else if("java.lang.Long".equals(propTypeName)){
|
||||
Long aLong = entry.getLong(name);
|
||||
}else if("java.math.BigDecimal".equals(propTypeName)){
|
||||
BigDecimal bigDecimal = entry.getBigDecimal(name);
|
||||
}else if("boolean".equals(propTypeName)){
|
||||
boolean aBoolean = entry.getBoolean(name);
|
||||
}else {
|
||||
String string = entry.getString(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("单据已变更的数据是:"+changeMap);
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(changeContent.toString())){
|
||||
this.getModel().setValue("tqq9_changeinfo_tag", changeContent);
|
||||
}
|
||||
}
|
||||
if("copy".equals(operateKey)) {
|
||||
super.beforeDoOperation(args);
|
||||
|
|
@ -190,13 +204,13 @@ public class MaterialBillPlugin extends AbstractBillPlugIn {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void afterCopyData(EventObject e) {
|
||||
super.afterCopyData(e);
|
||||
String copySrcBillNo = this.getView().getFormShowParameter().getCustomParam("copySrcBillNo");
|
||||
String copySrcBillNo = this.getView().getFormShowParameter().getCustomParam("copySrcBillName");
|
||||
DynamicObject dataEntity = this.getModel().getDataEntity(true);
|
||||
dataEntity.set("name", copySrcBillNo + "_copy");
|
||||
dataEntity.set("tqq9_srcnumber", copySrcBillNo + "_copy");
|
||||
this.getView().invokeOperation("save");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,38 @@
|
|||
package tqq9.lc123.cloud.app.plugin.form.sys;
|
||||
|
||||
import kd.bos.bill.BillShowParameter;
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.entity.LocaleString;
|
||||
import kd.bos.dataentity.metadata.IDataEntityProperty;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.EntityMetadataCache;
|
||||
import kd.bos.entity.datamodel.ListSelectedRow;
|
||||
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
||||
import kd.bos.entity.operate.result.IOperateInfo;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.form.control.events.ItemClickEvent;
|
||||
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||
import kd.bos.form.operate.FormOperate;
|
||||
import kd.bos.list.IListView;
|
||||
import kd.bos.list.events.BeforeShowBillFormEvent;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
import kd.bos.mvc.list.ListView;
|
||||
import kd.bos.orm.ORM;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.fi.cas.helper.OperateServiceHelper;
|
||||
import kd.imc.bdm.common.constant.BotpCallBackLogConstant;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import tqq9.lc123.cloud.app.api.utils.Constants;
|
||||
|
||||
import javax.swing.text.html.Option;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 物料列表界面插件
|
||||
|
|
@ -29,11 +40,8 @@ import java.util.List;
|
|||
public class MaterialListPlugin extends AbstractListPlugin implements Plugin {
|
||||
|
||||
|
||||
private static String BD_MATERIALSALINFO = "bd_materialsalinfo";//物料销售信息
|
||||
private static String BD_MATERIALSALINFO = "bd_materialsalinfo";//物料销售信息H
|
||||
private static String BD_MATERIALPURCHASEINFO = "bd_materialpurchaseinfo";//物料采购信息
|
||||
private static String SH = "SHLC";
|
||||
private static String BJ = "BJLC";
|
||||
private static String GZ = "GZLC";
|
||||
|
||||
@Override
|
||||
public void itemClick(ItemClickEvent evt) {
|
||||
|
|
@ -186,4 +194,20 @@ public class MaterialListPlugin extends AbstractListPlugin implements Plugin {
|
|||
// 将城市列表重新组合为字符串,城市间以逗号分隔
|
||||
return "," + String.join(",", cities) + ",";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void beforeShowBill(BeforeShowBillFormEvent e) {
|
||||
super.beforeShowBill(e);
|
||||
Object focusRowPkId = ((ListView) this.getView()).getFocusRowPkId();
|
||||
if(focusRowPkId != null){
|
||||
DynamicObject bd_material = BusinessDataServiceHelper.loadSingle(focusRowPkId, "bd_material");
|
||||
BillShowParameter parameter = e.getParameter();
|
||||
parameter.setCustomParam("copySrcBillName",bd_material.getString("name"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue