ZIPManufacturerDatautility.zip 1.99KB

qq_59708493

资源文件列表:

ManufacturerDatautility.zip 大约有1个文件
  1. ManufacturerDatautility.java 5.84KB

资源介绍:

111
package ext.rwd.part.datautility; import java.io.File; import java.io.InputStream; import java.util.ArrayList; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ptc.core.components.beans.CreateAndEditWizBean; import com.ptc.core.components.descriptor.ModelContext; import com.ptc.core.components.factory.AbstractDataUtility; import com.ptc.core.components.factory.dataUtilities.AttributeDataUtilityHelper; import com.ptc.core.components.rendering.GuiComponent; import com.ptc.core.components.rendering.guicomponents.ComboBox; import com.ptc.core.meta.type.common.impl.DefaultTypeInstance; import com.ptc.core.ui.resources.ComponentMode; import com.ptc.netmarkets.util.beans.NmCommandBean; import ext.lang.PIExcelUtils; import ext.lang.PIStringUtils; import ext.pi.PIException; import ext.pi.core.PIAttributeHelper; import ext.pi.core.PIContentHelper; import ext.pi.core.PICoreHelper; import ext.pi.core.PIDocumentHelper; import wt.content.ApplicationData; import wt.content.ContentItem; import wt.content.ContentServerHelper; import wt.doc.WTDocument; import wt.fc.WTObject; import wt.part.WTPart; import wt.util.WTException; public class ManufacturerDatautility extends AbstractDataUtility { private static final String CLASSNAME = ManufacturerDatautility.class.getName(); private static final Logger logger = LoggerFactory.getLogger(CLASSNAME); @Override public Object getDataValue(String s, Object obj, ModelContext mc) throws WTException { NmCommandBean nmCommandBean = mc.getNmCommandBean(); // 是否创建及编辑状态 boolean bool = CreateAndEditWizBean.isCreateEditWizard(nmCommandBean); logger.debug(" >>>>>bool=" + bool); if (bool) { if (obj instanceof DefaultTypeInstance) { DefaultTypeInstance instance = (DefaultTypeInstance) obj; String oid = instance.getPersistenceIdentifier(); logger.debug(">>>oid=" + oid); if (PIStringUtils.hasText(oid) && mc.getDescriptorMode().equals(ComponentMode.EDIT)) { WTObject wtobj = PICoreHelper.service.getWTObjectByOid(oid); if (wtobj != null && (wtobj instanceof WTPart)) { WTPart part = (WTPart) wtobj; String value = getValue(part, s); value = value == null ? "" : value; return getCom(s, obj, mc, value); } } else if (mc.getDescriptorMode().equals(ComponentMode.CREATE)) { return getCom(s, obj, mc, ""); } } } return null; } /** * 构建文本框 * * @param s * @param obj * @param mc * @param value * @return * @throws WTException */ private ArrayList<GuiComponent> getCom(String s, Object obj, ModelContext mc, String value) throws WTException { ArrayList<String> excelData = getExcelData(); logger.debug(" >>>>excelData=" + excelData); ArrayList<GuiComponent> component = new ArrayList<GuiComponent>(); if (excelData != null) { ArrayList<String> al = new ArrayList<>(); al.add(""); al.addAll(excelData); ComboBox combobox = new ComboBox(); combobox.setId(s); // combobox.setName(s); combobox.setColumnName(AttributeDataUtilityHelper.getColumnName(s, obj, mc)); combobox.setValues(al); combobox.setInternalValues(al); combobox.setSelected(value); combobox.setRequired(true); component.add(combobox); } return component; } /** * 获取属性值 * * @param p * @param compid * @return * @throws PIException */ public static String getValue(WTPart p, String compid) throws PIException { return (String) PIAttributeHelper.service.getValue(p, compid); } /** * 获取Excel数据 * * @return * @throws Exception */ public static ArrayList<String> getExcelData() throws WTException { ArrayList<String> list = new ArrayList<String>(); try { WTDocument doc = PIDocumentHelper.service.findWTDocument("T000001"); if (doc == null) { String templatePath = PICoreHelper.service.getCodebase()+ File.separator + "ext" + File.separator + "rwd" + File.separator + "template" + File.separator + "生产厂家配置表.xlsx"; File file = new File(templatePath); Workbook book = WorkbookFactory.create(file); Sheet sheet = book.getSheetAt(0); int lastRowNum = sheet.getLastRowNum(); logger.debug(" >>>>lastRowNum=" + lastRowNum); for (int i = 0; i <= lastRowNum; i++) { Row row = PIExcelUtils.getRow(sheet, i + 1, true); Cell cell = PIExcelUtils.getCell(row, 0, true); String excelValue = PIExcelUtils.getCellValueAsString(cell, null); if (!PIStringUtils.hasText(excelValue)) { break; } list.add(excelValue); } if (book != null) { book.close(); } } else { ContentItem content = PIContentHelper.service.findPrimaryContent(doc); if (content != null) { if (content instanceof ApplicationData) { ApplicationData data = (ApplicationData) content; InputStream is = ContentServerHelper.service.findContentStream(data); Workbook book = WorkbookFactory.create(is); Sheet sheet = book.getSheetAt(0); int lastRowNum = sheet.getLastRowNum(); logger.debug(" >>>>lastRowNum=" + lastRowNum); for (int i = 0; i <= lastRowNum; i++) { Row row = PIExcelUtils.getRow(sheet, i + 1, true); Cell cell = PIExcelUtils.getCell(row, 0, true); String excelValue = PIExcelUtils.getCellValueAsString(cell, null); if (!PIStringUtils.hasText(excelValue)) { break; } list.add(excelValue); } if (book != null) { book.close(); } } } } } catch (Exception e) { e.printStackTrace(); } return list; } }
100+评论
captcha
    类型标题大小时间
    ZIP中央民族大学-获奖证书.zip5.3MB10月前
    ZIP使用YOLOV8训练自己的数据集,获取更详细的map指标,map-small,map-medium,map-large等903.77KB10月前
    ZIP数字逻辑_习题答案库.zip9.12MB10月前
    ZIP组态王数据库多表联合查询教程及工程655.96KB10月前
    ZIP学生宿舍信息系统 JAVA+Vue.js+SpringBoot+MySQL38.84MB10月前
    ZIP酒店客房管理系统 JAVA+Vue.js+SpringBoot+MySQL39.36MB10月前
    ZIP安康旅游网站 JAVA+Vue.js+SpringBoot+MySQL53.17MB10月前
    ZIP基于Java编写的飞机大战小游戏98.1MB10月前