| | |
| | | public boolean addSave(OsStatusDTO statusDTO) throws Exception { |
| | | VciBaseUtil.alertNotNull( |
| | | statusDTO,"状态的信息", |
| | | statusDTO.getId(),"状态的英文名称", |
| | | statusDTO.getName(),"状态的中文名称" |
| | | statusDTO.getId(),"状态的英文名称" |
| | | ); |
| | | StatePool dbStatePool = platformClientUtil.getStatePoolService().getStatePool(statusDTO.getId()); |
| | | if (Func.isNotEmpty(dbStatePool) && Func.isNotBlank(dbStatePool.oid)) { |
| | | throw new PLException("500",new String[]{"名称重复请更换名称!"}); |
| | | if (statusDTO.getId().length()>50) { |
| | | throw new PLException("500",new String[]{"状态英文名称不能超过50个字符!"}); |
| | | } |
| | | // 状态池名称只能为英文字母 |
| | | String regex = "[a-z A-Z]*"; |
| | | if ((!statusDTO.getId().matches(regex))) { |
| | | if (!statusDTO.getId().matches(regex)) { |
| | | throw new PLException("500",new String[]{"名称只能为英文!"}); |
| | | } |
| | | StatePool dbStatePool = platformClientUtil.getStatePoolService().getStatePool(statusDTO.getId()); |
| | | if (Func.isNotEmpty(dbStatePool) && Func.isNotBlank(dbStatePool.oid)) { |
| | | throw new PLException("500",new String[]{"名称重复请更换名称!"}); |
| | | } |
| | | //虽然会自动生成oid,但是这儿设置主键,避免放入缓存的数据是没有oid的 |
| | | statusDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT)); |
| | |
| | | for(OsStatusDTO statusDTO : osStatusDTOS){ |
| | | //oid和ts判空 |
| | | String oid = statusDTO.getOid(); |
| | | //name主要用来对缓存数据删除 |
| | | String name = statusDTO.getName(); |
| | | //id主要用来对缓存数据删除 |
| | | String id = statusDTO.getId(); |
| | | //后台会用ts进行数据一致性校验 |
| | | Date ts = statusDTO.getTs(); |
| | | if(Func.isBlank(oid) || Func.isBlank(name) || Func.isEmpty(ts)){ |
| | | if(Func.isBlank(oid) || Func.isBlank(id) || Func.isEmpty(ts)){ |
| | | throw new PLException("500",new String[]{"待删除的状态列表中主键【oid】、调整时间【ts】、状态名称【name】不能为空!"}); |
| | | } |
| | | StatePool statePool = new StatePool(); |
| | | statePool.oid = oid; |
| | | statePool.name = name; |
| | | statePool.name = id; |
| | | statePool.ts = Func.format(ts,VciDateUtil.DateTimeMillFormat); |
| | | statePoolList.add(statePool); |
| | | boolean res = platformClientUtil.getStatePoolService().deleteStatePool(statePool); |
| | | if(!res){ |
| | | throw new PLException("500",new String[]{"删除状态名称为【" + name + "】的数据时出现错误!"}); |
| | | throw new PLException("500",new String[]{"删除状态名称为【" + id + "】的数据时出现错误!"}); |
| | | } |
| | | } |
| | | //clearCache(); |