From c86748a2c254ea22ac8f57d7984cc4743efaaed7 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期五, 26 七月 2024 16:53:07 +0800 Subject: [PATCH] Merge branch 'master' of http://dev.vci-tech.com:1065/r/PLTWEB --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java | 74 ++++++++++++++++++++++++------------- 1 files changed, 48 insertions(+), 26 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java index 9c4c8e1..7bae860 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java @@ -1,6 +1,5 @@ package com.vci.web.service.impl; -import com.vci.client.common.providers.ServiceProvider; import com.vci.corba.common.PLException; import com.vci.corba.omd.stm.StatePool; import com.vci.starter.web.annotation.log.VciUnLog; @@ -11,30 +10,30 @@ import com.vci.starter.web.util.LangBaseUtil; import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.util.VciDateUtil; -import com.vci.web.dto.OsStatusDTO; -import com.vci.web.model.OsStatusDO; -import com.vci.web.pageModel.OsStatusVO; +import com.vci.dto.OsStatusDTO; +import com.vci.model.OsStatusDO; +import com.vci.pagemodel.OsStatusVO; +import com.vci.starter.web.util.WebThreadLocalUtil; import com.vci.web.service.OsLifeCycleServiceI; import com.vci.web.service.OsStatusServiceI; import com.vci.web.service.WebBoServiceI; +import com.vci.web.util.Func; import com.vci.web.util.PlatformClientUtil; import com.vci.web.util.WebUtil; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import javax.swing.*; import java.util.*; import java.util.stream.Collectors; -import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; -import static com.vci.web.constant.CacheKeyConstant.ALL_STATUS; -import static com.vci.web.constant.CacheNameConstant.VCI_OBJECT_SERVICE; +import static com.vci.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; + /** * 鐘舵�佺殑鏈嶅姟 @@ -82,11 +81,12 @@ * @return 鏄剧ず瀵硅薄 */ @Override - public OsStatusVO statusDO2VO(com.vci.corba.omd.stm.StatePool statePool) { + public OsStatusVO statusDO2VO(StatePool statePool) { OsStatusVO statusVO = new OsStatusVO(); if(statePool!=null){ statusVO.setOid(statePool.oid); statusVO.setCreator(statePool.creator); + statusVO.setImagePath(statePool.imagePath); statusVO.setLastModifier(statePool.modifier); try { statusVO.setCreateTime(new Date(statePool.createTime)); @@ -109,7 +109,7 @@ * @return 鏄剧ず瀵硅薄 */ @Override - public List<OsStatusVO> statusDO2VOs(Collection<com.vci.corba.omd.stm.StatePool> statePools) { + public List<OsStatusVO> statusDO2VOs(Collection<StatePool> statePools) { List<OsStatusVO> statusVOS = new ArrayList<>(); if(!CollectionUtils.isEmpty(statePools)){ statePools.stream().forEach(statePool -> { @@ -129,8 +129,7 @@ @VciUnLog public List<OsStatusVO> selectAllStatus() { try { -// return statusDO2VOs(Arrays.stream(platformClientUtil.getStatePoolService().getStatePools()).collect(Collectors.toList())); - return statusDO2VOs(Arrays.stream(ServiceProvider.getOMDService().getStateService().getStatePools()).collect(Collectors.toList())); + return statusDO2VOs(Arrays.stream(platformClientUtil.getStatePoolService().getStatePools()).collect(Collectors.toList())); } catch (PLException vciError) { throw WebUtil.getVciBaseException(vciError); } @@ -139,7 +138,6 @@ /** * 娓呴櫎缂撳瓨 */ - @CacheEvict(value = VCI_OBJECT_SERVICE,key = ALL_STATUS) @Override public void clearCache(){ // @@ -151,7 +149,6 @@ */ @Override @VciUnLog - @Cacheable(value = VCI_OBJECT_SERVICE,key = ALL_STATUS,unless = "#result == null") public Map<String,OsStatusVO> selectAllStatusMap(){ return Optional.ofNullable(self.selectAllStatus()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getId(),t->t,(o1,o2)->o1)); } @@ -176,7 +173,7 @@ * @param statePoolList 鐘舵�佸唴瀹� */ @Override - public void batchAddStatus(List<StatePool> statePoolList) { + public boolean batchAddStatus(List<StatePool> statePoolList) throws Exception{ if(!CollectionUtils.isEmpty(statePoolList)){ for(StatePool statePool : statePoolList) { try { @@ -186,6 +183,7 @@ } } } + return true; } /** @@ -193,7 +191,7 @@ * @param statePoolList 鐘舵�佸唴瀹� */ @Override - public void batchEditSave(List<StatePool> statePoolList) { + public boolean batchEditSave(List<StatePool> statePoolList) { if(!CollectionUtils.isEmpty(statePoolList)){ for(StatePool statePool : statePoolList) { try { @@ -203,6 +201,7 @@ } } } + return true; } /** @@ -262,26 +261,46 @@ * @param statusDTO 鐘舵�佺殑鏁版嵁浼犺緭瀵硅薄 */ @Override - public void addSave(OsStatusDTO statusDTO) { - VciBaseUtil.alertNotNull(statusDTO,"鐘舵�佺殑淇℃伅",statusDTO.getId(),"鐘舵�佺殑鑻辨枃鍚嶇О",statusDTO.getName(),"鐘舵�佺殑涓枃鍚嶇О"); + public boolean addSave(OsStatusDTO statusDTO) throws Exception { + VciBaseUtil.alertNotNull( + statusDTO,"鐘舵�佺殑淇℃伅", + statusDTO.getId(),"鐘舵�佺殑鑻辨枃鍚嶇О", + statusDTO.getName(),"鐘舵�佺殑涓枃鍚嶇О" + ); + StatePool dbStatePool = platformClientUtil.getStatePoolService().getStatePool(statusDTO.getName()); + if (Func.isNotEmpty(dbStatePool) || Func.isNotBlank(dbStatePool.oid)) { + throw new PLException("500",new String[]{"鍚嶇О閲嶅璇锋洿鎹㈠悕绉帮紒"}); + } + // 鐘舵�佹睜鍚嶇О鍙兘涓鸿嫳鏂囧瓧姣� + String regex = "[a-z A-Z]*"; + if ((!dbStatePool.name.matches(regex))) { + throw new PLException("500",new String[]{"鍚嶇О鍙兘涓鸿嫳鏂囷紒"}); + } + //铏界劧浼氳嚜鍔ㄧ敓鎴恛id锛屼絾鏄繖鍎胯缃富閿紝閬垮厤鏀惧叆缂撳瓨鐨勬暟鎹槸娌℃湁oid鐨� statusDTO.setOid(VciBaseUtil.getPk()); StatePool pool = statusDTO2DO(statusDTO); List<StatePool> poolList = new ArrayList<>(); poolList.add(pool); batchAddStatus(poolList); - clearCache(); + //clearCache(); self.selectAllStatusMap(); + return true; } - /** * 缂栬緫鐘舵�� * @param statusDTO 鐘舵�佺殑鏁版嵁浼犺緭瀵硅薄 */ @Override - public void editSave(OsStatusDTO statusDTO){ - VciBaseUtil.alertNotNull(statusDTO,"鐘舵�佺殑淇℃伅",statusDTO.getId(),"鐘舵�佺殑鑻辨枃鍚嶇О",statusDTO.getName(),"鐘舵�佺殑涓枃鍚嶇О",statusDTO.getOid(),"涓婚敭"); + public boolean editSave(OsStatusDTO statusDTO) throws Exception { + VciBaseUtil.alertNotNull(statusDTO,"鐘舵�佺殑淇℃伅", + statusDTO.getId(),"鐘舵�佺殑鑻辨枃鍚嶇О", + statusDTO.getName(),"鐘舵�佺殑涓枃鍚嶇О", + statusDTO.getOid(),"涓婚敭"); OsStatusVO statusVO = getObjectByOid(statusDTO.getOid()); + if(Func.isEmpty(statusVO) || Func.isBlank(statusVO.getOid())){ + throw new PLException("500",new String[]{"淇敼鐨勭姸鎬佸璞′笉瀛樺湪锛�"}); + } StatePool pool = statusDTO2DO(statusDTO); pool.creator = statusVO.getCreator(); pool.createTime = VciDateUtil.getTime(statusVO.getCreateTime()); @@ -290,6 +309,7 @@ batchEditSave(poolList); clearCache(); self.selectAllStatusMap(); + return true; } /** @@ -297,7 +317,7 @@ * @param oids 涓婚敭 */ @Override - public void delete(String oids){ + public boolean delete(String oids){ VciBaseUtil.alertNotNull(oids,"涓婚敭"); //鍒ゆ柇鏄惁琚紩鐢� List<OsStatusVO> statusVOList1 = selectByOidCollection(VciBaseUtil.str2List(oids)); @@ -313,6 +333,7 @@ }); clearCache(); self.selectAllStatusMap(); + return true; } /** @@ -326,9 +347,10 @@ statePool.oid = statusDTO.getOid(); statePool.id = ""; statePool.name = statusDTO.getId(); + statePool.imagePath = statusDTO.getImagePath(); statePool.description = statusDTO.getDescription()==null?"":statusDTO.getDescription(); - String userId = VciBaseUtil.getCurrentUserId(); - long now = VciDateUtil.getTime(VciDateUtil.getNow()); + String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); + long now = VciDateUtil.getNowTime(); statePool.creator = userId; statePool.createTime = now; statePool.modifier = userId; -- Gitblit v1.9.3