You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

531 lines
24 KiB
Java

package com.weaver.seconddev.sxjg.controller;
/**
*
*/
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.weaver.common.authority.annotation.WeaPermission;
import com.weaver.seconddev.sxjg.util.NccApiUtil;
import com.weaver.seconddev.sxjg.util.PersondataQueryUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.*;
@RestController
@RequestMapping("/papi/secondev/nccloud/api/hrtrn/openAPI")
public class EmployeeSelfServiceController {
private final Logger log = LoggerFactory.getLogger(EmployeeSelfServiceController.class);
@Autowired
private PersondataQueryUtil persondataQueryUtil;
/**
* use:
*/
@WeaPermission(publicPermission = true)
@PostMapping("/persondata/query")
public JSONObject persondataQuery(
@RequestBody String body
) throws Exception {
JSONObject r3 = JSONObject.parseObject(body);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/persondata/query";
String rs11 = nccApiUtil.doJsonPost(url,token,r3.toJSONString());
JSONObject resJsonObject = JSONObject.parseObject(rs11);
if("1000000000".equals(resJsonObject.getString("code"))) {
JSONArray dataArrayOne = resJsonObject.getJSONArray("data");
if(dataArrayOne!=null && dataArrayOne.size() > 0) {
for(int i = 0; i<dataArrayOne.size();i++) {
JSONObject jsonObjectone = dataArrayOne.getJSONObject(i);
JSONArray dataArrayTwo = jsonObjectone.getJSONArray("data");
if(dataArrayTwo!=null && dataArrayTwo.size() >0) {
for(int j = 0; j<dataArrayTwo.size();j++) {
JSONObject re3 = dataArrayTwo.getJSONObject(j);
for(Map.Entry<String, Object> re4 : re3.entrySet()){
String key = re4.getKey();
JSONObject re5 = re3.getJSONObject(key);
re5.put("isExamine",false);
}
}
}
}
}
nccApiUtil = new NccApiUtil();
nccApiUtil.init();
token = nccApiUtil.getToken();
url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/psninfoedit/approveDetailVO";
rs11 = nccApiUtil.doJsonPost(url,token,r3.toJSONString());
JSONObject resJsonObject2= JSONObject.parseObject(rs11);
if("1000000000".equals(resJsonObject2.getString("code"))) {
JSONObject dataObj2 = resJsonObject2.getJSONObject("data");
if(dataObj2.containsKey("data")) {
JSONObject dataObj21 = dataObj2.getJSONObject("data");
//如果是基本信息查询
if("bd_psndoc".equals(r3.getString("tableCode"))) {
JSONArray afterdata = null;
if(dataObj21 != null && dataObj21.containsKey("afterData") && dataObj21.get("afterData") != null) {
afterdata = dataObj21.getJSONArray("afterData");
}
if(afterdata != null && afterdata.size() > 0) {
dataArrayOne = resJsonObject.getJSONArray("data");
if(dataArrayOne!=null && dataArrayOne.size() > 0) {
for(int i = 0; i<dataArrayOne.size();i++) {
JSONObject jsonObjectone = dataArrayOne.getJSONObject(i);
JSONArray dataArrayTwo = jsonObjectone.getJSONArray("data");
if(dataArrayTwo!=null && dataArrayTwo.size() >0) {
for(int j = 0; j<dataArrayTwo.size();j++) {
JSONObject re3 = dataArrayTwo.getJSONObject(j);
for(Map.Entry<String, Object> re4 : re3.entrySet()){
String key = re4.getKey();
JSONObject re5 = re3.getJSONObject(key);
for(int x = 0;x < afterdata.size();x ++) {
JSONObject afertObj = afterdata.getJSONObject(x);
String columnValue = afertObj.getString("columnValue");
String columnKey = afertObj.getString("columnKey");
if(columnKey!=null && columnKey.length()>0 && columnKey.equals(re5.getString("key"))) {
re5.put("isExamine",true);
}
}
}
}
}
}
}
}
}else {//子级信息查询
if(dataObj21.containsKey("changeTypeMap")){
JSONObject changeData= dataObj21.getJSONObject("changeTypeMap");
List<String> shhs = new ArrayList<>();
for(String key : changeData.keySet()) {
shhs.add(key);
}
if(shhs!=null && shhs.size()>0) {
if(dataArrayOne!=null && dataArrayOne.size() > 0) {
for(int i = 0; i<dataArrayOne.size();i++) {
JSONObject jsonObjectone = dataArrayOne.getJSONObject(i);
String rowDataPk = jsonObjectone.getString("rowDataPk");
if(shhs.contains(rowDataPk)) {
JSONArray dataArrayTwo = jsonObjectone.getJSONArray("data");
if(dataArrayTwo!=null && dataArrayTwo.size() >0) {
for(int j = 0; j<dataArrayTwo.size();j++) {
JSONObject re3 = dataArrayTwo.getJSONObject(j);
for(Map.Entry<String, Object> re4 : re3.entrySet()){
String key = re4.getKey();
JSONObject re5 = re3.getJSONObject(key);
re5.put("isExamine",true);
}
}
}
}
}
}
}
}
}
}
}
}
return resJsonObject;
}
@WeaPermission(publicPermission = true)
@PostMapping("/persondata/query2")
public String persondataQuery2(@RequestBody String body) throws Exception {
String resJsonStr = persondataQueryUtil.queryNccloudPersondata(body);
return resJsonStr;
}
/**
* use:
*/
@WeaPermission(publicPermission = true)
@PostMapping("/psninfoconf/list")
public JSONObject psninfoconfList(
@RequestBody String body
) throws Exception {
JSONObject requestbody = JSONObject.parseObject(body);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/psninfoconf/list";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
JSONObject resJsonObject = JSONObject.parseObject(rs11);
return resJsonObject;
}
/**
* use:<>
*/
@WeaPermission(publicPermission = true)
@PostMapping("/psninfoconf/check")
public JSONObject psninfoconfCheck(
@RequestBody String body
) throws Exception {
JSONObject requestbody = JSONObject.parseObject(body);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/psninfoconf/check";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
JSONObject resJsonObject = JSONObject.parseObject(rs11);
return resJsonObject;
}
/**
* use:-
*/
@WeaPermission(publicPermission = true)
@PostMapping("/psninfoedit/save")
public JSONObject psninfoeditSave(
@RequestBody String body
) throws Exception {
JSONObject requestbody = JSONObject.parseObject(body);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/psninfoedit/save";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
JSONObject resJsonObject = JSONObject.parseObject(rs11);
return resJsonObject;
}
/**
* use:
*/
@WeaPermission(publicPermission = true)
@PostMapping("/psninfoedit/approvelist")
public JSONObject psninfoeditApprovelist(
@RequestBody String body
) throws Exception {
JSONObject requestbody = JSONObject.parseObject(body);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/psninfoedit/approvelist";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
JSONObject resJsonObject = JSONObject.parseObject(rs11);
return resJsonObject;
}
/**
* use:
*/
@WeaPermission(publicPermission = true)
@PostMapping("/psninfoedit/retractapprove")
public JSONObject psninfoeditRetractapprove(
@RequestBody String body
) throws Exception {
JSONObject requestbody = JSONObject.parseObject(body);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/psninfoedit/retractapprove";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
JSONObject resJsonObject = JSONObject.parseObject(rs11);
return resJsonObject;
}
/**
* use:
*/
@WeaPermission(publicPermission = true)
@PostMapping("/psninfoedit/approveDetailVO")
public JSONObject psninfoeditApproveDetailVO(
@RequestBody String body
) throws Exception {
JSONObject requestbody = JSONObject.parseObject(body);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/psninfoedit/approveDetailVO";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
JSONObject resJsonObject = JSONObject.parseObject(rs11);
return resJsonObject;
}
/**
* use:
*/
@WeaPermission(publicPermission = true)
@PostMapping("/psninfoconf/querytablecodeisuserd")
public JSONObject queryTablecodeisuserd(
@RequestBody String body
) throws Exception {
JSONObject requestbody = JSONObject.parseObject(body);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/psninfoconf/querytablecodeisuserd";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
JSONObject resJsonObject = JSONObject.parseObject(rs11);
return resJsonObject;
}
/**
* use:
*/
@WeaPermission(publicPermission = true)
@PostMapping("/attachment/query")
public JSONObject attachmentQuery(
@RequestBody String body
) throws Exception {
JSONObject requestbody = JSONObject.parseObject(body);
String pk1 = requestbody.getString("pk");
JSONObject inter2 = new JSONObject();
inter2.put("pk_psndoc",pk1);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/attachment/query";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
try {
JSONObject resJsonObject = JSONObject.parseObject(rs11);
String code = resJsonObject.getString("code");
if("1000000000".equals(code)) {
//详情接口合并
NccApiUtil nccApiUtil2 = new NccApiUtil();
nccApiUtil2.init();
String token2 = nccApiUtil2.getToken();
String url2 = nccApiUtil2.getBaseUrl()+"nccloud/api/hrtrn/openAPI/attachment/unreviewed";
String rs12 = nccApiUtil2.doJsonPost(url2,token2,inter2.toJSONString());
JSONObject resJsonObject2 = JSONObject.parseObject(rs12);
String code2 = resJsonObject2.getString("code");
JSONObject dataObject = resJsonObject.getJSONObject("data");
if(dataObject.keySet()!=null && dataObject.keySet().size()>0) {
for(String key1 : dataObject.keySet()) {
JSONArray keysz1 = dataObject.getJSONArray(key1);
for(int i = 0; i<keysz1.size();i++) {
JSONObject one = keysz1.getJSONObject(i);
one.put("isExamine",false);
one.put("file_state","0");
}
}
}
//拼接待审核
if("1000000000".equals(code2)) {
JSONArray data2 = resJsonObject2.getJSONArray("data");
if(data2!=null && data2.size()>0) {
for(int i = 0; i < data2.size(); i++) {
JSONObject obj2 = data2.getJSONObject(i);
JSONObject y2 = new JSONObject();
String pk_annex_approve = obj2.getString("pk_annex_approve");
String file_name = obj2.getString("file_name");
String checkstatus = obj2.getString("checkstatus");
String type = obj2.getString("type");
String file_state = obj2.getString("file_state");
//仅checkstatus==0待审核时才展示
if("0".equals(checkstatus)) {
y2.put("pk",pk_annex_approve);
y2.put("type",type);
y2.put("name",file_name);
y2.put("path","");
y2.put("file_state",file_state);
y2.put("isExamine",true);
if(dataObject.containsKey(type)) {
JSONArray b1 = dataObject.getJSONArray(type);
b1.add(y2);
}else {
JSONArray b2 = new JSONArray();
b2.add(y2);
dataObject.put(type,b2);
}
}
}
}
}
}
return resJsonObject;
}catch (Exception e) {
throw new Exception(rs11);
}
}
/**
* use:
*/
@WeaPermission(publicPermission = true)
@PostMapping("/attachment/download")
public JSONObject attachmentDownload(
@RequestBody String body
) throws Exception {
JSONObject requestbody = JSONObject.parseObject(body);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/attachment/download";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
try {
JSONObject resJsonObject = JSONObject.parseObject(rs11);
return resJsonObject;
}catch (Exception e) {
throw new Exception(rs11);
}
}
/**
* use:
*/
@WeaPermission(publicPermission = true)
@GetMapping("/attachment/download1")
public void attachmentDownload1(
@RequestParam("fullPath") String fullPath,
HttpServletResponse response
) throws Exception {
JSONObject requestbody = new JSONObject();
requestbody.put("fullPath",fullPath);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/attachment/download";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
try {
JSONObject resJsonObject2 = JSONObject.parseObject(rs11);
if(resJsonObject2.getBoolean("success")) {
JSONObject resJsonObject = resJsonObject2.getJSONObject("data");
String bytes = resJsonObject.getString("bytes");
byte [] liufile = Base64.getDecoder().decode(bytes);
String filenames = resJsonObject.getString("name");
response.setContentType("application/x-download");
String fileName = URLEncoder.encode(filenames, "UTF-8");
response.setCharacterEncoding("UTF-8");
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
try {
ServletOutputStream out = response.getOutputStream();
out.write(liufile,0,liufile.length);
out.close();
out.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
}catch (Exception e) {
throw new Exception(rs11);
}
}
/**
* use:
*/
@WeaPermission(publicPermission = true)
@PostMapping("/attachment/receive")
public JSONObject attachmentReceive(
@RequestBody String body
) throws Exception {
JSONObject requestbody = JSONObject.parseObject(body);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/attachment/receive";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
try {
JSONObject resJsonObject = JSONObject.parseObject(rs11);
return resJsonObject;
}catch (Exception e) {
throw new Exception(rs11);
}
}
// @WeaPermission(publicPermission = true)
// @PostMapping("/attachment/upload")
// public JSONObject attachmentUpload(
// @RequestParam("file") MultipartFile[] file,
// @RequestParam("pk_psndoc") String pk_psndoc,
// @RequestParam("file_state") String file_state,
// @RequestParam("type") String type,
// @RequestParam("file_type") String file_type,
// @RequestParam("file_name") String file_name
// ) throws Exception {
// JSONObject rs = new JSONObject();
// if (file.isEmpty()) {
// rs.put("status",false);
// rs.put("msg","文件为空,请重新上传");
// return rs;
// }
// // 获取文件名
// String fileName = file.getOriginalFilename();
// // 获取文件的字节内容
// byte[] bytes = file.getBytes();
// String filebase64str = Base64.getEncoder().encodeToString(bytes);
// JSONObject send = new JSONObject();
// send.put("pk_psndoc",pk_psndoc);
// JSONArray data = new JSONArray();
// JSONObject dataObject = new JSONObject();
// dataObject.put("file_name",file_name);
// dataObject.put("file_state",file_state);
// dataObject.put("filebytes",filebase64str);
// dataObject.put("type",type);
// dataObject.put("file_type",file_type);
// data.add(dataObject);
// send.put("data",data);
// NccApiUtil nccApiUtil = new NccApiUtil();
// nccApiUtil.init();
// String token = nccApiUtil.getToken();
// String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/attachment/receive";
// String rs11 = nccApiUtil.doJsonPost(url,token,send.toJSONString());
// try {
// JSONObject resJsonObject = JSONObject.parseObject(rs11);
// return resJsonObject;
// }catch (Exception e) {
// throw new Exception(rs11);
// }
// }
/**
* use:
*/
@WeaPermission(publicPermission = true)
@PostMapping("/attachment/unreviewed")
public JSONObject attachmentUnreviewed(
@RequestBody String body
) throws Exception {
JSONObject requestbody = JSONObject.parseObject(body);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/attachment/unreviewed";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
try {
JSONObject resJsonObject = JSONObject.parseObject(rs11);
return resJsonObject;
}catch (Exception e) {
throw new Exception(rs11);
}
}
/**
* use:
*/
@WeaPermission(publicPermission = true)
@PostMapping("/attachment/cancel")
public JSONObject attachmentCancel(@RequestBody String body) throws Exception {
JSONObject requestbody = JSONObject.parseObject(body);
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrtrn/openAPI/attachment/cancel";
String rs11 = nccApiUtil.doJsonPost(url,token,requestbody.toJSONString());
try {
JSONObject resJsonObject = JSONObject.parseObject(rs11);
return resJsonObject;
}catch (Exception e) {
throw new Exception(rs11);
}
}
}