|
@@ -10,13 +10,17 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.qmrb.system.adatper.CaSignAdatper;
|
|
|
import com.qmrb.system.adatper.EmrAdatper;
|
|
|
import com.qmrb.system.common.constant.DeptNameMapping;
|
|
|
+import com.qmrb.system.common.constant.SecurityConstants;
|
|
|
import com.qmrb.system.common.constant.SystemConstants;
|
|
|
import com.qmrb.system.common.proc.CommonJDBCTemplate;
|
|
|
import com.qmrb.system.common.proc.CommonTemplate;
|
|
|
import com.qmrb.system.common.result.Result;
|
|
|
import com.qmrb.system.common.util.AesUtils;
|
|
|
import com.qmrb.system.framework.security.CaConstants;
|
|
|
+import com.qmrb.system.framework.security.JwtTokenManager;
|
|
|
+import com.qmrb.system.framework.security.userdetails.SysUserDetails;
|
|
|
import com.qmrb.system.framework.security.util.SecurityUtils;
|
|
|
+import com.qmrb.system.pojo.bo.UserAuthInfo;
|
|
|
import com.qmrb.system.pojo.dto.CaSignFileDTO;
|
|
|
import com.qmrb.system.pojo.dto.CallBackResponse;
|
|
|
import com.qmrb.system.pojo.dto.SoapReturnDTO;
|
|
@@ -43,6 +47,7 @@ import okhttp3.Request;
|
|
|
import org.apache.axis.client.Call;
|
|
|
import org.apache.axis.client.Service;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.commons.lang3.SystemUtils;
|
|
|
import org.springdoc.core.annotations.ParameterObject;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -54,6 +59,9 @@ import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
|
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
|
+import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
@@ -116,6 +124,17 @@ public class CaSignController {
|
|
|
|
|
|
@Autowired
|
|
|
private RedisTemplate redisTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IContractService contractService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private JwtTokenManager jwtTokenManager;
|
|
|
+ /**
|
|
|
+ * token有效期(单位:秒)
|
|
|
+ */
|
|
|
+ @Value("${auth.token.overDue}")
|
|
|
+ private Long overDue;
|
|
|
|
|
|
@Autowired
|
|
|
private SysUserService userService;
|
|
@@ -2348,6 +2367,81 @@ public class CaSignController {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取优惠券的二维码
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("getCouponQrcode")
|
|
|
+ public Result<?> getCouponQrcode(){
|
|
|
+ // public ResponseEntity<byte []> getCouponQrcode(){
|
|
|
+ if(SecurityUtils.getUserId() == null){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ SysUser user = userService.getById(SecurityUtils.getUserId());
|
|
|
+ // 获取到协议的二维码登录地址
|
|
|
+ Contract contract = contractService.getById(user.getContractId());
|
|
|
+ if(contract == null){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+// String signUrl = "";
|
|
|
+ try {
|
|
|
+// String token = OkHttpUtils.getTokenNew();
|
|
|
+// signUrl = CaConstants.qrCodeDomain + "/goto.html?cardId=" + social_no + "&access_token=" + token;
|
|
|
+// log.info(signUrl);
|
|
|
+// String signUrl = (String)redisTemplate.opsForValue().get(deviceNo);
|
|
|
+
|
|
|
+ // 生成token
|
|
|
+ List<SimpleGrantedAuthority> roleList = userService.getUserAuthInfo(contract.getUsername()).getRoles()
|
|
|
+ .stream().map(role -> new SimpleGrantedAuthority("ROLE_" + role)).toList();
|
|
|
+ UsernamePasswordAuthenticationToken authenticationToken =
|
|
|
+ new UsernamePasswordAuthenticationToken(contract.getUsername(), contract.getPassword(),
|
|
|
+ roleList);
|
|
|
+ UserAuthInfo userAuthInfo = userService.getUserAuthInfo(contract.getUsername());
|
|
|
+ SysUserDetails sysUserDetails = new SysUserDetails(userAuthInfo);
|
|
|
+ authenticationToken.setDetails(sysUserDetails);
|
|
|
+ SecurityContextHolder.getContext().setAuthentication(authenticationToken);
|
|
|
+ String accessToken = jwtTokenManager.createToken(authenticationToken);
|
|
|
+ // 保存token至redis中
|
|
|
+ String tokenId = SecurityConstants.CONTRACT_TOKEN_CACHE_PREFIX + user.getId() + UUID.randomUUID();
|
|
|
+ redisTemplate.opsForValue().set(tokenId,accessToken,overDue,TimeUnit.SECONDS);
|
|
|
+ String url = contract.getQrcodeLoginUrl() + "?tokenId=" + tokenId;
|
|
|
+ // byte[] imageBytes = QRCodeUtil.createQrCodeToByte(url);
|
|
|
+ String base64 = QRCodeUtil.createCodeToOutputStream(url);
|
|
|
+ // HttpHeaders headers = new HttpHeaders();
|
|
|
+ // headers.setContentType(MediaType.IMAGE_JPEG);
|
|
|
+ // headers.setContentLength(imageBytes.length);
|
|
|
+ // map.put("data",imageBytes);
|
|
|
+ map.put("data",base64);
|
|
|
+ map.put("contractName",contract.getContractName());
|
|
|
+
|
|
|
+ // return new ResponseEntity<>(imageBytes, headers, HttpStatus.OK);
|
|
|
+ return Result.success(map);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取优惠券的二维码
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("getTokenByTokenId")
|
|
|
+ public Result<?> getTokenByTokenId(@RequestParam String tokenId){
|
|
|
+
|
|
|
+ // 保存token至redis中
|
|
|
+ Object token = redisTemplate.opsForValue().get(tokenId);
|
|
|
+ if(token == null){
|
|
|
+ return Result.failed("已过期,请刷新后重新扫码。");
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.success((String) token);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 影像检查报告查询-医联康护
|