|
@@ -8,16 +8,17 @@ import com.bz.smart_city.commom.util.ExcelUtil;
|
|
|
import com.bz.smart_city.commom.util.FileUtil;
|
|
|
import com.bz.smart_city.commom.util.UserUtil;
|
|
|
import com.bz.smart_city.commom.util.Util;
|
|
|
-import com.bz.smart_city.dao.pay.BaseWaterPropertyMapper;
|
|
|
-import com.bz.smart_city.dao.pay.PayBaseAccountMapper;
|
|
|
-import com.bz.smart_city.dao.pay.PayBaseConfigMapper;
|
|
|
-import com.bz.smart_city.dao.pay.PayRechargeaccountMapper;
|
|
|
+import com.bz.smart_city.dao.OrganizationMapper;
|
|
|
+import com.bz.smart_city.dao.pay.*;
|
|
|
import com.bz.smart_city.dao.pay.archives.PayBaseCustomerandmeterrelaMapper;
|
|
|
import com.bz.smart_city.dto.LoginUser;
|
|
|
+import com.bz.smart_city.dto.OrganizationDto;
|
|
|
import com.bz.smart_city.dto.pay.*;
|
|
|
import com.bz.smart_city.entity.Organization;
|
|
|
+import com.bz.smart_city.entity.ProgramItem;
|
|
|
import com.bz.smart_city.entity.pay.PayBaseAccount;
|
|
|
import com.bz.smart_city.entity.pay.PayBaseWaterprice;
|
|
|
+import com.bz.smart_city.entity.pay.PayMeter;
|
|
|
import com.bz.smart_city.entity.pay.PayPayRechargeaccount;
|
|
|
import com.bz.smart_city.entity.pay.archives.*;
|
|
|
import com.bz.smart_city.service.pay.PayBaseAccountService;
|
|
@@ -28,12 +29,14 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.jxls.util.JxlsHelper;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
@@ -76,6 +79,12 @@ public class PayBaseCustomerandmeterrelaServiceImpl implements PayBaseCustomeran
|
|
|
@Resource
|
|
|
private PayRechargeaccountMapper payRechargeaccountMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private PaySysDictMapper paySysDictMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private OrganizationMapper organizationMapper;
|
|
|
+
|
|
|
@Value("${files.path}")
|
|
|
private String filesPath;
|
|
|
|
|
@@ -710,25 +719,67 @@ public class PayBaseCustomerandmeterrelaServiceImpl implements PayBaseCustomeran
|
|
|
|
|
|
@Override
|
|
|
public void downTemplate(HttpServletResponse response){
|
|
|
-
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ BigInteger siteId = BigInteger.valueOf(loginUser.getSiteId());
|
|
|
+ BigInteger customerId = BigInteger.valueOf(loginUser.getCustomerId());
|
|
|
+ String filePath = this.getFilePath();
|
|
|
+ log.info("filePath:" + filePath);
|
|
|
// 实现文件下载
|
|
|
byte[] buffer = new byte[1024];
|
|
|
InputStream fis = null;
|
|
|
BufferedInputStream bis = null;
|
|
|
try {
|
|
|
- String headStr = "attachment;filename*=UTF-8''" + URLEncoder.encode("批量开户导入模板.xlsx", "UTF-8");
|
|
|
- response.setContentType("APPLICATION/OCTET-STREAM");
|
|
|
- response.setHeader("Content-Disposition", headStr);
|
|
|
-
|
|
|
-
|
|
|
- fis = this.getClass().getClassLoader().getResourceAsStream("excel/batchOpenAccountTemplate.xlsx");
|
|
|
- bis = new BufferedInputStream(fis);
|
|
|
- OutputStream os = response.getOutputStream();
|
|
|
- int i = bis.read(buffer);
|
|
|
- while (i != -1) {
|
|
|
- os.write(buffer, 0, i);
|
|
|
- i = bis.read(buffer);
|
|
|
- }
|
|
|
+ //jx:each(items="customerList" var="customer" lastCell="B2")
|
|
|
+ //jx:area(lastCell="B2")
|
|
|
+ //1.查抄未开户水表信息集合
|
|
|
+ List<ProgramItem> programItemList = loginUser.getDataPermissionMap().get(siteId);
|
|
|
+ //查找待开户信息
|
|
|
+ List<PayMeter> meterInfoList = payBaseAccountMapper.findMeterInfo(null,"1",siteId,customerId,null,null,programItemList);
|
|
|
+ //2.查找用水性质集合
|
|
|
+ List<BaseWaterPropertyDto> propertyList = baseWaterPropertyMapper.getList(null,customerId,siteId);
|
|
|
+ //3.查找结算方式集合
|
|
|
+ List<PaySysDictSelectDto> settlementList = paySysDictMapper.getAll(null,null,"结算方式",siteId,customerId);
|
|
|
+ //4.查找证件类型集合
|
|
|
+ List<PaySysDictSelectDto> cardList = paySysDictMapper.getAll(null,null,"证件类型",siteId,customerId);
|
|
|
+ //5.查找机构类型集合
|
|
|
+ List<OrganizationDto> organizationList = organizationMapper.findListForCustomer(loginUser.getCustomerId());
|
|
|
+ //6.查找住房类型集合
|
|
|
+ List<PaySysDictSelectDto> houseList = paySysDictMapper.getAll(null,null,"住房类型",siteId,customerId);
|
|
|
+ //7.查找开户分组集合
|
|
|
+ List<PaySysDictSelectDto> customerList = paySysDictMapper.getAll(null,null,"开户分组",siteId,customerId);
|
|
|
+ //列表数据将存储到指定的excel文件路径
|
|
|
+ FileOutputStream out = new FileOutputStream(filePath);
|
|
|
+ //这里的context是jxls框架上的context内容
|
|
|
+ org.jxls.common.Context context = new org.jxls.common.Context();
|
|
|
+ InputStream in = this.getClass().getClassLoader().getResourceAsStream("excel/batchOpenAccountTemplate.xlsx");
|
|
|
+ context.putVar("meterInfoList", meterInfoList);
|
|
|
+ context.putVar("propertyList", propertyList);
|
|
|
+ context.putVar("settlementList", settlementList);
|
|
|
+ context.putVar("cardList", cardList);
|
|
|
+ context.putVar("organizationList", organizationList);
|
|
|
+ context.putVar("houseList", houseList);
|
|
|
+ context.putVar("customerList", customerList);
|
|
|
+ //将List<Exam>列表数据按照模板文件中的格式生成到scoreOutput.xls文件中
|
|
|
+ JxlsHelper.getInstance().processTemplate(in, out, context);
|
|
|
+ log.info("save file success");
|
|
|
+
|
|
|
+
|
|
|
+ //下面步骤为浏览器下载部分
|
|
|
+ //指定数据生成后的文件输入流(将上述out的路径作为文件的输入流)
|
|
|
+ FileInputStream fileInputStream = new FileInputStream(filePath);
|
|
|
+ //导出excel文件,设置文件名
|
|
|
+ String filename = URLEncoder.encode( "批量开户导入模板.xlsx", "UTF-8");
|
|
|
+ //设置下载头
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + filename);
|
|
|
+ ServletOutputStream outputStream = response.getOutputStream();
|
|
|
+
|
|
|
+ //将文件写入浏览器
|
|
|
+ byte[] bys = new byte[fileInputStream.available()];
|
|
|
+ fileInputStream.read(bys);
|
|
|
+ outputStream.write(bys);
|
|
|
+ outputStream.flush();
|
|
|
+ outputStream.close();
|
|
|
+
|
|
|
System.out.println("Download the song successfully!");
|
|
|
}
|
|
|
catch (Exception e) {
|