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.
161 lines
6.1 KiB
161 lines
6.1 KiB
3 years ago
|
package com.eco.plugin.xxx.bjgjdata.controller;
|
||
|
|
||
|
import com.eco.plugin.xxx.bjgjdata.config.PluginSimpleConfig;
|
||
|
import com.eco.plugin.xxx.bjgjdata.db.bean.DBEntity;
|
||
|
import com.eco.plugin.xxx.bjgjdata.db.bean.OrgEntity;
|
||
|
import com.eco.plugin.xxx.bjgjdata.db.bean.RecordEntity;
|
||
|
import com.eco.plugin.xxx.bjgjdata.db.controller.DBController;
|
||
|
import com.eco.plugin.xxx.bjgjdata.utils.DataUtils;
|
||
|
import com.eco.plugin.xxx.bjgjdata.utils.DateUtilSelf;
|
||
|
import com.eco.plugin.xxx.bjgjdata.utils.ResponseUtils;
|
||
|
import com.eco.plugin.xxx.bjgjdata.utils.Utils;
|
||
|
import com.fr.decision.webservice.annotation.LoginStatusChecker;
|
||
|
import com.fr.json.JSONObject;
|
||
|
import com.fr.plugin.context.PluginContexts;
|
||
|
import com.fr.plugin.transform.FunctionRecorder;
|
||
|
import com.fr.stable.fun.Authorize;
|
||
|
import com.fr.third.springframework.stereotype.Controller;
|
||
|
import com.fr.third.springframework.web.bind.annotation.GetMapping;
|
||
|
import com.fr.third.springframework.web.bind.annotation.PostMapping;
|
||
|
import com.fr.third.springframework.web.bind.annotation.ResponseBody;
|
||
|
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
import javax.servlet.http.HttpServletResponse;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Date;
|
||
|
import java.util.List;
|
||
|
import java.util.UUID;
|
||
|
|
||
|
@Controller
|
||
|
@LoginStatusChecker(required = false)
|
||
|
@FunctionRecorder
|
||
|
@Authorize(callSignKey = "com.eco.plugin.xxx.bjgjdata")
|
||
|
public class ControllerSelf {
|
||
|
|
||
|
@GetMapping(value = "/getAllData")
|
||
|
@ResponseBody
|
||
|
public void getAllData(HttpServletRequest request,HttpServletResponse response){
|
||
|
if(!PluginContexts.currentContext().isAvailable()){
|
||
|
ResponseUtils.failedResponse(response,"插件授权过期,请联系管理员!");
|
||
|
return ;
|
||
|
}
|
||
|
List<DBEntity> list = new ArrayList<DBEntity>();
|
||
|
try {
|
||
|
DataUtils.getData("RY","",1,"", PluginSimpleConfig.getInstance(),list);
|
||
|
} catch (Exception e) {
|
||
|
ResponseUtils.failedResponse(response,"同步人员数据异常"+e.getMessage());
|
||
|
return ;
|
||
|
}
|
||
|
|
||
|
DBController.batch(list,null);
|
||
|
}
|
||
|
|
||
|
@GetMapping(value = "/getWBRYData")
|
||
|
@ResponseBody
|
||
|
public void getWBRYData(HttpServletRequest request,HttpServletResponse response){
|
||
|
if(!PluginContexts.currentContext().isAvailable()){
|
||
|
ResponseUtils.failedResponse(response,"插件授权过期,请联系管理员!");
|
||
|
return ;
|
||
|
}
|
||
|
List<DBEntity> list = new ArrayList<DBEntity>();
|
||
|
try {
|
||
|
DataUtils.getData("WBRY","",1,"", PluginSimpleConfig.getInstance(),list);
|
||
|
} catch (Exception e) {
|
||
|
ResponseUtils.failedResponse(response,"同步人员数据异常"+e.getMessage());
|
||
|
return ;
|
||
|
}
|
||
|
|
||
|
DBController.batch(list,null);
|
||
|
}
|
||
|
|
||
|
@GetMapping(value = "/getAllOrgData")
|
||
|
@ResponseBody
|
||
|
public void getAllOrgData(HttpServletRequest request,HttpServletResponse response){
|
||
|
if(!PluginContexts.currentContext().isAvailable()){
|
||
|
ResponseUtils.failedResponse(response,"插件授权过期,请联系管理员!");
|
||
|
return ;
|
||
|
}
|
||
|
|
||
|
List<OrgEntity> orgList = new ArrayList<OrgEntity>();
|
||
|
try {
|
||
|
DataUtils.getOrgData("JG","",1,"", PluginSimpleConfig.getInstance(),orgList);
|
||
|
} catch (Exception e) {
|
||
|
ResponseUtils.failedResponse(response,"同步机构数据异常"+e.getMessage());
|
||
|
return ;
|
||
|
}
|
||
|
|
||
|
DBController.batchOrg(orgList,null);
|
||
|
}
|
||
|
|
||
|
@GetMapping(value = "/getWBJGData")
|
||
|
@ResponseBody
|
||
|
public void getWBJGData(HttpServletRequest request,HttpServletResponse response){
|
||
|
if(!PluginContexts.currentContext().isAvailable()){
|
||
|
ResponseUtils.failedResponse(response,"插件授权过期,请联系管理员!");
|
||
|
return ;
|
||
|
}
|
||
|
|
||
|
List<OrgEntity> orgList = new ArrayList<OrgEntity>();
|
||
|
try {
|
||
|
DataUtils.getOrgData("WBJG","",1,"", PluginSimpleConfig.getInstance(),orgList);
|
||
|
} catch (Exception e) {
|
||
|
ResponseUtils.failedResponse(response,"同步机构数据异常"+e.getMessage());
|
||
|
return ;
|
||
|
}
|
||
|
|
||
|
DBController.batchOrg(orgList,null);
|
||
|
}
|
||
|
|
||
|
@PostMapping(value = "/incrementData")
|
||
|
@ResponseBody
|
||
|
public StringBuilder incrementData(HttpServletRequest request,HttpServletResponse response){
|
||
|
if(!PluginContexts.currentContext().isAvailable()){
|
||
|
return new StringBuilder("插件授权过期,请联系管理员!");
|
||
|
}
|
||
|
|
||
|
JSONObject param = Utils.getRequestBody(request);
|
||
|
String tableAlias = param.getString("tableAlias");
|
||
|
String updateTime = param.getString("updateTime");
|
||
|
Long notifyId = param.getLong("notifyId");
|
||
|
String createTime = DateUtilSelf.DateToString(new Date(),"yyyy-MM-dd HH:mm:ss");
|
||
|
|
||
|
//添加日志
|
||
|
RecordEntity record = new RecordEntity();
|
||
|
record.setTableAlias(tableAlias);
|
||
|
record.setCreatetime(new Date());
|
||
|
record.setUpdateTime(updateTime);
|
||
|
record.setNotifyId(notifyId);
|
||
|
record.setId(UUID.randomUUID().toString());
|
||
|
|
||
|
DBController.addRecord(record);
|
||
|
|
||
|
if("RY".equals(tableAlias) || "WBRY".equals(tableAlias)){
|
||
|
//添加人员信息
|
||
|
List<DBEntity> list = new ArrayList<DBEntity>();
|
||
|
try {
|
||
|
DataUtils.getData(tableAlias,updateTime,1,"", PluginSimpleConfig.getInstance(),list);
|
||
|
} catch (Exception e) {
|
||
|
ResponseUtils.failedResponse(response,"同步数据异常"+e.getMessage());
|
||
|
return new StringBuilder("FAIL");
|
||
|
}
|
||
|
|
||
|
DBController.batch(list,null);
|
||
|
}else{
|
||
|
//添加机构信息
|
||
|
List<OrgEntity> list = new ArrayList<OrgEntity>();
|
||
|
try {
|
||
|
DataUtils.getOrgData(tableAlias,updateTime,1,"", PluginSimpleConfig.getInstance(),list);
|
||
|
} catch (Exception e) {
|
||
|
ResponseUtils.failedResponse(response,"同步机构数据异常"+e.getMessage());
|
||
|
return new StringBuilder("FAIL");
|
||
|
}
|
||
|
|
||
|
DBController.batchOrg(list,null);
|
||
|
}
|
||
|
|
||
|
|
||
|
return new StringBuilder("SUCCESS");
|
||
|
}
|
||
|
|
||
|
}
|