非定额物料分类改为基础资料F7
This commit is contained in:
parent
4dd746909a
commit
7057e05c1f
|
@ -34,6 +34,7 @@ public class ContractMaterialImportPlugin extends AbstractFormPlugin {
|
||||||
private static final String BD_MATERIAL = "bd_material";//物料实体
|
private static final String BD_MATERIAL = "bd_material";//物料实体
|
||||||
|
|
||||||
private static final Set<ImportMaterial> materialList = new HashSet<>();
|
private static final Set<ImportMaterial> materialList = new HashSet<>();
|
||||||
|
|
||||||
//TODO: 生成物料逻辑迁移到导入过程中,获取excel行
|
//TODO: 生成物料逻辑迁移到导入过程中,获取excel行
|
||||||
@Override
|
@Override
|
||||||
public void queryImportBasedata(QueryImportBasedataEventArgs e) {
|
public void queryImportBasedata(QueryImportBasedataEventArgs e) {
|
||||||
|
@ -67,6 +68,7 @@ public class ContractMaterialImportPlugin extends AbstractFormPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long newMaterial(String number, Set<ImportMaterial> set) {
|
private Long newMaterial(String number, Set<ImportMaterial> set) {
|
||||||
DynamicObject bd_material = null;
|
DynamicObject bd_material = null;
|
||||||
Long id = null;
|
Long id = null;
|
||||||
|
@ -156,14 +158,15 @@ public class ContractMaterialImportPlugin extends AbstractFormPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
materialList.clear();
|
materialList.clear();
|
||||||
Set<String> existCodes = new HashSet<>();
|
Set<String> existComb = new HashSet<>();
|
||||||
|
|
||||||
// 获取已存在的物料编码
|
// 获取已存在的物料名称+规格组合
|
||||||
DynamicObjectCollection orderFormEntry = (DynamicObjectCollection) this.getModel().getValue("qeug_orderformentry");
|
DynamicObjectCollection orderFormEntry = (DynamicObjectCollection) this.getModel().getValue("qeug_orderformentry");
|
||||||
if (orderFormEntry != null && !orderFormEntry.isEmpty()) {
|
if (orderFormEntry != null && !orderFormEntry.isEmpty()) {
|
||||||
for (DynamicObject dynamicObject : orderFormEntry) {
|
for (DynamicObject dynamicObject : orderFormEntry) {
|
||||||
String number = dynamicObject.getString("qeug_material.number");
|
String name = dynamicObject.getString("qeug_materialnames");
|
||||||
existCodes.add(number);
|
String model = dynamicObject.getString("qeug_importmodel");
|
||||||
|
existComb.add(name.trim()+model.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,12 +203,14 @@ public class ContractMaterialImportPlugin extends AbstractFormPlugin {
|
||||||
importMaterial.setMaterialNumber(material.getString("number"));
|
importMaterial.setMaterialNumber(material.getString("number"));
|
||||||
}
|
}
|
||||||
//物料类型校验
|
//物料类型校验
|
||||||
String impMaterialType = (String) map.get("qeug_importmaterialtype");
|
String typeName="待分类";
|
||||||
if (!validMaterialTypes.contains(impMaterialType)) {
|
JSONObject materialType = (JSONObject) map.get("qeug_materialtypeid");//物料分类
|
||||||
map.replace("qeug_importmaterialtype", "待分类");
|
if (materialType!=null && validMaterialTypes.contains(materialType.getString("name"))){
|
||||||
|
typeName = materialType.getString("name");
|
||||||
|
|
||||||
}
|
}
|
||||||
importMaterial.setMaterialName((String) map.get("qeug_materialnames"));
|
importMaterial.setMaterialName((String) map.get("qeug_materialnames"));
|
||||||
importMaterial.setMaterialType((String) map.get("qeug_importmaterialtype"));
|
importMaterial.setMaterialType(typeName);
|
||||||
importMaterial.setMaterialModel((String) map.get("qeug_importmodel"));
|
importMaterial.setMaterialModel((String) map.get("qeug_importmodel"));
|
||||||
importMaterial.setMaterialUnit((String) map.get("qeug_importunit"));
|
importMaterial.setMaterialUnit((String) map.get("qeug_importunit"));
|
||||||
importMaterial.setMaterialBrand((String) map.get("qeug_brand"));
|
importMaterial.setMaterialBrand((String) map.get("qeug_brand"));
|
||||||
|
@ -223,7 +228,7 @@ public class ContractMaterialImportPlugin extends AbstractFormPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 进行校验
|
// 进行校验
|
||||||
Map<Integer, String> indexVsMsgMap = validateEntry(entryEntityImportDataList, existCodes);
|
Map<Integer, String> indexVsMsgMap = validateEntry(entryEntityImportDataList, existComb);
|
||||||
Set<Integer> indexSet = indexVsMsgMap.keySet();
|
Set<Integer> indexSet = indexVsMsgMap.keySet();
|
||||||
Map<String, List<Object>> logMap = e.getEntryDataMap();
|
Map<String, List<Object>> logMap = e.getEntryDataMap();
|
||||||
ImportLogger importLogger = (ImportLogger) logMap.get(entryName).get(0);
|
ImportLogger importLogger = (ImportLogger) logMap.get(entryName).get(0);
|
||||||
|
@ -255,12 +260,11 @@ public class ContractMaterialImportPlugin extends AbstractFormPlugin {
|
||||||
/**
|
/**
|
||||||
* 校验物料名称、物料单位
|
* 校验物料名称、物料单位
|
||||||
* @param entryDataList
|
* @param entryDataList
|
||||||
* @param existingMaterialCodes
|
* @param existComb
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Map<Integer, String> validateEntry(List<ImportEntryData> entryDataList,Set<String> existingMaterialCodes) {
|
private Map<Integer, String> validateEntry(List<ImportEntryData> entryDataList,Set<String> existComb) {
|
||||||
Map<Integer, String> indexVsMsgMap = new HashMap<>();
|
Map<Integer, String> indexVsMsgMap = new HashMap<>();
|
||||||
// Set<String> encounteredMaterialCodes = new HashSet<>(); // 用于记录当前批次中的物料编码
|
|
||||||
|
|
||||||
for (int i = 0; i < entryDataList.size(); i++) {
|
for (int i = 0; i < entryDataList.size(); i++) {
|
||||||
ImportEntryData entryData = entryDataList.get(i);
|
ImportEntryData entryData = entryDataList.get(i);
|
||||||
|
@ -268,33 +272,23 @@ public class ContractMaterialImportPlugin extends AbstractFormPlugin {
|
||||||
// 获取当前行的 JSONObject 数据
|
// 获取当前行的 JSONObject 数据
|
||||||
JSONObject data = entryData.getData();
|
JSONObject data = entryData.getData();
|
||||||
Map<String, Object> map = data.toJavaObject(Map.class);
|
Map<String, Object> map = data.toJavaObject(Map.class);
|
||||||
//JSONObject material = (JSONObject) map.get("qeug_material");
|
|
||||||
|
|
||||||
// 获取物料编码和物料单位
|
|
||||||
//String materialCode = material.getString("number"); // 物料编码
|
|
||||||
String materialUnit = (String) map.get("qeug_importunit"); // 物料单位
|
String materialUnit = (String) map.get("qeug_importunit"); // 物料单位
|
||||||
// 获取当前行号
|
// 获取当前行号
|
||||||
Integer rowNum = (Integer) entryData.getData().get("rowNum");
|
Integer rowNum = (Integer) entryData.getData().get("rowNum");
|
||||||
|
|
||||||
// 校验物料编码和物料单位
|
//校验物料单位
|
||||||
// if (materialCode == null || materialCode.trim().isEmpty()) {
|
|
||||||
// indexVsMsgMap.put(rowNum, "第" + (i + 1) + "行:物料编码不能为空或空字符串");
|
|
||||||
// }
|
|
||||||
if (materialUnit == null || materialUnit.trim().isEmpty()) {
|
if (materialUnit == null || materialUnit.trim().isEmpty()) {
|
||||||
indexVsMsgMap.put(rowNum, "第" + (i + 1) + "行:物料单位不能为空或空字符串");
|
indexVsMsgMap.put(rowNum, "第" + (i + 1) + "行:物料单位不能为空或空字符串");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验物料编码是否重复
|
String name = (String) map.get("qeug_materialnames"); // 物料单位
|
||||||
// if (encounteredMaterialCodes.contains(materialCode)) {
|
String model = (String) map.get("qeug_importmodel"); // 物料单位
|
||||||
// indexVsMsgMap.put(rowNum, "第" + (i + 1) + "行:物料编码重复");
|
|
||||||
// } else {
|
// 校验物料编码是否已经存在于当前页面的表格中
|
||||||
// encounteredMaterialCodes.add(materialCode);
|
if (existComb.contains(name.trim()+model.trim())) {
|
||||||
// }
|
indexVsMsgMap.put(rowNum, "第" + (i + 1) + "行:物料+规格已存在,请勿重复导入");
|
||||||
//
|
}
|
||||||
// // 校验物料编码是否已经存在于当前页面的表格中
|
|
||||||
// if (existingMaterialCodes.contains(materialCode)) {
|
|
||||||
// indexVsMsgMap.put(rowNum, "第" + (i + 1) + "行:物料编码已存在,不能重复");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return indexVsMsgMap;
|
return indexVsMsgMap;
|
||||||
|
|
|
@ -7,7 +7,11 @@ import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.dataentity.utils.StringUtils;
|
import kd.bos.dataentity.utils.StringUtils;
|
||||||
import kd.bos.entity.datamodel.IBillModel;
|
import kd.bos.entity.datamodel.IBillModel;
|
||||||
import kd.bos.entity.datamodel.IDataModel;
|
import kd.bos.entity.datamodel.IDataModel;
|
||||||
|
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
||||||
import kd.bos.form.control.events.BeforeItemClickEvent;
|
import kd.bos.form.control.events.BeforeItemClickEvent;
|
||||||
|
import kd.bos.form.field.BasedataEdit;
|
||||||
|
import kd.bos.form.field.events.AfterF7SelectEvent;
|
||||||
|
import kd.bos.form.field.events.AfterF7SelectListener;
|
||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
@ -22,7 +26,7 @@ import java.util.EventObject;
|
||||||
* 动态表单插件
|
* 动态表单插件
|
||||||
* 带出物料编码
|
* 带出物料编码
|
||||||
*/
|
*/
|
||||||
public class MaterialSaveCarryNumberPlugin extends AbstractBillPlugIn implements Plugin {
|
public class MaterialSaveCarryNumberPlugin extends AbstractBillPlugIn implements Plugin, AfterF7SelectListener {
|
||||||
|
|
||||||
private static final String BOS_ORG = "bos_org";//组织实体
|
private static final String BOS_ORG = "bos_org";//组织实体
|
||||||
|
|
||||||
|
@ -32,6 +36,9 @@ public class MaterialSaveCarryNumberPlugin extends AbstractBillPlugIn implements
|
||||||
public void registerListener(EventObject e) {
|
public void registerListener(EventObject e) {
|
||||||
super.registerListener(e);
|
super.registerListener(e);
|
||||||
this.addItemClickListeners("tbmain");
|
this.addItemClickListeners("tbmain");
|
||||||
|
//监听分录物料F7
|
||||||
|
BasedataEdit bEdit = this.getView().getControl("qeug_material");
|
||||||
|
bEdit.addAfterF7SelectListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,7 +72,7 @@ public class MaterialSaveCarryNumberPlugin extends AbstractBillPlugIn implements
|
||||||
if (entryEntity != null && entryEntity.size() != 0) {
|
if (entryEntity != null && entryEntity.size() != 0) {
|
||||||
for (int i = 0; i < entryEntity.size(); i++) {
|
for (int i = 0; i < entryEntity.size(); i++) {
|
||||||
DynamicObject material = entryEntity.get(i).getDynamicObject(materialIdLogotype);//物料-基础资料
|
DynamicObject material = entryEntity.get(i).getDynamicObject(materialIdLogotype);//物料-基础资料
|
||||||
String type = entryEntity.get(i).getString("qeug_importmaterialtype");//物料分类
|
String type = entryEntity.get(i).getString("qeug_materialtypeid.name");//物料分类
|
||||||
String model = entryEntity.get(i).getString("qeug_importmodel");//规格型号
|
String model = entryEntity.get(i).getString("qeug_importmodel");//规格型号
|
||||||
String unit = entryEntity.get(i).getString("qeug_importunit");//规格型号
|
String unit = entryEntity.get(i).getString("qeug_importunit");//规格型号
|
||||||
String brand = entryEntity.get(i).getString("qeug_brand");//规格型号
|
String brand = entryEntity.get(i).getString("qeug_brand");//规格型号
|
||||||
|
@ -267,4 +274,29 @@ public class MaterialSaveCarryNumberPlugin extends AbstractBillPlugIn implements
|
||||||
}
|
}
|
||||||
SaveServiceHelper.update(dynamicObject);
|
SaveServiceHelper.update(dynamicObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 选完物料后带出当前行的物料类型基础资料
|
||||||
|
* @param afterF7SelectEvent
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void afterF7Select(AfterF7SelectEvent afterF7SelectEvent) {
|
||||||
|
|
||||||
|
//获取当前选中行号
|
||||||
|
int currentRowIndex = afterF7SelectEvent.getCurrentRowIndex();
|
||||||
|
//所选数据
|
||||||
|
ListSelectedRowCollection listSelectedRowCollection = afterF7SelectEvent.getListSelectedRowCollection();
|
||||||
|
Object[] primaryKeyValues = listSelectedRowCollection.getPrimaryKeyValues();
|
||||||
|
//物料id
|
||||||
|
Object primaryKeyValue = primaryKeyValues[0];
|
||||||
|
//获取映射表
|
||||||
|
DynamicObject groupStandard = BusinessDataServiceHelper.loadSingle("bd_materialgroupdetail", new QFilter("material.id", QCP.equals, primaryKeyValue).toArray());
|
||||||
|
if (groupStandard != null) {
|
||||||
|
DynamicObject group = groupStandard.getDynamicObject("group");
|
||||||
|
if (group != null) {
|
||||||
|
this.getModel().setValue("qeug_materialtypeid", group, currentRowIndex);
|
||||||
|
this.getView().updateView("qeug_materialtypeid", currentRowIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue