package com.nis.web.service.configuration; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.nis.domain.configuration.AreaIpCfg; import com.nis.domain.configuration.BaseCfg; import com.nis.domain.configuration.BaseIpCfg; import com.nis.util.Constants; import com.nis.web.dao.configuration.AreaIpCfgDao; import com.nis.web.dao.configuration.IpCfgDao; import com.nis.web.service.CrudService; /** * IP相关配置事务类 * @author dell * */ @Service public class IpCfgService extends CrudService { @Autowired protected IpCfgDao ipCfgDao; @Autowired protected AreaIpCfgDao areaIpCfgDao; /** * * addIpCfg(新增IP类配置) * (继承BaseIpCfg这个类方可使用) * @param baseIpCfg * @return *int * @exception * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int addIpCfg(BaseIpCfg baseIpCfg,List areaIpCfgs){ if(areaIpCfgs!=null&&areaIpCfgs.size()>0){ this.saveIpBatch(areaIpCfgs); } return ipCfgDao.insert(baseIpCfg); } /** * * updateIpCfg(更新IP类配置) * (继承BaseIpCfg这个类方可使用) * @param baseIpCfg * @return *int * @exception * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int updateIpCfg(BaseIpCfg baseIpCfg,List addAreaCfg,List updateAreaCfg,List deleteAreaCfgs){ if(addAreaCfg!=null&&addAreaCfg.size()>0){ this.saveIpBatch(addAreaCfg); } if(updateAreaCfg!=null&&updateAreaCfg.size()>0){ this.updateIpBatch(updateAreaCfg); } if(deleteAreaCfgs!=null&&deleteAreaCfgs.size()>0){ this.deleteIpBatch(deleteAreaCfgs); } return ipCfgDao.update(baseIpCfg); } /** * * auditIpCfg(审核IP类配置) * (继承BaseIpCfg这个类方可使用) * @param baseIpCfg * @return *int * @throws Exception * @exception * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public void auditIpCfg(int isAduit,List auditCfg,List areaCfg,List sendCfg) throws Exception{ List> sendCfgs=new ArrayList>(); for(BaseIpCfg c:sendCfg){ List cArr=new ArrayList<>(); cArr.add(c); sendCfgs.add(cArr); } if(Constants.AUDIT_NOT_YES==isAduit|| Constants.AUDIT_YES==isAduit){//审核通过,取消审核通过需要发到maat if(sendToMaatConvertorBatch(isAduit,sendCfgs)){ if(areaCfg!=null&&areaCfg.size()>0){ this.auditIpBatch(areaCfg); } this.auditBatch(auditCfg, IpCfgDao.class); } }else{ if(areaCfg!=null&&areaCfg.size()>0){ this.auditIpBatch(areaCfg); } this.auditBatch(auditCfg, IpCfgDao.class); } } /** * * deleteIpCfg(删除IP类配置) * (继承BaseIpCfg这个类方可使用) * @param baseIpCfg * @return *int * @exception * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public void deleteIpCfg(List baseIpCfg, List areaCfg){ List cfgs=new ArrayList<>(); cfgs.addAll(areaCfg); if(areaCfg!=null&&areaCfg.size()>0){ this.deleteBatch(cfgs,IpCfgDao.class); } if(baseIpCfg!=null&&baseIpCfg.size()>0){ this.deleteBatch(baseIpCfg, IpCfgDao.class); } } /** * * getIpCfg(根据IP与类名获取IP配置) * (继承BaseIpCfg这个类方可使用) * @param clazz * @param id * @return *BaseIpCfg * @exception * @since 1.0.0 */ public BaseIpCfg getIpCfgById(BaseIpCfg baseIpCfg){ return ipCfgDao.getById(baseIpCfg.getTableName(), baseIpCfg.getCfgId()); } public Integer getIsValid(BaseIpCfg baseIpCfg){ return ipCfgDao.getIsValid(baseIpCfg); } public Integer getIsValid(String tableName, long id){ return ipCfgDao.getIsValid(tableName,id); } public Integer getIsAudit(BaseIpCfg baseIpCfg){ return ipCfgDao.getIsAudit(baseIpCfg); } public Integer getIsAudit(String tableName, long id){ return ipCfgDao.getIsAudit(tableName,id); } public List getAreaCfgByCompileId(int compileId){ return areaIpCfgDao.getByCompileId(compileId); } public List getList(String tableName,String ids){ return ipCfgDao.getList(tableName,ids); } }