Compare commits
No commits in common. 'master' and 'dongdingding' have entirely different histories.
master
...
dongdingdi
@ -1,30 +0,0 @@
|
||||
package com.ruoyi.docking.entity.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 绑定项目
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/7/18 17:14
|
||||
*/
|
||||
@Data
|
||||
public class EditProjectRequest {
|
||||
|
||||
/**
|
||||
* 本系统项目id
|
||||
*/
|
||||
@ApiModelProperty("本系统项目id")
|
||||
@NotNull(message = "本系统项目id不能为空!")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@ApiModelProperty("项目id")
|
||||
@NotNull(message = "项目id不能为空!")
|
||||
private Integer projectId;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package com.ruoyi.docking.entity.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 项目月度信息投资统计
|
||||
* @author du
|
||||
* @since 2025/5/8 10:10
|
||||
*/
|
||||
@Data
|
||||
public class YdxxtjRequest {
|
||||
|
||||
@NotNull(message = "年份不能为空!")
|
||||
@ApiModelProperty("年份")
|
||||
private String years;
|
||||
|
||||
|
||||
@NotNull(message = "项目id不能为空!")
|
||||
@ApiModelProperty("项目id")
|
||||
private Long xmId;
|
||||
|
||||
@NotNull(message = "请选择类别!")
|
||||
@ApiModelProperty("1年度 2季度")
|
||||
private Integer type;
|
||||
}
|
@ -1,299 +1,77 @@
|
||||
package com.ruoyi.gysl.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.gysl.entity.baseModel.BaseModel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 入驻企业基本信息 bms_enterprise_basic_info
|
||||
* 入驻企业基本信息(Enterprise)实体类
|
||||
*
|
||||
* @author farben
|
||||
* @date 2023-08-25
|
||||
* @author makejava
|
||||
* @since 2025-02-24 11:26:49
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("gysl_enterprise")
|
||||
@ApiModel(value = "Enterprise", description = "入驻企业基本信息")
|
||||
public class Enterprise extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@ApiModelProperty(value = "主键id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@ApiModelProperty("项目id")
|
||||
@ApiModelProperty(value = "项目id")
|
||||
@TableField("xm_id")
|
||||
private Long xmId;
|
||||
|
||||
/**
|
||||
* 源主键
|
||||
*/
|
||||
@ApiModelProperty("源主键")
|
||||
private String ywid;
|
||||
|
||||
/**
|
||||
* 源表org
|
||||
*/
|
||||
@ApiModelProperty("源表org")
|
||||
private String org;
|
||||
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
@ApiModelProperty("企业名称")
|
||||
@Excel(name = "企业名称*",required = true)
|
||||
private String qymc;
|
||||
|
||||
/**
|
||||
* 标识证号
|
||||
*/
|
||||
@ApiModelProperty("标识证号")
|
||||
private String bszh;
|
||||
@ApiModelProperty(value = "企业名称")
|
||||
@TableField("name")
|
||||
@Excel(name = "企业名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 统一社会信用代码
|
||||
*/
|
||||
@ApiModelProperty("统一社会信用代码")
|
||||
@Excel(name = "统一社会信用代码*",required = true)
|
||||
private String tyshxydm;
|
||||
|
||||
/**
|
||||
* 企业注册号
|
||||
*/
|
||||
@ApiModelProperty("企业注册号")
|
||||
private String qyzch;
|
||||
|
||||
/**
|
||||
* 组织机构代码
|
||||
*/
|
||||
@ApiModelProperty("组织机构代码")
|
||||
private String zzjgdm;
|
||||
|
||||
/**
|
||||
* 经济类型代码
|
||||
*/
|
||||
@ApiModelProperty("经济类型代码")
|
||||
private String jjlxdm;
|
||||
|
||||
/**
|
||||
* 经济类型名称
|
||||
*/
|
||||
@ApiModelProperty("经济类型名称")
|
||||
private String jjlxmc;
|
||||
|
||||
/**
|
||||
* 企业类型代码
|
||||
*/
|
||||
@ApiModelProperty("企业类型代码")
|
||||
private String qylxdm;
|
||||
|
||||
/**
|
||||
* 企业类型名称
|
||||
*/
|
||||
@ApiModelProperty("企业类型名称")
|
||||
private String qylxmc;
|
||||
|
||||
/**
|
||||
* 注册资金
|
||||
*/
|
||||
@ApiModelProperty("注册资金")
|
||||
private String zczj;
|
||||
|
||||
/**
|
||||
* 注册资本币种
|
||||
*/
|
||||
@ApiModelProperty("注册资本币种")
|
||||
private String zczbbz;
|
||||
|
||||
/**
|
||||
* 注册类型
|
||||
*/
|
||||
@ApiModelProperty("注册类型")
|
||||
private String zclx;
|
||||
|
||||
/**
|
||||
* 经营范围
|
||||
*/
|
||||
@ApiModelProperty("经营范围")
|
||||
private String jyfw;
|
||||
|
||||
/**
|
||||
* 经营或营业起始日期
|
||||
*/
|
||||
@ApiModelProperty("经营或营业起始日期")
|
||||
private String jyhyyqsrq;
|
||||
|
||||
/**
|
||||
* 经营或营业截止日期
|
||||
*/
|
||||
@ApiModelProperty("经营或营业截止日期")
|
||||
private String jyhyyjzrq;
|
||||
|
||||
/**
|
||||
* 行业代码
|
||||
*/
|
||||
@ApiModelProperty("行业代码")
|
||||
private String hydm;
|
||||
|
||||
/**
|
||||
* 行业名称
|
||||
*/
|
||||
@ApiModelProperty("行业名称")
|
||||
private String hymc;
|
||||
|
||||
/**
|
||||
* 行业门类
|
||||
*/
|
||||
@ApiModelProperty("行业门类")
|
||||
private String hyml;
|
||||
|
||||
/**
|
||||
* 产业类型
|
||||
*/
|
||||
@ApiModelProperty("产业类型")
|
||||
private String cylx;
|
||||
|
||||
/**
|
||||
* 企业住所
|
||||
*/
|
||||
@ApiModelProperty("企业住所")
|
||||
private String qyzs;
|
||||
|
||||
/**
|
||||
* 经营场所
|
||||
*/
|
||||
@ApiModelProperty("经营场所")
|
||||
private String jycs;
|
||||
|
||||
/**
|
||||
* 经营场所行政区划
|
||||
*/
|
||||
@ApiModelProperty("经营场所行政区划")
|
||||
private String jycsxzqh;
|
||||
|
||||
/**
|
||||
* 邮政编码
|
||||
*/
|
||||
@ApiModelProperty("邮政编码")
|
||||
private String yzbm;
|
||||
|
||||
/**
|
||||
* 成立日期
|
||||
*/
|
||||
@ApiModelProperty("成立日期")
|
||||
private String clrq;
|
||||
|
||||
/**
|
||||
* 信用等级
|
||||
*/
|
||||
@ApiModelProperty("信用等级")
|
||||
private String xydj;
|
||||
|
||||
/**
|
||||
* 企业规模
|
||||
*/
|
||||
@ApiModelProperty("企业规模")
|
||||
private String qygm;
|
||||
|
||||
/**
|
||||
* 法定代表人姓名
|
||||
*/
|
||||
@ApiModelProperty("法定代表人姓名")
|
||||
private String fddbrxm;
|
||||
|
||||
/**
|
||||
* 法定代表人证件号码
|
||||
*/
|
||||
@ApiModelProperty("法定代表人证件号码")
|
||||
private String fddbrzjhm;
|
||||
|
||||
/**
|
||||
* 登记机关
|
||||
*/
|
||||
@ApiModelProperty("登记机关")
|
||||
private String djjg;
|
||||
|
||||
/**
|
||||
* 核准日期
|
||||
*/
|
||||
@ApiModelProperty("核准日期")
|
||||
private String hzrq;
|
||||
|
||||
/**
|
||||
* 经营状态
|
||||
*/
|
||||
@ApiModelProperty("经营状态")
|
||||
private String jyzt;
|
||||
|
||||
/**
|
||||
* 状态日期
|
||||
*/
|
||||
@ApiModelProperty("状态日期")
|
||||
private String ztrq;
|
||||
|
||||
/**
|
||||
* 注销日期
|
||||
*/
|
||||
@ApiModelProperty("注销日期")
|
||||
private String zxrq;
|
||||
|
||||
/**
|
||||
* 吊销日期
|
||||
*/
|
||||
@ApiModelProperty("吊销日期")
|
||||
private String dxrq;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
@ApiModelProperty("联系电话")
|
||||
private String lxdh;
|
||||
|
||||
/**
|
||||
* 是否园区内
|
||||
*/
|
||||
@ApiModelProperty("是否园区内")
|
||||
private String sfyqn;
|
||||
|
||||
/**
|
||||
* 操作标识
|
||||
*/
|
||||
@ApiModelProperty("操作标识")
|
||||
private String dwOperation;
|
||||
|
||||
/**
|
||||
* 入库时间
|
||||
*/
|
||||
@ApiModelProperty("入库时间")
|
||||
private String dwTimestamp;
|
||||
|
||||
/**
|
||||
* 代理键
|
||||
*/
|
||||
@ApiModelProperty("代理键")
|
||||
private String dwAgencykey;
|
||||
@ApiModelProperty(value = "统一社会信用代码")
|
||||
@TableField("code")
|
||||
@Excel(name = "统一社会信用代码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 来源机构
|
||||
* 所属行业
|
||||
*/
|
||||
@ApiModelProperty("来源机构")
|
||||
private String dwLyjg;
|
||||
@ApiModelProperty(value = "所属行业 ")
|
||||
@TableField("sshy")
|
||||
@Excel(name = "所属行业")
|
||||
private String sshy;
|
||||
|
||||
/**
|
||||
* 来源表名
|
||||
* 租金价格
|
||||
*/
|
||||
@ApiModelProperty("来源表名")
|
||||
private String dwLyb;
|
||||
@ApiModelProperty(value = "租金价格")
|
||||
@TableField("zjjg")
|
||||
@Excel(name = "租金价格")
|
||||
private Integer zjjg;
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
package com.ruoyi.gysl.entity.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 项目手册分页请求
|
||||
* @author du
|
||||
* @since 2025/4/17 17:18
|
||||
*/
|
||||
@Data
|
||||
public class HandbookRequest {
|
||||
|
||||
@ApiModelProperty(value ="手册名称" )
|
||||
private String name;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "开始时间 yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间 yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@ApiModelProperty(value = "页数")
|
||||
private Integer current = 1;
|
||||
|
||||
@ApiModelProperty(value = "页码s")
|
||||
private Integer size = 10;
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.ruoyi.gysl.entity.response;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 建筑工程竣工验收备案表
|
||||
* @author du
|
||||
* @since 2025/5/21 下午2:30
|
||||
*/
|
||||
@Data
|
||||
public class JgysbabResponse {
|
||||
|
||||
@ApiModelProperty(value ="证照颁发日期" )
|
||||
private String ZZBFRQ;
|
||||
|
||||
@ApiModelProperty(value ="证照颁发机构" )
|
||||
private String ZZBFJG;
|
||||
|
||||
@ApiModelProperty(value ="证照有效期截至日期" )
|
||||
private String ZZYXQJZRQ;
|
||||
|
||||
@ApiModelProperty(value ="持证主体代码类型代码" )
|
||||
private String CZZTDMLXDM;
|
||||
|
||||
@ApiModelProperty(value ="持证主体代码" )
|
||||
private String CZZTDM;
|
||||
|
||||
@ApiModelProperty(value ="证照编号" )
|
||||
private String ZZBH;
|
||||
|
||||
@ApiModelProperty(value ="持证主体" )
|
||||
private String CZZT;
|
||||
|
||||
@ApiModelProperty(value ="证照文件流" )
|
||||
private String pdfBase64;
|
||||
|
||||
@ApiModelProperty(value ="持证主体代码类型" )
|
||||
private String CZZTDMLX;
|
||||
|
||||
@ApiModelProperty(value ="证照有效期起始日期" )
|
||||
private String ZZYXQQSRQ;
|
||||
|
||||
@ApiModelProperty(value ="证照标识" )
|
||||
private String ZZBS;
|
||||
|
||||
@ApiModelProperty(value ="证照名称" )
|
||||
private String ZZMC;
|
||||
|
||||
@ApiModelProperty(value ="证照颁发机构代码" )
|
||||
private String ZZBFJGDM;
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.ruoyi.gysl.entity.response;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 项目月度信息投资统计
|
||||
* @author du
|
||||
* @since 2025/5/8 9:34
|
||||
*/
|
||||
@Data
|
||||
public class YdxxtjResponse {
|
||||
|
||||
@ApiModelProperty("月度")
|
||||
private String month;
|
||||
|
||||
@ApiModelProperty("季度")
|
||||
private Integer jd;
|
||||
|
||||
@ApiModelProperty("季度投资额")
|
||||
private BigDecimal jdtze;
|
||||
|
||||
@ApiModelProperty("月投资额")
|
||||
private BigDecimal ytze;
|
||||
|
||||
@ApiModelProperty("月投资比例")
|
||||
private BigDecimal ytzbl;
|
||||
|
||||
@ApiModelProperty("累计投资额")
|
||||
private BigDecimal ljtze;
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
package com.ruoyi.gysl.login.controller;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.gysl.login.dto.request.UserInfoRequestDTO;
|
||||
import com.ruoyi.gysl.login.dto.response.ChiefResponse;
|
||||
import com.ruoyi.gysl.login.dto.response.ThirdUserInfoResponse;
|
||||
import com.ruoyi.gysl.login.service.LoginTokenService;
|
||||
import com.ruoyi.gysl.login.util.HMAC256Config;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 政务端登录
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/4 9:53
|
||||
*/
|
||||
@Api(tags = "政务端单点登录")
|
||||
@RequestMapping("/system/chief")
|
||||
@RestController
|
||||
public class ChiefController {
|
||||
|
||||
@Value("${clientId}")
|
||||
private String clientId;
|
||||
|
||||
@Value("${clientSecret}")
|
||||
private String clientSecret;
|
||||
|
||||
|
||||
@Value("${appkey}")
|
||||
private String appkey;
|
||||
|
||||
@Value("${getInfoId}")
|
||||
private String getInfoId;
|
||||
|
||||
@Value("${getAllInfo}")
|
||||
private String getAllInfo;
|
||||
|
||||
@Resource
|
||||
private LoginTokenService loginTokenService;
|
||||
|
||||
@ApiOperation("政务端登录")
|
||||
@GetMapping
|
||||
public AjaxResult login(
|
||||
@RequestParam("userToken") String userToken,
|
||||
@RequestParam("timespan") String timespan,
|
||||
@RequestParam("signature") String signature
|
||||
) throws Exception {
|
||||
String encode = Base64.encode((HMAC256Config.HmacSHA256(clientId + timespan + userToken, clientSecret)));
|
||||
if (encode.equals(signature)) {
|
||||
//经济大脑(政务端)获取用户信息接口
|
||||
UserInfoRequestDTO req = new UserInfoRequestDTO();
|
||||
req.setClientId(clientId);
|
||||
req.setUserToken(userToken);
|
||||
//请求头
|
||||
HashMap<String, String> headers = new HashMap<>();//存放请求头,可以存放多个请求头
|
||||
headers.put("signature", Base64.encode(HMAC256Config.HmacSHA256(JSONUtil.parse(req).toString() + timespan, clientSecret)));
|
||||
headers.put("timespan", timespan);
|
||||
//请求体
|
||||
JSONObject jsonObject = new JSONObject();//存放参数
|
||||
jsonObject.set("clientId", clientId);
|
||||
jsonObject.set("userToken", userToken);
|
||||
HttpResponse response = HttpRequest.post(getInfoId)
|
||||
.addHeaders(headers)
|
||||
.body(jsonObject.toString())
|
||||
.execute();
|
||||
// 获取响应状态码
|
||||
if (response.getStatus() == 200) {
|
||||
//经济大脑(政务端)获取用户信息接口
|
||||
JSONObject jsonObj = JSONUtil.parseObj(response.body());
|
||||
ThirdUserInfoResponse res = JSONUtil.toBean(jsonObj.get("data").toString(), ThirdUserInfoResponse.class);
|
||||
//政务通获取用户信息接口(可选)
|
||||
String getInfo = getAllInfo + "?id=" + res.getUserId() + "&appkey=" + appkey;
|
||||
HttpResponse getMain = HttpRequest.get(getInfo).execute();
|
||||
if (getMain.getStatus() == 200) {
|
||||
JSONObject dataJson = JSONUtil.parseObj(getMain.body());
|
||||
ChiefResponse bean = JSONUtil.toBean(dataJson, ChiefResponse.class);
|
||||
//判断几个政务端用户,等待商量结果
|
||||
bean.setToken(loginTokenService.singleLogin(bean.getAccountName(),
|
||||
bean.getName(),
|
||||
"01", bean.getMobile(),bean.getEmail()));
|
||||
return AjaxResult.success(bean);
|
||||
} else {
|
||||
throw new ServiceException("登陆失败");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ServiceException("登陆失败");
|
||||
}
|
||||
throw new ServiceException("登陆失败");
|
||||
}
|
||||
|
||||
|
||||
// @ApiOperation("政务根据信用代码返回跳转路由")
|
||||
// @GetMapping("/returnUrl")
|
||||
// public AjaxResult returnUrl(@RequestParam("code") String code,
|
||||
// @RequestParam("userToken") String userToken) throws Exception {
|
||||
// //请求的地址
|
||||
// StringBuilder url = new StringBuilder("http://172.21.10.12/sipsg-enterprise-mobile-manage/#/loginVerify?");
|
||||
// //当前时间的时间戳
|
||||
// String timespan = Long.toString(System.currentTimeMillis());
|
||||
// UserInfoRequestDTO req = new UserInfoRequestDTO();
|
||||
// req.setClientId(clientId);
|
||||
// req.setUserToken(userToken);
|
||||
// String signature = Base64.encode(HMAC256Config.HmacSHA256(JSONUtil.parse(req).toString() + timespan, clientSecret));
|
||||
// url.append("signature=").append(signature);
|
||||
// url.append("×pan=").append(timespan);
|
||||
// url.append("&userToken=").append(userToken);
|
||||
// url.append("&gourl=")
|
||||
// .append(URLEncoder.encode("https://172.21.10.12/sipsg-enterprise-mobile-manage/#/workPlat/search/enterprise/detail?id="+code,"UTF-8"));
|
||||
// url.append("&clientid=").append(clientId);
|
||||
// return AjaxResult.success(url.toString());
|
||||
// }
|
||||
}
|
@ -1,179 +0,0 @@
|
||||
package com.ruoyi.gysl.login.controller;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @since 2024/5/22 15:50
|
||||
*/
|
||||
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.gysl.entity.BasicInformation;
|
||||
import com.ruoyi.gysl.login.dto.response.UserMainResponse;
|
||||
import com.ruoyi.gysl.login.dto.response.UserResponse;
|
||||
import com.ruoyi.gysl.login.service.LoginTokenService;
|
||||
import com.ruoyi.gysl.service.BasicInformationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 单点登陆
|
||||
*/
|
||||
@Api(tags = "企业端单点登陆")
|
||||
@RestController
|
||||
@RequestMapping("/system/singlelogin")
|
||||
public class SingleLoginController {
|
||||
|
||||
|
||||
@Value("${url}")
|
||||
private String url;
|
||||
|
||||
@Value("${infoUrl}")
|
||||
private String infoUrl;
|
||||
|
||||
@Value("${logoutUrl}")
|
||||
private String logoutUrl;
|
||||
|
||||
@Value("${returnUrl}")
|
||||
private String returnUrl;
|
||||
|
||||
|
||||
@Resource
|
||||
private LoginTokenService loginTokenService;
|
||||
|
||||
@Value("${enterpriseAppId}")
|
||||
private String enterpriseAppId;
|
||||
|
||||
@Value("${enterpriseAppsecret}")
|
||||
private String enterpriseAppsecret;
|
||||
|
||||
@Resource
|
||||
private BasicInformationService basicInformationService;
|
||||
|
||||
/**
|
||||
* 统一登陆
|
||||
*/
|
||||
@ApiOperation("统一登陆")
|
||||
@GetMapping("/login")
|
||||
public void login(HttpServletResponse response) throws IOException {
|
||||
//变成参数模式,appid 用于校验提交的来源地址,生产环境会校验,试用环境暂不校验
|
||||
String scUrl = "clientUrl=" + URLEncoder.encode(returnUrl, "UTF-8") + "&appid=" + enterpriseAppId;
|
||||
//加密后的客户端地址
|
||||
scUrl = Base64.getEncoder().encodeToString(scUrl.getBytes());
|
||||
//最终跳转地址
|
||||
String jumpurl = url + "?scUrl=" + URLEncoder.encode(scUrl, "UTF-8");
|
||||
// 添加请求头
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("X-Requested-With", "XMLHttpRequest");
|
||||
response.sendRedirect(jumpurl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@ApiOperation(value = "获取用户信息", response = UserResponse.class)
|
||||
@GetMapping("/getInfo")
|
||||
public AjaxResult getInfo(String clientToken) throws Exception {
|
||||
HttpResponse response = HttpRequest.get(infoUrl)
|
||||
.form("clienttoken", clientToken)
|
||||
.addHeaders(generationHeader())
|
||||
.execute();
|
||||
System.out.println(response.body());
|
||||
String responseBody;
|
||||
int statusCode = response.getStatus();
|
||||
if (statusCode == 200) {
|
||||
// 获取响应内容
|
||||
responseBody = response.body();
|
||||
JSONObject jsonObj = JSONUtil.parseObj(responseBody);
|
||||
JSONObject dataObj = jsonObj.getJSONObject("data");
|
||||
//判断是法人用户
|
||||
if ("ep".equals(dataObj.get("usertype"))) {
|
||||
JSONObject mainobj = dataObj.getJSONObject("mainbody");
|
||||
UserResponse res = JSONUtil.toBean(dataObj, UserResponse.class);
|
||||
UserMainResponse req = JSONUtil.toBean(mainobj, UserMainResponse.class);
|
||||
Long count = basicInformationService.lambdaQuery()
|
||||
.eq(BasicInformation::getTyshxydm, req.getUscc())
|
||||
.or()
|
||||
.eq(BasicInformation::getXmfrdwxz, req.getEpname()).count();
|
||||
if (count > 0) {
|
||||
String token = loginTokenService.singleLogin(req.getUscc(), req.getEpname(),
|
||||
"02", null, null);
|
||||
res.setToken(token);
|
||||
res.setMain(req);
|
||||
return AjaxResult.success(res);
|
||||
}else {
|
||||
throw new ServiceException("贵公司无需参与苏州工业园区工业上楼相关填报工作。系统将即刻为您返回企业服务一张网界面,以便您处理其他业务事宜!");
|
||||
}
|
||||
} else {
|
||||
throw new ServiceException("该用户不是企业法人");
|
||||
}
|
||||
} else {
|
||||
throw new ServiceException("未知异常请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*
|
||||
* @param clienttoken clienttoken
|
||||
* @return 响应类
|
||||
*/
|
||||
@ApiOperation(value = "退出登录")
|
||||
@GetMapping("/enterpriseLogout")
|
||||
public AjaxResult enterpriseLogout(@RequestParam("clienttoken") String clienttoken) {
|
||||
String url = logoutUrl + "?clienttoken=" + clienttoken;
|
||||
HttpResponse execute = HttpUtil.createGet(url)
|
||||
.addHeaders(generationHeader())
|
||||
.execute();
|
||||
String str;
|
||||
// 获取响应状态码
|
||||
int statusCode = execute.getStatus();
|
||||
if (statusCode == 200) {
|
||||
str = "退出成功";
|
||||
} else {
|
||||
str = "退出失败";
|
||||
}
|
||||
return AjaxResult.success(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 正式环境需要的请求头
|
||||
*
|
||||
* @return 请求头
|
||||
*/
|
||||
private Map<String, String> generationHeader() {
|
||||
// 定义时间格式化器
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
||||
String format = LocalDateTime.now().format(formatter);
|
||||
//正式端需要请求头
|
||||
HashMap<String, String> headers = new HashMap<>();//存放请求头,可以存放多个请求头
|
||||
headers.put("appid", enterpriseAppId);
|
||||
headers.put("time", format);
|
||||
headers.put("sign", DigestUtil.md5Hex(enterpriseAppId + enterpriseAppsecret + format));
|
||||
return headers;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.ruoyi.gysl.login.dto.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 获取用户信息请求类
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/20 11:20
|
||||
*/
|
||||
@Data
|
||||
public class UserInfoRequestDTO {
|
||||
private String clientId;
|
||||
private String userToken;
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package com.ruoyi.gysl.login.dto.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 政务端用户
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/4 11:05
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("政务端用户")
|
||||
public class ChiefResponse {
|
||||
@ApiModelProperty("本系统token")
|
||||
private String token;
|
||||
|
||||
private String id;
|
||||
private String mainTopOrganizationId;
|
||||
private String isEnabled;
|
||||
private String isOfficial;
|
||||
private String isUseOA;
|
||||
private String name;
|
||||
private String familyName;
|
||||
private String givenName;
|
||||
private String accountName;
|
||||
private String email;
|
||||
private String mobile;
|
||||
private String sex;
|
||||
private String idNumber;
|
||||
private String birthday;
|
||||
private String workPhone;
|
||||
private String shortPhone;
|
||||
private String workAddress;
|
||||
private String state;
|
||||
private String description;
|
||||
// private String post;
|
||||
private String secondaryEmail;
|
||||
private String hasDomainAccount;
|
||||
private SettingsResponse settings;
|
||||
private List<OrganizationsResponse> organizations;
|
||||
private String whenCreated;
|
||||
private String whenUpdated;
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.ruoyi.gysl.login.dto.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* organizations其他响应类
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/4 14:42
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("organizations其他响应类")
|
||||
public class OrganizationsOtherResponse {
|
||||
|
||||
private String id;
|
||||
private String parentId;
|
||||
private String name;
|
||||
private String path;
|
||||
private String displayName;
|
||||
private String description;
|
||||
private String order;
|
||||
private String whenCreated;
|
||||
private String whenUpdated;
|
||||
private String type;
|
||||
private SettingsResponse settings;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.ruoyi.gysl.login.dto.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* organizations响应类
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/4 14:40
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("organizations响应类")
|
||||
public class OrganizationsResponse {
|
||||
private String userId;
|
||||
private String isPrimary;
|
||||
private String organizationId;
|
||||
private String userOrder;
|
||||
private String organizationOrder;
|
||||
private String user;
|
||||
private OrganizationsOtherResponse organization;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.ruoyi.gysl.login.dto.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* settings响应类
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/4 11:07
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("settings响应类")
|
||||
public class SettingsResponse {
|
||||
private String isContactsHidden;
|
||||
private String isContactsHiddenMobile;
|
||||
private String isContactsHiddenBirthday;
|
||||
private String isContactsHiddenWorkPhone;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package com.ruoyi.gysl.login.dto.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @since 2024/5/27 14:37
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("法人用户机构代码")
|
||||
public class UserMainResponse {
|
||||
|
||||
/**
|
||||
* 对应企业的组织机构代码
|
||||
*/
|
||||
@ApiModelProperty(value = "对应企业的组织机构代码")
|
||||
private String organcode;
|
||||
|
||||
|
||||
/**
|
||||
* 对应企业的统一社会信用代码
|
||||
*/
|
||||
@ApiModelProperty(value = "对应企业的统一社会信用代码")
|
||||
private String uscc;
|
||||
|
||||
|
||||
/**
|
||||
* 对应企业名称
|
||||
*/
|
||||
@ApiModelProperty(value = "对应企业名称")
|
||||
private String epname;
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.ruoyi.gysl.login.service;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @author du
|
||||
* @since 2025/5/9 下午2:24
|
||||
*/
|
||||
public interface LoginTokenService {
|
||||
|
||||
|
||||
/**
|
||||
* 返回token
|
||||
*/
|
||||
String singleLogin(String accountName, String name, String b, String mobile,String email);
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
package com.ruoyi.gysl.login.service;
|
||||
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.manager.AsyncManager;
|
||||
import com.ruoyi.framework.manager.factory.AsyncFactory;
|
||||
import com.ruoyi.framework.security.context.AuthenticationContextHolder;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 登录实现
|
||||
*
|
||||
* @author du
|
||||
* @since 2025/5/9 下午2:30
|
||||
*/
|
||||
@Service
|
||||
public class LoginTokenServiceImpl implements LoginTokenService {
|
||||
|
||||
@Resource
|
||||
private ISysUserService userService;
|
||||
|
||||
@Resource
|
||||
private AuthenticationManager authenticationManager;
|
||||
|
||||
@Resource
|
||||
private TokenService tokenService;
|
||||
|
||||
|
||||
@Override
|
||||
public String singleLogin(String accountName,
|
||||
String name,
|
||||
String type,
|
||||
String mobile,
|
||||
String email) {
|
||||
// 用户验证
|
||||
Authentication authentication;
|
||||
try {
|
||||
SysUser user = new SysUser();
|
||||
user.setUserName(accountName);
|
||||
user.setNickName(name);
|
||||
user.setPassword("Gysl@2025//**...");
|
||||
user.setPhonenumber(mobile);
|
||||
user.setEmail(email);
|
||||
Long[] roles = new Long[1];
|
||||
if ("01".equals(type)) {
|
||||
if("jjdntest".equals(accountName)||"yanyq".equals(accountName)){
|
||||
roles[0] = 101L;
|
||||
}else {
|
||||
roles[0] = 2L;
|
||||
}
|
||||
} else if ("02".equals(type)) {
|
||||
roles[0] = 100L;
|
||||
}
|
||||
user.setRoleIds(roles);
|
||||
user.setStatus("0");
|
||||
//如果用户名也就是信用代码没有重复的就新增用户
|
||||
if (userService.checkUserNameUnique(user)) {
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
userService.insertUser(user);
|
||||
}
|
||||
//新增user账号密码
|
||||
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(accountName, "Gysl@2025//**...");
|
||||
AuthenticationContextHolder.setContext(authenticationToken);
|
||||
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
||||
authentication = authenticationManager.authenticate(authenticationToken);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof BadCredentialsException) {
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(accountName, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
|
||||
throw new UserPasswordNotMatchException();
|
||||
} else {
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(accountName, Constants.LOGIN_FAIL, e.getMessage()));
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
} finally {
|
||||
AuthenticationContextHolder.clearContext();
|
||||
}
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(accountName, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
||||
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||
return tokenService.createToken(loginUser);
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package com.ruoyi.gysl.login.util;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 签名验证
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/20 10:15
|
||||
*/
|
||||
public class HMAC256Config {
|
||||
|
||||
/**
|
||||
* 加解密统一编码方式
|
||||
*/
|
||||
private final static String ENCODING = "utf-8";
|
||||
|
||||
/**
|
||||
* 加解密方式
|
||||
*/
|
||||
private final static String ALGORITHM = "AES";
|
||||
|
||||
/**
|
||||
* 加密模式及填充方式
|
||||
*/
|
||||
private final static String PATTERN = "AES/CBC/pkcs5padding";
|
||||
|
||||
//AES解密
|
||||
|
||||
/**
|
||||
* @param content 密文
|
||||
* @param key aes密钥
|
||||
* @return 原文
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String decrypt(String content, String key) throws Exception {
|
||||
|
||||
//反序列化AES密钥
|
||||
SecretKeySpec keySpec = new SecretKeySpec(Base64.decodeBase64(key.getBytes()), ALGORITHM);
|
||||
|
||||
//128bit全零的IV向量
|
||||
byte[] iv = new byte[16];
|
||||
for (int i = 0; i < iv.length; i++) {
|
||||
iv[i] = 0;
|
||||
}
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
|
||||
|
||||
//初始化加密器并加密
|
||||
Cipher deCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
deCipher.init(Cipher.DECRYPT_MODE, keySpec, ivParameterSpec);
|
||||
byte[] encryptedBytes = Base64.decodeBase64(content.getBytes(ENCODING));
|
||||
byte[] bytes = deCipher.doFinal(encryptedBytes);
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
public static byte[] HmacSHA256(String data, String key) throws Exception {
|
||||
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
|
||||
SecretKeySpec secret_key = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
|
||||
sha256_HMAC.init(secret_key);
|
||||
byte[] array = sha256_HMAC.doFinal(data.getBytes(StandardCharsets.UTF_8));
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,232 @@
|
||||
package com.ruoyi.gysl.utils;
|
||||
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.Image;
|
||||
import com.itextpdf.text.Paragraph;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import com.itextpdf.tool.xml.XMLWorkerFontProvider;
|
||||
import com.itextpdf.tool.xml.XMLWorkerHelper;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class HtmlToPdfConverter {
|
||||
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
|
||||
|
||||
public static MultipartFile convertHtmlToPdf(String htmlArticleTitle, String htmlContent) throws IOException {
|
||||
|
||||
String ht = content2Html(htmlContent);
|
||||
|
||||
|
||||
String path = System.getProperty("user.dir");
|
||||
// 根据日期建文件夹
|
||||
String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||
String[] split = format.split("-");
|
||||
Path dirPath = Paths.get(path, "temporary", split[0], split[1], split[2]);
|
||||
try {
|
||||
// clearTemporaryDirectory(Paths.get(path, "temporary")); // 清理目录
|
||||
Files.createDirectories(dirPath);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("创建文件夹失败: " + e.getMessage(), e);
|
||||
}
|
||||
File pdfFile = new File(dirPath.toFile(), "pdf-" + System.currentTimeMillis() + ".pdf");
|
||||
// 创建PDF文档
|
||||
Document document = new Document();
|
||||
|
||||
FileOutputStream fos = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
fos = new FileOutputStream(pdfFile);
|
||||
|
||||
PdfWriter writer = PdfWriter.getInstance(document, fos);
|
||||
XMLWorkerFontProvider fontProvider = new XMLWorkerFontProvider(XMLWorkerFontProvider.DONTLOOKFORFONTS);
|
||||
fontProvider.register("C:/Windows/Fonts/simsun.ttc");
|
||||
|
||||
document.open();
|
||||
// 添加标题
|
||||
Paragraph paragraph = new Paragraph(htmlArticleTitle); // 设置你自定义的字体格式
|
||||
document.add(paragraph);
|
||||
String updatedHtmlContent = "";
|
||||
if (htmlContent.contains("img")) {
|
||||
updatedHtmlContent = replaceImgSrcWithBase64(ht);
|
||||
|
||||
if (updatedHtmlContent != null) {
|
||||
is = new ByteArrayInputStream(updatedHtmlContent.getBytes(StandardCharsets.UTF_8));
|
||||
XMLWorkerHelper.getInstance().parseXHtml(writer, document, is, StandardCharsets.UTF_8, fontProvider);
|
||||
// 添加图片
|
||||
Elements imgElements = Jsoup.parse(updatedHtmlContent).select("img");
|
||||
for (Element img : imgElements) {
|
||||
String imgSrc = img.attr("src");
|
||||
if (imgSrc.startsWith("data:image/jpeg;base64,")) {
|
||||
String base64Data = imgSrc.substring("data:image/jpeg;base64,".length());
|
||||
byte[] imageBytes = Base64.getDecoder().decode(base64Data);
|
||||
Image image = Image.getInstance(imageBytes);
|
||||
document.add(image); // 添加图片到 PDF
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
is = new ByteArrayInputStream(ht.getBytes(StandardCharsets.UTF_8));
|
||||
XMLWorkerHelper.getInstance().parseXHtml(writer, document, is, StandardCharsets.UTF_8, fontProvider);
|
||||
|
||||
}
|
||||
|
||||
} catch (DocumentException | IOException e) {
|
||||
throw new RuntimeException("转换PDF失败: " + e.getMessage(), e);
|
||||
} finally {
|
||||
|
||||
if (document.isOpen()) {
|
||||
document.close(); // 确保Document关闭
|
||||
}
|
||||
if (fos != null) {
|
||||
try {
|
||||
fos.close(); // 关闭文件输出流
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close(); // 关闭输入流
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
MultipartFile multipartFile = getMultipartFile(pdfFile);
|
||||
// 在此处删除创建的 PDF 文件
|
||||
boolean deleted = pdfFile.delete();
|
||||
if (!deleted) {
|
||||
log.error("删除文件失败: " + pdfFile.getAbsolutePath());
|
||||
|
||||
}
|
||||
return multipartFile;
|
||||
}
|
||||
|
||||
private static MultipartFile getMultipartFile(File file) throws IOException {
|
||||
try (FileInputStream fileInputStream = new FileInputStream(file)) {
|
||||
return new MockMultipartFile(file.getName(), file.getName(), "application/pdf", fileInputStream);
|
||||
}
|
||||
}
|
||||
|
||||
public static String content2Html(String htmlContent) {
|
||||
String COMPLETE_CONTENT = "<html><head></head><body style=\"font-family: SimSun;\">" + htmlContent + "</body></html>";
|
||||
return COMPLETE_CONTENT.replace("<br>", "<br/>");
|
||||
}
|
||||
|
||||
|
||||
private static String replaceImgSrcWithBase64(String htmlContent) {
|
||||
List<String> imgSrcs = new ArrayList<>();
|
||||
String regex = "<img[^>]+src=\"([^\"]+)\"[^>]*>"; // 正确的正则表达式
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(htmlContent);
|
||||
String baseUrl = "http://39.101.188.84:7071";
|
||||
|
||||
// 使用 StringBuilder 来构建新的 HTML
|
||||
StringBuilder updatedHtml = new StringBuilder(htmlContent);
|
||||
|
||||
// 定义要替换的起始位置
|
||||
int offset = 0;
|
||||
|
||||
while (matcher.find()) {
|
||||
String imgSrc = matcher.group(1); // 捕获组返回 img src 的值
|
||||
String imgUrl = baseUrl + imgSrc;
|
||||
|
||||
// 将 URL 转化为 Base64
|
||||
try {
|
||||
URL url = new URL(imgUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0"); // 添加 User-Agent
|
||||
connection.setDoInput(true);
|
||||
connection.connect();
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
inputStream.close();
|
||||
byte[] imageBytes = outputStream.toByteArray();
|
||||
String base64 = Base64.getEncoder().encodeToString(imageBytes);
|
||||
|
||||
// 替换 img 标签的 src 属性为 Base64 数据
|
||||
String base64ImgTag = "<img src=\"data:image/jpeg;base64," + base64 + "\" />";
|
||||
int start = matcher.start() + offset; // 累计偏移量
|
||||
int end = matcher.end();
|
||||
|
||||
// 替换原来的 img 标签
|
||||
updatedHtml.replace(start, end, base64ImgTag);
|
||||
//System.out.println(updatedHtml.toString());
|
||||
// 更新偏移量
|
||||
offset += base64ImgTag.length() - (end - start);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null; // 处理异常或返回特定的错误值
|
||||
}
|
||||
}
|
||||
return updatedHtml.toString();
|
||||
}
|
||||
|
||||
public String convertImageToBase64(String imgUrl) {
|
||||
try {
|
||||
// String encodedImgUrl = URLEncoder.encode(imgUrl, StandardCharsets.UTF_8.toString());
|
||||
|
||||
URL url = new URL(imgUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0"); // 添加 User-Agent
|
||||
connection.setDoInput(true);
|
||||
connection.connect();
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
inputStream.close();
|
||||
|
||||
byte[] imageBytes = outputStream.toByteArray();
|
||||
String base64 = Base64.getEncoder().encodeToString(imageBytes);
|
||||
return "data:image/jpeg;base64," + base64; // 根据实际情况修改 MIME 类型
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null; // 处理异常或返回特定的错误值
|
||||
}
|
||||
}
|
||||
private static void clearTemporaryDirectory(Path directory) {
|
||||
File dir = directory.toFile();
|
||||
if (dir.exists() && dir.isDirectory()) {
|
||||
for (File file : dir.listFiles()) {
|
||||
if (!file.isDirectory()) {
|
||||
file.delete(); // 删除文件
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.ruoyi.gysl.utils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
public class ImgBase64Extractor {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
String imgUrl ="http://39.101.188.84:7071/profile/upload/2025/03/24/abc_20250324154129A006.jpg";
|
||||
|
||||
URL url = new URL(imgUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoInput(true);
|
||||
// 添加请求头
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
connection.setRequestProperty("Accept", "image/webp,image/apng,image/*,*/*;q=0.8");
|
||||
connection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
|
||||
|
||||
// 连接并获取响应
|
||||
connection.connect();
|
||||
|
||||
// 检查响应码
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
// 连接成功,获取输入流
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
|
||||
// 读取输入流
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
byte[] imageBytes = outputStream.toByteArray();
|
||||
System.out.println(imageBytes);
|
||||
} else {
|
||||
System.out.println("Error: Server returned HTTP response code: " + responseCode);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,15 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.docking.mapper.ProjectMapper">
|
||||
<update id="editProject" parameterType="BasicInformation">
|
||||
update gysl_basic_information set project_id = #{req.projectId}
|
||||
where id = #{req.id}
|
||||
</update>
|
||||
<select id="page" resultType="com.ruoyi.docking.entity.Project">
|
||||
SELECT
|
||||
b.*
|
||||
FROM project b
|
||||
where b.project_name like concat('%',#{name},'%')
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue