Commit cbc16ecb7517f032c1bebfd0ea77fff3688b0555

Authored by fangcheng
1 parent 3398d51086
Exists in master

hospital.mac打包xml

添加省市区字典管理

Showing 8 changed files with 437 additions and 10 deletions

parent/base.common/src/main/java/com/lyms/base/common/entity/region/Regions.java View file @ cbc16ec
... ... @@ -3,8 +3,10 @@
3 3 import java.io.Serializable;
4 4 import java.util.Date;
5 5  
  6 +import com.alibaba.fastjson.JSON;
6 7 import com.baomidou.mybatisplus.annotations.TableField;
7 8 import com.baomidou.mybatisplus.annotations.TableName;
  9 +import com.google.gson.JsonObject;
8 10  
9 11 /**
10 12 * <p>
... ... @@ -64,6 +66,8 @@
64 66 */
65 67 @TableField(value = "FOREIGN_ID")
66 68 private String foreignId;
  69 + @TableField(exist = false)
  70 + private boolean isParent = true;
67 71  
68 72 public String getId() {
69 73 return id;
... ... @@ -137,5 +141,16 @@
137 141 this.foreignId = foreignId;
138 142 }
139 143  
  144 + public boolean getIsParent() {
  145 + return isParent;
  146 + }
  147 +
  148 + public void setIsParent(boolean parent) {
  149 + isParent = parent;
  150 + }
  151 +
  152 + public static void main(String[] args) {
  153 + System.out.println(JSON.toJSONString(new Regions()));
  154 + }
140 155 }
parent/base.common/src/main/java/com/lyms/base/common/service/region/RegionsService.java View file @ cbc16ec
... ... @@ -4,6 +4,7 @@
4 4 import java.util.List;
5 5  
6 6 import com.lyms.base.common.entity.region.Regions;
  7 +import com.lyms.base.common.entity.sys.SysDict;
7 8 import com.lyms.web.service.BaseService;
8 9  
9 10 /**
... ... @@ -35,6 +36,33 @@
35 36 * <li>修改时间:
36 37 */
37 38 public List<Regions> selectRegions(String id);
  39 +
  40 + /**
  41 + * <li>@Description:添加一个地区
  42 + * <li>@param dict
  43 + * <li>@return
  44 + * <li>创建人:方承
  45 + * <li>创建时间:2017年5月26日
  46 + * <li>修改人:
  47 + * <li>修改时间:
  48 + */
  49 + public boolean createRegion(Regions regions);
  50 +
  51 + public boolean updateRegion(Regions regions);
  52 +
  53 +
  54 + /**
  55 + * <li>@Description:禁用
  56 + * <li>@param id
  57 + * <li>@return
  58 + * <li>创建人:方承
  59 + * <li>创建时间:2017年5月26日
  60 + * <li>修改人:
  61 + * <li>修改时间:
  62 + */
  63 + public boolean disable(String id);
  64 +
  65 + public boolean enable(String id);
38 66  
39 67 }
parent/base.common/src/main/java/com/lyms/base/common/service/region/impl/RegionsServiceImpl.java View file @ cbc16ec
... ... @@ -3,6 +3,8 @@
3 3 import java.io.Serializable;
4 4 import java.util.List;
5 5  
  6 +import com.lyms.base.common.entity.sys.SysDict;
  7 +import com.lyms.util.StrUtils;
6 8 import org.apache.commons.lang3.StringUtils;
7 9 import org.springframework.beans.factory.annotation.Autowired;
8 10 import org.springframework.stereotype.Service;
... ... @@ -36,6 +38,37 @@
36 38 id = NOT_PARENT_TAG;
37 39 }
38 40 return regionsMapper.selectRegionsById(id);
  41 + }
  42 +
  43 + @Override
  44 + public boolean createRegion(Regions regions) {
  45 + if (StrUtils.isEmpty(regions.getId())) {
  46 + regions.setId(StrUtils.uuid());
  47 + }
  48 + Integer tag = baseMapper.insert(regions);
  49 + return tag > 0;
  50 + }
  51 +
  52 + @Override
  53 + public boolean updateRegion(Regions regions) {
  54 + Integer tag = baseMapper.updateById(regions);
  55 + return tag > 0;
  56 + }
  57 +
  58 + @Override
  59 + public boolean disable(String id) {
  60 + Regions regions = new Regions();
  61 + regions.setId(id);
  62 + regions.setEnable(0);
  63 + return baseMapper.updateById(regions) > 0;
  64 + }
  65 +
  66 + @Override
  67 + public boolean enable(String id) {
  68 + Regions regions = new Regions();
  69 + regions.setId(id);
  70 + regions.setEnable(1);
  71 + return baseMapper.updateById(regions) > 0;
39 72 }
40 73 }
parent/center.manager/src/main/java/com/lyms/cm/controller/sys/SysRegionsController.java View file @ cbc16ec
... ... @@ -2,10 +2,15 @@
2 2  
3 3 import java.util.List;
4 4  
  5 +import com.baomidou.mybatisplus.mapper.EntityWrapper;
  6 +import com.lyms.base.common.entity.sys.SysDict;
  7 +import com.lyms.constants.OperationName;
  8 +import com.lyms.web.bean.AjaxResult;
  9 +import org.apache.commons.lang3.StringUtils;
5 10 import org.springframework.beans.factory.annotation.Autowired;
6   -import org.springframework.web.bind.annotation.RequestMapping;
7   -import org.springframework.web.bind.annotation.RequestMethod;
8   -import org.springframework.web.bind.annotation.RestController;
  11 +import org.springframework.stereotype.Controller;
  12 +import org.springframework.ui.Model;
  13 +import org.springframework.web.bind.annotation.*;
9 14  
10 15 import com.baomidou.mybatisplus.plugins.Page;
11 16 import com.lyms.base.common.entity.region.Regions;
12 17  
... ... @@ -20,13 +25,19 @@
20 25 * @author maliang
21 26 * @since 2017-03-08
22 27 */
23   -@RestController
  28 +@Controller
24 29 @RequestMapping("/sysRegions")
25 30 public class SysRegionsController extends BaseController {
26 31  
27 32 @Autowired
28 33 private RegionsService regionService;
29 34  
  35 +
  36 + @RequestMapping(value = "/toList", method = RequestMethod.GET)
  37 + public String toList(Model model) {
  38 + return "/region/region_list";
  39 + }
  40 +
30 41 /**
31 42 * <li>@Description:获取区域信息
32 43 * <li>@return
33 44  
... ... @@ -38,12 +49,111 @@
38 49 * @return
39 50 */
40 51 @RequestMapping(value = "/find", method = RequestMethod.GET)
  52 + @ResponseBody
41 53 public Page<Regions> findRegions(String id) {
42 54 Page<Regions> page = getPage();
43 55 page.setSize(Integer.MAX_VALUE);
44 56 List<Regions> regions = regionService.selectRegions(id);
45 57 page.setRecords(regions);
46 58 return page;
  59 + }
  60 +
  61 + @RequestMapping(value = "/findById")
  62 + @ResponseBody
  63 + public List<Regions> findById(String id) {
  64 + Page<Regions> page = getPage();
  65 + page.setSize(Integer.MAX_VALUE);
  66 + List<Regions> regions = regionService.selectRegions(id);
  67 + return regions;
  68 + }
  69 +
  70 +
  71 + @RequestMapping(value = "/create", method = RequestMethod.POST)
  72 + @ResponseBody
  73 + public AjaxResult create(Regions regions, AjaxResult ajaxResult) {
  74 + boolean tag = regionService.createRegion(regions);
  75 + return handleAjaxResult(ajaxResult, tag, OperationName.CREATE);
  76 + }
  77 +
  78 + @RequestMapping(value = "/update", method = { RequestMethod.POST })
  79 + @ResponseBody
  80 + public AjaxResult update(Regions regions, AjaxResult ajaxResult) {
  81 + boolean tag = regionService.updateRegion(regions);
  82 + return handleAjaxResult(ajaxResult, tag, OperationName.UPDATE);
  83 +
  84 + }
  85 +
  86 + /**
  87 + * 跳转到编辑页面
  88 + *
  89 + * @return
  90 + */
  91 + @RequestMapping(value = { "/{id}/toEdit" }, method = RequestMethod.GET)
  92 + public String toEdit(@PathVariable String id, Model model) {
  93 + String pid = RegionsService.NOT_PARENT_TAG;
  94 + if (!StringUtils.isBlank(id) & !"0".equals(id)) {
  95 + Regions regions = regionService.selectById(id);
  96 + model.addAttribute("regions", regions);
  97 + pid = regions.getParentId();
  98 + }
  99 + EntityWrapper<Regions> ew = new EntityWrapper<Regions>();
  100 + ew.where("ID={0}",pid);
  101 + ew.orderBy("enable", false);
  102 + List<Regions> list = regionService.selectList(ew);
  103 + model.addAttribute("regionsList", list);
  104 + return "/region/region_edit";
  105 + }
  106 +
  107 + /**
  108 + * 跳转到添加子字典
  109 + *
  110 + * @return
  111 + */
  112 + @RequestMapping(value = { "/{pid}/toAddSub" }, method = RequestMethod.GET)
  113 + public String toAddSub(@PathVariable String pid, Model model) {
  114 + EntityWrapper<Regions> ew = new EntityWrapper<Regions>();
  115 + ew.where("ID={0}",pid);
  116 + ew.orderBy("enable", false);
  117 + List<Regions> list = regionService.selectList(ew);
  118 + model.addAttribute("regionsList", list);
  119 + Regions regions = new Regions();
  120 + regions.setParentId(pid);
  121 + model.addAttribute("regions", regions);
  122 + return "/region/region_edit";
  123 + }
  124 +
  125 + /**
  126 + * <li>@Description:禁用地区
  127 + * <li>@param id
  128 + * <li>@param ajaxResult
  129 + * <li>@return
  130 + * <li>创建人:方承
  131 + * <li>创建时间:2017年5月26日
  132 + * <li>修改人:
  133 + * <li>修改时间:
  134 + */
  135 + @RequestMapping(value = "/{id}/disable", method = { RequestMethod.GET, RequestMethod.POST })
  136 + @ResponseBody
  137 + public AjaxResult disable(@PathVariable String id, AjaxResult ajaxResult) {
  138 + boolean tag = regionService.disable(id);
  139 + return handleAjaxResult(ajaxResult, tag, OperationName.DISABLE);
  140 + }
  141 +
  142 + /**
  143 + * <li>@Description:禁用地区
  144 + * <li>@param id
  145 + * <li>@param ajaxResult
  146 + * <li>@return
  147 + * <li>创建人:方承
  148 + * <li>创建时间:2017年5月26日
  149 + * <li>修改人:
  150 + * <li>修改时间:
  151 + */
  152 + @RequestMapping(value = "/{id}/enable", method = { RequestMethod.GET, RequestMethod.POST })
  153 + @ResponseBody
  154 + public AjaxResult enable(@PathVariable String id, AjaxResult ajaxResult) {
  155 + boolean tag = regionService.enable(id);
  156 + return handleAjaxResult(ajaxResult, tag, OperationName.ENABLE);
47 157 }
48 158  
49 159 }
parent/center.manager/src/main/webapp/WEB-INF/views/dict/dict_list.html View file @ cbc16ec
... ... @@ -67,7 +67,7 @@
67 67 var zTree = $.fn.zTree.getZTreeObj('dictTree');
68 68 var nodes = zTree.getSelectedNodes();
69 69 if(nodes.length > 0){
70   - layer.confirm('确定删除选中的数据', {
  70 + layer.confirm('确定禁用选中的数据', {
71 71 btn: ['确定','取消'] //按钮
72 72 }, function(){
73 73 var url = APP.PATH + controllerRequestMappint + nodes[0]['id'] + "/disable";
parent/center.manager/src/main/webapp/WEB-INF/views/region/region_edit.html View file @ cbc16ec
  1 +#override("css")
  2 +<link rel="stylesheet" href="${ctx}/static/js/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css" />
  3 +#end
  4 +#override("body")
  5 +<div class="ibox float-e-margins">
  6 + <form id="validForm" class="form-horizontal m-t" novalidate="novalidate">
  7 + <div class="ibox-content">
  8 + <div class="col-sm-4">
  9 + <input type="hidden" id="regions.id" name="id" value="$!regions.id"/>
  10 + <div class="form-group">
  11 + <label class="col-sm-3 control-label">上级字典:</label>
  12 + <div class="col-sm-8">
  13 + <select id="parentId" name="parentId" style="width:250px;" class="selectator" data-selectator-keep-open="true" data-selectator-show-all-options-on-focus="true" data-selectator-search-fields="value text subtitle right">
  14 + <option value="f6c505dd-835a-43d7-b0bb-fdb9eb0b7b31" selected>中国</option>
  15 + #foreach($oneSelect in $regionsList)
  16 + <option value="${oneSelect.id}"
  17 + #if( $string.isNotEmpty($regions.parentId))
  18 + #if($string.equals(${regions.parentId}, ${oneSelect.id}) )
  19 + selected
  20 + #end
  21 + #end
  22 + >${oneSelect.name}</option>
  23 + #end
  24 + </select>
  25 + <script type="text/javascript">
  26 + $(function () {
  27 + var pid_select = $('#pid');
  28 + pid_select.selectator({
  29 + labels: {
  30 + showAllOptionsOnFocus: true,
  31 + keepOpen: true,
  32 + search: 'Search here...'
  33 + }
  34 + });
  35 + });
  36 + </script>
  37 + </div>
  38 + </div>
  39 + <div class="form-group">
  40 + <label class="col-sm-3 control-label">地区名称:</label>
  41 + <div class="col-sm-8">
  42 + <input type="text" placeholder="地区名称" value="$!regions.name" aria-required="true" required="true" minlength="2" class="form-control" name="name" id="name">
  43 + </div>
  44 + </div>
  45 + <div class="form-group">
  46 + <label class="col-sm-3 control-label">CODE:</label>
  47 + <div class="col-sm-8">
  48 + <input type="text" placeholder="CODE" value="$!regions.code" class="form-control" name="code" id="code">
  49 + </div>
  50 + </div>
  51 + <div class="hr-line-dashed"></div>
  52 + <div class="form-group">
  53 + <div class="col-sm-4 col-sm-offset-3 pull-right">
  54 + <button type="button" class="btn btn-primary" onclick="save();"><i class="fa fa-check"></i>&nbsp;提交</button>
  55 + <button type="button" class="btn btn-white" onclick="parent.closeAll();"><i class="fa fa-close"></i>&nbsp;取消</button>
  56 + </div>
  57 + </div>
  58 + </div>
  59 + </div>
  60 + </form>
  61 +</div>
  62 +<script type="text/javascript">
  63 + function search(){
  64 + var queryParams = {
  65 + query:{
  66 + name: $("#groupName").val()
  67 + }
  68 + }
  69 + $('#dataTable').bootstrapTable('refresh', queryParams );
  70 + }
  71 +
  72 +
  73 + function save(){
  74 + if($('#validForm').valid()){
  75 + var data = $('#validForm').serialize();
  76 + data = data + "&" + $('#roleForm').serialize();
  77 + if("$!regions.id" == ""){
  78 + ajaxPost(APP.PATH + "/sysRegions/create",data);
  79 + }else{
  80 + ajaxPost(APP.PATH + "/sysRegions/update",data);
  81 + }
  82 + /* timeoutThread(reloadTree_inner,500);
  83 + function reloadTree_inner(){
  84 + parent.location.reload();
  85 + } */
  86 + }
  87 + }
  88 +
  89 +
  90 +</script>
  91 +#end
  92 +#extends("/common/base_list.html")
parent/center.manager/src/main/webapp/WEB-INF/views/region/region_list.html View file @ cbc16ec
  1 +#override("css")
  2 +<link rel="stylesheet" href="${ctx}/static/js/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css" />
  3 +#end
  4 +#override("body")
  5 +<div class="wrapper wrapper-content">
  6 + <div class="row">
  7 + <div class="col-sm-12">
  8 + <div id="toolbar">
  9 + <button class="btn btn-info " type="button" onclick="addSub();"><i class="fa fa-plus"></i> 添加子区域</button>
  10 + <button class="btn btn-info " type="button" onclick="edit();"><i class="fa fa-paste"></i> 修改</button>
  11 + <button class="btn btn-info " type="button" onclick="add();"><i class="fa fa-plus"></i> 添加省</button>
  12 + <button class="btn btn-info " type="button" onclick="enable();"><i class=""></i> 启用</button>
  13 + <button class="btn btn-danger" type="button" onclick="disable();"><i class=""></i> 禁用</button>
  14 + <button class="btn btn-success m-r-xs" type="button" onclick="reload();"><i class=""></i> 刷新</button>
  15 +
  16 + </div>
  17 + <div>
  18 + <div id="treeContent_resource" class="menuContent">
  19 + <ul id="regionTree" class="ztree" style="margin-top:0; width:180px; height: 250px;"></ul>
  20 + </div>
  21 + </div>
  22 + </div>
  23 + </div>
  24 +</div>
  25 +#end
  26 +#override("js")
  27 +<script src="${ctx}/static/js/zTree_v3/js/jquery.ztree.all-3.5.min.js" type="text/javascript"></script>
  28 +<script type="text/javascript">
  29 +var controllerRequestMappint = "/sysRegions/";
  30 +function search(){
  31 + var queryParams = {
  32 + query:{
  33 + name: $("#searchName").val(),
  34 + account: $("#searchAccount").val(),
  35 + phone: $("#searchPhone").val(),
  36 + orgId: $("#searchOrgId").val(),
  37 + deptId: $("#searchdeptId").val()
  38 + }
  39 + }
  40 + $('#dataTable').bootstrapTable('refresh', queryParams );
  41 +}
  42 +
  43 +function add() {
  44 + fullWindow("添加省", APP.PATH + controllerRequestMappint + "0/toEdit");
  45 +}
  46 +function addSub() {
  47 + var zTree = $.fn.zTree.getZTreeObj('regionTree');
  48 + var nodes = zTree.getSelectedNodes();
  49 + if(nodes.length > 0){
  50 + fullWindow("添加子区域", APP.PATH + controllerRequestMappint + nodes[0]['id'] + "/toAddSub");
  51 + }else{
  52 + msg("请选中需要添加子区域的父区域项");
  53 + }
  54 +}
  55 +function edit(){
  56 + var zTree = $.fn.zTree.getZTreeObj('regionTree');
  57 + var nodes = zTree.getSelectedNodes();
  58 + if(nodes.length > 0){
  59 + fullWindow("修改区域", APP.PATH + controllerRequestMappint + nodes[0]['id'] + "/toEdit");
  60 + }else{
  61 + msg("请选中需要编辑的区域数据");
  62 + }
  63 +}
  64 +function reload(){
  65 + location.reload();
  66 +}
  67 +function disable(){
  68 + var zTree = $.fn.zTree.getZTreeObj('regionTree');
  69 + var nodes = zTree.getSelectedNodes();
  70 + if(nodes.length > 0){
  71 + layer.confirm('确定禁用选中的数据', {
  72 + btn: ['确定','取消'] //按钮
  73 + }, function(){
  74 + var url = APP.PATH + controllerRequestMappint + nodes[0]['id'] + "/disable";
  75 + ajaxPost(url,null,function(r){
  76 + msg(r.message);
  77 + });
  78 + }, function(){
  79 +
  80 + });
  81 + }else{
  82 + msg("请选中需要禁用的区域数据");
  83 + }
  84 +}
  85 +function enable(){
  86 + var zTree = $.fn.zTree.getZTreeObj('regionTree');
  87 + var nodes = zTree.getSelectedNodes();
  88 + if(nodes.length > 0){
  89 + layer.confirm('确定启用选中的数据', {
  90 + btn: ['确定','取消'] //按钮
  91 + }, function(){
  92 + var url = APP.PATH + controllerRequestMappint + nodes[0]['id'] + "/enable";
  93 + ajaxPost(url,null,function(r){
  94 + msg(r.message);
  95 + });
  96 + }, function(){
  97 +
  98 + });
  99 + }else{
  100 + msg("请选中需要启用的区域数据");
  101 + }
  102 +}
  103 +var setting = {
  104 + async: {
  105 + enable: true,
  106 + url:APP.PATH + "/sysRegions/findById",
  107 + autoParam:["id"],
  108 + dataFilter: filter
  109 + }
  110 +};
  111 +function filter(treeId, parentNode, childNodes) {
  112 + if (!childNodes) return null;
  113 + for (var i=0, l=childNodes.length; i<l; i++) {
  114 + var message = "";
  115 + if(childNodes[i].enable == 0){
  116 + message = "(已禁用)";
  117 + }
  118 + childNodes[i].name = childNodes[i].name + message;
  119 + }
  120 + return childNodes;
  121 +}
  122 +
  123 +$(document).ready(function(){
  124 + $.fn.zTree.init($("#regionTree"), setting);
  125 +});
  126 +</script>
  127 +#end
  128 +#extends("/common/base_list.html")
parent/hospital.mac/pom.xml View file @ cbc16ec
1 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3 3 <modelVersion>4.0.0</modelVersion>
4   -
  4 +
5 5 <parent>
6 6 <groupId>com.lyms</groupId>
7 7 <artifactId>parent</artifactId>
8 8 <version>0.0.1-SNAPSHOT</version>
9 9 </parent>
10 10 <artifactId>hospital.mac</artifactId>
11   -
  11 +
12 12 <properties>
13   -
  13 +
14 14 </properties>
15   -
  15 +
16 16 <dependencies>
17 17 <dependency>
18 18 <groupId>com.lyms</groupId>
... ... @@ -25,6 +25,27 @@
25 25 <version>1.0</version>
26 26 </dependency>
27 27 </dependencies>
28   -
  28 + <build>
  29 + <resources>
  30 + <resource>
  31 + <directory>src/main/resources</directory>
  32 + <includes>
  33 + <include>**/*.properties</include>
  34 + <include>**/*.xml</include>
  35 + <include>**/*.tld</include>
  36 + </includes>
  37 + <filtering>false</filtering>
  38 + </resource>
  39 + <resource>
  40 + <directory>src/main/java</directory>
  41 + <includes>
  42 + <include>**/*.properties</include>
  43 + <include>**/*.xml</include>
  44 + <include>**/*.tld</include>
  45 + </includes>
  46 + <filtering>false</filtering>
  47 + </resource>
  48 + </resources>
  49 + </build>
29 50 </project>