2018-03-17 17:09:19 +08:00
|
|
|
package com.nis.web.service.specific;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2018-03-28 18:24:09 +08:00
|
|
|
|
2018-06-21 09:12:25 +08:00
|
|
|
|
2018-03-17 17:09:19 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
2018-03-28 18:24:09 +08:00
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
2018-03-17 17:09:19 +08:00
|
|
|
|
|
|
|
|
import com.beust.jcommander.internal.Lists;
|
|
|
|
|
import com.nis.domain.Page;
|
2018-04-03 11:12:49 +08:00
|
|
|
import com.nis.domain.specific.ConfigGroupInfo;
|
2018-03-17 17:09:19 +08:00
|
|
|
import com.nis.domain.specific.SpecificServiceCfg;
|
2018-04-03 11:12:49 +08:00
|
|
|
import com.nis.main.ConvertTool;
|
2018-06-21 09:12:25 +08:00
|
|
|
import com.nis.util.ConfigServiceUtil;
|
2018-03-17 17:09:19 +08:00
|
|
|
import com.nis.util.StringUtil;
|
|
|
|
|
import com.nis.web.dao.specific.SpecificServiceCfgDao;
|
|
|
|
|
import com.nis.web.service.BaseService;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class SpecificServiceCfgService extends BaseService{
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private SpecificServiceCfgDao specificServiceCfgDao;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据id查询对象
|
|
|
|
|
* @param specServiceId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public SpecificServiceCfg getBySpecServiceId(Integer specServiceId) {
|
|
|
|
|
return specificServiceCfgDao.getBySpecServiceId(specServiceId);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 查询所有符合条件的顶层分页
|
|
|
|
|
* @param page
|
|
|
|
|
* @param specificServiceCfg
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Page<SpecificServiceCfg> findTopPage(Page<SpecificServiceCfg> page, SpecificServiceCfg specificServiceCfg){
|
|
|
|
|
// 设置分页参数
|
|
|
|
|
specificServiceCfg.setPage(page);
|
|
|
|
|
// 执行分页查询
|
|
|
|
|
List<SpecificServiceCfg> list = Lists.newArrayList();
|
|
|
|
|
list = specificServiceCfgDao.findTopPage(specificServiceCfg);
|
|
|
|
|
SpecificServiceCfg ss = new SpecificServiceCfg();
|
|
|
|
|
ss.setSpecServiceId(0);
|
|
|
|
|
for(SpecificServiceCfg ssc:list){
|
|
|
|
|
ssc.setParent(ss);
|
|
|
|
|
}
|
|
|
|
|
page.setList(list);
|
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 查询所有符合条件的数据
|
|
|
|
|
* @param specificServiceCfg
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2018-03-21 13:43:43 +08:00
|
|
|
public List<SpecificServiceCfg> findAllSpecificServiceCfg(SpecificServiceCfg specificServiceCfg, String orderBy) {
|
|
|
|
|
return specificServiceCfgDao.findAllSpecificServiceCfg(specificServiceCfg,orderBy);
|
2018-03-17 17:09:19 +08:00
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 保存或修改
|
|
|
|
|
* @param specificServiceCfg
|
2018-04-03 11:12:49 +08:00
|
|
|
* @throws Exception
|
2018-03-17 17:09:19 +08:00
|
|
|
*/
|
2018-03-28 18:24:09 +08:00
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
2018-06-21 09:12:25 +08:00
|
|
|
public void saveOrUpdate(SpecificServiceCfg specificServiceCfg) throws Exception {
|
2018-04-03 11:12:49 +08:00
|
|
|
if(specificServiceCfg.getGroupId()==null || specificServiceCfg.getGroupId()==0){
|
2018-06-21 09:12:25 +08:00
|
|
|
Integer groupId = ConfigServiceUtil.getId(2, 1).get(0);
|
|
|
|
|
specificServiceCfg.setGroupId(groupId);
|
2018-04-03 11:12:49 +08:00
|
|
|
}
|
|
|
|
|
//新增协议分组
|
|
|
|
|
ConfigGroupInfo group = specificServiceCfgDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId());
|
|
|
|
|
if(group==null){
|
|
|
|
|
group = new ConfigGroupInfo();
|
|
|
|
|
group.setGroupId(specificServiceCfg.getGroupId());
|
|
|
|
|
group.setGroupName(specificServiceCfg.getSpecServiceName());
|
|
|
|
|
group.setIsIssued(0);
|
|
|
|
|
group.setGroupType(1);
|
|
|
|
|
specificServiceCfgDao.insertConfigGroupInfo(group);
|
2018-03-21 13:43:43 +08:00
|
|
|
}
|
2018-06-21 09:12:25 +08:00
|
|
|
if(specificServiceCfg.getSpecServiceId()==null){//新增
|
2018-06-21 18:10:07 +08:00
|
|
|
if(specificServiceCfg.getIsLeaf()==null){
|
|
|
|
|
if(specificServiceCfg.getParent().getSpecServiceId().equals(0)){
|
|
|
|
|
specificServiceCfg.setIsLeaf(0);
|
|
|
|
|
}else{
|
|
|
|
|
specificServiceCfg.setIsLeaf(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-17 17:09:19 +08:00
|
|
|
specificServiceCfg.setIsValid(1);
|
|
|
|
|
specificServiceCfg.setOpTime(new Date());
|
|
|
|
|
specificServiceCfgDao.insert(specificServiceCfg);
|
|
|
|
|
}else{//修改
|
2018-06-21 18:10:07 +08:00
|
|
|
if(specificServiceCfg.getIsLeaf()==null){
|
|
|
|
|
if(specificServiceCfg.getParent().getSpecServiceId().equals(0)){
|
|
|
|
|
specificServiceCfg.setIsLeaf(0);
|
|
|
|
|
}else{
|
|
|
|
|
specificServiceCfg.setIsLeaf(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-17 17:09:19 +08:00
|
|
|
specificServiceCfg.setOpTime(new Date());
|
2018-06-21 09:12:25 +08:00
|
|
|
specificServiceCfgDao.update(specificServiceCfg);
|
2018-03-17 17:09:19 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
* @param specificServiceCfg
|
2018-03-28 18:24:09 +08:00
|
|
|
* @throws Exception
|
2018-03-17 17:09:19 +08:00
|
|
|
*/
|
2018-03-28 18:24:09 +08:00
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
|
|
|
|
public void delete(String mulitId){
|
2018-03-17 17:09:19 +08:00
|
|
|
String[] ids = mulitId.split(",");
|
|
|
|
|
for(String id:ids){
|
|
|
|
|
if (!id.equals("")) {
|
|
|
|
|
SpecificServiceCfg specificServiceCfg = specificServiceCfgDao.getBySpecServiceId(Integer.valueOf(id));
|
|
|
|
|
List<SpecificServiceCfg> list = Lists.newArrayList();
|
|
|
|
|
//找出所有下级
|
|
|
|
|
if(specificServiceCfg!=null){
|
2018-03-21 13:43:43 +08:00
|
|
|
SpecificServiceCfg.sortList(list, specificServiceCfgDao.findAllSpecificServiceCfg(new SpecificServiceCfg(),""), specificServiceCfg.getSpecServiceId(), true);
|
2018-03-17 17:09:19 +08:00
|
|
|
list.add(specificServiceCfg);
|
|
|
|
|
for(SpecificServiceCfg ss:list){
|
|
|
|
|
ss.setIsValid(0);
|
|
|
|
|
specificServiceCfgDao.delete(ss);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据specServiceId查询所有下级
|
|
|
|
|
* @param specServiceId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<SpecificServiceCfg> getChildrenById(Integer specServiceId) {
|
|
|
|
|
return specificServiceCfgDao.getChildrenById(specServiceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|