package com.dy.pipIrrStatistics.statistics;
|
|
import com.dy.pipIrrGlobal.daoRm.RmLossDayMapper;
|
import com.dy.pipIrrGlobal.daoSt.StLossMonthMapper;
|
import com.dy.pipIrrGlobal.daoSt.StLossYearMapper;
|
import com.dy.pipIrrGlobal.pojoSt.StLossMonth;
|
import com.dy.pipIrrGlobal.pojoSt.StLossYear;
|
import com.dy.pipIrrGlobal.voSt.VoIntakeLossStatistics;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.List;
|
|
/**
|
* @Author: liurunyu
|
* @Date: 2024/7/24 11:24
|
* @Description
|
*/
|
@Component
|
public class StLossSv {
|
|
@Autowired
|
protected RmLossDayMapper rmLossDayDao;
|
|
@Autowired
|
protected StLossMonthMapper stLossMonthDao ;
|
|
@Autowired
|
protected StLossYearMapper stLossYearDao ;
|
|
/**
|
* 月统计---漏损
|
*/
|
@Transactional
|
protected void statisticsMonth(Integer statisticsYear, Integer statisticsMonth, Long statisticsStartId, Long statisticsEndId){
|
List<VoIntakeLossStatistics> list = rmLossDayDao.statisticsByIntake(statisticsStartId, statisticsEndId) ;
|
if(list != null && list.size() > 0){
|
for(VoIntakeLossStatistics vo : list){
|
List<StLossMonth> listOfMonth = this.stLossMonthDao.selectByIntakeIdAndYearAndMonth(vo.intakeId, statisticsYear, statisticsMonth) ;
|
StLossMonth po = null ;
|
if (listOfMonth != null && listOfMonth.size() > 0){
|
//程序逻辑控制上,集合中只有一个对象
|
po = listOfMonth.get(0) ;
|
}
|
if(po == null){
|
po = new StLossMonth() ;
|
}
|
po.intakeId = vo.intakeId ;
|
po.year = statisticsYear ;
|
po.month = statisticsMonth ;
|
po.amount = vo.amount;
|
if(po.id == null) {
|
stLossMonthDao.insert(po);
|
}else{
|
stLossMonthDao.updateByPrimaryKey(po) ;
|
}
|
}
|
}
|
}
|
|
/**
|
* 年统计---漏损
|
*/
|
@Transactional
|
protected void statisticsYear(Integer statisticsYear){
|
List<VoIntakeLossStatistics> list = stLossMonthDao.statisticsByIntake(statisticsYear) ;
|
if(list != null && list.size() > 0){
|
for(VoIntakeLossStatistics vo : list){
|
List<StLossYear> listOfYear = this.stLossYearDao.selectByIntakeIdAndYear(vo.intakeId, statisticsYear) ;
|
StLossYear po = null ;
|
if(listOfYear != null && listOfYear.size() > 0){
|
//程序逻辑控制上,集合中只有一个对象
|
po = listOfYear.get(0) ;
|
}
|
if(po == null) {
|
po = new StLossYear();
|
}
|
po.intakeId = vo.intakeId ;
|
po.year = statisticsYear ;
|
po.amount = vo.amount;
|
if(po.id == null) {
|
stLossYearDao.insert(po);
|
}else{
|
stLossYearDao.updateByPrimaryKey(po) ;
|
}
|
}
|
}
|
}
|
}
|