Commit ff529cf2 by guanchen

更新汇总拓展用户

parent 831b02c4
......@@ -3,9 +3,9 @@ package com.lanren.huhu.partner.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lanren.huhu.partner.domain.AgentExpandDaily;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import com.lanren.huhu.partner.service.AgentExpandDailyService;
import org.apache.ibatis.annotations.*;
@Mapper
public interface AgentExpandDailyMapper extends BaseMapper<AgentExpandDaily> {
......@@ -17,26 +17,6 @@ public interface AgentExpandDailyMapper extends BaseMapper<AgentExpandDaily> {
int insertOrUpdateSelective(AgentExpandDaily record);
@Update("INSERT INTO agent_expand_daily(dat, agent_id, user_id, cnt_expand, created_at, updated_at, year_str, month_str, day_str) " +
"SELECT * " +
"FROM ( " +
" SELECT '#{datStr}' dat_, " +
" a.agent_id, " +
" b.user_id, " +
" a.cnt_expand_, " +
" UNIX_TIMESTAMP(now()), " +
" UNIX_TIMESTAMP(now()) updated_at_, " +
" SUBSTR('#{datStr}', 1, 4), " +
" SUBSTR('#{datStr}', 6, 2), " +
" SUBSTR('#{datStr}', 9, 2) " +
" FROM " +
" (SELECT agent_id, " +
" COUNT(*) cnt_expand_ " +
" FROM agent_expand_detail " +
" WHERE dat='#{datStr}' " +
" GROUP BY 1) a " +
" JOIN user_agent b ON a.agent_id=b.agent_id " +
") a ON DUPLICATE KEY " +
"UPDATE updated_at=updated_at_;")
@UpdateProvider(type = AgentExpandDailySqlProvider.class, method = "updateByDatByDetail")
int updateByDatByDetail(String datStr);
}
\ No newline at end of file
package com.lanren.huhu.partner.dao;
import org.apache.ibatis.annotations.Param;
/**
* @author chen
* @title: AgentExpandDailySqlProvider
* @projectName partner
* @description: sql provider
* @package com.lanren.huhu.partner.dao
* @date 2019-07-08 18:52
*/
public class AgentExpandDailySqlProvider {
public String updateByDatByDetail(@Param("datStr") String datStr) {
return "INSERT INTO agent_expand_daily(dat, agent_id, user_id, cnt_expand, created_at, updated_at, year_str, month_str, day_str) " +
"SELECT * " +
"FROM ( " +
" SELECT '"+ datStr +"' dat_, " +
" a.agent_id, " +
" b.user_id, " +
" a.cnt_expand_, " +
" UNIX_TIMESTAMP(now()), " +
" UNIX_TIMESTAMP(now()) updated_at_, " +
" SUBSTR('"+ datStr +"', 1, 4), " +
" SUBSTR('"+ datStr +"', 6, 2), " +
" SUBSTR('"+ datStr +"', 9, 2) " +
" FROM " +
" (SELECT agent_id, " +
" COUNT(*) cnt_expand_ " +
" FROM agent_expand_detail " +
" WHERE dat='"+ datStr +"' " +
" GROUP BY 1) a " +
" JOIN user_agent b ON a.agent_id=b.agent_id " +
") a ON DUPLICATE KEY " +
"UPDATE updated_at=updated_at_;";
}
}
......@@ -13,7 +13,7 @@ public interface AgentExpandDetailMapper extends BaseMapper<AgentExpandDetail> {
int batchInsert(@Param("list") List<AgentExpandDetail> list);
int saveOrUpdate(AgentExpandDetail record);
int insertOrUpdate(AgentExpandDetail record);
int insertOrUpdateSelective(AgentExpandDetail record);
}
\ No newline at end of file
package com.lanren.huhu.partner.schedule;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
import com.lanren.huhu.partner.constants.Constants;
import com.lanren.huhu.partner.domain.AgentExpandDaily;
import com.lanren.huhu.partner.domain.AgentExpandDetail;
......@@ -45,12 +46,15 @@ public class AgentDailyExpandTask {
AgentExpandDetailService agentExpandDetailService;
@Autowired
AgentExpandDailyService agentExpandDailyService;
@Autowired
MybatisPlusProperties mybatisPlusProperties;
// @Scheduled(cron="0 5 */2 * * *")
// @Scheduled(cron="0 5 */2 * * *")
@Scheduled(fixedDelay = 10000L)
public void runScheduledTask() {
logger.info("run AgentDailyExpandTask");
runSummary();
logger.info("MapperLocations is: {}", mybatisPlusProperties.getMapperLocations());
// logger.info("run AgentDailyExpandTask");
// runSummary();
}
@Async
......
......@@ -20,9 +20,6 @@ import com.lanren.huhu.partner.service.AgentExpandDetailService;
@Service
public class AgentExpandDetailServiceImpl extends ServiceImpl<AgentExpandDetailMapper, AgentExpandDetail> implements AgentExpandDetailService{
@Autowired
AgentExpandDetailMapper agentExpandDetailMapper;
@Override
public int updateBatch(List<AgentExpandDetail> list) {
return baseMapper.updateBatch(list);
......@@ -33,7 +30,7 @@ public class AgentExpandDetailServiceImpl extends ServiceImpl<AgentExpandDetailM
}
@Override
public int insertOrUpdate(AgentExpandDetail record) {
return agentExpandDetailMapper.saveOrUpdate(record);
return baseMapper.insertOrUpdate(record);
}
@Override
public int insertOrUpdateSelective(AgentExpandDetail record) {
......
......@@ -96,6 +96,7 @@ mybatis:
mybatis-plus:
type-aliases-package: com.lanren.huhu.partner.domain
mapper-locations: classpath*:mapper/*.xml
logging:
level:
......
......@@ -56,7 +56,7 @@
#{item.createdAt}, #{item.updatedAt})
</foreach>
</insert>
<insert id="saveOrUpdate" parameterType="com.lanren.huhu.partner.domain.AgentExpandDetail">
<insert id="insertOrUpdate" parameterType="com.lanren.huhu.partner.domain.AgentExpandDetail">
<!--@mbg.generated-->
insert into agent_expand_detail
(dat, agent_id, expand_user_id, user_id, expand_user_reg_time, created_at, updated_at)
......@@ -64,12 +64,6 @@
(#{dat}, #{agentId}, #{expandUserId}, #{userId}, #{expandUserRegTime}, #{createdAt},
#{updatedAt})
on duplicate key update
dat = #{dat},
agent_id = #{agentId},
expand_user_id = #{expandUserId},
user_id = #{userId},
expand_user_reg_time = #{expandUserRegTime},
created_at = #{createdAt},
updated_at = #{updatedAt}
</insert>
<insert id="insertOrUpdateSelective" parameterType="com.lanren.huhu.partner.domain.AgentExpandDetail">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment