kangwei : 物料类别列表:根据是否药剂赛选集合
正在显示
7 个修改的文件
包含
114 行增加
和
12 行删除
... | @@ -3,10 +3,7 @@ package com.skua.modules.supplies.controller.web; | ... | @@ -3,10 +3,7 @@ package com.skua.modules.supplies.controller.web; |
3 | import java.io.IOException; | 3 | import java.io.IOException; |
4 | import java.io.UnsupportedEncodingException; | 4 | import java.io.UnsupportedEncodingException; |
5 | import java.net.URLDecoder; | 5 | import java.net.URLDecoder; |
6 | import java.util.ArrayList; | 6 | import java.util.*; |
7 | import java.util.Arrays; | ||
8 | import java.util.List; | ||
9 | import java.util.Map; | ||
10 | import java.util.stream.Collectors; | 7 | import java.util.stream.Collectors; |
11 | import javax.servlet.http.HttpServletRequest; | 8 | import javax.servlet.http.HttpServletRequest; |
12 | import javax.servlet.http.HttpServletResponse; | 9 | import javax.servlet.http.HttpServletResponse; |
... | @@ -80,11 +77,14 @@ public class EquipmentSparepartTypeController { | ... | @@ -80,11 +77,14 @@ public class EquipmentSparepartTypeController { |
80 | if (StringUtils.isNotBlank(itemText)) { | 77 | if (StringUtils.isNotBlank(itemText)) { |
81 | queryWrapper.like("item_text",itemText); | 78 | queryWrapper.like("item_text",itemText); |
82 | } | 79 | } |
83 | if (equipmentSparepartType.isMedicament()) {//查询药剂类别 | ||
84 | queryWrapper.eq("is_medicament",equipmentSparepartType.isMedicament()); | ||
85 | } | ||
86 | List<EquipmentSparepartType> equipmentSparepartTypeList = equipmentSparepartTypeService.list(queryWrapper); | 80 | List<EquipmentSparepartType> equipmentSparepartTypeList = equipmentSparepartTypeService.list(queryWrapper); |
87 | 81 | ||
82 | if (equipmentSparepartType.isMedicament()) {//查询药剂类别 | ||
83 | queryWrapper.eq("medicament",equipmentSparepartType.isMedicament()); | ||
84 | //药剂的物料分类 | ||
85 | List<EquipmentSparepartType> medicamentList = equipmentSparepartTypeService.list(queryWrapper); | ||
86 | equipmentSparepartTypeList = this.equipmentSparepartTypeListByMedicament(equipmentSparepartTypeList , medicamentList ); | ||
87 | } | ||
88 | List<EquipmentSparepartTypeVO> voList = new ArrayList<>(); | 88 | List<EquipmentSparepartTypeVO> voList = new ArrayList<>(); |
89 | getTree(voList, equipmentSparepartTypeList, null); | 89 | getTree(voList, equipmentSparepartTypeList, null); |
90 | result.setSuccess(true); | 90 | result.setSuccess(true); |
... | @@ -92,6 +92,12 @@ public class EquipmentSparepartTypeController { | ... | @@ -92,6 +92,12 @@ public class EquipmentSparepartTypeController { |
92 | return result; | 92 | return result; |
93 | } | 93 | } |
94 | 94 | ||
95 | /*** | ||
96 | * 递归转换为tree结构 | ||
97 | * @param voList | ||
98 | * @param entityList | ||
99 | * @param tmp | ||
100 | */ | ||
95 | private void getTree(List<EquipmentSparepartTypeVO> voList, List<EquipmentSparepartType> entityList, EquipmentSparepartTypeVO tmp) { | 101 | private void getTree(List<EquipmentSparepartTypeVO> voList, List<EquipmentSparepartType> entityList, EquipmentSparepartTypeVO tmp) { |
96 | for (EquipmentSparepartType item : entityList) { | 102 | for (EquipmentSparepartType item : entityList) { |
97 | String parentId = item.getParentId(); | 103 | String parentId = item.getParentId(); |
... | @@ -110,6 +116,42 @@ public class EquipmentSparepartTypeController { | ... | @@ -110,6 +116,42 @@ public class EquipmentSparepartTypeController { |
110 | } | 116 | } |
111 | } | 117 | } |
112 | 118 | ||
119 | /*** | ||
120 | * 拼装 药剂的物料分类 | ||
121 | * @param allTypeList | ||
122 | * @param medicamentList | ||
123 | * @return | ||
124 | */ | ||
125 | private List<EquipmentSparepartType> equipmentSparepartTypeListByMedicament(List<EquipmentSparepartType> allTypeList ,List<EquipmentSparepartType> medicamentList ){ | ||
126 | Set<EquipmentSparepartType> resultSet = new HashSet<>(); | ||
127 | // List<EquipmentSparepartType> dataList = new ArrayList<>(); | ||
128 | StringBuffer ancestors = new StringBuffer(); | ||
129 | for( EquipmentSparepartType equipmentSparepartType : medicamentList){ | ||
130 | ancestors.append(equipmentSparepartType.getAncestors()).append(","); | ||
131 | resultSet.add(equipmentSparepartType ); | ||
132 | for( EquipmentSparepartType equipmentSparepartType2 : allTypeList){ | ||
133 | // 添加下游数据 | ||
134 | if(equipmentSparepartType2.getAncestors().contains( equipmentSparepartType.getAncestors() )){ | ||
135 | resultSet.add(equipmentSparepartType2 ); | ||
136 | } | ||
137 | } | ||
138 | // 将原始字符串按逗号分隔并放入LinkedHashSet中去重 | ||
139 | Set<String> uniqueFruits = new LinkedHashSet<>(Arrays.asList(ancestors.toString().split(","))); | ||
140 | //添加上游数据 | ||
141 | for(String id : uniqueFruits){ | ||
142 | for( EquipmentSparepartType equipmentSparepartType3 : allTypeList){ | ||
143 | if(id.equals( equipmentSparepartType3.getId() )){ | ||
144 | resultSet.add(equipmentSparepartType3 ) ; | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | } | ||
149 | return new ArrayList<>(resultSet); | ||
150 | } | ||
151 | |||
152 | |||
153 | |||
154 | |||
113 | /** | 155 | /** |
114 | * 添加 | 156 | * 添加 |
115 | * | 157 | * |
... | @@ -168,6 +210,11 @@ public class EquipmentSparepartTypeController { | ... | @@ -168,6 +210,11 @@ public class EquipmentSparepartTypeController { |
168 | try { | 210 | try { |
169 | equipmentSparepartType.setDelFlag(0); | 211 | equipmentSparepartType.setDelFlag(0); |
170 | equipmentSparepartTypeService.saveAndUpdateParent(equipmentSparepartType); | 212 | equipmentSparepartTypeService.saveAndUpdateParent(equipmentSparepartType); |
213 | if(StringUtils.isNotEmpty( equipmentSparepartType.getParentId() )){ | ||
214 | EquipmentSparepartType parentSparepartType = equipmentSparepartTypeService.getById( equipmentSparepartType.getParentId() ); | ||
215 | equipmentSparepartType.setAncestors( parentSparepartType.getAncestors() +","+ equipmentSparepartType.getId()) ; | ||
216 | equipmentSparepartTypeService.updateById( equipmentSparepartType ); | ||
217 | } | ||
171 | result.success("添加成功!"); | 218 | result.success("添加成功!"); |
172 | } catch (Exception e) { | 219 | } catch (Exception e) { |
173 | e.printStackTrace(); | 220 | e.printStackTrace(); |
... | @@ -192,14 +239,26 @@ public class EquipmentSparepartTypeController { | ... | @@ -192,14 +239,26 @@ public class EquipmentSparepartTypeController { |
192 | if (equipmentSparepartTypeEntity == null) { | 239 | if (equipmentSparepartTypeEntity == null) { |
193 | result.error500("未找到对应实体"); | 240 | result.error500("未找到对应实体"); |
194 | } else { | 241 | } else { |
242 | if(StringUtils.isNotEmpty( equipmentSparepartType.getParentId() )){ | ||
243 | EquipmentSparepartType parentSparepartType = equipmentSparepartTypeService.getById( equipmentSparepartType.getParentId() ); | ||
244 | equipmentSparepartType.setAncestors( parentSparepartType.getAncestors() +","+ equipmentSparepartType.getId()) ; | ||
245 | // 跟新父节点节点状态 | ||
246 | if( parentSparepartType.getIsLeaf()){ | ||
247 | parentSparepartType.setIsLeaf(false); | ||
248 | equipmentSparepartTypeService.updateById( parentSparepartType ); | ||
249 | } | ||
250 | } | ||
195 | boolean ok = equipmentSparepartTypeService.updateById(equipmentSparepartType); | 251 | boolean ok = equipmentSparepartTypeService.updateById(equipmentSparepartType); |
252 | |||
253 | //批量更改祖籍信息 | ||
254 | equipmentSparepartTypeService.updateAncestors(equipmentSparepartTypeEntity.getAncestors(), equipmentSparepartType.getAncestors() ); | ||
196 | //更新父级叶子节点状态 | 255 | //更新父级叶子节点状态 |
197 | String parentId = equipmentSparepartType.getParentId(); | 256 | /* String parentId = equipmentSparepartType.getParentId(); |
198 | if(StringUtils.isNotEmpty(parentId)) { | 257 | if(StringUtils.isNotEmpty(parentId)) { |
199 | EquipmentSparepartType parentEquipmentSparepartTypeEntity = equipmentSparepartTypeService.getById(parentId); | 258 | EquipmentSparepartType parentEquipmentSparepartTypeEntity = equipmentSparepartTypeService.getById(parentId); |
200 | parentEquipmentSparepartTypeEntity.putIsLeaf(false); | 259 | parentEquipmentSparepartTypeEntity.putIsLeaf(false); |
201 | equipmentSparepartTypeService.updateById(parentEquipmentSparepartTypeEntity); | 260 | equipmentSparepartTypeService.updateById(parentEquipmentSparepartTypeEntity); |
202 | } | 261 | }*/ |
203 | if (ok) { | 262 | if (ok) { |
204 | result.success("修改成功!"); | 263 | result.success("修改成功!"); |
205 | } | 264 | } | ... | ... |
... | @@ -2,6 +2,7 @@ package com.skua.modules.supplies.entity; | ... | @@ -2,6 +2,7 @@ package com.skua.modules.supplies.entity; |
2 | 2 | ||
3 | import java.util.Date; | 3 | import java.util.Date; |
4 | 4 | ||
5 | import com.baomidou.mybatisplus.annotation.TableField; | ||
5 | import org.jeecgframework.poi.excel.annotation.Excel; | 6 | import org.jeecgframework.poi.excel.annotation.Excel; |
6 | import org.springframework.format.annotation.DateTimeFormat; | 7 | import org.springframework.format.annotation.DateTimeFormat; |
7 | 8 | ||
... | @@ -38,6 +39,9 @@ public class EquipmentSparepartType { | ... | @@ -38,6 +39,9 @@ public class EquipmentSparepartType { |
38 | @Excel(name = "父ID", width = 15) | 39 | @Excel(name = "父ID", width = 15) |
39 | @ApiModelProperty(value = "父ID") | 40 | @ApiModelProperty(value = "父ID") |
40 | private String parentId; | 41 | private String parentId; |
42 | |||
43 | @ApiModelProperty(value = "祖籍信息") | ||
44 | private String ancestors; | ||
41 | /** | 45 | /** |
42 | * 文本key | 46 | * 文本key |
43 | */ | 47 | */ |
... | @@ -71,7 +75,8 @@ public class EquipmentSparepartType { | ... | @@ -71,7 +75,8 @@ public class EquipmentSparepartType { |
71 | 75 | ||
72 | @Excel(name = "是否药剂,1:是 0:不是", width = 15) | 76 | @Excel(name = "是否药剂,1:是 0:不是", width = 15) |
73 | @ApiModelProperty(value = "是否药剂,1:是 0:不是") | 77 | @ApiModelProperty(value = "是否药剂,1:是 0:不是") |
74 | private boolean isMedicament = false; | 78 | private boolean medicament = false; |
79 | |||
75 | /** | 80 | /** |
76 | * 创建人 | 81 | * 创建人 |
77 | */ | 82 | */ |
... | @@ -107,6 +112,14 @@ public class EquipmentSparepartType { | ... | @@ -107,6 +112,14 @@ public class EquipmentSparepartType { |
107 | @ApiModelProperty(value = "删除状态 0正常 1已删除") | 112 | @ApiModelProperty(value = "删除状态 0正常 1已删除") |
108 | private Integer delFlag; | 113 | private Integer delFlag; |
109 | 114 | ||
115 | public boolean getIsLeaf() { | ||
116 | return isLeaf; | ||
117 | } | ||
118 | |||
119 | public void setIsLeaf(boolean isLeaf) { | ||
120 | this.isLeaf = isLeaf; | ||
121 | } | ||
122 | |||
110 | public void putIsLeaf(Boolean isLeaf) { | 123 | public void putIsLeaf(Boolean isLeaf) { |
111 | if (isLeaf != null) { | 124 | if (isLeaf != null) { |
112 | this.isLeaf = isLeaf; | 125 | this.isLeaf = isLeaf; | ... | ... |
sk-module-equipment/src/main/java/com/skua/modules/supplies/mapper/EquipmentSparepartTypeMapper.java
... | @@ -2,10 +2,17 @@ package com.skua.modules.supplies.mapper; | ... | @@ -2,10 +2,17 @@ package com.skua.modules.supplies.mapper; |
2 | 2 | ||
3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
4 | import com.skua.modules.supplies.entity.EquipmentSparepartType; | 4 | import com.skua.modules.supplies.entity.EquipmentSparepartType; |
5 | import org.apache.ibatis.annotations.Param; | ||
5 | 6 | ||
6 | /** | 7 | /** |
7 | * 设备物资类型 | 8 | * 设备物资类型 |
8 | */ | 9 | */ |
9 | public interface EquipmentSparepartTypeMapper extends BaseMapper<EquipmentSparepartType> { | 10 | public interface EquipmentSparepartTypeMapper extends BaseMapper<EquipmentSparepartType> { |
10 | 11 | ||
12 | /*** | ||
13 | * 批量更改祖籍信息 | ||
14 | * @param oldAncestors | ||
15 | * @param newAncestors | ||
16 | */ | ||
17 | public void updateAncestors(@Param("oldAncestors") String oldAncestors,@Param("newAncestors") String newAncestors); | ||
11 | } | 18 | } | ... | ... |
... | @@ -2,4 +2,8 @@ | ... | @@ -2,4 +2,8 @@ |
2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | <mapper namespace="com.skua.modules.supplies.mapper.EquipmentSparepartTypeMapper"> | 3 | <mapper namespace="com.skua.modules.supplies.mapper.EquipmentSparepartTypeMapper"> |
4 | 4 | ||
5 | <!-- 批量更改祖籍信息 --> | ||
6 | <update id="updateAncestors"> | ||
7 | update equipment_sparepart_type set ancestors = REPLACE(ancestors,#{oldAncestors}, #{newAncestors}); | ||
8 | </update> | ||
5 | </mapper> | 9 | </mapper> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -27,4 +27,10 @@ public interface IEquipmentSparepartTypeService extends IService<EquipmentSparep | ... | @@ -27,4 +27,10 @@ public interface IEquipmentSparepartTypeService extends IService<EquipmentSparep |
27 | */ | 27 | */ |
28 | void saveAndUpdateParent(EquipmentSparepartType equipmentSparepartType); | 28 | void saveAndUpdateParent(EquipmentSparepartType equipmentSparepartType); |
29 | 29 | ||
30 | /*** | ||
31 | * 批量更改祖籍信息 | ||
32 | * @param oldAncestors | ||
33 | * @param newAncestors | ||
34 | */ | ||
35 | void updateAncestors(String oldAncestors, String newAncestors); | ||
30 | } | 36 | } | ... | ... |
... | @@ -63,4 +63,13 @@ public class EquipmentSparepartTypeServiceImpl extends ServiceImpl<EquipmentSpar | ... | @@ -63,4 +63,13 @@ public class EquipmentSparepartTypeServiceImpl extends ServiceImpl<EquipmentSpar |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | /*** | ||
67 | * 批量更改祖籍信息 | ||
68 | * @param oldAncestors | ||
69 | * @param newAncestors | ||
70 | */ | ||
71 | public void updateAncestors(String oldAncestors, String newAncestors){ | ||
72 | this.baseMapper.updateAncestors(oldAncestors, newAncestors); | ||
73 | } | ||
74 | |||
66 | } | 75 | } | ... | ... |
... | @@ -5,7 +5,9 @@ import java.util.List; | ... | @@ -5,7 +5,9 @@ import java.util.List; |
5 | 5 | ||
6 | import com.skua.modules.supplies.entity.EquipmentSparepartType; | 6 | import com.skua.modules.supplies.entity.EquipmentSparepartType; |
7 | 7 | ||
8 | import io.swagger.annotations.ApiModelProperty; | ||
8 | import lombok.Data; | 9 | import lombok.Data; |
10 | import org.jeecgframework.poi.excel.annotation.Excel; | ||
9 | 11 | ||
10 | /** | 12 | /** |
11 | * @author sonin | 13 | * @author sonin |
... | @@ -22,6 +24,7 @@ public class EquipmentSparepartTypeVO { | ... | @@ -22,6 +24,7 @@ public class EquipmentSparepartTypeVO { |
22 | 24 | ||
23 | private String itemValue; | 25 | private String itemValue; |
24 | 26 | ||
27 | private Boolean medicament = false; | ||
25 | private String remark; | 28 | private String remark; |
26 | 29 | ||
27 | private Integer sort; | 30 | private Integer sort; |
... | @@ -37,8 +40,9 @@ public class EquipmentSparepartTypeVO { | ... | @@ -37,8 +40,9 @@ public class EquipmentSparepartTypeVO { |
37 | this.itemValue = entity.getItemValue(); | 40 | this.itemValue = entity.getItemValue(); |
38 | this.remark = entity.getRemark(); | 41 | this.remark = entity.getRemark(); |
39 | this.sort = entity.getSort(); | 42 | this.sort = entity.getSort(); |
40 | this.isLeaf = entity.isLeaf(); | 43 | this.isLeaf = entity.getIsLeaf(); |
41 | if (!entity.isLeaf()) { | 44 | this.medicament = entity.isMedicament(); |
45 | if (!entity.getIsLeaf()) { | ||
42 | this.children = new ArrayList<>(); | 46 | this.children = new ArrayList<>(); |
43 | } | 47 | } |
44 | } | 48 | } | ... | ... |
-
请 注册 或 登录 后发表评论