ソースを参照

组织架构优化处理
学生家长电话号码修改功能

shenhao 4 年 前
コミット
0aa49bcbfb

+ 50 - 9
src/main/java/com/ssj/sys/controller/ImLibUserController.java

@@ -14,6 +14,10 @@ import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.ssj.bean.sys.role.domain.Admin;
+import com.ssj.bean.weixin.problem.domain.RequestMethodLog;
+import com.ssj.framework.core.util.WebUtil;
+import com.ssj.service.weixin.problem.service.RequestMethodLogService;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.DateUtil;
@@ -26,10 +30,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Sort.Direction;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import com.ssj.bean.common.framework.core.domain.Response;
@@ -116,8 +117,10 @@ public class ImLibUserController extends BaseController {
 	private IBookManagerService bookManagerService;
 
 	@Autowired
- 	private ILibJoinConsumeService joinConsumeService;    
-	
+ 	private ILibJoinConsumeService joinConsumeService;
+
+	@Autowired
+	private RequestMethodLogService requestMethodLogService;
 	
 	/**
 	 * ----------------机构相关功能-----------------------
@@ -329,9 +332,47 @@ public class ImLibUserController extends BaseController {
 		TbLibJoin tbLibJoin=joinService.getById(libId);
 		model.addAttribute("tbLibJoin", tbLibJoin);
 		return "sys/imlibuser/studentList";
-	}	
-	
-	
+	}
+
+	@RequestMapping(value = "/updateSortNo", method = RequestMethod.POST)
+	@ResponseBody
+	public Response updateSortNo(String id, String phone){
+		Response response = new  Response();
+		User user = userService.findByMobile(phone);
+		if(user !=null){
+			response.failure("平台已经存在"+phone+"的用户!");
+			return response;
+		}
+		LibVip vip = libVipService.getById(id);
+		if(vip!=null){
+			String oldPhone = vip.getPhone();
+			vip.setPhone(phone);
+			libVipService.save(vip);
+			User parentUser = userService.getById(vip.getUserId());
+			if(parentUser!=null){
+				parentUser.setMobile(phone);
+				userService.save(parentUser);
+			}
+			recodeData(vip.getUserId(),phone,oldPhone,id);
+		}
+		response.success();
+		return response;
+	}
+
+	private  void recodeData(String userId,String phone,String oldPhone, String vipId){
+		Admin admin= (Admin) request.getSession().getAttribute("admin");
+		if(admin !=null) {
+			RequestMethodLog methodLog = new RequestMethodLog();
+			methodLog.setAccountName(admin.getLoginName());
+			methodLog.setMethodUrl("imlibuser/updateSortNo");
+			methodLog.setMethodName("修改用户手机号码");
+			methodLog.setIpAddress(WebUtil.getRemoteAddr(request));
+			// methodLog.setOrgCode(admin.getOrgCode());
+			methodLog.setCreateTime(new Date());
+			methodLog.setSubstance("vipId->"+vipId+"-userId->"+userId+"-原手机号码->"+oldPhone+"修改为-"+phone);
+			requestMethodLogService.save(methodLog);
+		}
+	}
 	
 	@RequestMapping(value="/student/exlist/{libId}")
     @ResponseBody

+ 77 - 20
src/main/java/com/ssj/sys/controller/OrganizationController.java

@@ -4,6 +4,7 @@ import com.ssj.bean.common.framework.core.domain.Response;
 import com.ssj.bean.sys.organization.domain.Organization;
 import com.ssj.bean.sys.role.domain.Admin;
 import com.ssj.bean.sys.role.domain.AdminOrg;
+import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
 import com.ssj.bean.weixin.sales.domain.LibStaffing;
 import com.ssj.framework.basic.common.bean.SplitPage;
 import com.ssj.framework.core.common.controller.BaseController;
@@ -11,6 +12,7 @@ import com.ssj.service.sys.organization.service.OrganizationService;
 import com.ssj.service.sys.role.service.AdminOrgService;
 import com.ssj.service.sys.role.service.AdminService;
 import com.ssj.service.sys.sort.service.SortService;
+import com.ssj.service.weixin.library.service.ILibJoinService;
 import com.ssj.service.weixin.sales.service.LibStaffingService;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.formula.functions.Now;
@@ -49,6 +51,9 @@ public class OrganizationController  extends BaseController {
 
   @Autowired
   private AdminService adminService;
+
+  @Autowired
+  private ILibJoinService joinService;
 	 
     /**
      * 栏目主页面
@@ -60,7 +65,7 @@ public class OrganizationController  extends BaseController {
     }
     /**
      * 栏目树
-     * @param pid
+     * @param
      * @return
      * @throws Exception 
      */
@@ -92,7 +97,7 @@ public class OrganizationController  extends BaseController {
     
     /**
      * 查询列表
-     * @param request
+     * @param
      * @return
      * @throws Exception 
      */
@@ -136,10 +141,16 @@ public class OrganizationController  extends BaseController {
     	 model.addAttribute("org", org);
     	 return "sys/org/edit";
     }
+    @RequestMapping(value = "/batchEdit")
+    public String batchEdit(HttpServletRequest request, Model model, String id,String pId) throws Exception {
+		Organization org = organizationService.getById(pId);
+    	 model.addAttribute("org", org);
+    	 return "sys/org/batchEdit";
+    }
     
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @ResponseBody
-    public Response  updateSortNo(Organization org){
+    public Response  save(Organization org){
     	Response response = new  Response();
     	Boolean isAdd = StringUtils.isEmpty(org.getId())?true:false;
     	org.setCreateTime(new Date());
@@ -147,28 +158,74 @@ public class OrganizationController  extends BaseController {
     	org=organizationService.save(org);
     	organizationService.changeSubCount(org.getpId(), true);
     	if(isAdd){
-			//给当前账号插入权限
-			//String adminId = adminId();
-			List<String> list = new ArrayList<>();
-			list.add("admin");
-			list.add("sishujia");
-			list.add("xsxb");
-			for(String str:list){
-			    Admin admin = adminService.getByLoginName(str);
-			    if(admin == null){continue;}
-                AdminOrg adminOrg = new AdminOrg();
-                adminOrg.setAdminId(admin.getId());
-                adminOrg.setCreateTime(new Date());
-                adminOrg.setOrgCode(org.getCode());
-                adminOrg.setOrgId(org.getId());
-                adminOrgService.save(adminOrg);
-            }
+			addAdminOrg(org);
 		}
 
     	response.success(org);
         return response;
     }
-    
+    @RequestMapping(value = "/batchSave", method = RequestMethod.POST)
+    @ResponseBody
+    public Response  batchSave(String beginIndex,String pId,String totalNum){
+    	Response response = new  Response();
+		Organization org = organizationService.getById(pId);
+		int addNum = Integer.parseInt(totalNum);
+		int beginNum = Integer.parseInt(beginIndex);
+		for(int i=0;i<addNum;i++){
+			Organization addOrg = new Organization();
+			addOrg.setCreateTime(new Date());
+			addOrg.setpId(pId);
+			addOrg.setStatus(1);
+			addOrg.setArea(org.getName());
+			addOrg.setName(org.getName()+(beginNum+i));
+			addOrg.setCode(org.getCode()+"-"+(beginNum+i));
+			addOrg.setSortNo(beginNum+i);
+			addOrg.setOrgLevel(org.getOrgLevel()+1);
+			addOrg=organizationService.save(addOrg);
+			organizationService.changeSubCount(pId, true);
+			addAdminOrg(addOrg);
+			//创建图书馆
+            addJoin(addOrg);
+		}
+    	response.success(org);
+        return response;
+    }
+
+    private void addJoin(Organization org ){
+		//给当前账号插入权限
+		//String adminId = adminId();
+        TbLibJoin join = new TbLibJoin();
+        join.setLeagueCode(org.getCode());
+        join.setLeagueName(org.getName());
+        join.setLibtype(2);
+        join.setType(1);
+        join.setOrgCode(org.getCode());
+        join.setCreateTime(new Date());
+        join.setLeagueAddress("乌鲁木齐市新市区新医路393号");
+        join.setLeagueLat("43.83503");
+        join.setLeagueLng("87.58042");
+        join.setLeagueCity(org.getArea());
+        joinService.save(join);
+	}
+	private void addAdminOrg(Organization org ){
+		//给当前账号插入权限
+		//String adminId = adminId();
+		List<String> list = new ArrayList<>();
+		list.add("admin");
+		list.add("sishujia");
+		list.add("xsxb");
+		for(String str:list){
+			Admin admin = adminService.getByLoginName(str);
+			if(admin == null){continue;}
+			AdminOrg adminOrg = new AdminOrg();
+			adminOrg.setAdminId(admin.getId());
+			adminOrg.setCreateTime(new Date());
+			adminOrg.setOrgCode(org.getCode());
+			adminOrg.setOrgId(org.getId());
+			adminOrgService.save(adminOrg);
+		}
+	}
+
     @RequestMapping(value = "/delete", method = RequestMethod.POST)
     @ResponseBody
     public Response  delete(String id,String pId){

+ 34 - 4
src/main/resources/templates/sys/imlibuser/studentList.html

@@ -95,7 +95,9 @@
 				<td th:text="${item.grade}"></td>
 				<td th:text="${item.parent_name}"></td>
 				<td th:text="${item.parent_role}"></td>
-				<td th:text="${item.phone}"></td>
+				<td>
+					<input type="number" th:value="${item.phone}" th:onBlur="'updateSort(\''+${item.id}+'\',\''+${item.phone}+'\',this)'"  class="dfinput" style="width: 160px; height: 30px;"  />
+				</td>
 				<td th:text="${item.derver}"></td>
 <!-- 				<td th:text="${item.libVipService.startTime}"></td> -->
 <!-- 				<td th:text="${item.libVipService.endTime}"></td> -->
@@ -194,9 +196,37 @@ $("#exbutton").on('click',function(){
 		parent.layer.closeAll();
 		layer.closeAll();
 	}
-	
-	
-	
+
+
+	//修改排序号
+	function updateSort(id,oldSortNo,_this){
+		var sortNo = $(_this).val();
+		if(sortNo == oldSortNo){
+			return false;
+		}
+		if(sortNo ==''|| sortNo ==null){
+			return false;
+		}
+		$(_this).removeAttr("onBlur");
+		$.ajax({
+			url : "[[${sysUrl}]]/sys/imlibuser/updateSortNo",
+			type : "post",
+			data : {
+				id : id,
+				phone : sortNo
+			},
+			dataType : "json",
+			success : function(data) {
+				if(data.meta.success){
+					parent.layer.msg('操作成功',{icon:1});
+					location.reload();
+				}else{
+					parent.layer.msg(data.meta.message,{icon: 9})
+					location.reload();
+				}
+			}
+		});
+	}
 	
 	
 	function studentServiceAdd(vipId){

+ 111 - 0
src/main/resources/templates/sys/org/batchEdit.html

@@ -0,0 +1,111 @@
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+<title>私塾家</title>
+<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
+<script th:include="sys/common/metaJS" th:remove="tag"></script> 
+<script src="sys/js/jquery.validate.min.js" th:src="@{/static/sys/js/jquery.validate.min.js}"></script>
+<script src="sys/js/jquery-validation/messages_zh.js" th:src="@{/static/sys/js/jquery-validation/messages_zh.js}"></script>
+<style type="text/css">
+    body{min-width:280px;}
+    </style>
+</head>
+
+
+<body>
+<div class="formbody">
+	<div class="formtitle"><span>基本信息</span></div>
+	<form id="submitFrom" method="post" class="form-horizontal form-validate">
+		<input type="hidden" name="pId" th:value="${org.id}" />
+		<input type="hidden" name="name" th:value="${org.name}" />
+		<input type="hidden" name="code" th:value="${org.code}" id="code"/>
+		<ul class="forminfo">
+			<li>
+				<label>开始序号<b>*</b></label>
+				<input type="text" name="beginIndex" id="beginIndex"  class="dfinput" />
+			</li>
+			<li>
+				<label>数量<b>*</b></label>
+				<input type="text" name="totalNum"  class="dfinput"/>
+			</li>
+			<li>
+				<label>&nbsp;</label>
+				<button type="submit" class="btn">保存</button>
+				<button type="button" class="btn" onclick="closeWin();">取消</button>
+			</li>
+		</ul>
+	</form>
+</div>
+<script type="text/javascript">
+
+$(function(){
+	
+	
+	$(function(){
+		$("#submitFrom").validate({
+			rules : {
+
+				beginIndex : {
+					required : true,
+					maxlength: 300
+				},
+				totalNum : {
+					required : true,
+					maxlength: 300
+				}
+			},
+			messages: {
+				beginIndex : {
+					required : "名称不能为空",
+					maxlength : "最多300个字符"
+				},
+				totalNum : {
+					required : "名称不能为空",
+					maxlength : "最多300个字符"
+				}
+			},
+			errorPlacement : function(error, element) {
+					error.appendTo(element.parent()); 
+			},
+			submitHandler : function(form) {
+				roleFrom();
+			}
+		});
+		
+	});
+	function roleFrom(){
+		var url="[[${sysUrl}]]/sys/org/batchSave";
+		var params = $("#submitFrom").serialize();
+		var id="";
+		if($("#submitFrom").find("input[name='id']").val() != undefined){
+			id = $("#submitFrom").find("input[name='id']").val();
+		}
+		var pid = $("#submitFrom").find("input[name='pId']").val();
+		var name =$("#submitFrom").find("input[name='name']").val()+$("#beginIndex").val();
+		$.post(url,params,function(data){
+			if(data != null){
+					if(data.meta.success){
+						parent.layer.msg('操作成功',{icon:1});
+						refreshTree(id, pid, name);
+				    	setTimeout(function(){
+				    		parent.refreshList();
+							closeWin();
+						},1000);
+					}else{
+						layer.msg(data.meta.message,{icon:11});
+					}
+			}
+			
+		});
+	}
+});
+
+function refreshTree(id, pid, name){
+	parent.refreshNode(id, pid, name);
+}
+
+function closeWin(){
+	parent.layer.close(parent.layer.getFrameIndex(window.name));
+}
+</script>
+</body>
+</html>

+ 3 - 3
src/main/resources/templates/sys/org/edit.html

@@ -26,15 +26,15 @@
 			</li>
 			<li>
 				<label>编码<b>*</b></label>
-				<input type="text" name="code" th:value="${org.code}" class="dfinput"/>
+				<input type="text" name="code" th:value="${org.code}" class="dfinput" disabled/>
 			</li>
 			<li>
 				<label>地区<b>*</b></label>
-				<input type="text" name="area" th:value="${org.area}" class="dfinput"/>
+				<input type="text" name="area" th:value="${org.area}" class="dfinput" disabled/>
 			</li>
 			<li>
 				<label>排序号</label>
-				<input type="number" name="sortNo" th:value="${org.sortNo}" class="dfinput" />
+				<input type="number" name="sortNo" th:value="${org.sortNo}" class="dfinput" disabled/>
 			</li>
 			<li>
 				<label>&nbsp;</label>

+ 20 - 3
src/main/resources/templates/sys/org/list.html

@@ -17,11 +17,17 @@
 						<label>&nbsp;</label>
 						<input type="button" class="scbtn" value="查询" />
 					</li>
-					<li>
+					<li th:if="${ #httpSession.getAttribute('admin') !=null  && #httpSession.getAttribute('admin').loginName eq 'admin'  } " >
 							<ul class="toolbar">
 							<a href="javascript:void(0);"  th:onclick="'openEdit(-2,\''+${search.get('EQ_pId')}+'\',1)'"  ><li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>添加</li></a>
 							</ul>
 					</li>
+					<li th:if="${ #httpSession.getAttribute('admin') !=null  && #httpSession.getAttribute('admin').loginName eq 'admin'  } " >
+							<ul class="toolbar">
+							<a href="javascript:void(0);"  th:onclick="'openBatchEdit(-2,\''+${search.get('EQ_pId')}+'\',1)'"  ><li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>批量添加</li></a>
+							</ul>
+					</li>
+
 				</ul>
 		</form>
 	
@@ -44,8 +50,8 @@
 					<td>[[${item.name}]]<p th:text="'创建时间:'+${#calendars.format(item.createTime,'yyyy-MM-dd HH:mm:ss')}"></p></td>
 					<td th:text="${item.code}" ></td>
 					<td th:text="${item.area}" ></td>
-					<td style="text-align: center;" >
-					 <input type="number" th:value="${item.sortNo}" th:onBlur="'updateSort(\''+${item.id}+'\',\''+${item.sortNo}+'\',this)'"  class="dfinput" style="width: 60px; height: 30px;"  >
+					<td style="text-align: center;" th:text="${item.sortNo}" >
+<!--					 <input type="number" th:value="${item.sortNo}" th:onBlur="'updateSort(\''+${item.id}+'\',\''+${item.sortNo}+'\',this)'"  class="dfinput" style="width: 60px; height: 30px;"  >-->
 					</td>
 					<td>
 						<a href="javascript:;" th:onclick="'deleteById(\''+${item.id}+'\' ,\''+${item.pId}+'\',\''+${item.name}+'\')'"  class="tablelink" >删除</a>
@@ -75,6 +81,17 @@ function openEdit(id,pId,title){
 		content: '[[${sysUrl}]]/sys/org/edit.html?id='+id+'&pId='+pId
 	});
 }
+function openBatchEdit(id,pId,title){
+	parent.layer.open({
+		type: 2,
+		title: title ==1 ? '新增' :'修改',
+		shadeClose: false,
+		shade: 0.8,
+		offset: '60px',
+		area: ['670px', '520px'],
+		content: '[[${sysUrl}]]/sys/org/batchEdit.html?id='+id+'&pId='+pId
+	});
+}
 
 
 //修改排序号