采购计划F7超额过滤
This commit is contained in:
parent
2cbc4b6036
commit
486001ab85
|
@ -29,15 +29,16 @@ public class PurDemandListPlugin extends AbstractListPlugin {
|
|||
public void setFilter(SetFilterEvent e) {
|
||||
super.setFilter(e);
|
||||
|
||||
e.getQFilters().clear();
|
||||
|
||||
|
||||
IFormView parentView = this.getView().getParentView();
|
||||
IDataModel model = parentView.getModel();
|
||||
DynamicObject dataEntity = model.getDataEntity();
|
||||
IDataEntityType dataEntityType = dataEntity.getDataEntityType();
|
||||
String name = dataEntityType.getName();
|
||||
//立项||费用登记
|
||||
if ("rebm_project".equals(name) || "recon_connotextbill".equals(name) ||"rebm_purplan".equals(name)) {
|
||||
//立项||采购计划
|
||||
if ("rebm_project".equals(name) ||"rebm_purplan".equals(name)) {
|
||||
e.getQFilters().clear();
|
||||
DynamicObject org = dataEntity.getDynamicObject("org");
|
||||
if (null != org) {
|
||||
List<QFilter> qFilters = e.getQFilters();
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package shkd.repc.recon.formplugin;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.form.field.BasedataEdit;
|
||||
import kd.bos.form.field.RefBillEdit;
|
||||
import kd.bos.form.field.events.BeforeF7SelectEvent;
|
||||
import kd.bos.form.field.events.BeforeF7SelectListener;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
import kd.bos.list.ListShowParameter;
|
||||
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.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 动态表单插件
|
||||
* 【费用登记】-
|
||||
*/
|
||||
public class ConNoTextBillFromPlugin extends AbstractFormPlugin implements Plugin, BeforeF7SelectListener {
|
||||
|
||||
|
||||
@Override
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
RefBillEdit bEdit = this.getView().getControl("qeug_refbillfield");
|
||||
bEdit.addBeforeF7SelectListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeF7Select(BeforeF7SelectEvent evt) {
|
||||
ListShowParameter formShowParameter = (ListShowParameter) evt.getFormShowParameter();
|
||||
ArrayList<Long> canSeeDataId = new ArrayList<>();
|
||||
//查找所有已审核采购需求数据
|
||||
DynamicObject org = (DynamicObject) this.getModel().getValue("org");
|
||||
QFilter qFilter = new QFilter("billstatus", QCP.equals, "C");
|
||||
qFilter.and(new QFilter("org.name", QCP.equals, org.getString("name")));
|
||||
DynamicObject[] settlePlanBills = BusinessDataServiceHelper.load("recon_settleplanbill", "id,bill,qeug_applyamount", qFilter.toArray());
|
||||
//判断申请金额是否被费用登记用完
|
||||
for (int i = 0; i < settlePlanBills.length; i++) {
|
||||
DynamicObject settlePlanBill = settlePlanBills[i];
|
||||
long id = settlePlanBill.getLong("id");
|
||||
BigDecimal applyAmount = settlePlanBill.getBigDecimal("qeug_applyamount");
|
||||
BigDecimal allOriAmt=BigDecimal.ZERO;
|
||||
QFilter qFilter1 = new QFilter("qeug_refbillfield.id", QCP.equals, id);
|
||||
DynamicObject[] conNoTextBills = BusinessDataServiceHelper.load("recon_connotextbill", "id,oriamt", qFilter1.toArray());
|
||||
if (conNoTextBills.length!=0){
|
||||
for (int j = 0; j < conNoTextBills.length; j++) {
|
||||
DynamicObject conNoTextBill = conNoTextBills[j];
|
||||
BigDecimal oriAmt = conNoTextBill.getBigDecimal("oriamt");
|
||||
allOriAmt=allOriAmt.add(oriAmt);
|
||||
}
|
||||
}
|
||||
//还有余额
|
||||
if (applyAmount.compareTo(allOriAmt)>0){
|
||||
canSeeDataId.add(id);
|
||||
}
|
||||
}
|
||||
List<QFilter> qFilters = new ArrayList<>();
|
||||
qFilters.add(new QFilter("id", QCP.in, canSeeDataId));
|
||||
formShowParameter.getListFilterParameter().setQFilters(qFilters);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -68,127 +68,136 @@ public class ContractMaterialImportPlugin extends AbstractFormPlugin {
|
|||
}
|
||||
}
|
||||
private Long newMaterial(String number,Set<ImportMaterial> set){
|
||||
ImportMaterial materialByNumber = getMaterialByNumber(number, set);
|
||||
DynamicObject bd_material = null;
|
||||
try {
|
||||
ImportMaterial materialByNumber = getMaterialByNumber(number, set);
|
||||
|
||||
DynamicObject bd_material = BusinessDataServiceHelper.newDynamicObject(BD_MATERIAL);
|
||||
//物料编码
|
||||
bd_material.set("number",number);
|
||||
//物料名称
|
||||
bd_material.set("name",materialByNumber.getMaterialName());
|
||||
//所属组织
|
||||
long rootOrgId = OrgUnitServiceHelper.getRootOrgId();
|
||||
DynamicObject org = BusinessDataServiceHelper.loadSingle(rootOrgId, BOS_ORG);
|
||||
if (null != org) {
|
||||
bd_material.set("createorg",org);
|
||||
bd_material = BusinessDataServiceHelper.newDynamicObject(BD_MATERIAL);
|
||||
//物料编码
|
||||
bd_material.set("number",number);
|
||||
//物料名称
|
||||
bd_material.set("name",materialByNumber.getMaterialName());
|
||||
//所属组织
|
||||
long rootOrgId = OrgUnitServiceHelper.getRootOrgId();
|
||||
DynamicObject org = BusinessDataServiceHelper.loadSingle(rootOrgId, BOS_ORG);
|
||||
if (null != org) {
|
||||
bd_material.set("createorg",org);
|
||||
}
|
||||
//物料分类
|
||||
DynamicObject materialGroup = BusinessDataServiceHelper.loadSingle("bd_materialgroup",(new QFilter("name", QCP.equals, materialByNumber.getMaterialType())).toArray());
|
||||
if (null==materialGroup){
|
||||
materialGroup=BusinessDataServiceHelper.loadSingle("bd_materialgroup",(new QFilter("number", QCP.equals, "gc-tlfs")).toArray());
|
||||
}
|
||||
//物料分组
|
||||
bd_material.set("group",materialGroup);
|
||||
//分类标准
|
||||
DynamicObjectCollection groupStandard = bd_material.getDynamicObjectCollection("entry_groupstandard");
|
||||
DynamicObject newEntry = groupStandard.addNew();
|
||||
QFilter qFilter = new QFilter("name", QCP.equals, "物料基本分类标准");
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("bd_materialgroupstandard", qFilter.toArray());
|
||||
if (null!=dynamicObject){
|
||||
newEntry.set("standardid",dynamicObject);
|
||||
}
|
||||
//分类
|
||||
newEntry.set("groupid",materialGroup.getLong("id"));
|
||||
//物料单位
|
||||
QFilter unit = new QFilter("name", QCP.equals, materialByNumber.getMaterialUnit());
|
||||
DynamicObject measureUnits = BusinessDataServiceHelper.loadSingle("bd_measureunits",unit.toArray());
|
||||
if (null!=measureUnits){
|
||||
bd_material.set("baseunit",measureUnits);
|
||||
}
|
||||
bd_material.set("modelnum",materialByNumber.getMaterialModel());//规格
|
||||
bd_material.set("materialtype","1");//物料类型:物资
|
||||
bd_material.set("enable", "1");//使用状态:可用
|
||||
bd_material.set("status", "C");//数据状态:审核
|
||||
bd_material.set("ctrlstrategy", "5");//控制策略:全局共享
|
||||
bd_material.set("enablepur",true);//可采购
|
||||
bd_material.set("enablesale",true);//可销售
|
||||
bd_material.set("enableinv",true);//可库存
|
||||
SaveServiceHelper.save(new DynamicObject[]{bd_material});
|
||||
} catch (Exception e) {
|
||||
this.getView().showMessage(e.getMessage());
|
||||
}
|
||||
//物料分类
|
||||
DynamicObject materialGroup = BusinessDataServiceHelper.loadSingle("bd_materialgroup",(new QFilter("name", QCP.equals, materialByNumber.getMaterialType())).toArray());
|
||||
if (null==materialGroup){
|
||||
materialGroup=BusinessDataServiceHelper.loadSingle("bd_materialgroup",(new QFilter("number", QCP.equals, "waitgroup")).toArray());
|
||||
}
|
||||
//物料分组
|
||||
bd_material.set("group",materialGroup);
|
||||
//分类标准
|
||||
DynamicObjectCollection groupStandard = bd_material.getDynamicObjectCollection("entry_groupstandard");
|
||||
DynamicObject newEntry = groupStandard.addNew();
|
||||
QFilter qFilter = new QFilter("name", QCP.equals, "物料基本分类标准");
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("bd_materialgroupstandard", qFilter.toArray());
|
||||
if (null!=dynamicObject){
|
||||
newEntry.set("standardid",dynamicObject);
|
||||
}
|
||||
//分类
|
||||
newEntry.set("groupid",materialGroup);
|
||||
//物料单位
|
||||
QFilter unit = new QFilter("name", QCP.equals, materialByNumber.getMaterialUnit());
|
||||
DynamicObject measureUnits = BusinessDataServiceHelper.loadSingle("bd_measureunits",unit.toArray());
|
||||
if (null!=measureUnits){
|
||||
bd_material.set("baseunit",measureUnits);
|
||||
}
|
||||
bd_material.set("modelnum",materialByNumber.getMaterialModel());//规格
|
||||
bd_material.set("materialtype","1");//物料类型:物资
|
||||
bd_material.set("enable", "1");//使用状态:可用
|
||||
bd_material.set("status", "C");//数据状态:审核
|
||||
bd_material.set("ctrlstrategy", "5");//控制策略:全局共享
|
||||
bd_material.set("enablepur",true);//可采购
|
||||
bd_material.set("enablesale",true);//可销售
|
||||
bd_material.set("enableinv",true);//可库存
|
||||
SaveServiceHelper.save(new DynamicObject[]{bd_material});
|
||||
return bd_material.getLong("id");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeImportEntry(BeforeImportEntryEventArgs e) {
|
||||
super.beforeImportEntry(e);
|
||||
materialList.clear();
|
||||
Set<String> existCodes = new HashSet<>();
|
||||
try {
|
||||
materialList.clear();
|
||||
Set<String> existCodes = new HashSet<>();
|
||||
|
||||
// 获取已存在的物料编码
|
||||
DynamicObjectCollection orderFormEntry = (DynamicObjectCollection) this.getModel().getValue("qeug_orderformentry");
|
||||
if (orderFormEntry != null && !orderFormEntry.isEmpty()) {
|
||||
for (DynamicObject dynamicObject : orderFormEntry) {
|
||||
String number = dynamicObject.getString("qeug_material.number");
|
||||
existCodes.add(number);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理导入数据
|
||||
HashMap itemEntry = (HashMap) e.getSource();
|
||||
ArrayList list = (ArrayList) itemEntry.get("qeug_orderformentry");
|
||||
|
||||
Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ImportEntryData importData = (ImportEntryData) iterator.next();
|
||||
JSONObject data = importData.getData();
|
||||
Map<String, Object> map = data.toJavaObject(Map.class);
|
||||
JSONObject material = (JSONObject) map.get("qeug_material");
|
||||
|
||||
// 如果 material 为空,则直接移除该行数据
|
||||
if (material == null) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
ImportMaterial importMaterial = new ImportMaterial();
|
||||
importMaterial.setMaterialNumber(material.getString("number"));
|
||||
importMaterial.setMaterialName((String) map.get("qeug_materialnames"));
|
||||
importMaterial.setMaterialType((String) map.get("qeug_importmaterialtype"));
|
||||
importMaterial.setMaterialModel((String) map.get("qeug_importmodel"));
|
||||
importMaterial.setMaterialUnit((String) map.get("qeug_importunit"));
|
||||
materialList.add(importMaterial);
|
||||
}
|
||||
|
||||
// 校验数据
|
||||
Set<Map.Entry<String, List<ImportEntryData>>> entries = itemEntry.entrySet();
|
||||
for (Map.Entry<String, List<ImportEntryData>> entry : entries) {
|
||||
String entryName = entry.getKey();
|
||||
List<ImportEntryData> entryEntityImportDataList = entry.getValue();
|
||||
if (CollectionUtils.isEmpty(entryEntityImportDataList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 进行校验
|
||||
Map<Integer, String> indexVsMsgMap = validateEntry(entryEntityImportDataList, existCodes);
|
||||
Set<Integer> indexSet = indexVsMsgMap.keySet();
|
||||
Map<String, List<Object>> logMap = e.getEntryDataMap();
|
||||
ImportLogger importLogger = (ImportLogger) logMap.get(entryName).get(0);
|
||||
|
||||
// 记录错误日志
|
||||
for (Map.Entry<Integer, String> indexVsMsgEntry : indexVsMsgMap.entrySet()) {
|
||||
Integer index = indexVsMsgEntry.getKey();
|
||||
importLogger.log(index, indexVsMsgEntry.getValue());
|
||||
importLogger.fail();
|
||||
importLogger.setTotal(importLogger.getTotal() + 1);
|
||||
}
|
||||
|
||||
// 移除校验失败的数据
|
||||
Iterator<ImportEntryData> iterator2 = entryEntityImportDataList.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
ImportEntryData entryData = iterator2.next();
|
||||
Integer rowNum = (Integer) entryData.getData().get("rowNum");
|
||||
if (indexSet.contains(rowNum)) {
|
||||
iterator.remove();
|
||||
// 获取已存在的物料编码
|
||||
DynamicObjectCollection orderFormEntry = (DynamicObjectCollection) this.getModel().getValue("qeug_orderformentry");
|
||||
if (orderFormEntry != null && !orderFormEntry.isEmpty()) {
|
||||
for (DynamicObject dynamicObject : orderFormEntry) {
|
||||
String number = dynamicObject.getString("qeug_material.number");
|
||||
existCodes.add(number);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理导入数据
|
||||
HashMap itemEntry = (HashMap) e.getSource();
|
||||
ArrayList list = (ArrayList) itemEntry.get("qeug_orderformentry");
|
||||
|
||||
Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ImportEntryData importData = (ImportEntryData) iterator.next();
|
||||
JSONObject data = importData.getData();
|
||||
Map<String, Object> map = data.toJavaObject(Map.class);
|
||||
JSONObject material = (JSONObject) map.get("qeug_material");
|
||||
|
||||
// 如果 material 为空,则直接移除该行数据
|
||||
if (material == null) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
ImportMaterial importMaterial = new ImportMaterial();
|
||||
importMaterial.setMaterialNumber(material.getString("number"));
|
||||
importMaterial.setMaterialName((String) map.get("qeug_materialnames"));
|
||||
importMaterial.setMaterialType((String) map.get("qeug_importmaterialtype"));
|
||||
importMaterial.setMaterialModel((String) map.get("qeug_importmodel"));
|
||||
importMaterial.setMaterialUnit((String) map.get("qeug_importunit"));
|
||||
materialList.add(importMaterial);
|
||||
}
|
||||
|
||||
// 校验数据
|
||||
Set<Map.Entry<String, List<ImportEntryData>>> entries = itemEntry.entrySet();
|
||||
for (Map.Entry<String, List<ImportEntryData>> entry : entries) {
|
||||
String entryName = entry.getKey();
|
||||
List<ImportEntryData> entryEntityImportDataList = entry.getValue();
|
||||
if (CollectionUtils.isEmpty(entryEntityImportDataList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 进行校验
|
||||
Map<Integer, String> indexVsMsgMap = validateEntry(entryEntityImportDataList, existCodes);
|
||||
Set<Integer> indexSet = indexVsMsgMap.keySet();
|
||||
Map<String, List<Object>> logMap = e.getEntryDataMap();
|
||||
ImportLogger importLogger = (ImportLogger) logMap.get(entryName).get(0);
|
||||
|
||||
// 记录错误日志
|
||||
for (Map.Entry<Integer, String> indexVsMsgEntry : indexVsMsgMap.entrySet()) {
|
||||
Integer index = indexVsMsgEntry.getKey();
|
||||
importLogger.log(index, indexVsMsgEntry.getValue());
|
||||
importLogger.fail();
|
||||
importLogger.setTotal(importLogger.getTotal() + 1);
|
||||
}
|
||||
|
||||
// 移除校验失败的数据
|
||||
Iterator<ImportEntryData> iterator2 = entryEntityImportDataList.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
ImportEntryData entryData = iterator2.next();
|
||||
Integer rowNum = (Integer) entryData.getData().get("rowNum");
|
||||
if (indexSet.contains(rowNum)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
this.getView().showMessage(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue