Browse Source

人口数信息保存到REDIS修改

lyr 8 năm trước cách đây
mục cha
commit
197df2fe95

+ 5 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/statistics/PopulationBaseDao.java

@ -5,6 +5,9 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Iterator;
import java.util.List;
/**
 * Created by lyr on 2016/08/18.
 */
@ -14,4 +17,6 @@ public interface PopulationBaseDao extends PagingAndSortingRepository<Population
    int findPeopleNumByCode(String code);
    PopulationBase findByCodeAndYear(String code,Integer year);
    List<PopulationBase> findByYear(Integer year);
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -83,7 +83,7 @@ public class StatisticsService extends BaseService {
     * @return
     */
    public boolean peopleNumToRedis() {
        Iterable<PopulationBase> peopleNums = peopleNumDao.findAll();
        List<PopulationBase> peopleNums = peopleNumDao.findByYear(Calendar.getInstance().get(Calendar.YEAR));
        for (PopulationBase peopleNum : peopleNums) {
            redisTemplate.opsForValue().set("people:num:" + peopleNum.getCode(), new JSONObject(peopleNum).toString());