|
@@ -1,11 +1,25 @@
|
|
|
package org.jeecg.modules.dataElectricity.service.impl;
|
|
|
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.modules.dataElectricity.entity.DataElectricity;
|
|
|
+import org.jeecg.modules.dataElectricity.entity.DataElectricitySta;
|
|
|
import org.jeecg.modules.dataElectricity.mapper.DataElectricityMapper;
|
|
|
import org.jeecg.modules.dataElectricity.service.IDataElectricityService;
|
|
|
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
+import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @Description: ems_data_electricity
|
|
@@ -16,4 +30,67 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
@Service
|
|
|
public class DataElectricityServiceImpl extends ServiceImpl<DataElectricityMapper, DataElectricity> implements IDataElectricityService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DataElectricityMapper dataElectricityMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用电集抄
|
|
|
+ *
|
|
|
+ * @param emsElectricity 分时电量
|
|
|
+ * @return 分时电量
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<DataElectricitySta> selectEmsElecSta(DataElectricity emsElectricity)
|
|
|
+ {
|
|
|
+ List<DataElectricity> tempList = dataElectricityMapper.selectEmsElecSta(emsElectricity);
|
|
|
+ List<DataElectricitySta> elecList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 将信息转换一下
|
|
|
+ if (tempList != null && tempList.size() > 0) {
|
|
|
+ for (DataElectricity elec : tempList) {
|
|
|
+ if (elec == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ DataElectricitySta sta = new DataElectricitySta();
|
|
|
+ sta.setEquipmentname(elec.getEquipmentname());
|
|
|
+ sta.setEquipmentcode(elec.getEquipmentcode());
|
|
|
+ sta.setBeginvalue(elec.getBeginvalue());
|
|
|
+ sta.setEndvalue(elec.getEndvalue());
|
|
|
+ sta.setTagvalue(elec.getTagvalue());
|
|
|
+ sta.setElectricityvalue(elec.getElectricityvalue());
|
|
|
+
|
|
|
+ elecList.add(sta);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return elecList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出用电集抄
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ModelAndView exportsta(HttpServletRequest request, Class<DataElectricitySta> clazz, String title, DataElectricity dataElectricity) {
|
|
|
+// System.out.println("进入服务层");
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ //1.根据传送的时间找出用电集抄记录
|
|
|
+ List<DataElectricitySta> dataElectricityStaList = selectEmsElecSta(dataElectricity);
|
|
|
+ System.out.println(dataElectricityStaList);
|
|
|
+
|
|
|
+ // 2. AutoPoi 导出Excel
|
|
|
+ ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
+ //此处设置的filename无效 ,前端会重更新设置一下
|
|
|
+ mv.addObject(NormalExcelConstants.FILE_NAME, title);
|
|
|
+ mv.addObject(NormalExcelConstants.CLASS, clazz);
|
|
|
+ //update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
|
|
|
+ ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
|
|
|
+// exportParams.setImageBasePath(upLoadPath);
|
|
|
+ //update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
|
|
|
+ mv.addObject(NormalExcelConstants.PARAMS, exportParams);
|
|
|
+ mv.addObject(NormalExcelConstants.DATA_LIST, dataElectricityStaList);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|