package com.dy.pipIrrTemp.delSome; import com.dy.pipIrrGlobal.daoTmp.DeleteMapper; import com.dy.pipIrrGlobal.voTmp.VoStClientAmountDay; import com.dy.pipIrrGlobal.voTmp.VoStClientAmountMonth; import com.dy.pipIrrGlobal.voTmp.VoStClientAmountYear; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; /** * @Author: liurunyu * @Date: 2024/12/11 10:54 * @Description */ @Slf4j @Service public class DelSomeClientAmountSv { private DeleteMapper dao; @Autowired private void setDao(DeleteMapper dao){ this.dao = dao; } public void delStClientDay(){ VoStClientAmountDay first = null ; List list = dao.selectAllStClientDay() ; if(list != null && list.size() > 0){ for(VoStClientAmountDay vo : list){ if(first == null){ first = vo ; }else{ if(first.clientId.longValue() != vo.clientId.longValue()){ //农户变了 first = vo ; }else{ if(!first.dt.equals(vo.dt)) { //日期变了 first = vo ; }else{ //同一个农户同日期 doDelStClientDay(vo.id) ; } } } } } } public void delStClientMonth(){ VoStClientAmountMonth first = null ; List list = dao.selectAllStClientMonth() ; if(list != null && list.size() > 0){ for(VoStClientAmountMonth vo : list){ if(first == null){ first = vo ; }else{ if(first.clientId.longValue() != vo.clientId.longValue()){ //农户变了 first = vo ; }else{ if(first.year.intValue() != vo.year.intValue()) { //年度变了 first = vo ; }else{ if(first.month.intValue() != vo.month.intValue()){ //月份变了 first = vo ; }else{ //同一个农户同年同月 doDelStClientMonth(vo.id) ; } } } } } } } public void delStClientYear(){ VoStClientAmountYear first = null ; List list = dao.selectAllStClientYear() ; if(list != null && list.size() > 0){ for(VoStClientAmountYear vo : list){ if(first == null){ first = vo ; }else{ if(first.clientId.longValue() != vo.clientId.longValue()){ //农户变了 first = vo ; }else{ if(first.year.intValue() != vo.year.intValue()) { //年度变了 first = vo ; }else{ //同一个农户同年 doDelStClientYear(vo.id) ; } } } } } } @Transactional int doDelStClientDay(Long id){ return dao.deleteStClientDayById(id) ; } @Transactional int doDelStClientMonth(Long id){ return dao.deleteStClientMonthById(id) ; } @Transactional int doDelStClientYear(Long id){ return dao.deleteStClientYearById(id) ; } }