Commit ff529cf2 by guanchen

更新汇总拓展用户

parent 831b02c4
...@@ -3,9 +3,9 @@ package com.lanren.huhu.partner.dao; ...@@ -3,9 +3,9 @@ package com.lanren.huhu.partner.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lanren.huhu.partner.domain.AgentExpandDaily; import com.lanren.huhu.partner.domain.AgentExpandDaily;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import com.lanren.huhu.partner.service.AgentExpandDailyService;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.*;
@Mapper @Mapper
public interface AgentExpandDailyMapper extends BaseMapper<AgentExpandDaily> { public interface AgentExpandDailyMapper extends BaseMapper<AgentExpandDaily> {
...@@ -17,26 +17,6 @@ public interface AgentExpandDailyMapper extends BaseMapper<AgentExpandDaily> { ...@@ -17,26 +17,6 @@ public interface AgentExpandDailyMapper extends BaseMapper<AgentExpandDaily> {
int insertOrUpdateSelective(AgentExpandDaily record); 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) " + @UpdateProvider(type = AgentExpandDailySqlProvider.class, method = "updateByDatByDetail")
"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_;")
int updateByDatByDetail(String datStr); 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> { ...@@ -13,7 +13,7 @@ public interface AgentExpandDetailMapper extends BaseMapper<AgentExpandDetail> {
int batchInsert(@Param("list") List<AgentExpandDetail> list); int batchInsert(@Param("list") List<AgentExpandDetail> list);
int saveOrUpdate(AgentExpandDetail record); int insertOrUpdate(AgentExpandDetail record);
int insertOrUpdateSelective(AgentExpandDetail record); int insertOrUpdateSelective(AgentExpandDetail record);
} }
\ No newline at end of file
package com.lanren.huhu.partner.schedule; package com.lanren.huhu.partner.schedule;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
import com.lanren.huhu.partner.constants.Constants; import com.lanren.huhu.partner.constants.Constants;
import com.lanren.huhu.partner.domain.AgentExpandDaily; import com.lanren.huhu.partner.domain.AgentExpandDaily;
import com.lanren.huhu.partner.domain.AgentExpandDetail; import com.lanren.huhu.partner.domain.AgentExpandDetail;
...@@ -45,12 +46,15 @@ public class AgentDailyExpandTask { ...@@ -45,12 +46,15 @@ public class AgentDailyExpandTask {
AgentExpandDetailService agentExpandDetailService; AgentExpandDetailService agentExpandDetailService;
@Autowired @Autowired
AgentExpandDailyService agentExpandDailyService; AgentExpandDailyService agentExpandDailyService;
@Autowired
MybatisPlusProperties mybatisPlusProperties;
// @Scheduled(cron="0 5 */2 * * *") // @Scheduled(cron="0 5 */2 * * *")
@Scheduled(fixedDelay = 10000L) @Scheduled(fixedDelay = 10000L)
public void runScheduledTask() { public void runScheduledTask() {
logger.info("run AgentDailyExpandTask"); logger.info("MapperLocations is: {}", mybatisPlusProperties.getMapperLocations());
runSummary(); // logger.info("run AgentDailyExpandTask");
// runSummary();
} }
@Async @Async
......
...@@ -20,9 +20,6 @@ import com.lanren.huhu.partner.service.AgentExpandDetailService; ...@@ -20,9 +20,6 @@ import com.lanren.huhu.partner.service.AgentExpandDetailService;
@Service @Service
public class AgentExpandDetailServiceImpl extends ServiceImpl<AgentExpandDetailMapper, AgentExpandDetail> implements AgentExpandDetailService{ public class AgentExpandDetailServiceImpl extends ServiceImpl<AgentExpandDetailMapper, AgentExpandDetail> implements AgentExpandDetailService{
@Autowired
AgentExpandDetailMapper agentExpandDetailMapper;
@Override @Override
public int updateBatch(List<AgentExpandDetail> list) { public int updateBatch(List<AgentExpandDetail> list) {
return baseMapper.updateBatch(list); return baseMapper.updateBatch(list);
...@@ -33,7 +30,7 @@ public class AgentExpandDetailServiceImpl extends ServiceImpl<AgentExpandDetailM ...@@ -33,7 +30,7 @@ public class AgentExpandDetailServiceImpl extends ServiceImpl<AgentExpandDetailM
} }
@Override @Override
public int insertOrUpdate(AgentExpandDetail record) { public int insertOrUpdate(AgentExpandDetail record) {
return agentExpandDetailMapper.saveOrUpdate(record); return baseMapper.insertOrUpdate(record);
} }
@Override @Override
public int insertOrUpdateSelective(AgentExpandDetail record) { public int insertOrUpdateSelective(AgentExpandDetail record) {
......
...@@ -96,6 +96,7 @@ mybatis: ...@@ -96,6 +96,7 @@ mybatis:
mybatis-plus: mybatis-plus:
type-aliases-package: com.lanren.huhu.partner.domain type-aliases-package: com.lanren.huhu.partner.domain
mapper-locations: classpath*:mapper/*.xml
logging: logging:
level: level:
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#{item.createdAt}, #{item.updatedAt}) #{item.createdAt}, #{item.updatedAt})
</foreach> </foreach>
</insert> </insert>
<insert id="saveOrUpdate" parameterType="com.lanren.huhu.partner.domain.AgentExpandDetail"> <insert id="insertOrUpdate" parameterType="com.lanren.huhu.partner.domain.AgentExpandDetail">
<!--@mbg.generated--> <!--@mbg.generated-->
insert into agent_expand_detail insert into agent_expand_detail
(dat, agent_id, expand_user_id, user_id, expand_user_reg_time, created_at, updated_at) (dat, agent_id, expand_user_id, user_id, expand_user_reg_time, created_at, updated_at)
...@@ -64,12 +64,6 @@ ...@@ -64,12 +64,6 @@
(#{dat}, #{agentId}, #{expandUserId}, #{userId}, #{expandUserRegTime}, #{createdAt}, (#{dat}, #{agentId}, #{expandUserId}, #{userId}, #{expandUserRegTime}, #{createdAt},
#{updatedAt}) #{updatedAt})
on duplicate key update 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} updated_at = #{updatedAt}
</insert> </insert>
<insert id="insertOrUpdateSelective" parameterType="com.lanren.huhu.partner.domain.AgentExpandDetail"> <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