|
@@ -1,8 +1,14 @@
|
|
|
package com.hjy.module.service.gather.impl;
|
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.excel.ExcelWriter;
|
|
|
+import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.hjy.common.core.domain.entity.SysDept;
|
|
|
import com.hjy.common.core.page.TableDataInfo;
|
|
|
+import com.hjy.common.core.text.Convert;
|
|
|
import com.hjy.common.utils.CommomUtils;
|
|
|
+import com.hjy.common.utils.DictUtils;
|
|
|
import com.hjy.common.utils.PageUtils;
|
|
|
import com.hjy.module.domain.gether.CbGather;
|
|
|
import com.hjy.module.domain.gether.CbGatherFee;
|
|
@@ -20,13 +26,20 @@ import com.hjy.module.service.norm.ICbNormService;
|
|
|
import com.hjy.module.vo.gather.CbGatherFeeVo;
|
|
|
import com.hjy.module.vo.gather.CbGatherVo;
|
|
|
import com.hjy.module.vo.gather.CbGatherWarningVo;
|
|
|
+import com.hjy.module.vo.gather.GatherImportVo;
|
|
|
import com.hjy.module.vo.norm.CbNormFeeVo;
|
|
|
import com.hjy.module.vo.norm.CbNormVo;
|
|
|
+import com.hjy.system.mapper.SysDeptMapper;
|
|
|
+import com.hjy.system.service.ISysDeptService;
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -54,6 +67,9 @@ public class CbGatherServiceImpl extends ServiceImpl<CbGatherMapper, CbGather> i
|
|
|
@Autowired
|
|
|
private ICbGatherWarningService warningService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService sysDeptService;
|
|
|
+
|
|
|
@Override
|
|
|
public TableDataInfo<CbGatherVo> queryList(CbGatherVo entity) {
|
|
|
return PageUtils.buildDataInfo(this.baseMapper.queryList(PageUtils.buildPage(), entity));
|
|
@@ -166,6 +182,7 @@ public class CbGatherServiceImpl extends ServiceImpl<CbGatherMapper, CbGather> i
|
|
|
warningVo.setGetherId(entity.getId());
|
|
|
warningVo.setGetherfeeId(feeVo.getId());
|
|
|
warningVo.setErrValue(collValue);
|
|
|
+ warningVo.setStatus("0");
|
|
|
warningService.save(warningVo);
|
|
|
}
|
|
|
}
|
|
@@ -184,6 +201,7 @@ public class CbGatherServiceImpl extends ServiceImpl<CbGatherMapper, CbGather> i
|
|
|
warningVo.setGetherId(entity.getId());
|
|
|
warningVo.setGetherfeeId(feeVo.getId());
|
|
|
warningVo.setErrValue(collValue);
|
|
|
+ warningVo.setStatus("0");
|
|
|
warningService.save(warningVo);
|
|
|
}
|
|
|
}
|
|
@@ -204,6 +222,73 @@ public class CbGatherServiceImpl extends ServiceImpl<CbGatherMapper, CbGather> i
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 下载导入模板
|
|
|
+ * @param response
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void downloadModlue(HttpServletResponse response, String id) throws IOException {
|
|
|
+ CbGatherVo gatherVo = this.getInfoByColl(id);
|
|
|
+ SysDept dept = sysDeptService.selectDeptById(Convert.toLong(gatherVo.getDeptId()));
|
|
|
+ ServletOutputStream out = response.getOutputStream();
|
|
|
+ ExcelWriter writer = EasyExcel.write(out).build();
|
|
|
+ WriteSheet sheet1 = EasyExcel.writerSheet("sheet1").head(getHead(dept.getDeptName())).build();
|
|
|
+ List<GatherImportVo> importVoList = getImportData(gatherVo);
|
|
|
+ writer.write(importVoList,sheet1);
|
|
|
+ writer.close();
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构造导出数据
|
|
|
+ * @param gatherVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<GatherImportVo> getImportData(CbGatherVo gatherVo) {
|
|
|
+ List<GatherImportVo> resultList = Lists.newArrayList();
|
|
|
+ for (CbGatherFeeVo feeVo:gatherVo.getFeeLists()){
|
|
|
+ GatherImportVo importVo = new GatherImportVo();
|
|
|
+ importVo.setNormName(feeVo.getNormName());
|
|
|
+ importVo.setNormfeeName(feeVo.getNormfeeName());
|
|
|
+ importVo.setUint( DictUtils.getDictLabel("norm_uint",normFeeService.getById(feeVo.getNormfeeId()).getFunit()));
|
|
|
+ importVo.setCollCalue(feeVo.getCollCalue());
|
|
|
+ resultList.add(importVo);
|
|
|
+ }
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * excel表态构造
|
|
|
+ * @param lebal
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static List<List<String>> getHead( String lebal) {
|
|
|
+ List<List<String>> list = new ArrayList<List<String>>();
|
|
|
+ for (int i=0 ; i<4;i++){
|
|
|
+ List<String> row = Lists.newArrayList();
|
|
|
+ switch (i){
|
|
|
+ case 0:
|
|
|
+ row.add("指标分类");
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ row.add("指标名称");
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ row.add("计量单位");
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ row.add(lebal);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ list.add(row);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|