| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- package cn.com.lzt.userstats.service.impl;
- import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Propagation;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.UUID;
- import java.io.Serializable;
- import java.math.BigDecimal;
- import org.jeecgframework.core.util.ApplicationContextUtil;
- import org.jeecgframework.core.util.JeecgDataAutorUtils;
- import org.jeecgframework.core.util.LogUtil;
- import org.jeecgframework.core.util.MyClassLoader;
- import org.jeecgframework.core.util.StringUtil;
- import org.jeecgframework.minidao.pojo.MiniDaoPage;
- import org.jeecgframework.web.cgform.enhance.CgformEnhanceJavaInter;
- import antlr.StringUtils;
- import cn.com.lzt.common.util.DataUtil;
- import cn.com.lzt.dialogDeal.service.UserDepartOrgDealServiceI;
- import cn.com.lzt.overtimestats.entity.ProjOvertimeStatsEntity;
- import cn.com.lzt.userstats.dao.UserStatsMinidaoDao;
- import cn.com.lzt.userstats.enitity.DeptUserEntity;
- import cn.com.lzt.userstats.enitity.ProjUserEntity;
- import cn.com.lzt.userstats.service.UserStatsServiceI;
- @Service("userStatsService")
- @Transactional(propagation = Propagation.REQUIRES_NEW)
- public class UserStatsServiceImpl extends CommonServiceImpl implements UserStatsServiceI {
- @Autowired
- private UserStatsMinidaoDao userStatsMinidaoDao;
-
- @Autowired
- private UserDepartOrgDealServiceI userDepartOrgDealServiceI;
-
- @Override
- public void userStatsTaskData() {
- userStatsTaskData(null);
- }
- @Override
- public void userStatsTaskData(String attmonth) {
- LogUtil.info("===============人员统计定时任务开始=================");
- //String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
- String beforeMonth = DataUtil.getBeforeMonth();
- if(StringUtil.isNotEmpty(attmonth)){
- beforeMonth = attmonth;
- }
- Map<String,Object> params = new HashMap<String, Object>();
- params = DataUtil.getMonthInfo(beforeMonth);
- params.put("yearmonth", beforeMonth);
- //查询上个月的部门月度人员情况
- MiniDaoPage<DeptUserEntity> deptUserlist = new MiniDaoPage<DeptUserEntity>();
- deptUserlist = userStatsMinidaoDao.deptUserStatsData(params,null);
- List<DeptUserEntity> deptList = findByProperty(DeptUserEntity.class, "yearmonth", beforeMonth);
- List<DeptUserEntity> deptListRes = new ArrayList<DeptUserEntity>();
- List<DeptUserEntity> list = new ArrayList<DeptUserEntity>();
- //遍历通过部门id查询项目id
- for(DeptUserEntity due : deptUserlist.getResults()){
-
- if(StringUtil.isEmpty(due.getPjtId())){
- String pid = userDepartOrgDealServiceI.getProjectDepartParentId(due.getDeptId());
- if(StringUtil.isNotEmpty(pid)){
- String pmId = userStatsMinidaoDao.getPmIdByPid(pid);
- due.setPjtId(pid);
- due.setPmId(pmId);
- deptListRes.add(due);
- }
- }else{
- if(due.getPjtId() != null && due.getPjtId().equals(due.getDeptId())){
- list.add(due);
- }
- deptListRes.add(due);
-
-
- }
- }
- try {
- deleteAllEntitie(deptList);
- super.batchSave(deptListRes);
- LogUtil.info("===============部门人员统计表保存成功=================");
- } catch (Exception e) {
- LogUtil.info("===============部门人员统计表保存失败=================");
- }
-
- //查询上个月的项目月度人员情况
- MiniDaoPage<ProjUserEntity> projUserlist = new MiniDaoPage<ProjUserEntity>();
- projUserlist = userStatsMinidaoDao.projUserStatsData(params,null);
- List<ProjUserEntity> projList = findByProperty(ProjUserEntity.class, "yearmonth", beforeMonth);
- try {
- deleteAllEntitie(projList);
- /* for(ProjUserEntity pu : projUserlist.getResults()){
- for(DeptUserEntity de : list){
- if(pu.getPjtId().equals(de.getPjtId())){
- pu.setEarlymonthTotal(pu.getEarlymonthTotal() + de.getEarlymonthTotal());
- pu.setEntryTotal(pu.getEntryTotal() + de.getEntryTotal());
- pu.setLeaveTotal(pu.getLeaveTotal() + de.getLeaveTotal());
- pu.setEndmonthTotal(pu.getEarlymonthTotal() + pu.getEntryTotal() - pu.getLeaveTotal());
- float a = (float)pu.getLeaveTotal()/pu.getEarlymonthTotal() * 100;
- BigDecimal bd = new BigDecimal(a);
- pu.setFlowProportion(new BigDecimal(DataUtil.getFormatDecimailTwo(bd)));
- }
- }
- }*/
- super.batchSave(projUserlist.getResults());
- LogUtil.info("===============项目人员统计表保存成功=================");
- } catch (Exception e) {
- LogUtil.info("===============项目人员统计表保存失败=================");
- }
- LogUtil.info("===============人员统计定时任务开始=================");
-
- }
-
-
- }
|