Commit aaf55d6c by 龙于生

给国栋提交漏提交的代码

parent 2304e69a
package cn.timer.api.bean.yggl; package cn.timer.api.bean.yggl;
import java.util.Date; import java.util.Date;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* @author Tang 2019-11-15 * @author Tang 2019-11-15
*/ */
@Entity @Entity
@Data @Data
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Table(name="yggl_main_emp") @Table(name="yggl_main_emp")
@ApiModel("员工档案") @ApiModel("员工档案")
public class YgglMainEmp extends Model<YgglMainEmp> { public class YgglMainEmp extends Model<YgglMainEmp> {
private static final long serialVersionUID = 977019534920585689L; private static final long serialVersionUID = 977019534920585689L;
@Id @Id
@GeneratedValue @GeneratedValue
@TableId (type = IdType.AUTO) @TableId (type = IdType.AUTO)
@ApiModelProperty(value="员工编号 员工编号",example="101") @ApiModelProperty(value="员工编号 员工编号",example="101")
private Integer id; private Integer id;
@ApiModelProperty(value="员工工号 ",example="员工工号") @ApiModelProperty(value="员工工号 ",example="员工工号")
private Integer empNum; private Integer empNum;
@ApiModelProperty(value="手机号码 手机号码",example="101") @ApiModelProperty(value="手机号码 手机号码",example="101")
private String phone; private String phone;
@ApiModelProperty(value="密码 ",example="密码") @ApiModelProperty(value="密码 ",example="密码")
private String password; private String password;
@ApiModelProperty(value="头像 ",example="base64来处理头像") @ApiModelProperty(value="头像 ",example="base64来处理头像")
private String headUrl; private String headUrl;
@ApiModelProperty(value="名称 ",example="名称") @ApiModelProperty(value="名称 ",example="名称")
private String name; private String name;
@ApiModelProperty(value="英文名称 ",example="英文名称") @ApiModelProperty(value="英文名称 ",example="英文名称")
private String englishName; private String englishName;
@ApiModelProperty(value="性别 0:男;1:女",example="0") @ApiModelProperty(value="性别 0:男;1:女",example="0")
private Integer sex; private Integer sex;
@ApiModelProperty(value="证件类型 0:身份证;1:港澳居民来往内地通行证;2:台湾居民来往大陆通行证;3:外国护照;4:其他",example="101") @ApiModelProperty(value="证件类型 0:身份证;1:港澳居民来往内地通行证;2:台湾居民来往大陆通行证;3:外国护照;4:其他",example="101")
private Integer zjType; private Integer zjType;
@ApiModelProperty(value="证件号码 ",example="证件号码") @ApiModelProperty(value="证件号码 ",example="证件号码")
private String zjNum; private String zjNum;
@ApiModelProperty(value="身份证有效期 ",example="身份证有效到期日") @ApiModelProperty(value="身份证有效期 ",example="身份证有效到期日")
private Date sfzyxTime; private Date sfzyxTime;
@ApiModelProperty(value="出生日期 ",example="出生日期") @ApiModelProperty(value="出生日期 ",example="出生日期")
private Date birthday; private Date birthday;
@ApiModelProperty(value="年龄 年龄",example="101") @ApiModelProperty(value="年龄 年龄",example="101")
private Integer age; private Integer age;
@ApiModelProperty(value="是否已婚 0:否、1:是",example="101") @ApiModelProperty(value="是否已婚 0:否、1:是",example="101")
private Integer isMarried; private Integer isMarried;
@ApiModelProperty(value="是否已育 0:否、1:是",example="101") @ApiModelProperty(value="是否已育 0:否、1:是",example="101")
private Integer isPregnant; private Integer isPregnant;
@ApiModelProperty(value="国家地区 0:中国;1:中国香港;2:中国澳门;3:中国台湾",example="101") @ApiModelProperty(value="国家地区 0:中国;1:中国香港;2:中国澳门;3:中国台湾",example="101")
private Integer area; private Integer area;
@ApiModelProperty(value="民族 56个名族",example="101") @ApiModelProperty(value="民族 56个名族",example="101")
private Integer mz; private Integer mz;
@ApiModelProperty(value="政治面貌 1:中共党员;2:中共预备党员;3共青团员;4:民革党员;5:民盟盟员;6:民建会员;7:民进会员;8:农工党党员;9:致公党党员;10:九三学社社员;11:台盟盟员;12:无党派人士;13:群众",example="101") @ApiModelProperty(value="政治面貌 1:中共党员;2:中共预备党员;3共青团员;4:民革党员;5:民盟盟员;6:民建会员;7:民进会员;8:农工党党员;9:致公党党员;10:九三学社社员;11:台盟盟员;12:无党派人士;13:群众",example="101")
private Integer zzmm; private Integer zzmm;
@ApiModelProperty(value="籍贯 省",example="101") @ApiModelProperty(value="籍贯 省",example="101")
private String jg; private String jg;
@ApiModelProperty(value="籍贯 省id",example="101") @ApiModelProperty(value="籍贯 省id",example="101")
private String jgId; private String jgId;
@ApiModelProperty(value = "省") @ApiModelProperty(value = "省")
private String province; private String province;
@ApiModelProperty(value = "省id") @ApiModelProperty(value = "省id")
private String provinceId; private String provinceId;
@ApiModelProperty(value = "市") @ApiModelProperty(value = "市")
private String city; private String city;
@ApiModelProperty(value = "市id") @ApiModelProperty(value = "市id")
private String cityId; private String cityId;
@ApiModelProperty(value = "区") @ApiModelProperty(value = "区")
private String district; private String district;
@ApiModelProperty(value = "区编号") @ApiModelProperty(value = "区编号")
private String districtId; private String districtId;
@ApiModelProperty(value="户口性质 1:城镇户口;2:农村户口;3:居民户口",example="101") @ApiModelProperty(value="户口性质 1:城镇户口;2:农村户口;3:居民户口",example="101")
private Integer hkType; private Integer hkType;
@ApiModelProperty(value="户籍地址 ",example="详细地址") @ApiModelProperty(value="户籍地址 ",example="详细地址")
private String hkAddress; private String hkAddress;
@ApiModelProperty(value="QQ QQ",example="101") @ApiModelProperty(value="QQ QQ",example="101")
private Integer qq; private Integer qq;
@ApiModelProperty(value="微信 ",example="微信") @ApiModelProperty(value="微信 ",example="微信")
private String wechat; private String wechat;
// @ApiModelProperty(value="个人邮箱 ",example="个人邮箱") // @ApiModelProperty(value="个人邮箱 ",example="个人邮箱")
// private String email; // private String email;
@ApiModelProperty(value="血型 ",example="血型") @ApiModelProperty(value="血型 ",example="血型")
private String bloodType; private String bloodType;
@ApiModelProperty(value="语言 ",example="语言") @ApiModelProperty(value="语言 ",example="语言")
private String language; private String language;
@ApiModelProperty(value="最高学历 1:小学;2:初中;3:高中;4:中专;5:大专;6:本科;7:研究生;8:硕士;9:博士;",example="101") @ApiModelProperty(value="最高学历 1:小学;2:初中;3:高中;4:中专;5:大专;6:本科;7:研究生;8:硕士;9:博士;",example="101")
private Integer edu; private Integer edu;
@ApiModelProperty(value="专业 ",example="专业") @ApiModelProperty(value="专业 ",example="专业")
private String zy; private String zy;
@ApiModelProperty(value="转正备注 ",example="转正备注") @ApiModelProperty(value="转正备注 ",example="转正备注")
private String zzRemark; private String zzRemark;
@ApiModelProperty(value="工作性质 0全职、1实习、2兼职、3劳务派遣、4劳务、5派遣、6外包、7退休返聘",example="101") @ApiModelProperty(value="工作性质 0全职、1实习、2兼职、3劳务派遣、4劳务、5派遣、6外包、7退休返聘",example="101")
private Integer jobType; private Integer jobType;
@ApiModelProperty(value="员工状态 0试用、1正式、2离职中、3已离职",example="101") @ApiModelProperty(value="员工状态 0试用、1正式、2离职中、3已离职",example="101")
private Integer jobStatus; private Integer jobStatus;
@ApiModelProperty(value="入职日期 ",example="客户注册后的时间为入职时间") @ApiModelProperty(value="入职日期 ",example="客户注册后的时间为入职时间")
private Date rzTime; private Date rzTime;
@ApiModelProperty(value="试用期 0:无试用期;1:1个月;2:2个月;3:3个月;4:4个月;5:5个月;6:6个月(有试用期显示选项)",example="101") @ApiModelProperty(value="试用期 0:无试用期;1:1个月;2:2个月;3:3个月;4:4个月;5:5个月;6:6个月(有试用期显示选项)",example="101")
private Integer syq; private Integer syq;
@ApiModelProperty(value="应转正日期 ",example="人事记录要自动转正的日期") @ApiModelProperty(value="应转正日期 ",example="人事记录要自动转正的日期")
private Date zzTime; private Date zzTime;
@ApiModelProperty(value="实际转正日期 ",example="人事手动记录要转正的日期") @ApiModelProperty(value="实际转正日期 ",example="人事手动记录要转正的日期")
private Date sjzzTime; private Date sjzzTime;
@ApiModelProperty(value="是否计入考勤 0:否;1:是",example="101") @ApiModelProperty(value="是否计入考勤 0:否;1:是",example="101")
private Integer isJrkq; private Integer isJrkq;
@ApiModelProperty(value="公司内部工号 就是公司内部自己设置的工号",example="101") @ApiModelProperty(value="公司内部工号 就是公司内部自己设置的工号",example="101")
private String jobNum; private String jobNum;
@ApiModelProperty(value="工作地点 ",example="工作地点") @ApiModelProperty(value="工作地点 ",example="工作地点")
private String workAddress; private String workAddress;
@ApiModelProperty(value="工作电话 工作电话",example="101") @ApiModelProperty(value="工作电话 工作电话",example="101")
private Integer workPhone; private Integer workPhone;
@ApiModelProperty(value="工作邮箱 ",example="工作邮箱") @ApiModelProperty(value="工作邮箱 ",example="工作邮箱")
private String workEmail; private String workEmail;
@ApiModelProperty(value="招聘渠道 招聘渠道应该是活性的",example="101") @ApiModelProperty(value="招聘渠道 招聘渠道应该是活性的",example="101")
private Integer zpqd; private Integer zpqd;
@ApiModelProperty(value="部门岗位id 部门岗位id",example="101") @ApiModelProperty(value="部门岗位id 部门岗位id",example="101")
private Integer bmgwId; private Integer bmgwId;
@ApiModelProperty(value="部门名称",example="") @ApiModelProperty(value="部门名称",example="")
private String bmgwName; private String bmgwName;
@ApiModelProperty(value="修改时间",example="修改时间") @ApiModelProperty(value="修改时间",example="修改时间")
private Date updateTime; private Date updateTime;
@ApiModelProperty(value="修改人",example="修改人") @ApiModelProperty(value="修改人",example="修改人")
private Integer updateMan; private Integer updateMan;
@ApiModelProperty(value="组织机构代码 组织机构代码",example="101") @ApiModelProperty(value="组织机构代码 组织机构代码",example="101")
private Integer orgCode; private Integer orgCode;
@ApiModelProperty(value="微信id",example="UnionID微信系统唯一id") @ApiModelProperty(value="微信id",example="UnionID微信系统唯一id")
private String unionid; private String unionid;
@ApiModelProperty(value="公众号id",example="openid公众号唯一id") @ApiModelProperty(value="公众号id",example="openid公众号唯一id")
private String openid; private String openid;
@ApiModelProperty(value="小程序id",example="mpopenid小程序") @ApiModelProperty(value="小程序id",example="mpopenid小程序")
private String mpopenid; private String mpopenid;
@ApiModelProperty(value="手机APPid",example="appopenid手机app") @ApiModelProperty(value="手机APPid",example="appopenid手机app")
private String appopenid; private String appopenid;
// @ApiModelProperty(value="是否企业中心管理员 ",example="0-否 1-主账号 2-子账号") // @ApiModelProperty(value="是否企业中心管理员 ",example="0-否 1-主账号 2-子账号")
// private Integer isManager; // private Integer isManager;
@ApiModelProperty(value="离职前状态 1试用、2正式 ",example="1试用、2正式") @ApiModelProperty(value="离职前状态 1试用、2正式 ",example="1试用、2正式")
private Integer beforeLeavingSts; private Integer beforeLeavingSts;
@ApiModelProperty(value="自定义工号",example="") @ApiModelProperty(value="自定义工号",example="")
private String customNum; private String customNum;
@Transient @Transient
@TableField(exist = false) @TableField(exist = false)
private String workTime;//工龄 private String workTime;//工龄
@Transient @Transient
@TableField(exist = false) @TableField(exist = false)
private String error;//错误信息提示 private String error;//错误信息提示
@Transient @Transient
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(value="员工登陆账号(手机号)",example="员工登陆账号(手机号)") @ApiModelProperty(value="员工登陆账号(手机号)",example="员工登陆账号(手机号)")
private String empLoginPhone; private String empLoginPhone;
@ApiModelProperty(value="是否已投保:0否 1是",example="")
private int isInsure;
}
\ No newline at end of file }
...@@ -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;
/** /**
* 通用http发送方法 * 通用http发送方法
* *
* @author Tang * @author Tang
*/ */
public class HttpUtils public class HttpUtils
...@@ -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;
} }
} }
} /*参数转为字符串*/
\ No newline at end of file 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