Parcourir la source

Merge remote-tracking branch 'origin/0727' into 0727

609324174@qq.com il y a 4 ans
Parent
commit
d4f8954990
20 fichiers modifiés avec 163 ajouts et 84 suppressions
  1. 3 3
      smart-city-platform/src/main/java/com/bz/smart_city/advice/LogAdvice.java
  2. 3 4
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayPrintInvoiceController.java
  3. 18 2
      smart-city-platform/src/main/java/com/bz/smart_city/controller/system/OperationLogController.java
  4. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/OperationLogMapper.java
  5. 5 1
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayBaseAccountSelectAccountnumberDto.java
  6. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeInvoicePrintDto.java
  7. 5 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayMeter.java
  8. 0 4
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/archives/PayBaseCustomerandmeterrela.java
  9. 5 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/OperationLogService.java
  10. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/UserService.java
  11. 32 13
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/OperationLogServiceImpl.java
  12. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/UserServiceImpl.java
  13. 5 23
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/IssueElectronicInvoiceServiceImpl.java
  14. 3 3
      smart-city-platform/src/main/java/com/bz/smart_city/service/importfile/AsyncTaskImportService.java
  15. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/IssueElectronicInvoiceService.java
  16. 69 18
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/impl/PayBaseCustomerandmeterrelaServiceImpl.java
  17. BIN
      smart-city-platform/src/main/resources/excel/batchOpenAccountTemplate.xlsx
  18. 2 2
      smart-city-platform/src/main/resources/mapper/OperationLogMapper.xml
  19. 1 2
      smart-city-platform/src/main/resources/mapper/PayBaseCustomerandmeterrelaMapper.xml
  20. 6 1
      smart-city-platform/src/main/resources/mapper/pay/PayBaseAccountMapper.xml

+ 3 - 3
smart-city-platform/src/main/java/com/bz/smart_city/advice/LogAdvice.java

@@ -82,10 +82,10 @@ public class LogAdvice {
 				sysLogs.setRemark(e.getMessage());
 				throw e;
 			} finally {
-				if (sysLogs.getUserId() != null) {
+//				if (sysLogs.getUserId() != null) {
 				sysLogs.setCreateTime(LocalDateTime.now());
-					sysLogsService.insertSelective(sysLogs);
-				}
+//					sysLogsService.insertSelective(sysLogs);
+//				}
 			}
 		}else {
 			return joinPoint.proceed();

+ 3 - 4
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayPrintInvoiceController.java

@@ -46,9 +46,8 @@ public class PayPrintInvoiceController {
             @ApiParam(value = "站点ID", required = false) @RequestParam(required = false) String siteId,
             @ApiParam(value = "水司ID", required = false) @RequestParam(required = false) String customerId,
             @ApiParam(value = "用户编号", required = true) @RequestParam(required = true) String userCode,
-            @ApiParam(value = "缴费流水号", required = true) @RequestParam(required = true) String payseriesno,
-            @ApiParam(value = "email", required = true) @RequestParam(required = true) String email) {
-        ReturnPrintResultDto returnPrintResultDto = issueElectronicInvoiceService.requestPrint(siteId,customerId,"1", userCode, payseriesno, null,email);
+            @ApiParam(value = "缴费流水号", required = true) @RequestParam(required = true) String payseriesno) {
+        ReturnPrintResultDto returnPrintResultDto = issueElectronicInvoiceService.requestPrint(siteId,customerId,"1", userCode, payseriesno, null);
         return new AjaxMessage<>(ResultStatus.OK, returnPrintResultDto);
     }
 
@@ -59,7 +58,7 @@ public class PayPrintInvoiceController {
             @ApiParam(value = "水司ID", required = false) @RequestParam(required = false) String customerId,
             @ApiParam(value = "用户编号", required = true) @RequestParam(required = true) String userCode,
             @ApiParam(value = "票据ID", required = true) @RequestParam(required = true) String invoicePrintId) {
-        ReturnPrintResultDto returnPrintResultDto = issueElectronicInvoiceService.requestPrint(siteId, customerId, "2", null, null, invoicePrintId, null);
+        ReturnPrintResultDto returnPrintResultDto = issueElectronicInvoiceService.requestPrint(siteId,customerId,"2", null, null, invoicePrintId);
         return new AjaxMessage<>(ResultStatus.OK, returnPrintResultDto);
     }
     @ApiOperation(value = "发票列表")

+ 18 - 2
smart-city-platform/src/main/java/com/bz/smart_city/controller/system/OperationLogController.java

@@ -34,6 +34,7 @@ public class OperationLogController {
     @ApiOperation(value = "查询操作日志分页")
     public AjaxMessage<Pagination<OperationLog>> getPage(
             @ApiParam(value = "用户名", required = false) @RequestParam(required = false) String username,
+            @ApiParam(value = "操作名称", required = false) @RequestParam(required = false) String operationName,
             @ApiParam(value = "操作内容", required = false) @RequestParam(required = false) String content,
             @ApiParam(value = "手机号", required = false) @RequestParam(required = false) String mobilephone,
             @ApiParam(value = "开始时间 格式:yyyyMMddHHmmss", required = false) @RequestParam(required = false) @DateTimeFormat(pattern = "yyyyMMddHHmmss") LocalDateTime startDate,
@@ -41,7 +42,7 @@ public class OperationLogController {
             @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,
             @ApiParam(value = "条数,非必传,默认15条", required = false, defaultValue = "15") @RequestParam(required = false, defaultValue = "15") int pageSize
     ){
-        Pagination<OperationLog> pageInfo = operationLogService.getPage(username,content, startDate, endDate, pageNum, pageSize,mobilephone);
+        Pagination<OperationLog> pageInfo = operationLogService.getPage(username, operationName,content, startDate, endDate, pageNum, pageSize,mobilephone);
         return new AjaxMessage<>(ResultStatus.OK, pageInfo);
     }
 
@@ -59,12 +60,27 @@ public class OperationLogController {
     @ApiOperation(value = "操作日志导出excel")
     public void getExcel(
             @ApiParam(value = "用户名", required = false) @RequestParam(required = false) String username,
+            @ApiParam(value = "操作名称", required = false) @RequestParam(required = false) String operationName,
             @ApiParam(value = "操作内容", required = false) @RequestParam(required = false) String content,
             @ApiParam(value = "手机号码", required = false) @RequestParam(required = false) String mobilephone,
             @ApiParam(value = "开始时间 格式:yyyyMMddHHmmss", required = false) @RequestParam(required = false) @DateTimeFormat(pattern = "yyyyMMddHHmmss") LocalDateTime startDate,
             @ApiParam(value = "开始时间 格式:yyyyMMddHHmmss", required = false) @RequestParam(required = false) @DateTimeFormat(pattern = "yyyyMMddHHmmss") LocalDateTime endDate,
             HttpServletResponse httpServletResponse
     ) {
-        operationLogService.getExcel(username,content, startDate, endDate, mobilephone, httpServletResponse);
+        operationLogService.getExcel(username, operationName,content, startDate, endDate, mobilephone, httpServletResponse);
+    }
+
+    @GetMapping("/getPayfeeExcel")
+    @ApiOperation(value = "缴费操作日志导出excel")
+    public void getPayfeeExcel(
+            @ApiParam(value = "用户名", required = false) @RequestParam(required = false) String username,
+            @ApiParam(value = "操作名称", required = false) @RequestParam(required = false) String operationName,
+            @ApiParam(value = "操作内容", required = false) @RequestParam(required = false) String content,
+            @ApiParam(value = "手机号码", required = false) @RequestParam(required = false) String mobilephone,
+            @ApiParam(value = "开始时间 格式:yyyyMMddHHmmss", required = false) @RequestParam(required = false) @DateTimeFormat(pattern = "yyyyMMddHHmmss") LocalDateTime startDate,
+            @ApiParam(value = "开始时间 格式:yyyyMMddHHmmss", required = false) @RequestParam(required = false) @DateTimeFormat(pattern = "yyyyMMddHHmmss") LocalDateTime endDate,
+            HttpServletResponse httpServletResponse
+    ) {
+        operationLogService.getPayfeeExcel(username, operationName,content, startDate, endDate, mobilephone, httpServletResponse);
     }
 }

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dao/OperationLogMapper.java

@@ -15,6 +15,6 @@ public interface OperationLogMapper {
     int updateByPrimaryKeySelective(OperationLog record);
 
     List<OperationLog> getList(@Param("siteId") Integer siteId, @Param("programItems") List<ProgramItem> programItems,
-                               @Param("username") String username,  @Param("content") String content,
+                               @Param("username") String username, @Param("operationName") String operationName, @Param("content") String content,
                                @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate,@Param("mobilephone")String mobilephone);
 }

+ 5 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayBaseAccountSelectAccountnumberDto.java

@@ -28,7 +28,11 @@ public class PayBaseAccountSelectAccountnumberDto {
     private String	idTypeName	;
     @ApiModelProperty(example = "深圳宝安",notes = "客户地址")
     private String address	;
-    @ApiModelProperty(example = "1",notes = "数表数")
+    @ApiModelProperty(example = "123@qq.com", notes = "邮箱")
+    private String email;
+    @ApiModelProperty(example = "1232", notes = "公司税号")
+    private String vatno;
+    @ApiModelProperty(example = "1",notes = "水表数")
     private int waterNumber;
     @ApiModelProperty(example = "12.2",notes = "用水余额(元)")
     private BigDecimal remaining;

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeInvoicePrintDto.java

@@ -37,7 +37,7 @@ public class PayfeeInvoicePrintDto {
     private LocalDateTime printDate;
     @ApiModelProperty(value = "价税合计")
     private Double totalPrintAmount;
-    @ApiModelProperty(value = "发票状态: 0待生成  1 正常  3 已冲红  4 失败")
+    @ApiModelProperty(value = "发票状态 0:待生成 1:正常 2: 开票中(待生成) 3:已冲红 4:开票失败  5:已作废")
     private Integer state;
     @ApiModelProperty(value="发票状态")
     private String stateLabel;

+ 5 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayMeter.java

@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.time.LocalDateTime;
 
 /**
@@ -36,5 +37,9 @@ public class PayMeter {
     private BigDecimal initialData;
     @ApiModelProperty(example = "12.58",value = "当前读数")
     private BigDecimal CurrData;
+    @ApiModelProperty(example = "1",value = "客户ID")
+    public BigInteger accountId;
+    @ApiModelProperty(example = "1",value = "水表ID")
+    public BigInteger deviceId;
 
 }

+ 0 - 4
smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/archives/PayBaseCustomerandmeterrela.java

@@ -2,7 +2,6 @@ package com.bz.smart_city.entity.pay.archives;
 
 import com.bz.smart_city.entity.ProgramItem;
 import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -85,9 +84,6 @@ public class PayBaseCustomerandmeterrela {
 
     @ApiModelProperty(value = "电话号码", position = 30)
     private String telephone;
-    @JsonIgnore
-    @ApiModelProperty(value = "邮箱地址", position = 33)
-    private String email;
     @ApiModelProperty(value = "用水性质名称", position = 31)
     private String propertyName;
 

+ 5 - 2
smart-city-platform/src/main/java/com/bz/smart_city/service/OperationLogService.java

@@ -13,13 +13,16 @@ public interface OperationLogService {
 
     int updateByPrimaryKeySelective(OperationLog record);
 
-    Pagination<OperationLog> getPage(String username,  String content, LocalDateTime startDate,
+    Pagination<OperationLog> getPage(String username, String operationName, String content, LocalDateTime startDate,
                                      LocalDateTime endDate, int pageNum, int pageSize,String mobilephone);
 
     void add(OperationLog operationLog);
 
-    void getExcel(String username,  String content, LocalDateTime startDate, LocalDateTime endDate,String mobilephone, HttpServletResponse httpServletResponse);
+    void getExcel(String username, String operationName, String content, LocalDateTime startDate, LocalDateTime endDate,String mobilephone, HttpServletResponse httpServletResponse);
 
     void addMobileOperationLog(OperationLog operationLog);
+
+    void getPayfeeExcel(String username, String operationName, String content, LocalDateTime startDate, LocalDateTime endDate,String mobilephone, HttpServletResponse httpServletResponse);
+
 }
 

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/UserService.java

@@ -116,5 +116,5 @@ public interface UserService {
 
     void bindOpenId(String openId);
 
-    User findUserByName(String name, BigInteger sitId);
+    User findUserByName(String name, BigInteger customerId);
 }

+ 32 - 13
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/OperationLogServiceImpl.java

@@ -47,12 +47,12 @@ public class OperationLogServiceImpl implements OperationLogService {
     }
 
     @Override
-    public Pagination<OperationLog> getPage(String username,  String content,
+    public Pagination<OperationLog> getPage(String username, String operationName, String content,
                                             LocalDateTime startDate, LocalDateTime endDate, int pageNum, int pageSize,String mobilephone) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         PageHelper.startPage(pageNum, pageSize);
         List<OperationLog> list = operationLogMapper.getList(loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), username,
-                 content, startDate, endDate,mobilephone);
+                operationName, content, startDate, endDate,mobilephone);
         return new Pagination<>(list);
     }
 
@@ -94,16 +94,39 @@ public class OperationLogServiceImpl implements OperationLogService {
     }
 
     @Override
-    public void getExcel(String username,  String content, LocalDateTime startDate, LocalDateTime endDate,String mobilephone, HttpServletResponse httpServletResponse) {
+    public void getExcel(String username, String operationName, String content, LocalDateTime startDate, LocalDateTime endDate,String mobilephone, HttpServletResponse httpServletResponse) {
         LoginUser loginUser = UserUtil.getCurrentUser();
-        List<OperationLog> list = operationLogMapper.getList(loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), username, content, startDate, endDate,mobilephone);
+        List<OperationLog> list = operationLogMapper.getList(loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), username, operationName, content, startDate, endDate,mobilephone);
         String title = "操作日志";
-        String[] rowsName;
-        if(loginUser.getSiteType() != null && loginUser.getSiteType() == 2){
-            rowsName = new String[]{"序号", "操作时间", "用户名","手机号", "操作内容"};
-        }else{
-            rowsName= new String[]{"序号", "时间", "用户名","手机号", "操作", "操作前", "操作后"};
+        String[] rowsName = new String[]{"序号", "时间", "用户名","手机号", "操作", "操作前", "操作后"};
+        List<Object[]> dataList = newArrayList();
+        Object[] objs = null;
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        for (int i = 0; i < list.size(); i++) {
+            OperationLog operationLog = list.get(i);
+            objs = new Object[rowsName.length];
+            objs[0] = (i + 1);
+            objs[1] = operationLog.getCreateDate().format(df);
+            objs[2] = operationLog.getUsername();
+            objs[3] = operationLog.getMobilePhone();
+            objs[4] = operationLog.getOperationName();
+            objs[5] = operationLog.getOldData().replaceAll("&", ",\r\n");
+            objs[6] = operationLog.getNewData().replaceAll("&", ",\r\n");
+            dataList.add(objs);
         }
+        ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
+        try {
+            excelUtil.export(httpServletResponse);
+        } catch (Exception e) {
+            throw new ServiceException(-900, "导出异常");
+        }
+    }
+
+    public void getPayfeeExcel(String username, String operationName, String content, LocalDateTime startDate, LocalDateTime endDate,String mobilephone, HttpServletResponse httpServletResponse) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        List<OperationLog> list = operationLogMapper.getList(loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), username, operationName, content, startDate, endDate,mobilephone);
+        String title = "操作日志";
+        String[] rowsName = new String[]{"序号", "操作时间", "用户名","手机号", "操作内容"};
         List<Object[]> dataList = newArrayList();
         Object[] objs = null;
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@@ -115,10 +138,6 @@ public class OperationLogServiceImpl implements OperationLogService {
             objs[2] = operationLog.getUsername();
             objs[3] = operationLog.getMobilePhone();
             objs[4] = operationLog.getOperationName();
-            if(loginUser.getSiteType() == null || loginUser.getSiteType() != 2) {
-                objs[5] = operationLog.getOldData().replaceAll("&", ",\r\n");
-                objs[6] = operationLog.getNewData().replaceAll("&", ",\r\n");
-            }
             dataList.add(objs);
         }
         ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/UserServiceImpl.java

@@ -615,7 +615,7 @@ public class UserServiceImpl implements UserService {
     }
 
     @Override
-    public User findUserByName(String name, BigInteger sitId) {
-        return userMapper.findUserByName(name,sitId);
+    public User findUserByName(String name, BigInteger customerId) {
+        return userMapper.findUserByName(name,customerId);
     }
 }

+ 5 - 23
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/IssueElectronicInvoiceServiceImpl.java

@@ -109,27 +109,16 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
      * @Author:
      * @Date: 2020/7/28
      */
-    public ReturnPrintResultDto requestPrint(String siteId, String customerId, String kpType, String userCode, String payseriesno, String invoicePrintId,String email) {
+    public ReturnPrintResultDto requestPrint(String siteId, String customerId, String kpType, String userCode, String payseriesno, String invoicePrintId) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         ReturnPrintResultDto returnPrintResultDto = new ReturnPrintResultDto();//开票返回结果信息
-
+        String name = loginUser.getName();//操作员姓名
         if(loginUser==null) {
-             User user = userService.findUserByName("系统操作", BigInteger.valueOf(Long.parseLong(siteId)));
-             loginUser = new LoginUser();
-             if(user!=null)
-             {
-                 loginUser.setName("系统操作");
-                 loginUser.setId(user.getId());
-             }else
-             {
-                 returnPrintResultDto.setResult("1");//开票失败
-                 returnPrintResultDto.setMsg("开票失败,失败原因:系统未配置操作员");
-                 return returnPrintResultDto;
-             }
+            // User user = userService.findUserByName("系统操作", BigInteger.valueOf(Long.parseLong(siteId)));
+            //loginUser = new LoginUser();
             loginUser.setCustomerId(Integer.valueOf(customerId));
             loginUser.setSiteId(Integer.valueOf(siteId));
         }
-        String name = loginUser.getName();//操作员姓名
         BaseClosingAccountInfo baseClosingAccountInfo = baseClosingAccountInfoService.getCurrentCloseInfo(loginUser.getSiteId(),loginUser.getCustomerId());
         if(baseClosingAccountInfo==null)
         {
@@ -261,14 +250,7 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
             return returnPrintResultDto;
         }
         payInvoiceOrderDto.setDetail(orderDetailDtos);
-        if(email!=null&& email.length()>0)
-            payInvoiceOrderDto.setEmail(email);
-        else {
-            if (payBaseAccount.getEmail() != null)
-                payInvoiceOrderDto.setEmail(payBaseAccount.getEmail());
-            else
-                payInvoiceOrderDto.setEmail(invoiceParam.get("saleEmail"));
-        }
+        payInvoiceOrderDto.setEmail(invoiceParam.get("saleEmail"));
         payEleInvoiceDto.setOrder(payInvoiceOrderDto);
         //发送开票请求
         String jsonsString = DESDZFP.encrypt(JSON.toJSONString(payEleInvoiceDto));

+ 3 - 3
smart-city-platform/src/main/java/com/bz/smart_city/service/importfile/AsyncTaskImportService.java

@@ -954,7 +954,7 @@ public class AsyncTaskImportService {
                             Cell idcardnoCell = row.getCell(10);//证件号码
                             Cell housetypeCell = row.getCell(11);//住房类型
                             Cell vatnoCell = row.getCell(12);//公司税号
-                            Cell emailCell = row.getCell(13);//电子邮箱
+                            Cell emailCell = row.getCell(13);//邮箱
                             //Cell c_remark = row.getCell(11);//备注
 
 
@@ -1026,8 +1026,8 @@ public class AsyncTaskImportService {
 
                             if(property == null){
                                 failTime++ ;
-                                msg +="客户编码【"+accountnumber+"】用水性质不能为空,";
-                                log.info("客户编码【"+accountnumber+"】用水性质不能为空,");
+                                msg +="客户编码【"+accountnumber+"】住房类型不能为空,";
+                                log.info("客户编码【"+accountnumber+"】住房类型不能为空,");
                                 //c_remark.setCellValue("客户编码【"+accountnumber+"】住房类型不能为空,");
                                 continue;
                             }

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/IssueElectronicInvoiceService.java

@@ -10,5 +10,5 @@ import com.bz.smart_city.dto.pay.ReturnPrintResultDto;
  * @Version V1.0
  **/
 public interface IssueElectronicInvoiceService {
-    ReturnPrintResultDto requestPrint(String siteId, String customerId,String kpType, String userCode, String payseriesno, String invoicePrintId,String email);
+    ReturnPrintResultDto requestPrint(String siteId, String customerId,String kpType, String userCode, String payseriesno, String invoicePrintId);
 }

+ 69 - 18
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/impl/PayBaseCustomerandmeterrelaServiceImpl.java

@@ -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) {

BIN
smart-city-platform/src/main/resources/excel/batchOpenAccountTemplate.xlsx


+ 2 - 2
smart-city-platform/src/main/resources/mapper/OperationLogMapper.xml

@@ -156,8 +156,8 @@
           </foreach>
         </if>
         <if test="username != null and username != ''"> AND sol.username LIKE concat('%',#{username},'%')</if>
-        <if test="content != null and content != ''"> AND (sol.operation_name LIKE concat('%',#{content},'%')
-         or (sol.old_data LIKE concat('%',#{content},'%') or sol.new_data LIKE concat('%',#{content},'%')))</if>
+        <if test="operationName != null and operationName != ''"> AND sol.operation_name LIKE concat('%',#{operationName},'%')</if>
+        <if test="content != null and content != ''"> AND (sol.old_data LIKE concat('%',#{content},'%') or sol.new_data LIKE concat('%',#{content},'%'))</if>
         <if test="startDate != null"> and sol.create_date <![CDATA[ >= ]]> #{startDate}</if>
         <if test="endDate != null"> and sol.create_date <![CDATA[ <= ]]> #{endDate}</if>
          <if test="mobilephone != null and mobilephone != ''">AND sol.mobilephone LIKE concat('%',#{mobilephone},'%')</if>

+ 1 - 2
smart-city-platform/src/main/resources/mapper/PayBaseCustomerandmeterrelaMapper.xml

@@ -617,8 +617,7 @@
         account.telephone as "telephone",
         account.address as "address",
         customer.vatno as "vatno",
-        customer.bankaccount as "bankaccount",
-        account.email as "email"
+        customer.bankaccount as "bankaccount"
         from pay_base_customerandmeterrela customer
         left join pay_base_account account on customer.account_id = account.id
         <where>

+ 6 - 1
smart-city-platform/src/main/resources/mapper/pay/PayBaseAccountMapper.xml

@@ -344,11 +344,14 @@
             pba.telephone,
             pba.idcardno,
             pba.address,
-            pba.id as "accountId"
+            pba.id as "accountId",
+            pba.email,
+            pbc.vatno
         from pay_base_account pba
         left join pay_sys_dict psd on pba.idtype=psd.`value` and psd.type='证件类型' and psd.site_id=#{siteId} and psd.customer_id=#{customerId}
         left join pay_pay_rechargeaccount ppr on pba.accountnumber=ppr.accountnumber and ppr.site_id=#{siteId} and ppr.customer_id=#{customerId}
         left join pay_sys_dict psd2 on pba.state = psd2.`value` and psd2.type='客户状态' and psd2.site_id=#{siteId} and psd2.customer_id=#{customerId}
+        left join pay_base_customerandmeterrela pbc on pbc.account_id = pba.id
         where pba.accountnumber = #{queryInfo} and pba.site_id=#{siteId} and pba.customer_id=#{customerId}
 
     </select>
@@ -474,6 +477,8 @@
             scinstall.install_time as installDate,
             concat(sdm.`name`,'/',sdt.equipment_type,'/',sdt.model) as deviceType,
             pba.accountnumber as accountnumber,
+            pba.id as accountId,
+            scd.id as deviceId,
             scinstall.is_accepted state,
             (case scinstall.is_accepted  WHEN  2 then '已开户' when 1 then '待开户' else '待验收' end) stateName,
             IFNULL(rd.reading,0) as CurrData