Merge remote-tracking branch 'origin/dev/dev' into dev/dev

This commit is contained in:
shahaibo
2024-04-23 15:55:36 +08:00
6 changed files with 101 additions and 24 deletions

View File

@@ -87,14 +87,31 @@ public class SRConsumer {
superResolutionDTO = JSONObject.parseObject(msg.getBody(), SuperResolutionDTO.class);
// channel.basicNack() 为不确认deliveryTag对应的消息第二个参数是否应用于多消息第三个参数是否requeue
setErrorMessage(msg, channel, e.getMsg(), superResolutionDTO);
try {
// 2.1 手动确认该消息
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
} catch (IOException ex) {
log.error("手动确认,不返回队列重新消费, error message : " + e.getMessage());
}
} catch (JSONException e) {
log.error(e.getMessage());
setErrorMessage(msg, channel, e.getMessage(), null);
try {
// 2.1 手动确认该消息
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
} catch (IOException ex) {
log.error("手动确认,不返回队列重新消费, error message : " + e.getMessage());
}
} catch (Exception e) {
log.error(e.getMessage());
superResolutionDTO = JSONObject.parseObject(msg.getBody(), SuperResolutionDTO.class);
setErrorMessage(msg, channel, e.getMessage(), superResolutionDTO);
try {
// 2.1 手动确认该消息
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
} catch (IOException ex) {
log.error("手动确认,不返回队列重新消费, error message : " + e.getMessage());
}
}
long end = System.currentTimeMillis();

View File

@@ -22,7 +22,7 @@ public enum GenerateModeEnum {
/**
* 通过文本和图片生成
*/
TEXT_IMAGE(2, "text-image","txt2img");
TEXT_IMAGE(2, "text-image","img2img");
private Integer code;
private String value;

View File

@@ -7,12 +7,15 @@ import com.ai.da.mapper.primary.DesignMapper;
import com.ai.da.mapper.primary.TrialOrderMapper;
import com.ai.da.mapper.primary.entity.TrialOrder;
import com.ai.da.model.dto.UserDesignStatisticDTO;
import io.netty.util.internal.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Api(tags = "便利查询")
@@ -31,7 +34,7 @@ public class ConvenientInquiryController {
@GetMapping("/getTrial")
public Response<List<TrialOrder>> getTrial(){
Long accountId = UserContext.getUserHolder().getId();
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)){
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)){
List<TrialOrder> trialOrders = trialOrderMapper.selectList(null);
return Response.success(trialOrders);
}else {
@@ -43,7 +46,13 @@ public class ConvenientInquiryController {
@GetMapping("/getDesignStatistic")
public Response<List<UserDesignStatisticDTO>> getDesignStatistic(@RequestParam String startTime,@RequestParam String endTime){
Long accountId = UserContext.getUserHolder().getId();
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)){
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)){
if (StringUtil.isNullOrEmpty(startTime)) startTime = "2024-02-01 00:00:00";
if (StringUtil.isNullOrEmpty(endTime)){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date date = new Date();
endTime = simpleDateFormat.format(date);
}
List<UserDesignStatisticDTO> designStatistic = designMapper.getDesignStatistic(startTime, endTime);
return Response.success(designStatistic);
}else {

View File

@@ -7,11 +7,25 @@ public class UserDesignStatisticDTO {
private Long accountId;
private Long useDesignTimes;
private Long designTimes;
private String userEmail;
private String userName;
private String isTrial;
private String trialOrderId;
private String title;
private String surname;
private String givenName;
private String country;
private String occupation;
private String createTime;
}

View File

@@ -123,6 +123,9 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
String text = generateThroughImageTextDTO.getText();
Long elementId = generateThroughImageTextDTO.getCollectionElementId();
validateGeneraType(generate, text, elementId, generateType);
if (generateType.equals("text") || generateType.equals("text-image")){
text = modifyPrompt(text, generate, generateThroughImageTextDTO.getLevel1Type());
}
// 2.1 sketch或print在t_collection_element表/t_library表中的信息是否需要更新 如 level2Type
CollectionElement collectionElement = collectionElementService.editLevel2Type(elementId, generateThroughImageTextDTO.getLevel2Type(), generateThroughImageTextDTO.getDesignType());
@@ -250,6 +253,25 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
}
}
private String modifyPrompt(String userInput, Generate generate, String level1Type){
String text = "";
switch (level1Type) {
case "Moodboard":
text = userInput + ",high quality";
generate.setText(text);
break;
case "Printboard":
text = userInput + ", fabric print, high quality";
generate.setText(text);
break;
case "Sketchboard":
text = "a single item , " + userInput + ", clean background, hand-drawing sketch style, high quality";
generate.setText(text);
default:
}
return text;
}
@Override
@Transactional(rollbackFor = Exception.class)
public GenerateLikeVO generateLike(GenerateLikeDTO generateLikeDTO) {

View File

@@ -4,30 +4,45 @@
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.ai.da.mapper.primary.entity.Design">
<id column="id" property="id" />
<result column="account_id" property="accountId" />
<result column="collection_id" property="collectionId" />
<result column="system_scale" property="systemScale" />
<result column="single_overall" property="singleOverall" />
<result column="switch_category" property="switchCategory" />
<result column="create_date" property="createDate" />
<result column="update_date" property="updateDate" />
<id column="id" property="id"/>
<result column="account_id" property="accountId"/>
<result column="collection_id" property="collectionId"/>
<result column="system_scale" property="systemScale"/>
<result column="single_overall" property="singleOverall"/>
<result column="switch_category" property="switchCategory"/>
<result column="create_date" property="createDate"/>
<result column="update_date" property="updateDate"/>
</resultMap>
<insert id="insertDesign" parameterType="com.ai.da.mapper.primary.entity.Design" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
<insert id="insertDesign" parameterType="com.ai.da.mapper.primary.entity.Design" useGeneratedKeys="true"
keyProperty="id" keyColumn="id">
insert into t_design
(account_id,collection_id,system_scale,single_overall,switch_category,create_date)
values(
#{accountId},
#{collectionId},
#{systemScale},
#{singleOverall},
#{switchCategory},
#{createDate});
(account_id, collection_id, system_scale, single_overall, switch_category, create_date)
values (#{accountId},
#{collectionId},
#{systemScale},
#{singleOverall},
#{switchCategory},
#{createDate});
</insert>
<select id="getDesignStatistic" resultType="com.ai.da.model.dto.UserDesignStatisticDTO" parameterType="String">
select a.account_id,count(a.account_id) use_design_times,b.user_email,b.user_name,b.is_trial
select d.*,c.id trialOrderId, c.title,c.surname,c.given_name,c.country,c.occupation,c.create_time
from (
select b.account_id,count(b.account_id) design_times,a.user_name,a.user_email,a.is_trial
from t_account a
left join t_design b on a.id = b.account_id
<where>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
b.create_date between #{startTime} and #{endTime}
</if>
</where>
and b.create_date not like '%:01'
and b.create_date not like '%:02'
GROUP BY b.account_id
ORDER BY b.account_id asc) d
left join trial_order c on d.user_email = c.email
<!--select a.account_id,count(a.account_id) use_design_times,b.user_email,b.user_name,b.is_trial
from `t_account` b
left join t_design a
on a.account_id = b.id
@@ -37,7 +52,7 @@
</if>
</where>
GROUP BY a.account_id
ORDER BY a.account_id ASC;
ORDER BY a.account_id ASC;-->
</select>
</mapper>