Commit aaf55d6c by 龙于生

给国栋提交漏提交的代码

parent 2304e69a
...@@ -224,6 +224,7 @@ public class YgglMainEmp extends Model<YgglMainEmp> { ...@@ -224,6 +224,7 @@ public class YgglMainEmp extends Model<YgglMainEmp> {
@ApiModelProperty(value="员工登陆账号(手机号)",example="员工登陆账号(手机号)") @ApiModelProperty(value="员工登陆账号(手机号)",example="员工登陆账号(手机号)")
private String empLoginPhone; private String empLoginPhone;
@ApiModelProperty(value="是否已投保:0否 1是",example="")
private int isInsure;
} }
...@@ -5,18 +5,15 @@ import cn.timer.api.bean.qyzx.QyzxEntInfoM; ...@@ -5,18 +5,15 @@ import cn.timer.api.bean.qyzx.QyzxEntInfoM;
import cn.timer.api.bean.yggl.YgglMainEmp; import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser; import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean; import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.controller.insure.bean.ExcelBean;
import cn.timer.api.utils.*; import cn.timer.api.utils.*;
import com.alibaba.druid.util.Base64; import com.alibaba.druid.util.Base64;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.beust.jcommander.internal.Lists; import com.beust.jcommander.internal.Lists;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.JsonObject;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -194,7 +191,7 @@ public class InsureContorll { ...@@ -194,7 +191,7 @@ public class InsureContorll {
} }
/*测试用生产环境不需要*/ /*测试用生产环境不需要*/
synchronized private Object requestAgent(Map bodyMap ){ synchronized private Object requestAgent(Map bodyMap ){
String data=HttpUtils.sendPost(insuredUrl,setParams(JSONObject.toJSONString(bodyMap)),bodyMap); String data= HttpUtils.sendPost(insuredUrl,setParams(JSONObject.toJSONString(bodyMap)),bodyMap);
Map<String,Object> dataMap = JSONObject.parseObject(data); Map<String,Object> dataMap = JSONObject.parseObject(data);
if (dataMap.get("errcode").toString().equals("suc")) { if (dataMap.get("errcode").toString().equals("suc")) {
return dataMap.get("data"); return dataMap.get("data");
...@@ -235,7 +232,7 @@ public class InsureContorll { ...@@ -235,7 +232,7 @@ public class InsureContorll {
bodyMap.put("name",file.getName()); bodyMap.put("name",file.getName());
bodyMap.put("file",fileBase64); bodyMap.put("file",fileBase64);
/*end*/ /*end*/
String data=HttpUtils.sendPost(uploadUrl,setParams(JSONObject.toJSONString(bodyMap)),bodyMap); String data= HttpUtils.sendPost(uploadUrl,setParams(JSONObject.toJSONString(bodyMap)),bodyMap);
log.info("请求返回的结果====="+data); log.info("请求返回的结果====="+data);
/*文件流base64*/ /*文件流base64*/
return ResultUtil.data(message(data)); return ResultUtil.data(message(data));
...@@ -261,7 +258,7 @@ public class InsureContorll { ...@@ -261,7 +258,7 @@ public class InsureContorll {
// bodyMap.put("name","劳务公司批增-月单(1).xlsx"); // bodyMap.put("name","劳务公司批增-月单(1).xlsx");
bodyMap.put("file",fileBase64); bodyMap.put("file",fileBase64);
/*end*/ /*end*/
String data=HttpUtils.sendPost(uploadUrl2,setParams2(JSONObject.toJSONString(bodyMap)),bodyMap); String data= HttpUtils.sendPost(uploadUrl2,setParams2(JSONObject.toJSONString(bodyMap)),bodyMap);
log.info("请求返回的结果====="+data); log.info("请求返回的结果====="+data);
/*文件流base64*/ /*文件流base64*/
return ResultUtil.data(message(data)); return ResultUtil.data(message(data));
...@@ -293,9 +290,8 @@ public class InsureContorll { ...@@ -293,9 +290,8 @@ public class InsureContorll {
public void downExcel(@CurrentUser UserBean userBean, HttpServletRequest request, HttpServletResponse resp){ public void downExcel(@CurrentUser UserBean userBean, HttpServletRequest request, HttpServletResponse resp){
LocalDate localDate = LocalDate.now(); LocalDate localDate = LocalDate.now();
/*获取该企业下所有未投保员工*/ /*获取该企业下所有未投保员工*/
List<YgglMainEmp> ygglMainEmpList =YgglMainEmp.builder().build().selectList(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode,userBean.getOrgCode()) List<YgglMainEmp> ygglMainEmpList = YgglMainEmp.builder().build().selectList(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode,userBean.getOrgCode())
.eq(YgglMainEmp::getIsInsure,0)); .eq(YgglMainEmp::getIsInsure,0));
ExcelBean excelBean;
List list=Lists.newArrayList(); List list=Lists.newArrayList();
for (YgglMainEmp y:ygglMainEmpList.subList(0,5)) { for (YgglMainEmp y:ygglMainEmpList.subList(0,5)) {
String[] arr =new String[]{String.valueOf(y.getId()),y.getName(),"身份证",y.getZjNum(),"50万意外/5万医疗/扩展24小时(A类)","","深圳名邦人力资源管理有限公司","无","A类"}; String[] arr =new String[]{String.valueOf(y.getId()),y.getName(),"身份证",y.getZjNum(),"50万意外/5万医疗/扩展24小时(A类)","","深圳名邦人力资源管理有限公司","无","A类"};
......
package cn.timer.api.utils; package cn.timer.api.utils;
import java.io.BufferedReader; import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ConnectException; import java.net.ConnectException;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.Map;
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -44,10 +44,10 @@ public class HttpUtils ...@@ -44,10 +44,10 @@ public class HttpUtils
String urlNameString = url + "?" + param; String urlNameString = url + "?" + param;
log.info("sendGet - {}", urlNameString); log.info("sendGet - {}", urlNameString);
URL realUrl = new URL(urlNameString); URL realUrl = new URL(urlNameString);
URLConnection connection = realUrl.openConnection(); HttpsURLConnection connection = (HttpsURLConnection)realUrl.openConnection();
connection.setRequestProperty("accept", "*/*"); connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive"); connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36)");
connection.connect(); connection.connect();
in = new BufferedReader(new InputStreamReader(connection.getInputStream())); in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line; String line;
...@@ -97,11 +97,12 @@ public class HttpUtils ...@@ -97,11 +97,12 @@ public class HttpUtils
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果 * @return 所代表远程资源的响应结果
*/ */
public static String sendPost(String url, String param) public static String sendPost(String url, Map paramMap, Map bodyMap)
{ {
PrintWriter out = null; DataOutputStream out=null;
BufferedReader in = null; BufferedReader in = null;
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
String param = getParamString(paramMap);
try try
{ {
String urlNameString = url + "?" + param; String urlNameString = url + "?" + param;
...@@ -110,15 +111,16 @@ public class HttpUtils ...@@ -110,15 +111,16 @@ public class HttpUtils
URLConnection conn = realUrl.openConnection(); URLConnection conn = realUrl.openConnection();
conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36)");
conn.setRequestProperty("Accept-Charset", "utf-8"); conn.setRequestProperty("Accept-Charset", "utf-8");
conn.setRequestProperty("contentType", "utf-8"); conn.setRequestProperty("contentType", "text/json;charset=UTF-8");
conn.setDoOutput(true); conn.setDoOutput(true);
conn.setDoInput(true); conn.setDoInput(true);
out = new PrintWriter(conn.getOutputStream()); out = new DataOutputStream(conn.getOutputStream());
out.print(param); String json = JSONObject.toJSONString(bodyMap);
out.write(json.getBytes(StandardCharsets.UTF_8));
out.flush(); out.flush();
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line; String line;
while ((line = in.readLine()) != null) while ((line = in.readLine()) != null)
{ {
...@@ -176,9 +178,9 @@ public class HttpUtils ...@@ -176,9 +178,9 @@ public class HttpUtils
HttpsURLConnection conn = (HttpsURLConnection) console.openConnection(); HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();
conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
conn.setRequestProperty("Accept-Charset", "utf-8"); conn.setRequestProperty("Accept-Charset", "utf-8");
conn.setRequestProperty("contentType", "utf-8"); conn.setRequestProperty("contentType", "text/json;charset=UTF-8");
conn.setDoOutput(true); conn.setDoOutput(true);
conn.setDoInput(true); conn.setDoInput(true);
...@@ -245,4 +247,16 @@ public class HttpUtils ...@@ -245,4 +247,16 @@ public class HttpUtils
return true; return true;
} }
} }
/*参数转为字符串*/
private static String getParamString(Map<String, String> paramMap){
if(null==paramMap || paramMap.isEmpty()){
return "";
}
StringBuilder builder = new StringBuilder();
for(String key : paramMap.keySet() ){
builder.append("&")
.append(key).append("=").append(paramMap.get(key));
}
return builder.deleteCharAt(0).toString();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment