2018-02-22 12:46:50 +08:00
|
|
|
|
package com.nis.web.service.configuration;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
import com.nis.domain.Page;
|
2018-03-01 19:13:57 +08:00
|
|
|
|
import com.nis.domain.SysMenu;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
import com.nis.domain.SysUser;
|
|
|
|
|
|
import com.nis.domain.configuration.ServiceDictInfo;
|
2018-02-25 18:43:20 +08:00
|
|
|
|
import com.nis.util.Constants;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
import com.nis.util.StringUtil;
|
|
|
|
|
|
import com.nis.web.dao.configuration.ServiceDictInfoDao;
|
|
|
|
|
|
import com.nis.web.security.UserUtils;
|
|
|
|
|
|
import com.nis.web.service.BaseService;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
|
public class ServiceDictInfoService extends BaseService{
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private ServiceDictInfoDao serviceDictInfoDao;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-04 19:20:32 +08:00
|
|
|
|
* 查询业务字典分页(无条件查询)
|
2018-02-22 12:46:50 +08:00
|
|
|
|
* @param page
|
|
|
|
|
|
* @param serviceDictInfo
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-03-04 19:20:32 +08:00
|
|
|
|
public Page<ServiceDictInfo> findTopDictList(Page<ServiceDictInfo> page, ServiceDictInfo serviceDictInfo,Integer[] itType) {
|
2018-02-22 12:46:50 +08:00
|
|
|
|
// 设置分页参数
|
|
|
|
|
|
serviceDictInfo.setPage(page);
|
2018-03-04 19:20:32 +08:00
|
|
|
|
List<ServiceDictInfo> parentList = Lists.newArrayList();
|
|
|
|
|
|
Integer tempType = 0;
|
|
|
|
|
|
if(serviceDictInfo.getItemType()!=null){
|
|
|
|
|
|
tempType = serviceDictInfo.getItemType();
|
|
|
|
|
|
}
|
2018-03-01 19:13:57 +08:00
|
|
|
|
//查出顶层分页查询
|
2018-03-04 19:20:32 +08:00
|
|
|
|
if(itType.length==1){
|
|
|
|
|
|
serviceDictInfo.setItemType(itType[0]);
|
|
|
|
|
|
parentList = serviceDictInfoDao.findTopDictList(serviceDictInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(itType.length==2){
|
|
|
|
|
|
if(tempType!=0){
|
|
|
|
|
|
parentList = serviceDictInfoDao.findTopDictList(serviceDictInfo);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
List<Integer> tempList = Lists.newArrayList();
|
|
|
|
|
|
tempList.add(1);tempList.add(2);tempList.add(3);
|
|
|
|
|
|
//Map<String,String> map = DictUtils.getDictOption("SERVICE_DICT_ITM_TYPE");
|
|
|
|
|
|
if(tempList.contains(itType[0])){
|
|
|
|
|
|
tempList.remove(itType[0]);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(tempList.contains(itType[1])){
|
|
|
|
|
|
tempList.remove(itType[1]);
|
|
|
|
|
|
}
|
|
|
|
|
|
serviceDictInfo.setItemType(tempList.get(0));
|
|
|
|
|
|
parentList = serviceDictInfoDao.findTopDictListN(serviceDictInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-01 19:13:57 +08:00
|
|
|
|
page.setList(parentList);
|
2018-02-22 12:46:50 +08:00
|
|
|
|
return page;
|
|
|
|
|
|
}
|
2018-03-01 19:13:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询所有有效字典配置
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public List<ServiceDictInfo> findAllDictList() {
|
|
|
|
|
|
|
|
|
|
|
|
return serviceDictInfoDao.findAllDictList(new ServiceDictInfo());
|
|
|
|
|
|
}
|
2018-02-22 12:46:50 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-04 19:20:32 +08:00
|
|
|
|
* 查询该类型所有的非叶子配置
|
2018-03-01 19:13:57 +08:00
|
|
|
|
*/
|
2018-03-04 19:20:32 +08:00
|
|
|
|
public List<ServiceDictInfo> findAllNoLeafDictList(String itType) {
|
|
|
|
|
|
List<ServiceDictInfo> list = Lists.newArrayList();
|
|
|
|
|
|
String[] strArr = itType.split("-");
|
|
|
|
|
|
Integer[] intArr = new Integer[strArr.length];
|
|
|
|
|
|
for(int i=0;i<strArr.length;i++){
|
|
|
|
|
|
intArr[i] = Integer.valueOf(strArr[i]);
|
|
|
|
|
|
List<ServiceDictInfo> tempList = serviceDictInfoDao.findAllNoLeafDictList(intArr[i]);
|
|
|
|
|
|
for(ServiceDictInfo serviceDictInfo:tempList){
|
|
|
|
|
|
list.add(serviceDictInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return list;
|
2018-03-01 19:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
/**
|
2018-03-04 19:20:32 +08:00
|
|
|
|
* 查询字典分页(含条件查询)
|
2018-02-22 12:46:50 +08:00
|
|
|
|
* @param page
|
|
|
|
|
|
* @param serviceDictInfo
|
2018-03-04 19:20:32 +08:00
|
|
|
|
* @param itType
|
2018-02-22 12:46:50 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-03-04 19:20:32 +08:00
|
|
|
|
public Page<ServiceDictInfo> findDictSearchList(Page<ServiceDictInfo> page, ServiceDictInfo serviceDictInfo, Integer[] itType) {
|
2018-02-22 12:46:50 +08:00
|
|
|
|
// 设置分页参数
|
2018-03-01 19:13:57 +08:00
|
|
|
|
serviceDictInfo.setPage(page);
|
2018-03-04 19:20:32 +08:00
|
|
|
|
|
|
|
|
|
|
List<ServiceDictInfo> list = Lists.newArrayList();
|
|
|
|
|
|
Integer tempType = 0;
|
|
|
|
|
|
if(serviceDictInfo.getItemType()!=null){
|
|
|
|
|
|
tempType = serviceDictInfo.getItemType();
|
|
|
|
|
|
}
|
|
|
|
|
|
//查出分页
|
|
|
|
|
|
if(itType.length==1){
|
|
|
|
|
|
serviceDictInfo.setItemType(itType[0]);
|
|
|
|
|
|
list = serviceDictInfoDao.findDictSearchList(serviceDictInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(itType.length==2){
|
|
|
|
|
|
if(tempType!=0){
|
|
|
|
|
|
list = serviceDictInfoDao.findTopDictList(serviceDictInfo);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
List<Integer> tempList = Lists.newArrayList();
|
|
|
|
|
|
tempList.add(1);tempList.add(2);tempList.add(3);
|
|
|
|
|
|
//Map<String,String> map = DictUtils.getDictOption("SERVICE_DICT_ITM_TYPE");
|
|
|
|
|
|
if(tempList.contains(itType[0])){
|
|
|
|
|
|
tempList.remove(itType[0]);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(tempList.contains(itType[1])){
|
|
|
|
|
|
tempList.remove(itType[1]);
|
|
|
|
|
|
}
|
|
|
|
|
|
serviceDictInfo.setItemType(tempList.get(0));
|
|
|
|
|
|
list = serviceDictInfoDao.findDictSearchListN(serviceDictInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
page.setList(list);
|
2018-03-01 19:13:57 +08:00
|
|
|
|
return page;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-01 19:13:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 根据主键查询字典详细信息
|
|
|
|
|
|
* @param serviceDictId
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public ServiceDictInfo getDictById(Integer serviceDictId) {
|
|
|
|
|
|
return serviceDictInfoDao.getDictById(serviceDictId);
|
|
|
|
|
|
}
|
2018-03-04 19:20:32 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据上级id选出所有下级
|
|
|
|
|
|
* @param parentId
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public List<ServiceDictInfo> getDictByParentId(Integer parentId) {
|
|
|
|
|
|
|
|
|
|
|
|
return serviceDictInfoDao.getDictByParentId(parentId);
|
|
|
|
|
|
}
|
2018-02-22 12:46:50 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 新增或修改业务字典表
|
|
|
|
|
|
* @param serviceDictInfo
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void saveOrUpdate(ServiceDictInfo serviceDictInfo) {
|
2018-03-04 19:20:32 +08:00
|
|
|
|
if(serviceDictInfo.getParent()==null
|
|
|
|
|
|
||(serviceDictInfo.getParent()!=null&&serviceDictInfo.getParent().getServiceDictId()==null)
|
|
|
|
|
|
||(serviceDictInfo.getParent()!=null&&serviceDictInfo.getParent().getServiceDictId()==-1)
|
|
|
|
|
|
||(serviceDictInfo.getParent()!=null&&serviceDictInfo.getParent().getServiceDictId()==0)
|
|
|
|
|
|
){
|
|
|
|
|
|
ServiceDictInfo parent = new ServiceDictInfo();
|
|
|
|
|
|
parent.setServiceDictId(0);
|
|
|
|
|
|
serviceDictInfo.setParent(parent);
|
|
|
|
|
|
}
|
2018-02-22 12:46:50 +08:00
|
|
|
|
SysUser user = UserUtils.getUser();
|
|
|
|
|
|
if(StringUtil.isEmpty(serviceDictInfo.getServiceDictId())) {//新增
|
|
|
|
|
|
serviceDictInfo.setIsValid(1);
|
|
|
|
|
|
serviceDictInfo.setServiceDictCreator(user);
|
|
|
|
|
|
serviceDictInfo.setCreateTime(new Date());
|
|
|
|
|
|
serviceDictInfo.setServiceDictEditor(user);
|
|
|
|
|
|
serviceDictInfo.setEditTime(serviceDictInfo.getCreateTime());
|
|
|
|
|
|
serviceDictInfoDao.insertDict(serviceDictInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
else {//修改
|
|
|
|
|
|
serviceDictInfo.setServiceDictEditor(user);
|
|
|
|
|
|
serviceDictInfo.setEditTime(new Date());
|
|
|
|
|
|
serviceDictInfoDao.update(serviceDictInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除
|
|
|
|
|
|
* @param serviceDictInfo
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void deleteDict(ServiceDictInfo serviceDictInfo) {
|
2018-03-01 19:13:57 +08:00
|
|
|
|
List<ServiceDictInfo> list = Lists.newArrayList();
|
|
|
|
|
|
//找出所有下级
|
|
|
|
|
|
//查出所有节点
|
|
|
|
|
|
ServiceDictInfo.sortList(list, serviceDictInfoDao.findAllDictList(new ServiceDictInfo()), serviceDictInfo.getServiceDictId(), true);
|
|
|
|
|
|
list.add(serviceDictInfo);
|
|
|
|
|
|
for(ServiceDictInfo se:list){
|
|
|
|
|
|
se.setIsValid(0);
|
|
|
|
|
|
serviceDictInfoDao.delete(se);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
2018-03-01 19:13:57 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-04 19:20:32 +08:00
|
|
|
|
* 根据itemCode查出对象集合
|
2018-03-01 19:13:57 +08:00
|
|
|
|
*/
|
2018-03-04 19:20:32 +08:00
|
|
|
|
public List<ServiceDictInfo> findByItemCode(Integer itemCode){
|
|
|
|
|
|
return serviceDictInfoDao.findByItemCode(itemCode);
|
2018-03-01 19:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-25 18:43:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* findFlDict(查找所有有效的分类)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*List<ServiceDictInfo>
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public List<ServiceDictInfo> findFlDict() {
|
|
|
|
|
|
return serviceDictInfoDao.findItemDict(Constants.ITEM_TYPE_FL,Constants.VALID_YES);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* findFlDict(查找所有有效的分类)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*List<ServiceDictInfo>
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public List<ServiceDictInfo> findAllFlDict() {
|
|
|
|
|
|
return serviceDictInfoDao.findAllItemDict(Constants.ITEM_TYPE_FL);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* findFlDict(查找所有有效的性质)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*List<ServiceDictInfo>
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public List<ServiceDictInfo> findXzDict() {
|
|
|
|
|
|
return serviceDictInfoDao.findItemDict(Constants.ITEM_TYPE_XZ,Constants.VALID_YES);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* findFlDict(查找所有有效的性质)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*List<ServiceDictInfo>
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public List<ServiceDictInfo> findAllXzDict() {
|
|
|
|
|
|
return serviceDictInfoDao.findAllItemDict(Constants.ITEM_TYPE_XZ);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* findFlDict(查找所有有效的标签)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*List<ServiceDictInfo>
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public List<ServiceDictInfo> findLableDict() {
|
|
|
|
|
|
return serviceDictInfoDao.findItemDict(Constants.ITEM_TYPE_LABEL,Constants.VALID_YES);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* findFlDict(查找所有有效的标签)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*List<ServiceDictInfo>
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public List<ServiceDictInfo> findAllLableDict() {
|
|
|
|
|
|
return serviceDictInfoDao.findAllItemDict(Constants.ITEM_TYPE_LABEL);
|
|
|
|
|
|
}
|
2018-03-01 19:13:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-04 19:20:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
|
|
|
|
|
|
|
}
|