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.

81 lines
2.8 KiB

package com.eco.plugin.xx.jlyhsjtb.openapi.caller;
import com.eco.plugin.xx.jlyhsjtb.config.PluginSimpleConfig;
import com.eco.plugin.xx.jlyhsjtb.db.bean.UserEntity;
import com.eco.plugin.xx.jlyhsjtb.db.controller.DBController;
import com.eco.plugin.xx.jlyhsjtb.utils.*;
import com.fr.decision.authority.AuthorityContext;
import com.fr.decision.authority.controller.DefaultAuthorityController;
import com.fr.decision.webservice.Response;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.tptj.plugin.hg.client.open.exception.CodeException;
import com.tptj.plugin.hg.client.open.impl.AbstractAPICaller;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class GetUserCaller extends AbstractAPICaller {
public static final GetUserCaller CALLER = new GetUserCaller();
private final DefaultAuthorityController authorityController = AuthorityContext.getInstance().getAuthorityController();
@Override
public Response call(HttpServletRequest request, Map<String, Object> map, Map<String, Object> map1) throws CodeException {
JSONObject param = Utils.getRequestBody(request);
String url = PluginSimpleConfig.getInstance().getUserurl();
String result = HttpUtils.HttpPostJson(url,param.toString(),null);
if(Utils.isNullStr(result)){
FRUtils.FRLogError("获取用户补偿数据异常");
return Response.ok("SUCCESS");
}
JSONObject userJson = new JSONObject(result);
JSONObject body = userJson.getJSONObject("body");
JSONArray usrInfArray = body.getJSONArray("usrInfArray");
for(int i =0;i<usrInfArray.length();i++){
operateUser(usrInfArray.getJSONObject(i));
}
return Response.ok("SUCCESS");
}
@Override
public String Description() {
return "用户补偿接口";
}
public static void operateUser(JSONObject userJson){
//增删改的标志
UserEntity userEntity = PubUtils.jsonObjToUserEntity(userJson);
String flag = userEntity.getType();
List<UserEntity> userList = new ArrayList<UserEntity>();
userList.add(userEntity);
if("delete".equals(flag)){
FRUtils.FRLogInfo("deleteUser:"+userEntity.getEmplyNo() + ";time:"+ DateUtilSelf.getNow());
DBController.batchUser(null,userList);
try {
FRUserUtils.deleteByUsername(userEntity.getEmplyNo());
} catch (Exception e) {
FRUtils.FRLogError("删除用户失败:"+userEntity.getUsrId()+e.getMessage());
}
return ;
}
try {
PubUtils.addOrUpdateUser(userList,userEntity);
} catch (Exception e) {
FRUtils.FRLogError("新增删除用户失败:"+userEntity.getUsrId()+e.getMessage());
}
}
}