首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

ManufacturerDatautility.zip

前端 1.99KB 15 需要积分: 1
立即下载

资源介绍:

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 getCom(String s, Object obj, ModelContext mc, String value) throws WTException { ArrayList excelData = getExcelData(); logger.debug(" >>>>excelData=" + excelData); ArrayList component = new ArrayList(); if (excelData != null) { ArrayList 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 getExcelData() throws WTException { ArrayList list = new ArrayList(); 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; } }

资源文件列表:

ManufacturerDatautility.zip 大约有1个文件
  1. ManufacturerDatautility.java 5.84KB
0评论
提交 加载更多评论
其他资源 中央民族大学-获奖证书.zip
中央民族大学-获奖证书.zip
使用YOLOV8训练自己的数据集,获取更详细的map指标,map-small,map-medium,map-large等
使用YOLOV8训练自己的数据集,获取更详细的map指标,map-small,map-medium,map-large等
数字逻辑_习题答案库.zip
数字逻辑_习题答案库.zip
数字逻辑_习题答案库.zip
组态王数据库多表联合查询教程及工程
7.5KVADODBGrid 控件查询不同的数据库表格用户教程,多表联合查询教程
组态王数据库多表联合查询教程及工程 组态王数据库多表联合查询教程及工程 组态王数据库多表联合查询教程及工程
学生宿舍信息系统 JAVA+Vue.js+SpringBoot+MySQL
基于Vue.js和SpringBoot的学生宿舍信息系统,分为管理后台和用户网页端,可以给管理员、学生角色使用,包括宿舍安排、宿舍报修、假期留宿、宿舍缴费模块和系统基础模块,项目编号T100。 项目录屏:https://www.bilibili.com/video/BV1r2421K7pT 启动教程:https://www.bilibili.com/video/BV1pW4y1P7GR 项目讲解视频:https://space.bilibili.com/417412814/channel/collectiondetail?sid=2242844
学生宿舍信息系统 JAVA+Vue.js+SpringBoot+MySQL 学生宿舍信息系统 JAVA+Vue.js+SpringBoot+MySQL 学生宿舍信息系统 JAVA+Vue.js+SpringBoot+MySQL
酒店客房管理系统 JAVA+Vue.js+SpringBoot+MySQL
基于Vue.js和SpringBoot的酒店客房管理系统,分为管理后台和用户网页端,可以给管理员、会员角色使用,包括会员管理、清洁工管理、客房管理、用户预约、用户入住模块和系统基础模块,项目编号T099。 项目录屏:https://www.bilibili.com/video/BV1Kz421Q7m3 启动教程:https://www.bilibili.com/video/BV1pW4y1P7GR 项目讲解视频:https://space.bilibili.com/417412814/channel/collectiondetail?sid=2242844
酒店客房管理系统 JAVA+Vue.js+SpringBoot+MySQL 酒店客房管理系统 JAVA+Vue.js+SpringBoot+MySQL 酒店客房管理系统 JAVA+Vue.js+SpringBoot+MySQL
安康旅游网站 JAVA+Vue.js+SpringBoot+MySQL
基于Vue.js和SpringBoot的安康旅游网站,分为管理后台和用户网页端,可以给管理员、游客角色使用,包括景点信息、省市信息、旅游线路、特产管理、购票订单模块和系统基础模块,项目编号T098。 项目录屏:https://www.bilibili.com/video/BV1Hx421y7gn 启动教程:https://www.bilibili.com/video/BV1pW4y1P7GR 项目讲解视频:https://space.bilibili.com/417412814/channel/collectiondetail?sid=2242844
安康旅游网站 JAVA+Vue.js+SpringBoot+MySQL 安康旅游网站 JAVA+Vue.js+SpringBoot+MySQL 安康旅游网站 JAVA+Vue.js+SpringBoot+MySQL
基于Java编写的飞机大战小游戏
基于Java编写的飞机大战小游戏