You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
3.7 KiB
121 lines
3.7 KiB
package com.fr.plugin.it.handler; |
|
|
|
import com.fr.decision.authority.data.User; |
|
import com.fr.decision.fun.impl.BaseHttpHandler; |
|
import com.fr.decision.webservice.bean.user.UserBean; |
|
import com.fr.decision.webservice.bean.user.UserUpdateBean; |
|
import com.fr.plugin.it.dbAccessProvider.DbController; |
|
import com.fr.plugin.it.utils.*; |
|
import com.fr.plugin.transform.FunctionRecorder; |
|
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
|
import sun.rmi.rmic.Util; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
import java.io.BufferedReader; |
|
import java.io.InputStreamReader; |
|
import java.util.ArrayList; |
|
import java.util.List; |
|
import java.util.Map; |
|
|
|
@FunctionRecorder |
|
public class ChangeDepartment extends BaseHttpHandler { |
|
|
|
public ChangeDepartment() { |
|
} |
|
|
|
@Override |
|
public RequestMethod getMethod() { |
|
return RequestMethod.POST; |
|
} |
|
|
|
@Override |
|
public String getPath() { |
|
return "/changeOrg"; |
|
} |
|
|
|
@Override |
|
public boolean isPublic() { |
|
return true; |
|
} |
|
|
|
@Override |
|
public void handle(HttpServletRequest req, HttpServletResponse res){ |
|
//获取xml报文 |
|
StringBuilder stb = new StringBuilder(); |
|
try{ |
|
BufferedReader in = new BufferedReader(new InputStreamReader(req.getInputStream())); |
|
|
|
String line = null; |
|
|
|
while ((line = in.readLine()) != null) { |
|
stb.append(line); |
|
} |
|
}catch(Exception e){ |
|
FRUtils.FRLogError("获取xml报文异常!"); |
|
} |
|
|
|
String xml = stb.toString(); |
|
FRUtils.FRLogInfo("xml:"+xml); |
|
|
|
List<Map<String,String>> map = XMLUtils.xmlToList(xml); |
|
|
|
String xmlResponse = ResponseTemplate.xmlTemplate("Y","",xml); |
|
|
|
for(Map<String,String> data : map){ |
|
String username = data.get("ACCOUNT_NO"); |
|
String orgCode = data.get("ORG_CODE"); |
|
String type = data.get("ACTION_TYPE"); |
|
String id = DbController.getOrg(orgCode).getDid(); |
|
|
|
if("E".equals(type)){ |
|
FRUtils.FRLogInfo("系统不支持修改操作!"); |
|
xmlResponse = ResponseTemplate.xmlTemplate("N","系统不支持修改操作!",xml); |
|
ResponseUtils.responseXml(res,xmlResponse); |
|
return; |
|
} |
|
|
|
if(Utils.isNullStr(id)){ |
|
xmlResponse = ResponseTemplate.xmlTemplate("N","系统中不存在此机构!",xml); |
|
ResponseUtils.responseXml(res,xmlResponse); |
|
return; |
|
} |
|
|
|
try { |
|
User user = FRUserUtils.getUserByUserName(username); |
|
String userId = user.getId(); |
|
|
|
UserUpdateBean userUpdateBean = new UserUpdateBean(); |
|
userUpdateBean.setDepartmentId(id); |
|
//新增 |
|
if("N".equals(type)){ |
|
userUpdateBean.setAddUserIds(new String[]{userId}); |
|
} |
|
|
|
//移除 |
|
if("D".equals(type)){ |
|
userUpdateBean.setRemoveUserIds(new String[]{userId}); |
|
} |
|
|
|
FRUserUtils.updateDepartmentPostUsers(id,"",userUpdateBean); |
|
} catch (Exception e) { |
|
String message = e.getMessage(); |
|
if(Utils.isNullStr(message)){ |
|
message = "用户组织关系变更异常!"; |
|
} |
|
FRUtils.FRLogError("用户组织关系变更异常!"); |
|
xmlResponse = ResponseTemplate.xmlTemplate("N",message,xml); |
|
ResponseUtils.responseXml(res,xmlResponse); |
|
return; |
|
} |
|
} |
|
|
|
ResponseUtils.responseXml(res,xmlResponse); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|