已完成:
①字典列表,配置编码移到配置内容前一列
②系统字典与业务字典的item_code字段int类型改为varchar(64)
③业务字典和系统字典表增加一个字段,level_no,层级(新增、修改已加入)
④完成条件分页查询(折叠逻辑与无条件查询一致,)
⑤优化分页查询代码(预留介入条件排序),
待完善:修改、删除时下层级递归处理待添加事务性及测试(待手动抛异常重点测试)
生效范围测试尚未完毕,待处理
jquery Validate验证层级关系受<sys:treeselect>影响,待处理
样式调整:分页样式(尚未调整),
This commit is contained in:
@@ -20,7 +20,7 @@ public class ServiceDictInfo extends BaseEntity<ServiceDictInfo>{
|
||||
|
||||
private Integer serviceDictId; //service_dict_id 字典ID int N 主键,自增
|
||||
private Integer itemType; //item_type 数据类型 int N 1:分类 2:性质 3:标签
|
||||
private Integer itemCode; //item_code编码 int N
|
||||
private String itemCode; //item_code编码 varchar(64) N
|
||||
private String itemValue; //item_value 编码对应值 varchar2(64) N
|
||||
private String itemDesc; //item_desc 描述信息 varcahr2(128) Y
|
||||
private ServiceDictInfo parent; //parent_id 父ID number(9) N 无父属性,默认填0
|
||||
@@ -30,7 +30,8 @@ public class ServiceDictInfo extends BaseEntity<ServiceDictInfo>{
|
||||
private Date createTime; //create_time 配置时间 date N
|
||||
private SysUser serviceDictEditor; //editor_id 修改人员 int Y 取自sys_user.id
|
||||
private Date editTime; //edit_time 修改时间 date Y
|
||||
private List<ServiceDictInfo> ChildrenList = new ArrayList<ServiceDictInfo>();//字列表
|
||||
private Integer levelNo; //层级
|
||||
private List<ServiceDictInfo> ChildrenList = new ArrayList<ServiceDictInfo>();//子列表
|
||||
|
||||
private Date beginDate; // 开始日期
|
||||
private Date endDate; // 结束日期
|
||||
@@ -47,12 +48,18 @@ public class ServiceDictInfo extends BaseEntity<ServiceDictInfo>{
|
||||
public void setItemType(Integer itemType) {
|
||||
this.itemType = itemType;
|
||||
}
|
||||
public Integer getItemCode() {
|
||||
public String getItemCode() {
|
||||
return itemCode;
|
||||
}
|
||||
public void setItemCode(Integer itemCode) {
|
||||
public void setItemCode(String itemCode) {
|
||||
this.itemCode = itemCode;
|
||||
}
|
||||
public Integer getLevelNo() {
|
||||
return levelNo;
|
||||
}
|
||||
public void setLevelNo(Integer levelNo) {
|
||||
this.levelNo = levelNo;
|
||||
}
|
||||
public String getItemValue() {
|
||||
return itemValue;
|
||||
}
|
||||
@@ -175,5 +182,4 @@ public class ServiceDictInfo extends BaseEntity<ServiceDictInfo>{
|
||||
return listTemp.size();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class SysDictInfo extends BaseEntity<SysDictInfo>{
|
||||
|
||||
private Integer sysDictId; //service_dict_id 字典ID int N 主键,自增
|
||||
private Integer itemType; //item_type 数据类型 int N 1:分类 2:性质 3:标签
|
||||
private Integer itemCode; //item_code编码 int N
|
||||
private String itemCode; //item_code编码 varchar N
|
||||
private String itemValue; //item_value 编码对应值 varchar2(64) N
|
||||
private String itemDesc; //item_desc 描述信息 varcahr2(128) Y
|
||||
private SysDictInfo parent; //parent_id 父ID number(9) N 无父属性,默认填0
|
||||
@@ -28,6 +28,7 @@ public class SysDictInfo extends BaseEntity<SysDictInfo>{
|
||||
private Date createTime; //create_time 配置时间 date N
|
||||
private SysUser sysDictEditor; //editor_id 修改人员 int Y 取自sys_user.id
|
||||
private Date editTime; //edit_time 修改时间 date Y
|
||||
private Integer levelNo; //层级
|
||||
private List<ServiceDictInfo> ChildrenList = new ArrayList<ServiceDictInfo>();//字列表
|
||||
|
||||
private Date beginDate; // 开始日期
|
||||
@@ -46,10 +47,10 @@ public class SysDictInfo extends BaseEntity<SysDictInfo>{
|
||||
public void setItemType(Integer itemType) {
|
||||
this.itemType = itemType;
|
||||
}
|
||||
public Integer getItemCode() {
|
||||
public String getItemCode() {
|
||||
return itemCode;
|
||||
}
|
||||
public void setItemCode(Integer itemCode) {
|
||||
public void setItemCode(String itemCode) {
|
||||
this.itemCode = itemCode;
|
||||
}
|
||||
public String getItemValue() {
|
||||
@@ -124,6 +125,12 @@ public class SysDictInfo extends BaseEntity<SysDictInfo>{
|
||||
public void setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
public Integer getLevelNo() {
|
||||
return levelNo;
|
||||
}
|
||||
public void setLevelNo(Integer levelNo) {
|
||||
this.levelNo = levelNo;
|
||||
}
|
||||
@JsonIgnore
|
||||
public static void sortList(List<SysDictInfo> list, List<SysDictInfo> sourcelist, Integer parentId, boolean cascade){
|
||||
for (int i=0; i<sourcelist.size(); i++){
|
||||
|
||||
@@ -96,6 +96,7 @@ public class ServiceDictInfoController extends BaseController {
|
||||
allList.addAll(page.getList());
|
||||
ServiceDictInfo.sortList(list,allList,0,true);
|
||||
|
||||
|
||||
model.addAttribute("itType", itType);
|
||||
model.addAttribute("intArr", Arrays.asList(intArr));
|
||||
model.addAttribute("list", list);
|
||||
@@ -113,12 +114,11 @@ public class ServiceDictInfoController extends BaseController {
|
||||
*/
|
||||
@RequiresPermissions("sys:dict:view")
|
||||
@RequestMapping(value = {"searchList"})
|
||||
public String searchList(String itType, ServiceDictInfo serviceDictInfo,HttpServletRequest request, HttpServletResponse response, Model model) {
|
||||
public String searchList(String itType, ServiceDictInfo serviceDictInfo,HttpServletRequest request, HttpServletResponse response, Model model,Integer selectedType) {
|
||||
if(StringUtils.strIsBlank(serviceDictInfo.getItemValue())
|
||||
&&serviceDictInfo.getItemCode()==null
|
||||
&&StringUtils.strIsBlank(serviceDictInfo.getItemCode())
|
||||
&&serviceDictInfo.getBeginDate()==null
|
||||
&&serviceDictInfo.getEndDate()==null){
|
||||
Integer selectedType = null;
|
||||
if(serviceDictInfo.getItemType()!=null){
|
||||
selectedType = serviceDictInfo.getItemType();
|
||||
return "redirect:"+ adminPath + "/basics/serviceDictInfo/list?itType="+itType+"&selectedType="+selectedType;
|
||||
@@ -130,11 +130,44 @@ public class ServiceDictInfoController extends BaseController {
|
||||
for(int i=0;i<strArr.length;i++){
|
||||
intArr[i] = Integer.valueOf(strArr[i]);
|
||||
}
|
||||
if(serviceDictInfo.getItemType()!=null){
|
||||
model.addAttribute("selectedType", serviceDictInfo.getItemType());
|
||||
}else{
|
||||
model.addAttribute("selectedType", selectedType);
|
||||
serviceDictInfo.setItemType(selectedType);
|
||||
}
|
||||
//先查出条件查询所有数据(注意顺序)
|
||||
List<ServiceDictInfo> allList = serviceDictInfoService.findAllDictSearchList(serviceDictInfo,intArr);
|
||||
|
||||
//查出条件查询顶层分页数据
|
||||
Page<ServiceDictInfo> page = serviceDictInfoService.findDictTopSearchList(new Page<ServiceDictInfo>(request, response), serviceDictInfo,intArr);
|
||||
model.addAttribute("page", page);
|
||||
|
||||
//处理数据,保留顶层中的所有下层数据
|
||||
List<ServiceDictInfo> list = Lists.newArrayList();
|
||||
//取出主键优化处理
|
||||
List<Integer> tempList = Lists.newArrayList();
|
||||
for(ServiceDictInfo se:page.getList()){
|
||||
if(se!=null&&se.getServiceDictId()!=null){
|
||||
tempList.add(se.getServiceDictId());
|
||||
}
|
||||
}
|
||||
//删除所有重复
|
||||
for(int i=allList.size()-1;i>=0;i--){
|
||||
ServiceDictInfo se = allList.get(i);
|
||||
if(se!=null&&se.getServiceDictId()!=null){
|
||||
if(tempList.contains(se.getServiceDictId())){
|
||||
allList.remove(se);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allList.addAll(page.getList());
|
||||
ServiceDictInfo.sortList(list,allList,0,true);
|
||||
|
||||
model.addAttribute("itType", itType);
|
||||
model.addAttribute("intArr", Arrays.asList(intArr));
|
||||
Page<ServiceDictInfo> page = serviceDictInfoService.findDictSearchList(new Page<ServiceDictInfo>(request, response), serviceDictInfo,intArr);
|
||||
model.addAttribute("page", page);
|
||||
|
||||
model.addAttribute("list", list);
|
||||
|
||||
return "/basics/serviceDictInfoSearchList";
|
||||
}
|
||||
@@ -180,10 +213,10 @@ public class ServiceDictInfoController extends BaseController {
|
||||
|
||||
try {
|
||||
serviceDictInfoService.saveOrUpdate(serviceDictInfo);
|
||||
addMessage(redirectAttributes, "保存配置成功");
|
||||
addMessage(redirectAttributes, "保存成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes, "保存配置失败!");
|
||||
addMessage(redirectAttributes, "保存失败!");
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/basics/serviceDictInfo/list?itType="+itType;
|
||||
@@ -202,10 +235,10 @@ public class ServiceDictInfoController extends BaseController {
|
||||
public String delete(ServiceDictInfo serviceDictInfo, RedirectAttributes redirectAttributes,String itType) {
|
||||
try {
|
||||
serviceDictInfoService.deleteDict(serviceDictInfo);
|
||||
addMessage(redirectAttributes, "删除配置成功");
|
||||
addMessage(redirectAttributes, "删除成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes, "删除配置失败!");
|
||||
addMessage(redirectAttributes, "删除失败!");
|
||||
}
|
||||
return "redirect:" + adminPath + "/basics/serviceDictInfo/list?itType="+itType;
|
||||
}
|
||||
@@ -266,7 +299,7 @@ public class ServiceDictInfoController extends BaseController {
|
||||
return true;
|
||||
}
|
||||
if(!StringUtil.isEmpty(itemCode)){
|
||||
list = serviceDictInfoService.findByItemCode(Integer.valueOf(itemCode));
|
||||
list = serviceDictInfoService.findByItemCode(itemCode);
|
||||
}
|
||||
if(list==null||list.size()==0){
|
||||
return true;
|
||||
@@ -373,4 +406,31 @@ public class ServiceDictInfoController extends BaseController {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验层级关系
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "isLevelTotalSure")
|
||||
public boolean isLevelTotalSure(Integer parentId,Integer currentId) {
|
||||
if(parentId==-1||parentId==0){
|
||||
return true;
|
||||
}else{
|
||||
ServiceDictInfo p = serviceDictInfoService.getDictById(parentId);
|
||||
if(currentId==null){
|
||||
if(p.getLevelNo()<4){
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
ServiceDictInfo c = serviceDictInfoService.getDictById(currentId);
|
||||
if((p.getLevelNo()+c.getLevelNo())<5){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -112,12 +112,11 @@ public class SysDictInfoController extends BaseController {
|
||||
*/
|
||||
@RequiresPermissions("sys:dict:view")
|
||||
@RequestMapping(value = {"searchList"})
|
||||
public String searchList(String itType, SysDictInfo sysDictInfo,HttpServletRequest request, HttpServletResponse response, Model model) {
|
||||
public String searchList(String itType, SysDictInfo sysDictInfo,HttpServletRequest request, HttpServletResponse response, Model model, Integer selectedType) {
|
||||
if(StringUtils.strIsBlank(sysDictInfo.getItemValue())
|
||||
&&sysDictInfo.getItemCode()==null
|
||||
&&StringUtils.strIsBlank(sysDictInfo.getItemCode())
|
||||
&&sysDictInfo.getBeginDate()==null
|
||||
&&sysDictInfo.getEndDate()==null){
|
||||
Integer selectedType = null;
|
||||
if(sysDictInfo.getItemType()!=null){
|
||||
selectedType = sysDictInfo.getItemType();
|
||||
return "redirect:"+ adminPath + "/basics/sysDictInfo/list?itType="+itType+"&selectedType="+selectedType;
|
||||
@@ -129,11 +128,46 @@ public class SysDictInfoController extends BaseController {
|
||||
for(int i=0;i<strArr.length;i++){
|
||||
intArr[i] = Integer.valueOf(strArr[i]);
|
||||
}
|
||||
if(sysDictInfo.getItemType()!=null){
|
||||
model.addAttribute("selectedType", sysDictInfo.getItemType());
|
||||
}else{
|
||||
model.addAttribute("selectedType", selectedType);
|
||||
sysDictInfo.setItemType(selectedType);
|
||||
}
|
||||
//先查出条件查询所有数据(注意顺序)
|
||||
List<SysDictInfo> allList = sysDictInfoService.findAllDictSearchList(sysDictInfo,intArr);
|
||||
|
||||
//查出条件查询顶层分页数据
|
||||
Page<SysDictInfo> page = sysDictInfoService.findDictTopSearchList(new Page<SysDictInfo>(request, response), sysDictInfo,intArr);
|
||||
model.addAttribute("page", page);
|
||||
|
||||
//处理数据,保留顶层中的所有下层数据
|
||||
List<SysDictInfo> list = Lists.newArrayList();
|
||||
//取出主键优化处理
|
||||
List<Integer> tempList = Lists.newArrayList();
|
||||
for(SysDictInfo se:page.getList()){
|
||||
if(se!=null&&se.getSysDictId()!=null){
|
||||
tempList.add(se.getSysDictId());
|
||||
}
|
||||
}
|
||||
//删除所有重复
|
||||
for(int i=allList.size()-1;i>=0;i--){
|
||||
SysDictInfo se = allList.get(i);
|
||||
System.out.println("山前顺序"+se.getSysDictId());
|
||||
if(se!=null&&se.getSysDictId()!=null){
|
||||
if(tempList.contains(se.getSysDictId())){
|
||||
allList.remove(se);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
allList.addAll(page.getList());
|
||||
SysDictInfo.sortList(list,allList,0,true);
|
||||
|
||||
model.addAttribute("itType", itType);
|
||||
model.addAttribute("intArr", Arrays.asList(intArr));
|
||||
Page<SysDictInfo> page = sysDictInfoService.findDictSearchList(new Page<SysDictInfo>(request, response), sysDictInfo,intArr);
|
||||
model.addAttribute("page", page);
|
||||
|
||||
model.addAttribute("list", list);
|
||||
|
||||
return "/basics/sysDictInfoSearchList";
|
||||
}
|
||||
@@ -187,10 +221,10 @@ public class SysDictInfoController extends BaseController {
|
||||
|
||||
try {
|
||||
sysDictInfoService.saveOrUpdate(sysDictInfo);
|
||||
addMessage(redirectAttributes, "保存配置成功");
|
||||
addMessage(redirectAttributes, "保存成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes, "保存配置失败!");
|
||||
addMessage(redirectAttributes, "保存失败!");
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/basics/sysDictInfo/list?itType="+itType;
|
||||
@@ -206,10 +240,10 @@ public class SysDictInfoController extends BaseController {
|
||||
public String delete(SysDictInfo sysDictInfo, RedirectAttributes redirectAttributes, String itType) {
|
||||
try {
|
||||
sysDictInfoService.deleteDict(sysDictInfo);
|
||||
addMessage(redirectAttributes, "删除配置成功");
|
||||
addMessage(redirectAttributes, "删除成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes, "删除配置失败!");
|
||||
addMessage(redirectAttributes, "删除失败!");
|
||||
}
|
||||
return "redirect:" + adminPath + "/basics/sysDictInfo/list?itType="+itType;
|
||||
}
|
||||
@@ -245,10 +279,6 @@ public class SysDictInfoController extends BaseController {
|
||||
map.put("id", sysDictInfo.getSysDictId());
|
||||
map.put("pId", sysDictInfo.getParent().getSysDictId());
|
||||
map.put("name",sysDictInfo.getItemValue());
|
||||
/*if(serviceDictInfo.getParent().getServiceDictId()!=0){
|
||||
ServiceDictInfo parent = serviceDictInfoService.getDictById(serviceDictInfo.getParent().getServiceDictId());
|
||||
//map.put("placeholder",parent.getItemType().toString());
|
||||
}*/
|
||||
|
||||
mapList.add(map);
|
||||
}
|
||||
@@ -276,7 +306,7 @@ public class SysDictInfoController extends BaseController {
|
||||
return true;
|
||||
}
|
||||
if(!StringUtil.isEmpty(itemCode)){
|
||||
list = sysDictInfoService.findByItemCode(Integer.valueOf(itemCode));
|
||||
list = sysDictInfoService.findByItemCode(itemCode);
|
||||
}
|
||||
if(list==null||list.size()==0){
|
||||
return true;
|
||||
@@ -385,6 +415,30 @@ public class SysDictInfoController extends BaseController {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 校验层级关系
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "isLevelTotalSure")
|
||||
public boolean isLevelTotalSure(Integer parentId,Integer currentId) {
|
||||
if(parentId==-1||parentId==0){
|
||||
return true;
|
||||
}else{
|
||||
SysDictInfo p = sysDictInfoService.getDictById(parentId);
|
||||
if(currentId==null){
|
||||
if(p.getLevelNo()<4){
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
SysDictInfo c = sysDictInfoService.getDictById(currentId);
|
||||
if((p.getLevelNo()+c.getLevelNo())<5){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -39,17 +39,29 @@ public interface ServiceDictInfoDao extends CrudDao<ServiceDictInfo> {
|
||||
*/
|
||||
List<ServiceDictInfo> getDictByParentId(Integer parentId);
|
||||
/**
|
||||
* 查询字典列表(含条件查询(==))
|
||||
* 查询条件查询顶层字典列表(含条件查询(==))
|
||||
* @param serviceDictInfo
|
||||
* @return
|
||||
*/
|
||||
List<ServiceDictInfo> findDictSearchList(ServiceDictInfo serviceDictInfo);
|
||||
List<ServiceDictInfo> findDictTopSearchList(ServiceDictInfo serviceDictInfo);
|
||||
/**
|
||||
* 查询字典列表(含条件查询(!=))
|
||||
* 查询条件查询顶层字典列表(含条件查询(!=))
|
||||
* @param serviceDictInfo
|
||||
* @return
|
||||
*/
|
||||
List<ServiceDictInfo> findDictSearchListN(ServiceDictInfo serviceDictInfo);
|
||||
List<ServiceDictInfo> findDictTopSearchListN(ServiceDictInfo serviceDictInfo);
|
||||
/**
|
||||
* 查询条件查询所有字典列表(含条件查询(==))
|
||||
* @param serviceDictInfo
|
||||
* @return
|
||||
*/
|
||||
List<ServiceDictInfo> findAllDictSearchList(ServiceDictInfo serviceDictInfo);
|
||||
/**
|
||||
* 查询条件查询所有字典列表(含条件查询(!=))
|
||||
* @param serviceDictInfo
|
||||
* @return
|
||||
*/
|
||||
List<ServiceDictInfo> findAllDictSearchListN(ServiceDictInfo serviceDictInfo);
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,6 +69,11 @@ public interface ServiceDictInfoDao extends CrudDao<ServiceDictInfo> {
|
||||
* @param serviceDictInfo
|
||||
*/
|
||||
void insertDict(ServiceDictInfo serviceDictInfo);
|
||||
/**
|
||||
* 保存层级
|
||||
* @param serviceDictInfo
|
||||
*/
|
||||
void updateLevelNo(ServiceDictInfo serviceDictInfo);
|
||||
|
||||
/**
|
||||
* 根据主键查询字典详细信息
|
||||
@@ -69,7 +86,7 @@ public interface ServiceDictInfoDao extends CrudDao<ServiceDictInfo> {
|
||||
* @param itemCode
|
||||
* @return
|
||||
*/
|
||||
List<ServiceDictInfo> findByItemCode(Integer itemCode);
|
||||
List<ServiceDictInfo> findByItemCode(String itemCode);
|
||||
/**
|
||||
* 查询itemCode最大值
|
||||
* @return
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
<resultMap id="dictResultMap" type="com.nis.domain.basics.ServiceDictInfo" >
|
||||
<id column="service_dict_id" property="serviceDictId" jdbcType="INTEGER" />
|
||||
<result column="item_type" property="itemType" jdbcType="INTEGER" />
|
||||
<result column="item_code" property="itemCode" jdbcType="INTEGER" />
|
||||
<result column="item_code" property="itemCode" jdbcType="VARCHAR" />
|
||||
<result column="item_value" property="itemValue" jdbcType="VARCHAR" />
|
||||
<result column="item_desc" property="itemDesc" jdbcType="VARCHAR" />
|
||||
<result column="is_leaf" property="isLeaf" jdbcType="INTEGER" />
|
||||
<result column="level_no" property="levelNo" jdbcType="INTEGER" />
|
||||
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
||||
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
|
||||
@@ -46,6 +47,7 @@
|
||||
s.item_desc AS itemDesc,
|
||||
s.parent_id AS "parent.serviceDictId",
|
||||
s.is_leaf AS isLeaf,
|
||||
s.level_no AS levelNo,
|
||||
s.is_valid AS isValid,
|
||||
s.creator_id AS "serviceDictCreator.id",
|
||||
s.create_time AS createTime,
|
||||
@@ -137,7 +139,7 @@
|
||||
<include refid="serviceDictInfoColumns"/>
|
||||
FROM service_dict_info s
|
||||
<include refid="menuJoins"/>
|
||||
WHERE s.is_valid =1
|
||||
WHERE s.is_valid =1 AND s.parent_id != 0
|
||||
</select>
|
||||
|
||||
<!-- 查询所有非叶子配置 -->
|
||||
@@ -146,72 +148,151 @@
|
||||
<include refid="serviceDictInfoColumns"/>
|
||||
FROM service_dict_info s
|
||||
WHERE s.is_valid = 1 AND s.is_leaf = 0 AND item_type = #{itemType}
|
||||
ORDER BY s.create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 条件查询分页(==) -->
|
||||
<select id="findDictSearchList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.ServiceDictInfo">
|
||||
SELECT * FROM service_dict_info WHERE is_valid=1
|
||||
|
||||
<if test="itemType != null and itemType != '' " >
|
||||
AND item_type like '%${itemType}%'
|
||||
</if>
|
||||
<if test="itemCode != null and itemCode != '' " >
|
||||
AND item_code like '%${itemCode}%'
|
||||
</if>
|
||||
<if test="itemValue!= null and itemValue != '' " >
|
||||
AND item_value like '%${itemValue}%'
|
||||
</if>
|
||||
<if test="beginDate !=null" >
|
||||
AND create_time >= #{beginDate,jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
<if test="endDate !=null" >
|
||||
AND create_time <= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
|
||||
|
||||
</if>
|
||||
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
ORDER BY ${page.orderBy}
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY create_time desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 条件查询分页(!=) -->
|
||||
<select id="findDictSearchListN" resultMap="dictResultMap" parameterType="com.nis.domain.basics.ServiceDictInfo">
|
||||
SELECT * FROM service_dict_info WHERE is_valid=1
|
||||
<!-- 条件查询顶层分页(==) -->
|
||||
<select id="findDictTopSearchList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.ServiceDictInfo">
|
||||
SELECT * FROM service_dict_info s WHERE s.is_valid=1
|
||||
|
||||
<if test="itemCode != null and itemCode != '' " >
|
||||
AND item_code like '%${itemCode}%'
|
||||
AND s.item_code like '%${itemCode}%'
|
||||
</if>
|
||||
<if test="itemValue!= null and itemValue != '' " >
|
||||
AND item_value like '%${itemValue}%'
|
||||
AND s.item_value like '%${itemValue}%'
|
||||
</if>
|
||||
<if test="itemType != null and itemType != '' " >
|
||||
AND item_type != ${itemType}
|
||||
AND s.item_type = ${itemType}
|
||||
</if>
|
||||
<if test="beginDate !=null" >
|
||||
AND s.create_time >= #{beginDate,jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
<if test="endDate !=null" >
|
||||
AND s.create_time <= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
|
||||
</if>
|
||||
AND s.parent_id not in (
|
||||
SELECT s2.service_dict_id FROM service_dict_info s2 WHERE s2.is_valid=1
|
||||
<if test="itemCode != null and itemCode != '' " >
|
||||
AND s2.item_code like '%${itemCode}%'
|
||||
</if>
|
||||
<if test="itemValue!= null and itemValue != '' " >
|
||||
AND s2.item_value like '%${itemValue}%'
|
||||
</if>
|
||||
<if test="itemType != null and itemType != '' " >
|
||||
AND s2.item_type = ${itemType}
|
||||
</if>
|
||||
<if test="beginDate !=null" >
|
||||
AND s2.create_time >= #{beginDate,jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
<if test="endDate !=null" >
|
||||
AND s2.create_time <= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
|
||||
</if>
|
||||
)
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
ORDER BY s.${page.orderBy}
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY s.create_time desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 条件查询顶层分页(!=) -->
|
||||
<select id="findDictTopSearchListN" resultMap="dictResultMap" parameterType="com.nis.domain.basics.ServiceDictInfo">
|
||||
SELECT * FROM service_dict_info s WHERE s.is_valid=1
|
||||
|
||||
<if test="itemCode != null and itemCode != '' " >
|
||||
AND s.item_code like '%${itemCode}%'
|
||||
</if>
|
||||
<if test="itemValue!= null and itemValue != '' " >
|
||||
AND s.item_value like '%${itemValue}%'
|
||||
</if>
|
||||
<if test="itemType != null and itemType != '' " >
|
||||
AND s.item_type != ${itemType}
|
||||
</if>
|
||||
<if test="beginDate !=null" >
|
||||
AND s.create_time >= #{beginDate,jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
<if test="endDate !=null" >
|
||||
AND s.create_time <= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
|
||||
</if>
|
||||
AND s.parent_id not in (
|
||||
SELECT s2.service_dict_id FROM service_dict_info s2 WHERE s2.is_valid=1
|
||||
<if test="itemCode != null and itemCode != '' " >
|
||||
AND s2.item_code like '%${itemCode}%'
|
||||
</if>
|
||||
<if test="itemValue!= null and itemValue != '' " >
|
||||
AND s2.item_value like '%${itemValue}%'
|
||||
</if>
|
||||
<if test="itemType != null and itemType != '' " >
|
||||
AND s2.item_type != ${itemType}
|
||||
</if>
|
||||
<if test="beginDate !=null" >
|
||||
AND s2.create_time >= #{beginDate,jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
<if test="endDate !=null" >
|
||||
AND s2.create_time <= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
|
||||
</if>
|
||||
)
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
ORDER BY s.${page.orderBy}
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY s.create_time desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<!-- 条件查询所有列表 (==)-->
|
||||
<select id="findAllDictSearchList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.ServiceDictInfo">
|
||||
SELECT * FROM service_dict_info WHERE is_valid=1
|
||||
|
||||
<if test="itemValue != null and itemValue != '' " >
|
||||
AND item_value like '%${itemValue}%'
|
||||
</if>
|
||||
<if test="itemCode != null and itemCode != '' " >
|
||||
AND item_code like '%${itemCode}%'
|
||||
</if>
|
||||
<if test="itemType != null and itemType != '' " >
|
||||
AND item_type = #{itemType}
|
||||
</if>
|
||||
<if test="beginDate !=null" >
|
||||
AND create_time >= #{beginDate,jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
<if test="endDate !=null" >
|
||||
AND create_time <= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
|
||||
|
||||
</if>
|
||||
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
ORDER BY ${page.orderBy}
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY create_time desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 条件查询所有列表 (!=)-->
|
||||
<select id="findAllDictSearchListN" resultMap="dictResultMap" parameterType="com.nis.domain.basics.ServiceDictInfo">
|
||||
SELECT * FROM service_dict_info WHERE is_valid=1
|
||||
|
||||
<if test="itemValue != null and itemValue != '' " >
|
||||
AND item_value like '%${itemValue}%'
|
||||
</if>
|
||||
<if test="itemCode != null and itemCode != '' " >
|
||||
AND item_code like '%${itemCode}%'
|
||||
</if>
|
||||
<if test="itemType != null and itemType != '' " >
|
||||
AND item_type != #{itemType}
|
||||
</if>
|
||||
<if test="beginDate !=null" >
|
||||
AND create_time >= #{beginDate,jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
<if test="endDate !=null" >
|
||||
AND create_time <= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 根据主键查询字典详细信息 -->
|
||||
@@ -246,10 +327,10 @@
|
||||
<!-- 新增字典信息 -->
|
||||
|
||||
<insert id="insertDict" parameterType="com.nis.domain.basics.ServiceDictInfo" useGeneratedKeys="true" keyProperty="id" >
|
||||
insert into service_dict_info (item_type, item_code, item_value, item_desc, parent_id, is_leaf, is_valid, creator_id, create_time, editor_id, edit_time)
|
||||
insert into service_dict_info (item_type, item_code, item_value, item_desc, parent_id, is_leaf, level_no, is_valid, creator_id, create_time, editor_id, edit_time)
|
||||
values ( #{itemType,jdbcType=INTEGER}, #{itemCode,jdbcType=INTEGER},
|
||||
#{itemValue,jdbcType=VARCHAR}, #{itemDesc,jdbcType=VARCHAR},
|
||||
#{parent.serviceDictId,jdbcType=INTEGER}, #{isLeaf,jdbcType=INTEGER}, #{isValid,jdbcType=INTEGER},
|
||||
#{parent.serviceDictId,jdbcType=INTEGER}, #{isLeaf,jdbcType=INTEGER},#{levelNo,jdbcType=VARCHAR}, #{isValid,jdbcType=INTEGER},
|
||||
#{serviceDictCreator.id,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
|
||||
#{serviceDictEditor.id,jdbcType=INTEGER}, #{editTime,jdbcType=TIMESTAMP})
|
||||
</insert>
|
||||
@@ -266,11 +347,19 @@
|
||||
s.item_desc = #{itemDesc},
|
||||
s.parent_id = #{parent.serviceDictId},
|
||||
s.is_leaf = #{isLeaf},
|
||||
s.level_no = #{levelNo},
|
||||
s.creator_id = #{serviceDictCreator.id},
|
||||
s.editor_id = #{serviceDictEditor.id},
|
||||
s.edit_time = #{editTime}
|
||||
WHERE s.service_dict_id = #{serviceDictId}
|
||||
</update>
|
||||
|
||||
<!-- 保存层级 -->
|
||||
<update id="updateLevelNo">
|
||||
UPDATE service_dict_info s SET
|
||||
s.level_no = #{levelNo}
|
||||
WHERE s.service_dict_id = #{serviceDictId}
|
||||
</update>
|
||||
|
||||
<!-- 删除 -->
|
||||
|
||||
@@ -296,7 +385,5 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -24,13 +24,18 @@ public interface SysDictInfoDao extends CrudDao<SysDictInfo> {
|
||||
* @return
|
||||
*/
|
||||
List<SysDictInfo> findAllDictList(SysDictInfo sysDictInfo);
|
||||
|
||||
/**
|
||||
* 查询字典列表(含条件查询(==)
|
||||
* 查询条件查询顶层字典列表(含条件查询(==))
|
||||
* @param sysDictInfo
|
||||
* @return
|
||||
*/
|
||||
List<SysDictInfo> findDictSearchList(SysDictInfo sysDictInfo);
|
||||
List<SysDictInfo> findDictTopSearchList(SysDictInfo sysDictInfo);
|
||||
/**
|
||||
* 查询字典列表(含条件查询(==))
|
||||
* @param sysDictInfo
|
||||
* @return
|
||||
*/
|
||||
List<SysDictInfo> findAllDictSearchList(SysDictInfo sysDictInfo);
|
||||
|
||||
|
||||
|
||||
@@ -60,7 +65,7 @@ public interface SysDictInfoDao extends CrudDao<SysDictInfo> {
|
||||
* @param itemCode
|
||||
* @return
|
||||
*/
|
||||
List<SysDictInfo> findByItemCode(Integer itemCode);
|
||||
List<SysDictInfo> findByItemCode(String itemCode);
|
||||
|
||||
/**
|
||||
* 根据上级id选出所有下级
|
||||
@@ -74,6 +79,11 @@ public interface SysDictInfoDao extends CrudDao<SysDictInfo> {
|
||||
* @return
|
||||
*/
|
||||
Integer findMaxItemCode();
|
||||
/**
|
||||
* 保存层级
|
||||
* @param sysDictInfo
|
||||
*/
|
||||
void updateLevelNo(SysDictInfo sysDictInfo);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
<resultMap id="dictResultMap" type="com.nis.domain.basics.SysDictInfo" >
|
||||
<id column="sys_dict_id" property="sysDictId" jdbcType="INTEGER" />
|
||||
<result column="item_type" property="itemType" jdbcType="INTEGER" />
|
||||
<result column="item_code" property="itemCode" jdbcType="INTEGER" />
|
||||
<result column="item_code" property="itemCode" jdbcType="VARCHAR" />
|
||||
<result column="item_value" property="itemValue" jdbcType="VARCHAR" />
|
||||
<result column="item_desc" property="itemDesc" jdbcType="VARCHAR" />
|
||||
<result column="is_leaf" property="isLeaf" jdbcType="INTEGER" />
|
||||
<result column="level_no" property="levelNo" jdbcType="INTEGER" />
|
||||
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
||||
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
|
||||
@@ -37,6 +38,7 @@
|
||||
s.item_desc AS itemDesc,
|
||||
s.parent_id AS "parent.sysDictId",
|
||||
s.is_leaf AS isLeaf,
|
||||
s.level_no AS levelNo,
|
||||
s.is_valid AS isValid,
|
||||
s.creator_id AS "sysDictCreator.id",
|
||||
s.create_time AS createTime,
|
||||
@@ -88,12 +90,60 @@
|
||||
WHERE s.is_valid =1
|
||||
</select>
|
||||
|
||||
<!-- 条件查询分页(==) -->
|
||||
<select id="findDictSearchList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.SysDictInfo">
|
||||
<!-- 条件查询顶层分页(==) -->
|
||||
<select id="findDictTopSearchList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.SysDictInfo">
|
||||
SELECT * FROM sys_dict_info s WHERE s.is_valid=1
|
||||
|
||||
<if test="itemCode != null and itemCode != '' " >
|
||||
AND s.item_code like '%${itemCode}%'
|
||||
</if>
|
||||
<if test="itemValue!= null and itemValue != '' " >
|
||||
AND s.item_value like '%${itemValue}%'
|
||||
</if>
|
||||
<if test="itemType != null and itemType != '' " >
|
||||
AND s.item_type = ${itemType}
|
||||
</if>
|
||||
<if test="beginDate !=null" >
|
||||
AND s.create_time >= #{beginDate,jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
<if test="endDate !=null" >
|
||||
AND s.create_time <= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
|
||||
</if>
|
||||
AND s.parent_id not in (
|
||||
SELECT s2.sys_dict_id FROM sys_dict_info s2 WHERE s2.is_valid=1
|
||||
<if test="itemCode != null and itemCode != '' " >
|
||||
AND s2.item_code like '%${itemCode}%'
|
||||
</if>
|
||||
<if test="itemValue!= null and itemValue != '' " >
|
||||
AND s2.item_value like '%${itemValue}%'
|
||||
</if>
|
||||
<if test="itemType != null and itemType != '' " >
|
||||
AND s2.item_type = ${itemType}
|
||||
</if>
|
||||
<if test="beginDate !=null" >
|
||||
AND s2.create_time >= #{beginDate,jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
<if test="endDate !=null" >
|
||||
AND s2.create_time <= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
|
||||
</if>
|
||||
)
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
ORDER BY s.${page.orderBy}
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY s.create_time desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 条件查询所有(==) -->
|
||||
<select id="findAllDictSearchList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.SysDictInfo">
|
||||
SELECT * FROM sys_dict_info WHERE is_valid=1
|
||||
|
||||
<if test="itemType != null and itemType != '' " >
|
||||
AND item_type like '%${itemType}%'
|
||||
AND item_type = ${itemType}
|
||||
</if>
|
||||
<if test="itemCode != null and itemCode != '' " >
|
||||
AND item_code like '%${itemCode}%'
|
||||
@@ -106,18 +156,7 @@
|
||||
</if>
|
||||
<if test="endDate !=null" >
|
||||
AND create_time <= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
|
||||
|
||||
</if>
|
||||
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
ORDER BY ${page.orderBy}
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY create_time desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 根据主键查询字典详细信息 -->
|
||||
@@ -131,10 +170,10 @@
|
||||
<!-- 新增字典信息 -->
|
||||
|
||||
<insert id="insertDict" parameterType="com.nis.domain.basics.SysDictInfo" useGeneratedKeys="true" keyProperty="id" >
|
||||
insert into sys_dict_info (item_type, item_code, item_value, item_desc, parent_id, is_leaf, is_valid, creator_id, create_time, editor_id, edit_time)
|
||||
values ( #{itemType,jdbcType=INTEGER}, #{itemCode,jdbcType=INTEGER},
|
||||
insert into sys_dict_info (item_type, item_code, item_value, item_desc, parent_id, is_leaf,level_no, is_valid, creator_id, create_time, editor_id, edit_time)
|
||||
values ( #{itemType,jdbcType=INTEGER}, #{itemCode,jdbcType=VARCHAR},
|
||||
#{itemValue,jdbcType=VARCHAR}, #{itemDesc,jdbcType=VARCHAR},
|
||||
#{parent.sysDictId,jdbcType=INTEGER}, #{isLeaf,jdbcType=INTEGER}, #{isValid,jdbcType=INTEGER},
|
||||
#{parent.sysDictId,jdbcType=INTEGER}, #{isLeaf,jdbcType=INTEGER}, #{levelNo,jdbcType=INTEGER}, #{isValid,jdbcType=INTEGER},
|
||||
#{sysDictCreator.id,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
|
||||
#{sysDictEditor.id,jdbcType=INTEGER}, #{editTime,jdbcType=TIMESTAMP})
|
||||
</insert>
|
||||
@@ -159,6 +198,7 @@
|
||||
s.item_desc = #{itemDesc},
|
||||
s.parent_id = #{parent.sysDictId},
|
||||
s.is_leaf = #{isLeaf},
|
||||
s.level_no = #{levelNo},
|
||||
s.creator_id = #{sysDictCreator.id},
|
||||
s.editor_id = #{sysDictEditor.id},
|
||||
s.edit_time = #{editTime}
|
||||
@@ -191,5 +231,12 @@
|
||||
<select id="findMaxItemCode" resultType="java.lang.Integer">
|
||||
select max(s.item_code) from sys_dict_info s
|
||||
</select>
|
||||
|
||||
<!-- 保存层级 -->
|
||||
<update id="updateLevelNo">
|
||||
UPDATE sys_dict_info s SET
|
||||
s.level_no = #{levelNo}
|
||||
WHERE s.sys_dict_id = #{sysDictId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -91,47 +91,172 @@ public class ServiceDictInfoService extends BaseService{
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 查询字典分页(含条件查询)
|
||||
* 查询条件查询顶层分页(含条件查询,考虑排序接入可行性)
|
||||
* @param page
|
||||
* @param serviceDictInfo
|
||||
* @param itType
|
||||
* @return
|
||||
*/
|
||||
public Page<ServiceDictInfo> findDictSearchList(Page<ServiceDictInfo> page, ServiceDictInfo serviceDictInfo, Integer[] itType) {
|
||||
public Page<ServiceDictInfo> findDictTopSearchList(Page<ServiceDictInfo> page, ServiceDictInfo serviceDictInfo, Integer[] itType) {
|
||||
// 设置分页参数
|
||||
serviceDictInfo.setPage(page);
|
||||
serviceDictInfo.setPage(page);
|
||||
//根据条件查询符合数据
|
||||
List<ServiceDictInfo> allList = Lists.newArrayList();
|
||||
List<ServiceDictInfo> list = Lists.newArrayList();
|
||||
Integer tempType = 0;
|
||||
if(serviceDictInfo.getItemType()!=null){
|
||||
tempType = serviceDictInfo.getItemType();
|
||||
}
|
||||
if(itType.length==1){
|
||||
serviceDictInfo.setItemType(itType[0]);
|
||||
allList = serviceDictInfoDao.findDictTopSearchList(serviceDictInfo);
|
||||
}
|
||||
if(itType.length==2){
|
||||
if(tempType!=0){
|
||||
allList = serviceDictInfoDao.findDictTopSearchList(serviceDictInfo);
|
||||
}else{
|
||||
List<Integer> tempIntegerList = Lists.newArrayList();
|
||||
tempIntegerList.add(1);tempIntegerList.add(2);tempIntegerList.add(3);
|
||||
//Map<String,String> map = DictUtils.getDictOption("SERVICE_DICT_ITM_TYPE");
|
||||
if(tempIntegerList.contains(itType[0])){
|
||||
tempIntegerList.remove(itType[0]);
|
||||
}
|
||||
if(tempIntegerList.contains(itType[1])){
|
||||
tempIntegerList.remove(itType[1]);
|
||||
}
|
||||
serviceDictInfo.setItemType(tempIntegerList.get(0));
|
||||
allList = serviceDictInfoDao.findDictTopSearchListN(serviceDictInfo);
|
||||
}
|
||||
|
||||
}
|
||||
ServiceDictInfo tempSe = new ServiceDictInfo();
|
||||
tempSe.setServiceDictId(0);
|
||||
for(ServiceDictInfo se:allList){
|
||||
se.setParent(tempSe);
|
||||
}
|
||||
page.setList(allList);
|
||||
|
||||
|
||||
/*//根据条件查询符合数据
|
||||
List<ServiceDictInfo> allList = Lists.newArrayList();
|
||||
List<Integer> tempList = Lists.newArrayList();
|
||||
List<ServiceDictInfo> list = Lists.newArrayList();
|
||||
List<ServiceDictInfo> listChild = Lists.newArrayList();
|
||||
List<ServiceDictInfo> listParent = Lists.newArrayList();
|
||||
Integer tempType = 0;
|
||||
Integer total = 0;
|
||||
Integer pageCount = 0;
|
||||
Integer lostCount = 0;
|
||||
if(serviceDictInfo.getItemType()!=null){
|
||||
tempType = serviceDictInfo.getItemType();
|
||||
}
|
||||
if(itType.length==1){
|
||||
serviceDictInfo.setItemType(itType[0]);
|
||||
allList = serviceDictInfoDao.findDictSearchList(serviceDictInfo);
|
||||
}
|
||||
if(itType.length==2){
|
||||
if(tempType!=0){
|
||||
allList = serviceDictInfoDao.findDictSearchList(serviceDictInfo);
|
||||
}else{
|
||||
List<Integer> tempIntegerList = Lists.newArrayList();
|
||||
tempIntegerList.add(1);tempIntegerList.add(2);tempIntegerList.add(3);
|
||||
//Map<String,String> map = DictUtils.getDictOption("SERVICE_DICT_ITM_TYPE");
|
||||
if(tempIntegerList.contains(itType[0])){
|
||||
tempIntegerList.remove(itType[0]);
|
||||
}
|
||||
if(tempIntegerList.contains(itType[1])){
|
||||
tempIntegerList.remove(itType[1]);
|
||||
}
|
||||
serviceDictInfo.setItemType(tempIntegerList.get(0));
|
||||
allList = serviceDictInfoDao.findDictSearchListN(serviceDictInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//处理数据
|
||||
//page.list中有多少个不是page.list中的顶层(其上级在page.list)
|
||||
ServiceDictInfo tempSe = new ServiceDictInfo();
|
||||
tempSe.setServiceDictId(0);
|
||||
//取出主键优化处理
|
||||
for(ServiceDictInfo se:allList){
|
||||
if(se!=null&&se.getServiceDictId()!=null){
|
||||
tempList.add(se.getServiceDictId());
|
||||
}
|
||||
}
|
||||
|
||||
for(ServiceDictInfo se:allList){
|
||||
if(se!=null&&se.getParent()!=null&&se.getParent().getServiceDictId()!=null){
|
||||
//ServiceDictInfo temp = serviceDictInfoDao.getDictById(se.getParent().getServiceDictId());
|
||||
if(tempList.contains(se.getParent().getServiceDictId())){
|
||||
listChild.add(se);
|
||||
lostCount+=lostCount;
|
||||
}else{
|
||||
se.setParent(tempSe);
|
||||
listParent.add(se);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//确定总页数
|
||||
total = allList.size() - lostCount;
|
||||
pageCount = total%page.getPageSize()==0?total%page.getPageSize():(total%page.getPageSize()+1);
|
||||
if(pageCount==0){
|
||||
pageCount=1;
|
||||
}
|
||||
//取出所有的顶层
|
||||
//获取分页 每页数量pageSize、、当前页数pageNo (排序,,,) 每页第一个(pageNo-1)*pageSize+1 最后一个pageNo*pageSize
|
||||
List<ServiceDictInfo> parentShow = Lists.newArrayList();
|
||||
for(int i=0;i<listParent.size();i++){
|
||||
if(i>=((page.getPageNo()-1)*page.getPageSize())&&i<page.getPageNo()*page.getPageSize()){
|
||||
parentShow.add(listParent.get(i));
|
||||
}
|
||||
}
|
||||
parentShow.addAll(listChild);
|
||||
|
||||
ServiceDictInfo.sortList(list,parentShow,0,true);
|
||||
|
||||
page.setList(list);*/
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 条件查询所有数据
|
||||
* @param serviceDictInfo
|
||||
* @param itType
|
||||
* @return
|
||||
*/
|
||||
public List<ServiceDictInfo> findAllDictSearchList(ServiceDictInfo serviceDictInfo,Integer[] itType){
|
||||
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);
|
||||
serviceDictInfo.setItemType(itType[0]);
|
||||
list = serviceDictInfoDao.findAllDictSearchList(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);
|
||||
}
|
||||
|
||||
if(tempType!=0){
|
||||
list = serviceDictInfoDao.findAllDictSearchList(serviceDictInfo);
|
||||
}else{
|
||||
List<Integer> tempIntegerList = Lists.newArrayList();
|
||||
tempIntegerList.add(1);tempIntegerList.add(2);tempIntegerList.add(3);
|
||||
//Map<String,String> map = DictUtils.getDictOption("SERVICE_DICT_ITM_TYPE");
|
||||
if(tempIntegerList.contains(itType[0])){
|
||||
tempIntegerList.remove(itType[0]);
|
||||
}
|
||||
if(tempIntegerList.contains(itType[1])){
|
||||
tempIntegerList.remove(itType[1]);
|
||||
}
|
||||
serviceDictInfo.setItemType(tempIntegerList.get(0));
|
||||
list = serviceDictInfoDao.findAllDictSearchListN(serviceDictInfo);
|
||||
}
|
||||
}
|
||||
if(tempType!=0){
|
||||
serviceDictInfo.setItemType(tempType);
|
||||
}else{
|
||||
serviceDictInfo.setItemType(null);
|
||||
}
|
||||
|
||||
page.setList(list);
|
||||
return page;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +282,7 @@ public class ServiceDictInfoService extends BaseService{
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改业务字典表
|
||||
* 新增或修改业务字典表(添加层级改变)
|
||||
* @param serviceDictInfo
|
||||
*/
|
||||
public void saveOrUpdate(ServiceDictInfo serviceDictInfo) {
|
||||
@@ -168,12 +293,16 @@ public class ServiceDictInfoService extends BaseService{
|
||||
){
|
||||
ServiceDictInfo parent = new ServiceDictInfo();
|
||||
parent.setServiceDictId(0);
|
||||
parent.setLevelNo(0);
|
||||
serviceDictInfo.setParent(parent);
|
||||
}
|
||||
if(serviceDictInfo.getParent().getServiceDictId()!=0){
|
||||
ServiceDictInfo parent = serviceDictInfoDao.getDictById(serviceDictInfo.getParent().getServiceDictId());
|
||||
serviceDictInfo.setParent(parent);
|
||||
}
|
||||
SysUser user = UserUtils.getUser();
|
||||
if(StringUtil.isEmpty(serviceDictInfo.getServiceDictId())) {//新增
|
||||
Integer maxCode = serviceDictInfoDao.findMaxItemCode();
|
||||
serviceDictInfo.setItemCode(maxCode==null?1:(maxCode+1));
|
||||
serviceDictInfo.setLevelNo(serviceDictInfo.getParent().getLevelNo()+1);
|
||||
serviceDictInfo.setIsValid(1);
|
||||
serviceDictInfo.setServiceDictCreator(user);
|
||||
serviceDictInfo.setCreateTime(new Date());
|
||||
@@ -182,12 +311,41 @@ public class ServiceDictInfoService extends BaseService{
|
||||
serviceDictInfoDao.insertDict(serviceDictInfo);
|
||||
}
|
||||
else {//修改
|
||||
List<ServiceDictInfo> resultList = Lists.newArrayList();
|
||||
List<ServiceDictInfo> list = serviceDictInfoDao.getDictByParentId(serviceDictInfo.getServiceDictId());
|
||||
|
||||
//处理层级
|
||||
if(serviceDictInfo.getParent().getServiceDictId()==0){
|
||||
serviceDictInfo.setLevelNo(1);
|
||||
//处理子集
|
||||
childLevel(serviceDictInfo,list,resultList);
|
||||
}else{
|
||||
serviceDictInfo.setLevelNo(serviceDictInfo.getParent().getLevelNo()+1);
|
||||
//处理子集
|
||||
childLevel(serviceDictInfo,list,resultList);
|
||||
}
|
||||
serviceDictInfo.setServiceDictEditor(user);
|
||||
serviceDictInfo.setEditTime(new Date());
|
||||
for(ServiceDictInfo sc:resultList){
|
||||
serviceDictInfoDao.updateLevelNo(sc);
|
||||
}
|
||||
serviceDictInfoDao.update(serviceDictInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//处理子集层级
|
||||
|
||||
public void childLevel(ServiceDictInfo serviceDictInfo, List<ServiceDictInfo> list,List<ServiceDictInfo> resultList){
|
||||
for(ServiceDictInfo se:list){
|
||||
se.setLevelNo(serviceDictInfo.getLevelNo()+1);
|
||||
resultList.add(se);
|
||||
List<ServiceDictInfo> newList = serviceDictInfoDao.getDictByParentId(se.getServiceDictId());
|
||||
childLevel(se,newList,resultList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
@@ -209,7 +367,7 @@ public class ServiceDictInfoService extends BaseService{
|
||||
/**
|
||||
* 根据itemCode查出对象集合
|
||||
*/
|
||||
public List<ServiceDictInfo> findByItemCode(Integer itemCode){
|
||||
public List<ServiceDictInfo> findByItemCode(String itemCode){
|
||||
return serviceDictInfoDao.findByItemCode(itemCode);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,28 +54,43 @@ public class SysDictInfoService extends BaseService{
|
||||
|
||||
}
|
||||
/**
|
||||
* 查询字典分页(含条件查询)
|
||||
* 条件查询所有数据
|
||||
* @param page
|
||||
* @param sysDictInfo
|
||||
* @param intArr
|
||||
* @return
|
||||
*/
|
||||
public Page<SysDictInfo> findDictSearchList(Page<SysDictInfo> page, SysDictInfo sysDictInfo, Integer[] itType) {
|
||||
// 设置分页参数
|
||||
sysDictInfo.setPage(page);
|
||||
|
||||
public List<SysDictInfo> findAllDictSearchList(SysDictInfo sysDictInfo, Integer[] itType) {
|
||||
|
||||
List<SysDictInfo> list = Lists.newArrayList();
|
||||
/*Integer tempType = 0;
|
||||
if(sysDictInfo.getItemType()!=null){
|
||||
tempType = sysDictInfo.getItemType();
|
||||
}*/
|
||||
//查出分页
|
||||
list = sysDictInfoDao.findDictSearchList(sysDictInfo);
|
||||
page.setList(list);
|
||||
|
||||
list = sysDictInfoDao.findAllDictSearchList(sysDictInfo);
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 查询条件查询顶层分页(含条件查询,考虑排序接入可行性)
|
||||
* @param page
|
||||
* @param sysDictInfo
|
||||
* @param itType
|
||||
* @return
|
||||
*/
|
||||
public Page<SysDictInfo> findDictTopSearchList(Page<SysDictInfo> page, SysDictInfo sysDictInfo, Integer[] itType) {
|
||||
// 设置分页参数
|
||||
sysDictInfo.setPage(page);
|
||||
//根据条件查询符合数据
|
||||
List<SysDictInfo> allList = Lists.newArrayList();
|
||||
List<SysDictInfo> list = Lists.newArrayList();
|
||||
Integer tempType = 0;
|
||||
allList = sysDictInfoDao.findDictTopSearchList(sysDictInfo);
|
||||
SysDictInfo tempSe = new SysDictInfo();
|
||||
tempSe.setSysDictId(0);
|
||||
for(SysDictInfo se:allList){
|
||||
se.setParent(tempSe);
|
||||
}
|
||||
page.setList(allList);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -99,14 +114,16 @@ public class SysDictInfoService extends BaseService{
|
||||
){
|
||||
SysDictInfo parent = new SysDictInfo();
|
||||
parent.setSysDictId(0);
|
||||
parent.setLevelNo(0);
|
||||
sysDictInfo.setParent(parent);
|
||||
}
|
||||
if(sysDictInfo.getParent().getSysDictId()!=0){
|
||||
SysDictInfo parent = sysDictInfoDao.getDictById(sysDictInfo.getParent().getSysDictId());
|
||||
sysDictInfo.setParent(parent);
|
||||
}
|
||||
SysUser user = UserUtils.getUser();
|
||||
if(StringUtil.isEmpty(sysDictInfo.getSysDictId())) {//新增
|
||||
if(sysDictInfo.getItemCode()==null){
|
||||
Integer maxCode = sysDictInfoDao.findMaxItemCode();
|
||||
sysDictInfo.setItemCode(maxCode==null?1:(maxCode+1));
|
||||
}
|
||||
sysDictInfo.setLevelNo(sysDictInfo.getParent().getLevelNo()+1);
|
||||
sysDictInfo.setIsValid(1);
|
||||
sysDictInfo.setSysDictCreator(user);
|
||||
sysDictInfo.setCreateTime(new Date());
|
||||
@@ -117,12 +134,43 @@ public class SysDictInfoService extends BaseService{
|
||||
}
|
||||
|
||||
else {//修改
|
||||
List<SysDictInfo> resultList = Lists.newArrayList();
|
||||
List<SysDictInfo> list = sysDictInfoDao.getDictByParentId(sysDictInfo.getSysDictId());
|
||||
|
||||
//处理层级
|
||||
if(sysDictInfo.getParent().getSysDictId()==0){
|
||||
sysDictInfo.setLevelNo(1);
|
||||
//处理子集
|
||||
childLevel(sysDictInfo,list,resultList);
|
||||
}else{
|
||||
sysDictInfo.setLevelNo(sysDictInfo.getParent().getLevelNo()+1);
|
||||
//处理子集
|
||||
childLevel(sysDictInfo,list,resultList);
|
||||
}
|
||||
|
||||
|
||||
sysDictInfo.setSysDictEditor(user);
|
||||
sysDictInfo.setEditTime(new Date());
|
||||
for(SysDictInfo sc:resultList){
|
||||
sysDictInfoDao.updateLevelNo(sc);
|
||||
}
|
||||
sysDictInfoDao.update(sysDictInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//处理子集层级
|
||||
|
||||
public void childLevel(SysDictInfo sysDictInfo, List<SysDictInfo> list,List<SysDictInfo> resultList){
|
||||
for(SysDictInfo se:list){
|
||||
se.setLevelNo(sysDictInfo.getLevelNo()+1);
|
||||
resultList.add(se);
|
||||
List<SysDictInfo> newList = sysDictInfoDao.getDictByParentId(se.getSysDictId());
|
||||
childLevel(se,newList,resultList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
@@ -161,7 +209,7 @@ public class SysDictInfoService extends BaseService{
|
||||
* @param itemCode
|
||||
* @return
|
||||
*/
|
||||
public List<SysDictInfo> findByItemCode(Integer itemCode) {
|
||||
public List<SysDictInfo> findByItemCode(String itemCode) {
|
||||
return sysDictInfoDao.findByItemCode(itemCode);
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user