From da4310936f073b70e64b87b842af43790d7d04e4 Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期五, 30 八月 2024 15:59:28 +0800
Subject: [PATCH] 链接类型查询模板
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java | 77 ++++++++++++++++++++++++++++++--------
1 files changed, 61 insertions(+), 16 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java
index a4e6359..c8facba 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java
@@ -479,10 +479,13 @@
);
//灞炴�ц嫳鏂囧悕绉版牎楠岋紙鍒ょ┖銆佺郴缁熶腑鍒ら噸銆佹槸鍚﹀叧閿瓧銆佹槸鍚﹀悎瑙勭瓑锛�
checkName(osAttributeDTO.getId());
+ //妫�鏌ュ睘鎬у悕鏄惁宸插瓨鍦ㄤ笌绯荤粺涓�
+ if(platformClientUtil.getAttributeService().checkRowIsExists(osAttributeDTO.getId())){
+ throw new PLException("500",new String[]{"灞炴�у悕绉般��" + osAttributeDTO.getId() + "銆戝湪绯荤粺涓凡瀛樺湪!"});
+ }
//妫�鏌ラ粯璁ゅ�间笌灞炴�х被鍨嬫槸鍚﹀尮閰�
checkDefValue(osAttributeDTO);
- //dto瀵硅薄杞崲涓哄瓨鍌ㄦ墍闇�瀵硅薄
- osAttributeDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
+ //osAttributeDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
AttributeDef attributeDef = this.osAttributeDTO2AttributeDef(osAttributeDTO);
return platformClientUtil.getAttributeService().addAttributeDef(attributeDef);
}
@@ -694,9 +697,9 @@
throw new PLException("500",new String[]{"灞炴�у悕鏃犳晥,鍘熷洜锛氬睘鎬у悕鏄暟鎹簱鍏抽敭瀛�!"});
}
//妫�鏌ュ睘鎬у悕鏄惁宸插瓨鍦ㄤ笌绯荤粺涓�
- if(platformClientUtil.getAttributeService().checkRowIsExists(abName)){
- throw new PLException("500",new String[]{"灞炴�у悕绉板湪绯荤粺涓凡瀛樺湪!"});
- }
+ /*if(platformClientUtil.getAttributeService().checkRowIsExists(abName)){
+ throw new PLException("500",new String[]{"灞炴�у悕绉般��" + abName + "銆戝湪绯荤粺涓凡瀛樺湪!"});
+ }*/
}
/**
@@ -890,8 +893,8 @@
excelDataList.add(new WriteExcelData(0,index, columns.get(index)));
}
//鎸夌収灞炴�у悕鏌ヨ灞炴�э紝鐒跺悗澶勭悊灞炴�у鍑�
- List<String> enumNameList = Func.toStrList(attrNames);
- List<OsAttributeVO> osAttributeVOS = this.listAttrByIds(enumNameList);
+ List<String> attrameList = Func.toStrList(attrNames);
+ List<OsAttributeVO> osAttributeVOS = this.listAttrByIds(attrameList);
if(Func.isEmpty(osAttributeVOS)){
excelDataList.add(new WriteExcelData(1,1, "鏍规嵁灞炴�у悕绉版湭鏌ヨ鍒板睘鎬т俊鎭紝璇峰埛鏂板悗灏濊瘯閲嶆柊瀵煎嚭锛�"));
}else{
@@ -998,10 +1001,12 @@
/**
* 瀵煎叆灞炴��
* @param file
+ * @param isContinue 绯荤粺涓嚭鐜伴噸澶嶆槸鍚﹁烦杩囨姤閿欑户缁墽琛�
* @return
+ * @throws Exception
*/
@Override
- public BaseResult importAttributes(File file) throws Exception{
+ public BaseResult importAttributes(File file, boolean isContinue) throws Exception{
VciBaseUtil.alertNotNull(file,"excel鏂囦欢");
if(!file.exists()){
throw new VciBaseException("瀵煎叆鐨別xcel鏂囦欢涓嶅瓨鍦�,{0}",new String[]{file.getPath()});
@@ -1018,14 +1023,29 @@
List<OsAttributeDTO> dtoList = new ArrayList<>();
//褰撳墠excel涓槸鍚﹂噸澶嶇敤鐨勫垽閲峂ap:锛坘ey锛氬垽閲嶅睘鎬э紝value锛氳鍙凤級
Map<String, String> excelReapeat = new HashMap<>();
- //鍒ゆ柇蹇呭~灞炴�ф槸鍚︿负绌猴紝鐢ㄦ埛鏄惁宸插瓨鍦紝浠ュ強閮ㄩ棬鏄惁濉敊绛夋牎楠岄�昏緫
- poList.stream().forEach(osAttributePO -> {
+ for (int i = 0; i < poList.size(); i++) {
+ OsAttributePO osAttributePO = poList.get(i);
if(Func.isBlank(osAttributePO.getId())){//灞炴�у悕鍒ょ┖
- throw new VciBaseException("绗��"+osAttributePO.getRowIndex()+"銆戣锛宔numnameerror");
+ throw new VciBaseException("绗��"+osAttributePO.getRowIndex()+"銆戣锛宎ttrnameerror");
}else if(Func.isBlank(osAttributePO.getAttributeDataType())){
throw new VciBaseException("绗��"+osAttributePO.getRowIndex()+"銆戣锛宼ypeerror");
}else if(excelReapeat.containsKey(osAttributePO.getId())){//灞炴�у悕琛ㄦ牸涓垽閲�
throw new VciBaseException("绗��"+excelReapeat.get(osAttributePO.getId())+"銆戣鍜岀銆�"+osAttributePO.getRowIndex()+"銆戣鏁版嵁锛屽睘鎬у悕閲嶅");
+ }else {
+ try {
+ if(platformClientUtil.getAttributeService().checkRowIsExists(osAttributePO.getId())){
+ throw new PLException("500",new String[]{"灞炴�у悕绉般��" + osAttributePO.getId() + "銆戝湪绯荤粺涓凡瀛樺湪!"});
+ }
+ } catch (PLException e) {
+ e.printStackTrace();
+ String errorMsg = "涓庣郴缁熶腑灞炴�у悕鏌ラ噸鏃跺嚭鐜伴敊璇�,鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(errorMsg);
+ //鏄惁璺宠繃褰撴湡閲嶅鏁版嵁
+ if(isContinue){
+ continue;
+ }
+ throw new VciBaseException(errorMsg);
+ }
}
//灞炴�у悕鏍¢獙
try {
@@ -1037,7 +1057,7 @@
//灞炴�у悕excel涓垽閲嶅鐞�
excelReapeat.put(osAttributePO.getId(),osAttributePO.getRowIndex());
OsAttributeDTO osAttributeDTO = new OsAttributeDTO();
- //鏌ヨ鏋氫妇鏄惁瀛樺湪锛屽~鍐欎簡鏋氫妇浣嗘病濉啓鍙栧�艰寖鍥达紝杩欐椂鍊欑洿鎺ヤ娇鐢ㄦ灇涓鹃」鍊间綔涓洪粯璁ょ殑range
+ //鏌ヨ灞炴�ф槸鍚﹀瓨鍦紝濉啓浜嗘灇涓句絾娌″~鍐欏彇鍊艰寖鍥达紝杩欐椂鍊欑洿鎺ヤ娇鐢ㄦ灇涓鹃」鍊间綔涓洪粯璁ょ殑range
if(Func.isNotBlank(osAttributePO.getEnumId()) && Func.isBlank(osAttributePO.getRange())){
try {
OsEnumVO enumVO = enumService.getEnumTypeById(osAttributePO.getEnumId());
@@ -1075,10 +1095,10 @@
checkDefValue(osAttributeDTO);
} catch (PLException e) {
e.printStackTrace();
- throw new VciBaseException(e.getMessage());
+ throw new VciBaseException(VciBaseUtil.getExceptionMessage(e));
}
dtoList.add(osAttributeDTO);
- });
+ }
//鎵ц淇濆瓨鎿嶄綔
dtoList.stream().forEach(dto->{
try {
@@ -1093,12 +1113,12 @@
});
}catch (Exception e){
if(logger.isErrorEnabled()){
- logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐢ㄦ埛淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",VciBaseUtil.getExceptionMessage(e));
+ logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨灞炴�ф椂鍑虹幇浜嗛敊璇紝鍏蜂綋鍘熷洜锛�",VciBaseUtil.getExceptionMessage(e));
}
e.printStackTrace();
return BaseResult.fail(VciBaseUtil.getExceptionMessage(e),new String[]{},e);
}
- return BaseResult.success("鏋氫妇瀵煎叆鎴愬姛锛�");
+ return BaseResult.success("灞炴�у鍏ユ垚鍔燂紒");
}
/**
@@ -1116,6 +1136,31 @@
}
/**
+ * 鏍规嵁涓氬姟绫诲瀷鑾峰彇灞炴�т俊鎭�
+ * @param btName 涓氬姟绫诲瀷/閾炬帴绫诲瀷
+ * @param typeFlag 0:涓氬姟绫诲瀷,1:閾炬帴绫诲瀷
+ * @return
+ */
+ @Override
+ public List<OsAttributeVO> getOsAttributeVOSByBtName(String btName, int typeFlag) throws Exception{
+ VciBaseUtil.alertNotNull(btName,"鍙傛暟涓嶅厑璁镐负绌�",typeFlag,"鍙傛暟涓嶅厑璁镐负绌�");
+ List<OsAttributeVO> attributeVOS=new ArrayList<>();
+ try {
+ AttributeDef[] attributeDefs=new AttributeDef[]{};
+ if(typeFlag==0){
+ attributeDefs= platformClientUtil.getBtmService().getAttributeDefs(btName);
+ }else{
+ attributeDefs=platformClientUtil.getLinkTypeService().getAttributes(btName);
+ }
+ attributeVOS=attributeDO2VOs(Arrays.asList(attributeDefs));
+ }catch (PLException e){
+ throw new Exception("鏍规嵁涓氬姟绫诲瀷鑾峰彇灞炴�у紓甯�"+e.getMessage());
+ }
+
+ return attributeVOS;
+ }
+
+ /**
* 鏄惁涓哄弬鐓у睘鎬�
* @param other 閰嶇疆鐨勫叾浠�
* @return true 鏄弬鐓�
--
Gitblit v1.9.3