Compare commits
	
		
			3 Commits
		
	
	
		
			929c11c0fd
			...
			51b9d9367e
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								 | 
						51b9d9367e | |
| 
							
							
								 | 
						6d36b643f0 | |
| 
							
							
								 | 
						28c4cf00a0 | 
| 
						 | 
				
			
			@ -2,9 +2,10 @@ package nccloud.web.uapbd.material.action;
 | 
			
		|||
 | 
			
		||||
import nc.bs.uapbd.util.GetPlmFileUtil;
 | 
			
		||||
import nccloud.framework.core.io.WebFile;
 | 
			
		||||
import nccloud.framework.web.action.itf.ICommonAction;
 | 
			
		||||
import nccloud.framework.web.container.IRequest;
 | 
			
		||||
import nccloud.web.action.NCCAction;
 | 
			
		||||
import nccloud.web.uapbd.commons.web.ParamUtils;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 获取物料PLM文件
 | 
			
		||||
| 
						 | 
				
			
			@ -12,15 +13,21 @@ import nccloud.web.uapbd.commons.web.ParamUtils;
 | 
			
		|||
 * @author mzr
 | 
			
		||||
 * @date 2025/8/4
 | 
			
		||||
 */
 | 
			
		||||
public class MaterialPlmDownloadAction extends NCCAction {
 | 
			
		||||
public class MaterialPlmDownloadAction implements ICommonAction {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public <T> Object execute(IRequest request, T para) throws Exception {
 | 
			
		||||
        ParamUtils param = new ParamUtils(request);
 | 
			
		||||
        String materialCode = param.getString("materialCode", null);
 | 
			
		||||
        materialCode = "101092250323";
 | 
			
		||||
    public Object doAction(IRequest request) {
 | 
			
		||||
        WebFile files = null;
 | 
			
		||||
        try {
 | 
			
		||||
            Map<String, String[]> params_1 = request.readParameters();
 | 
			
		||||
            String[] pks = params_1.get("materialCode"); // »ñÈ¡ËùÓÐ pk
 | 
			
		||||
            String materialCode = "101092250323,101092250323";
 | 
			
		||||
            String[] materialCodeArr = materialCode.split(",", -1);
 | 
			
		||||
            GetPlmFileUtil fileUtil = new GetPlmFileUtil();
 | 
			
		||||
        WebFile files = fileUtil.getPlmFiles(materialCodeArr);
 | 
			
		||||
            files = fileUtil.getPlmFiles(materialCodeArr);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException(e);
 | 
			
		||||
        }
 | 
			
		||||
        return files;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,21 +38,28 @@ public class MaterialToEpicMesListener implements IBusinessListener {
 | 
			
		|||
        BDCommonEvent e = (BDCommonEvent) event;
 | 
			
		||||
        String eventType = event.getEventType();
 | 
			
		||||
        Object[] objs = e.getObjs();
 | 
			
		||||
        MaterialVO[] useVOs = ArrayClassConvertUtil.convert(objs, MaterialVO.class);
 | 
			
		||||
 | 
			
		||||
        // EventType是事件编码 1002-新增后 1004-修改后 1071-状态由停用变为启用后 1069-状态由启用变为停用后
 | 
			
		||||
        if ("1002".equals(eventType) || "1004".equals(eventType)) {
 | 
			
		||||
            MaterialVO[] useVOs = ArrayClassConvertUtil.convert(objs, MaterialVO.class);
 | 
			
		||||
            configParams = MyHelper.getConfigParams("Dldz-config", null);
 | 
			
		||||
            if (configParams.isEmpty()) {
 | 
			
		||||
                throw new BusinessException("电力电子的艾普MES接口缺少配置");
 | 
			
		||||
            }
 | 
			
		||||
            buildSyncData(useVOs, eventType);
 | 
			
		||||
        } else if ("1071".equals(eventType) || "1069".equals(eventType)) {
 | 
			
		||||
            MaterialVO[] useVOs = ArrayClassConvertUtil.convert(objs, MaterialVO.class);
 | 
			
		||||
            configParams = MyHelper.getConfigParams("Dldz-config", null);
 | 
			
		||||
            if (configParams.isEmpty()) {
 | 
			
		||||
                throw new BusinessException("电力电子的艾普MES接口缺少配置");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        } else if ("1009".equals(eventType)) {
 | 
			
		||||
            Object[] newObjs = e.getNewObjs();
 | 
			
		||||
            // 物料可见性范围-分配后
 | 
			
		||||
            for (Object obj : newObjs) {
 | 
			
		||||
                MaterialVO vo = (MaterialVO) obj;
 | 
			
		||||
                String pkMaterial = vo.getPk_material();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
package nc.bs.uapbd.util;
 | 
			
		||||
 | 
			
		||||
import com.alibaba.fastjson.JSONArray;
 | 
			
		||||
import com.alibaba.fastjson.JSONObject;
 | 
			
		||||
import nc.bs.dao.DAOException;
 | 
			
		||||
import nc.bs.logging.Log;
 | 
			
		||||
| 
						 | 
				
			
			@ -41,11 +42,11 @@ public class GetPlmFileUtil {
 | 
			
		|||
    private String token = "";
 | 
			
		||||
    private static final String tokenUrl = "/sipmweb/api/oauth";
 | 
			
		||||
    // 根据物料编码获取零部件ID
 | 
			
		||||
    private String materialIdUrl = "/sipmweb/api/{rid}/search/{t}?key={key}&start={start}&size={size}";
 | 
			
		||||
    private String materialIdUrl = "/sipmweb/api/{rid}/search/{t}";
 | 
			
		||||
    // 根据零部件ID获取二维图档ID及信息
 | 
			
		||||
    private String materialFileIdUrl = "/sipmweb/api/{rid}/relation/{t}/{id}/data?re={re}&start={start}&item={item}";
 | 
			
		||||
    private String materialFileIdUrl = "/sipmweb/api/{rid}/relation/{t}/{id}/data";
 | 
			
		||||
    // 下载文件
 | 
			
		||||
    private String downlownUrl = "/sipmweb/web/download?rid={rid}&id={id}&t={t}&type={type}";
 | 
			
		||||
    private String downlownUrl = "/sipmweb/web/download";
 | 
			
		||||
    // http请求
 | 
			
		||||
    private static final PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
 | 
			
		||||
    private static final CloseableHttpClient httpClient;
 | 
			
		||||
| 
						 | 
				
			
			@ -165,7 +166,13 @@ public class GetPlmFileUtil {
 | 
			
		|||
        String result = doGet(fileUrl, map);
 | 
			
		||||
        logger.error("GetPlmFileUtil-getMaterialId-result = " + result);
 | 
			
		||||
        JSONObject jsonObject = JSONObject.parseObject(result);
 | 
			
		||||
        String objId = jsonObject.getString("objId");
 | 
			
		||||
        String list = jsonObject.getString("list");
 | 
			
		||||
        JSONArray jsonArray = JSONObject.parseArray(list);
 | 
			
		||||
        if (jsonArray == null || jsonArray.isEmpty()) {
 | 
			
		||||
            throw new BusinessException("获取PLM物料id失败");
 | 
			
		||||
        }
 | 
			
		||||
        JSONObject listJson = jsonArray.getJSONObject(0);
 | 
			
		||||
        String objId = listJson.getString("objId");
 | 
			
		||||
        if (objId == null || objId.isEmpty()) {
 | 
			
		||||
            throw new BusinessException("获取PLM物料id失败");
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -189,11 +196,17 @@ public class GetPlmFileUtil {
 | 
			
		|||
        String result = doGet(fileUrl, map);
 | 
			
		||||
        logger.error("GetPlmFileUtil-getFileId-result = " + result);
 | 
			
		||||
        JSONObject jsonObject = JSONObject.parseObject(result);
 | 
			
		||||
        String objId = jsonObject.getString("objId");
 | 
			
		||||
        String list = jsonObject.getString("list");
 | 
			
		||||
        JSONArray jsonArray = JSONObject.parseArray(list);
 | 
			
		||||
        if (jsonArray == null || jsonArray.isEmpty()) {
 | 
			
		||||
            throw new BusinessException("获取PLM物料的文件信息失败");
 | 
			
		||||
        }
 | 
			
		||||
        JSONObject listJson = jsonArray.getJSONObject(0);
 | 
			
		||||
        String objId = listJson.getString("objId");
 | 
			
		||||
        if (objId == null || objId.isEmpty()) {
 | 
			
		||||
            throw new BusinessException("获取PLM物料的文件信息失败");
 | 
			
		||||
        }
 | 
			
		||||
        return jsonObject;
 | 
			
		||||
        return listJson;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue