TASK:AiDA
This commit is contained in:
@@ -311,17 +311,27 @@ public class AccountController {
|
|||||||
return Response.success(accountService.getAccountDetail());
|
return Response.success(accountService.getAccountDetail());
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin
|
|
||||||
@GetMapping("/bindGoogle")
|
@GetMapping("/bindGoogle")
|
||||||
@ApiOperation(value = "绑定谷歌")
|
@ApiOperation(value = "绑定谷歌")
|
||||||
public Response<Boolean> bindGoogle(@RequestParam("credential") String credential) {
|
public Response<Boolean> bindGoogle(@RequestParam("credential") String credential) {
|
||||||
return Response.success(accountService.bindGoogle(credential));
|
return Response.success(accountService.bindGoogle(credential));
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin
|
|
||||||
@GetMapping("/bindWeChat")
|
@GetMapping("/bindWeChat")
|
||||||
@ApiOperation(value = "绑定微信")
|
@ApiOperation(value = "绑定微信")
|
||||||
public Response<Boolean> bindWeChat(@RequestParam("code") String code) {
|
public Response<Boolean> bindWeChat(@RequestParam("code") String code) {
|
||||||
return Response.success(accountService.bindWeChat(code));
|
return Response.success(accountService.bindWeChat(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/unbindWeChat")
|
||||||
|
@ApiOperation(value = "解除绑定微信")
|
||||||
|
public Response<Boolean> unbindWeChat() {
|
||||||
|
return Response.success(accountService.unbindWeChat());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/unbindGoogle")
|
||||||
|
@ApiOperation(value = "解除绑定谷歌")
|
||||||
|
public Response<Boolean> unbindGoogle() {
|
||||||
|
return Response.success(accountService.unbindGoogle());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,4 +44,6 @@ public class AccountLoginVO {
|
|||||||
|
|
||||||
private List<AccountExtend> accountExtendList;
|
private List<AccountExtend> accountExtendList;
|
||||||
|
|
||||||
|
private String Language;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3671,4 +3671,58 @@ public class PythonService {
|
|||||||
//生成失败
|
//生成失败
|
||||||
throw new BusinessException("Atribute recognition exception!");
|
throw new BusinessException("Atribute recognition exception!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JSONObject designBatch(DesignPythonObjects designPythonObjects) {
|
||||||
|
// todo 限流校验
|
||||||
|
// AccessLimitUtils.validate("design",5);
|
||||||
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
|
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||||
|
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
|
||||||
|
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
||||||
|
.build();
|
||||||
|
MediaType mediaType = MediaType.parse("application/json");
|
||||||
|
//关闭FastJson的引用检测 防止出现$ref 现象
|
||||||
|
|
||||||
|
String param = JSON.toJSONString(designPythonObjects, SerializerFeature.DisableCircularReferenceDetect);
|
||||||
|
log.info("design请求python 参数:####{}", param);
|
||||||
|
RequestBody body = RequestBody.create(mediaType, param);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(accessPythonIp + ":" + accessPythonPort + "/api/design_batch_generate")
|
||||||
|
// .url(fastApiPythonAddress + "/api/design")
|
||||||
|
// .url(accessPythonIp + ":10200/aifda/api/v1.0/generate")
|
||||||
|
.method("POST", body)
|
||||||
|
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||||
|
.addHeader("Content-Type", "application/json")
|
||||||
|
.build();
|
||||||
|
Response response;
|
||||||
|
String responseBody;
|
||||||
|
try {
|
||||||
|
response = client.newCall(request).execute();
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
AccessLimitUtils.validateOut("design");
|
||||||
|
log.error("PythonService##design异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||||
|
throw new BusinessException("design.interface.exception");
|
||||||
|
}
|
||||||
|
|
||||||
|
//去除限流
|
||||||
|
// AccessLimitUtils.validateOut("design");
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
try {
|
||||||
|
if (Objects.nonNull(response.body())) {
|
||||||
|
responseBody = response.body().string();
|
||||||
|
JSONObject responseObject = JSON.parseObject(responseBody);
|
||||||
|
log.info("PythonService##responseObject###{}", responseObject);
|
||||||
|
return responseObject;
|
||||||
|
}
|
||||||
|
throw new BusinessException("design.interface.exception");
|
||||||
|
} catch (IOException | JSONException e) {
|
||||||
|
log.error("PythonService##design异常###{}", e.getMessage());
|
||||||
|
throw new BusinessException("design.interface.exception");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.error("PythonService##design异常response###{}", response);
|
||||||
|
//生成失败
|
||||||
|
throw new BusinessException("design.interface.exception");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,4 +212,8 @@ public interface AccountService extends IService<Account> {
|
|||||||
Boolean bindGoogle(String credential);
|
Boolean bindGoogle(String credential);
|
||||||
|
|
||||||
Boolean bindWeChat(String code);
|
Boolean bindWeChat(String code);
|
||||||
|
|
||||||
|
Boolean unbindWeChat();
|
||||||
|
|
||||||
|
Boolean unbindGoogle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2185,12 +2185,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
log.info(name);
|
log.info(name);
|
||||||
|
|
||||||
// 检查数据库中是否已有该用户
|
// 检查数据库中是否已有该用户
|
||||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<AccountExtend> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.lambda().eq(Account::getUserEmail, email); // 根据邮箱查询用户
|
queryWrapper.lambda().eq(AccountExtend::getAuth, userId); // 根据邮箱查询用户
|
||||||
List<Account> accounts = accountMapper.selectList(queryWrapper);
|
List<AccountExtend> accountExtends = accountExtendMapper.selectList(queryWrapper);
|
||||||
Account account = new Account();
|
Account account = new Account();
|
||||||
if (CollectionUtil.isNotEmpty(accounts)) {
|
if (CollectionUtil.isNotEmpty(accountExtends)) {
|
||||||
account = accounts.get(0);
|
Long accountId = accountExtends.get(0).getAccountId();
|
||||||
|
account = accountMapper.selectById(accountId);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
AccountExtend accountExtendInsert = new AccountExtend();
|
AccountExtend accountExtendInsert = new AccountExtend();
|
||||||
@@ -2416,7 +2417,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
if (CollectionUtil.isNotEmpty(accountExtends)) {
|
if (CollectionUtil.isNotEmpty(accountExtends)) {
|
||||||
response.setAccountExtendList(accountExtends);
|
response.setAccountExtendList(accountExtends);
|
||||||
}
|
}
|
||||||
|
response.setLanguage(Language.valueOf(account.getLanguage()).name());
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2499,4 +2500,24 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean unbindWeChat() {
|
||||||
|
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||||
|
QueryWrapper<AccountExtend> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(AccountExtend::getAccountId, authPrincipalVo.getId());
|
||||||
|
qw.lambda().eq(AccountExtend::getAuthType, "WeChat");
|
||||||
|
accountExtendMapper.delete(qw);
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean unbindGoogle() {
|
||||||
|
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||||
|
QueryWrapper<AccountExtend> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(AccountExtend::getAccountId, authPrincipalVo.getId());
|
||||||
|
qw.lambda().eq(AccountExtend::getAuthType, "Google");
|
||||||
|
accountExtendMapper.delete(qw);
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -303,14 +303,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPostion());
|
collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPostion());
|
||||||
}else {
|
}else {
|
||||||
collectionId = collectionIdParam;
|
collectionId = collectionIdParam;
|
||||||
// Collection byId = collectionService.getById(collectionIdParam);
|
|
||||||
// if (!designDTO.getMoodboardPostion().equals(byId.getMoodboardPosition())) {
|
|
||||||
// byId.setMoodboardPosition(designDTO.getMoodboardPostion());
|
|
||||||
// }
|
|
||||||
// if (!designDTO.getMoodTemplateId().equals(byId.getMoodTemplateId())) {
|
|
||||||
// byId.setMoodTemplateId(designDTO.getMoodTemplateId());
|
|
||||||
// }
|
|
||||||
// collectionService.updateById(byId);
|
|
||||||
}
|
}
|
||||||
List<Long> elementIds = getElementId(elementVO);
|
List<Long> elementIds = getElementId(elementVO);
|
||||||
//批量关联element 到 collection
|
//批量关联element 到 collection
|
||||||
@@ -1566,7 +1558,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
String requestId = responseJSONObject.getString("requestId");
|
String requestId = responseJSONObject.getString("requestId");
|
||||||
Map<String, Object> context;
|
Map<String, Object> context;
|
||||||
synchronized (designContext) {
|
synchronized (designContext) {
|
||||||
log.info(designContext.toString());
|
|
||||||
context = designContext.get(requestId);
|
context = designContext.get(requestId);
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
log.error("上下文数据缺失,无法完成操作");
|
log.error("上下文数据缺失,无法完成操作");
|
||||||
@@ -1614,7 +1605,94 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
//校验collection element
|
//校验collection element
|
||||||
ValidateElementVO elementVO = collectionElementService.validateElement(designDTO);
|
ValidateElementVO elementVO = collectionElementService.validateElement(designDTO);
|
||||||
//design
|
//design
|
||||||
return designOrRedesignOperateNew(designDTO, userInfo, null, elementVO);
|
return designBatch(designDTO, userInfo, null, elementVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String designBatch(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo, Long collectionIdParam, ValidateElementVO elementVO) {
|
||||||
|
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
||||||
|
//编辑sketchBoard
|
||||||
|
collectionElementService.editSketchBoardsElement(elementVO, designDTO.getSketchBoards());
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(designDTO.getPrintBoards())) {
|
||||||
|
//编辑printBoard
|
||||||
|
collectionElementService.editPrintBoardsElement(elementVO, designDTO.getPrintBoards());
|
||||||
|
}
|
||||||
|
//保存collection
|
||||||
|
Long collectionId;
|
||||||
|
if (null == collectionIdParam) {
|
||||||
|
collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPostion());
|
||||||
|
}else {
|
||||||
|
collectionId = collectionIdParam;
|
||||||
|
// Collection byId = collectionService.getById(collectionIdParam);
|
||||||
|
// if (!designDTO.getMoodboardPostion().equals(byId.getMoodboardPosition())) {
|
||||||
|
// byId.setMoodboardPosition(designDTO.getMoodboardPostion());
|
||||||
|
// }
|
||||||
|
// if (!designDTO.getMoodTemplateId().equals(byId.getMoodTemplateId())) {
|
||||||
|
// byId.setMoodTemplateId(designDTO.getMoodTemplateId());
|
||||||
|
// }
|
||||||
|
// collectionService.updateById(byId);
|
||||||
|
}
|
||||||
|
List<Long> elementIds = getElementId(elementVO);
|
||||||
|
//批量关联element 到 collection
|
||||||
|
collectionElementService.relationCollection(elementIds, collectionId);
|
||||||
|
//library转化为collection(生成)
|
||||||
|
saveCollectionElemntsByLibrarys(elementVO, collectionId);
|
||||||
|
//generate转化为collection(生成)
|
||||||
|
saveCollectionElemntsByGenerates(elementVO, collectionId);
|
||||||
|
//保存颜色版
|
||||||
|
collectionElementService.saveColorBoard(designDTO.getColorBoards(), collectionId, designDTO.getTimeZone());
|
||||||
|
//保存design
|
||||||
|
Long designId = saveOne(designDTO, collectionId, userInfo.getId());
|
||||||
|
//计算library
|
||||||
|
// calculateLibraryAndSysFile(designDTO, elementVO, userInfo);
|
||||||
|
//组装design入参
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
|
||||||
|
designDTO.getSingleOverall(), designDTO.getSwitchCategory(), elementVO, designDTO.getProcessId());
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
long totalTimeInSeconds = (endTime - startTime) / 1000;
|
||||||
|
log.info("组装入参运行时间:" + totalTimeInSeconds + " 秒");
|
||||||
|
// pythonObjects增加image_id关联
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
|
List<Long> imageIds = relationImageIds(pythonObjects);
|
||||||
|
endTime = System.currentTimeMillis();
|
||||||
|
totalTimeInSeconds = (endTime - startTime) / 1000;
|
||||||
|
log.info("增加image_id关联运行时间:" + totalTimeInSeconds + " 秒");
|
||||||
|
//design
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
|
String requestId = UUID.randomUUID().toString();
|
||||||
|
pythonObjects.setRequestId(requestId);
|
||||||
|
JSONObject responseJSONObject = pythonService.designBatch(pythonObjects);
|
||||||
|
endTime = System.currentTimeMillis();
|
||||||
|
totalTimeInSeconds = (endTime - startTime) / 1000;
|
||||||
|
log.info("design python端运行时间:" + totalTimeInSeconds + " 秒");
|
||||||
|
//生成library
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
|
generateLibrary(elementVO, designDTO.getTimeZone());
|
||||||
|
//处理关联关系,修复element覆盖得情况
|
||||||
|
List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
|
||||||
|
List<Long> relationElementIds = relationElements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
||||||
|
handleCollectionElementRelation(collectionId, null != collectionIdParam, relationElementIds);
|
||||||
|
endTime = System.currentTimeMillis();
|
||||||
|
totalTimeInSeconds = (endTime - startTime) / 1000;
|
||||||
|
log.info("处理关联关系运行时间:" + totalTimeInSeconds + " 秒");
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, Object> context = new HashMap<>();
|
||||||
|
context.put("pythonObjects", pythonObjects); // 转换后的 Python 请求参数
|
||||||
|
context.put("designId", designId); // 设计 ID
|
||||||
|
context.put("collectionId", collectionId); // 集合 ID
|
||||||
|
context.put("userInfo", userInfo); // 用户信息
|
||||||
|
context.put("timeZone", designDTO.getTimeZone()); // 时区
|
||||||
|
context.put("singleOverall", designDTO.getSingleOverall()); // 其他设计参数
|
||||||
|
context.put("requestIdList", elementVO.getRequestIdList());
|
||||||
|
|
||||||
|
// 将上下文存入全局设计上下文中
|
||||||
|
designContext.put(requestId, context);
|
||||||
|
|
||||||
|
//保存python返回信息;保存designItem和detail
|
||||||
|
// return savePythonDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone(), responseJSONObject, designDTO.getSingleOverall());
|
||||||
|
return requestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user