Merge remote-tracking branch 'origin/dev_1.0.1' into dev_1.0.1

v0.0.1-final^2
huwei 2026-07-20 11:03:07 +08:00
commit a1c58b525f
6 changed files with 133 additions and 9 deletions

View File

@ -1,14 +1,24 @@
package org.qinan.safetyeval.adapter.web; package org.qinan.safetyeval.adapter.web;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.jjb.saas.framework.auth.model.SSOUser;
import com.jjb.saas.framework.utils.JwtTokenUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.dromara.x.file.storage.core.FileInfo;
import org.dromara.x.file.storage.core.FileStorageService;
import org.qinan.safetyeval.infrastructure.mapper.AccountMapper; import org.qinan.safetyeval.infrastructure.mapper.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RestController; import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
/** /**
* *
@ -19,26 +29,94 @@ import org.springframework.web.bind.annotation.RestController;
@Api(tags = "对外开放接口") @Api(tags = "对外开放接口")
@RestController @RestController
@RequestMapping("/safetyEval-h5/wsp") @RequestMapping("/safetyEval-h5/wsp")
@Slf4j
public class H5OpenController { public class H5OpenController {
@Autowired @Autowired
private AccountMapper accountMapper; private AccountMapper accountMapper;
@Autowired
private FileStorageService fileStorageService;
@ApiOperation("wps回调预览") @ApiOperation("wps回调预览")
@GetMapping(value = "/v3/3rd/files/{file_id}", produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(value = "/v3/3rd/files/{file_id}", produces = MediaType.APPLICATION_JSON_VALUE)
public String getWpsInfoByFileId(@PathVariable("file_id") String fileId) { public String getWpsInfoByFileId(@PathVariable("file_id") String file_id, HttpServletRequest request) {
log.info("token, {}", request.getHeader("token"));
log.info("Token, {}", request.getHeader("Token"));
String header = request.getHeader("X-Weboffice-Token");
log.info("X-Weboffice-Token, {}", request.getHeader("X-Weboffice-Token"));
String token = header;
log.info("2.5token不为空:{}", token);
token = token.replaceAll("jjb-saas-auth:oauth:", "").trim();
String json = null;
SSOUser ssoUser;
try {
json = JwtTokenUtils.parseToken(token);
} catch (Exception var41) {
}
if (null != json) {
ssoUser = (SSOUser) JSONUtil.toBean(json, SSOUser.class);
} else {
ssoUser = new SSOUser();
}
log.info("ssoUser:{}", ssoUser);
log.info("wps回调预览{}", file_id);
return accountMapper.getWps(1); return accountMapper.getWps(1);
} }
@ApiOperation("wps回调下载") @ApiOperation("wps回调下载")
@GetMapping(value = "/v3/3rd/files/{file_id}/download", produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(value = "/v3/3rd/files/{file_id}/download", produces = MediaType.APPLICATION_JSON_VALUE)
public String getWpsDownloadByFileId(@PathVariable("file_id") String fileId) { public String getWpsDownloadByFileId(@PathVariable("file_id") String file_id) {
log.info("wps回调下载{}", file_id);
return accountMapper.getWps(2); return accountMapper.getWps(2);
} }
@ApiOperation("wps回调用户信息") @ApiOperation("wps回调权限信息")
@GetMapping(value = "/v3/3rd/files/{file_id}/permission", produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(value = "/v3/3rd/files/{file_id}/permission", produces = MediaType.APPLICATION_JSON_VALUE)
public String getWpsPermissionByFileId(@PathVariable("file_id") String fileId) { public String getWpsPermissionByFileId(@PathVariable("file_id") String file_id) {
log.info("wps回调权限信息{}", file_id);
return accountMapper.getWps(3); return accountMapper.getWps(3);
} }
@ApiOperation("wps回调用户信息")
@GetMapping(value = "/v3/3rd/users", produces = MediaType.APPLICATION_JSON_VALUE)
public String getWpsUsers(@RequestParam List<Long> user_ids) {
log.info("wps回调用户信息{}", user_ids);
return accountMapper.getWps(4);
}
@ApiOperation("wps回调上传第一步")
@GetMapping(value = "/v3/3rd/files/{file_id}/upload/prepare", produces = MediaType.APPLICATION_JSON_VALUE)
public String getWpsUpLoadOne(@PathVariable("file_id") String file_id) {
log.info("wps回调上传第一步{}", file_id);
return accountMapper.getWps(5);
}
@ApiOperation("wps回调上传第二步")
@PostMapping(value = "/v3/3rd/files/{file_id}/upload/address")
public String getWpsUpLoadTwo(@PathVariable("file_id") String file_id, @RequestBody Map<String, Object> map) {
log.info("wps回调上传第二步{}, map: {}", file_id, JSON.toJSONString(map));
return accountMapper.getWps(6);
}
@ApiOperation("wps回调上传第三步")
@PostMapping(value = "/v3/3rd/files/{file_id}/upload/complete")
public String getWpsUpLoadThree(@PathVariable("file_id") String file_id, @RequestBody Map<String, Object> map) {
String msg = accountMapper.getWps(7);
log.info("wps回调上传第三步{}, map: {}", file_id, msg);
return msg;
}
@PutMapping(value = "/upload/{file_id}", consumes = "application/octet-stream")
public String uploadFile(@PathVariable("file_id") String file_id, HttpServletRequest request) throws IOException {
// 获取文件的二进制流
try (InputStream inputStream = request.getInputStream()) {
FileInfo upload = fileStorageService.of(inputStream, file_id).upload();
log.info("上传文件成功:{}", JSON.toJSONString(upload));
return "ok";
} catch (Exception e) {
log.error("上传文件失败:{}", e.getMessage());
return "上传文件失败";
}
}
} }

View File

@ -13,6 +13,8 @@ import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.OrgEquipmentDomainService; import org.qinan.safetyeval.domain.service.OrgEquipmentDomainService;
import org.qinan.safetyeval.infrastructure.adapter.ThreadLocalUserInfoAdapter; import org.qinan.safetyeval.infrastructure.adapter.ThreadLocalUserInfoAdapter;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter; import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.qinan.safetyeval.infrastructure.persistence.domainobject.OrgBusinessScopeDeviceRefDO;
import org.qinan.safetyeval.infrastructure.persistence.queryservice.OrgBusinessScopeDeviceRefQueryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -29,6 +31,10 @@ public class OrgEquipmentExecutor implements OrgEquipmentApi {
@Autowired(required = false) @Autowired(required = false)
private OrgEquipmentDomainService orgEquipmentDomainService; private OrgEquipmentDomainService orgEquipmentDomainService;
@Lazy
@Autowired(required = false)
private OrgBusinessScopeDeviceRefQueryService orgBusinessScopeDeviceRefQueryService;
@Override @Override
public SingleResponse<OrgEquipmentCO> add(OrgEquipmentAddCmd cmd) { public SingleResponse<OrgEquipmentCO> add(OrgEquipmentAddCmd cmd) {
OrgEquipmentEntity entity = new OrgEquipmentEntity(); OrgEquipmentEntity entity = new OrgEquipmentEntity();
@ -56,7 +62,14 @@ public class OrgEquipmentExecutor implements OrgEquipmentApi {
@Override @Override
public SingleResponse<OrgEquipmentCO> get(Long id) { public SingleResponse<OrgEquipmentCO> get(Long id) {
OrgEquipmentEntity entity = orgEquipmentDomainService.get(id); OrgEquipmentEntity entity = orgEquipmentDomainService.get(id);
return SingleResponse.success(toCO(entity)); OrgEquipmentCO co = toCO(entity);
if (co != null && co.getDeviceTypeCode() != null) {
OrgBusinessScopeDeviceRefDO refDO = orgBusinessScopeDeviceRefQueryService.getByDeviceTypeCode(co.getDeviceTypeCode());
if (refDO != null) {
co.setDeviceTypeName(refDO.getDeviceTypeName());
}
}
return SingleResponse.success(co);
} }
@Override @Override

View File

@ -21,6 +21,14 @@ public interface OrgBusinessScopeDeviceRefQueryService {
*/ */
OrgBusinessScopeDeviceRefDO getById(Long id); OrgBusinessScopeDeviceRefDO getById(Long id);
/**
*
*
* @param deviceTypeCode
* @return
*/
OrgBusinessScopeDeviceRefDO getByDeviceTypeCode(String deviceTypeCode);
/** /**
* *
* *

View File

@ -32,6 +32,11 @@ public class OrgBusinessScopeDeviceRefQueryServiceImpl implements OrgBusinessSco
return orgBusinessScopeDeviceRefRepository.getById(id); return orgBusinessScopeDeviceRefRepository.getById(id);
} }
@Override
public OrgBusinessScopeDeviceRefDO getByDeviceTypeCode(String deviceTypeCode) {
return orgBusinessScopeDeviceRefRepository.getByDeviceTypeCode(deviceTypeCode);
}
@Override @Override
public PageResponse<OrgBusinessScopeDeviceRefCo> listOrgBusinessScopeDeviceRefPage(OrgBusinessScopeDeviceRefPageQry orgBusinessScopeDeviceRefPageQry) { public PageResponse<OrgBusinessScopeDeviceRefCo> listOrgBusinessScopeDeviceRefPage(OrgBusinessScopeDeviceRefPageQry orgBusinessScopeDeviceRefPageQry) {
IPage<OrgBusinessScopeDeviceRefDO> orgBusinessScopeDeviceRefDoPage = orgBusinessScopeDeviceRefRepository.listOrgBusinessScopeDeviceRefPage(PageHelper.queryToPage(orgBusinessScopeDeviceRefPageQry), orgBusinessScopeDeviceRefPageQry); IPage<OrgBusinessScopeDeviceRefDO> orgBusinessScopeDeviceRefDoPage = orgBusinessScopeDeviceRefRepository.listOrgBusinessScopeDeviceRefPage(PageHelper.queryToPage(orgBusinessScopeDeviceRefPageQry), orgBusinessScopeDeviceRefPageQry);

View File

@ -20,6 +20,14 @@ public interface OrgBusinessScopeDeviceRefRepository extends BaseRepository<OrgB
*/ */
OrgBusinessScopeDeviceRefDO getById(Long id); OrgBusinessScopeDeviceRefDO getById(Long id);
/**
*
*
* @param deviceTypeCode
* @return
*/
OrgBusinessScopeDeviceRefDO getByDeviceTypeCode(String deviceTypeCode);
/** /**
* *
* *

View File

@ -7,6 +7,7 @@ import com.jjb.saas.framework.enums.enums.BooleanEnum;
import com.jjb.saas.framework.repository.repo.impl.BaseRepositoryImpl; import com.jjb.saas.framework.repository.repo.impl.BaseRepositoryImpl;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.qinan.safetyeval.client.ref.request.OrgBusinessScopeDeviceRefPageQry; import org.qinan.safetyeval.client.ref.request.OrgBusinessScopeDeviceRefPageQry;
import org.qinan.safetyeval.domain.constant.BooleanQAEnum;
import org.qinan.safetyeval.infrastructure.persistence.domainobject.OrgBusinessScopeDeviceRefDO; import org.qinan.safetyeval.infrastructure.persistence.domainobject.OrgBusinessScopeDeviceRefDO;
import org.qinan.safetyeval.infrastructure.persistence.mapper.OrgBusinessScopeDeviceRefMapper; import org.qinan.safetyeval.infrastructure.persistence.mapper.OrgBusinessScopeDeviceRefMapper;
import org.qinan.safetyeval.infrastructure.persistence.repository.OrgBusinessScopeDeviceRefRepository; import org.qinan.safetyeval.infrastructure.persistence.repository.OrgBusinessScopeDeviceRefRepository;
@ -31,6 +32,17 @@ public class OrgBusinessScopeDeviceRefRepositoryImpl extends BaseRepositoryImpl<
return super.lambdaQuery().eq(OrgBusinessScopeDeviceRefDO::getId, id).eq(OrgBusinessScopeDeviceRefDO::getDeleteEnum, BooleanEnum.FALSE.getValue()).one(); return super.lambdaQuery().eq(OrgBusinessScopeDeviceRefDO::getId, id).eq(OrgBusinessScopeDeviceRefDO::getDeleteEnum, BooleanEnum.FALSE.getValue()).one();
} }
@Override
public OrgBusinessScopeDeviceRefDO getByDeviceTypeCode(String deviceTypeCode) {
return super.lambdaQuery()
.select(OrgBusinessScopeDeviceRefDO::getDeviceTypeCode, OrgBusinessScopeDeviceRefDO::getId
, OrgBusinessScopeDeviceRefDO::getIndustryCode,OrgBusinessScopeDeviceRefDO::getDeviceTypeName)
.eq(OrgBusinessScopeDeviceRefDO::getDeviceTypeCode, deviceTypeCode)
.eq(OrgBusinessScopeDeviceRefDO::getDeleteEnum, BooleanQAEnum.FALSE.getValue())
.last("LIMIT 1")
.one();
}
@Override @Override
public IPage<OrgBusinessScopeDeviceRefDO> listOrgBusinessScopeDeviceRefPage(IPage iPage, OrgBusinessScopeDeviceRefPageQry orgBusinessScopeDeviceRefPageQry) { public IPage<OrgBusinessScopeDeviceRefDO> listOrgBusinessScopeDeviceRefPage(IPage iPage, OrgBusinessScopeDeviceRefPageQry orgBusinessScopeDeviceRefPageQry) {
QueryWrapper<OrgBusinessScopeDeviceRefDO> orgBusinessScopeDeviceRefDoQueryWrapper = new QueryWrapper<>(); QueryWrapper<OrgBusinessScopeDeviceRefDO> orgBusinessScopeDeviceRefDoQueryWrapper = new QueryWrapper<>();