Browse Source

Merge branch '0617' of http://114.135.61.188:53000/ZONIOT/water-iot into 0617

chenlong 4 years ago
parent
commit
e239eb62ad
16 changed files with 497 additions and 314 deletions
  1. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/commom/security/WebSecurityConfig.java
  2. 21 7
      smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java
  3. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/DeviceTypeMapper.java
  4. 12 10
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/archives/PayBaseCustomerandmeterrelaMapper.java
  5. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceDataDto.java
  6. 12 12
      smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceDto.java
  7. 11 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/UserArchivesInfo.java
  8. 16 14
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java
  9. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceTypeService.java
  10. 132 34
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java
  11. 3 3
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceTypeServiceImpl.java
  12. 96 50
      smart-city-platform/src/main/java/com/bz/smart_city/service/importfile/AsyncTaskImportService.java
  13. BIN
      smart-city-platform/src/main/resources/excel/batchOpenAccountTemplate.xlsx
  14. 1 1
      smart-city-platform/src/main/resources/mapper/DeviceTypeMapper.xml
  15. 164 160
      smart-city-platform/src/main/resources/mapper/PayBaseCustomerandmeterrelaMapper.xml
  16. 21 20
      smart-city-platform/src/main/resources/mapper/pay/PayRechargeaccountMapper.xml

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/commom/security/WebSecurityConfig.java

@@ -99,7 +99,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/watermeter/getMeterReadData","/watermeter/getDeviceCustomerInfo","/watermeter/getPeriodMeterReadData","/data/clearingData","/data/meterReadData")
                 .antMatchers("/apply/register","/apply/detail","/apply/approve")
                 .antMatchers("/payFee/payFee")
-                .antMatchers("/waterMeter/getMeterByDeviceNo");
+                .antMatchers("/waterMeter/getMeterByDeviceNo")
+                .antMatchers("/device/synArchies");
     }
 
 

+ 21 - 7
smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java

@@ -72,16 +72,16 @@ public class DeviceController {
     @GetMapping("/simpleQueryDeviceList")
     @ApiOperation(value = "简易设备查询接口")
     public AjaxMessage<Pagination<DeviceDto>> simpleQueryDeviceList(
-    		@ApiParam(value = "场景", required = true) @RequestParam(required = true) Integer sysId,
-    		@ApiParam(value = "设备编号", required = false) @RequestParam(required = false) String deviceNo,
-    		@ApiParam(value = "水表电子号", required = false) @RequestParam(required = false) String waterMeterNo,
-    		@ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,
+            @ApiParam(value = "场景", required = true) @RequestParam(required = true) Integer sysId,
+            @ApiParam(value = "设备编号", required = false) @RequestParam(required = false) String deviceNo,
+            @ApiParam(value = "水表电子号", required = false) @RequestParam(required = false) String waterMeterNo,
+            @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){
-    	LoginUser loginUser = UserUtil.getCurrentUser();
-    	Pagination<DeviceDto> pageInfo = deviceService.simpleQueryDeviceList(loginUser.getCurrentSiteId(), sysId, deviceNo, waterMeterNo, pageNum, pageSize);
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        Pagination<DeviceDto> pageInfo = deviceService.simpleQueryDeviceList(loginUser.getCurrentSiteId(), sysId, deviceNo, waterMeterNo, pageNum, pageSize);
         return new AjaxMessage<>(ResultStatus.OK, pageInfo);
     }
-    
+
     @GetMapping("/getDeviceListExcel")
     @ApiOperation(value = "导出设备列表excel")
     public void getDeviceListExcel(
@@ -199,6 +199,7 @@ public class DeviceController {
         return new AjaxMessage(ResultStatus.OK);
     }
 
+
     @ResponseBody
     @PutMapping("edit")
     //@PreAuthorize("hasAuthority('sys:device:edit')")
@@ -274,4 +275,17 @@ public class DeviceController {
         return new AjaxMessage(ResultStatus.OK);
     }
 
+
+    @ResponseBody
+    @PostMapping("synArchies")
+    public String synArchies(@RequestBody String json){
+        //接口调用插入表信息
+        String msg = "";
+        try{
+            msg = deviceService.synArchives(json);
+        }catch (Exception ex){
+            ex.printStackTrace();
+        }
+        return msg;
+    }
 }

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

@@ -41,7 +41,7 @@ public interface DeviceTypeMapper {
 
     List<DeviceTypeDto> findByIds(@Param("deviceTypeIds") List<Integer> deviceTypeIds);
 
-    DeviceTypeDto getByName(@Param("deviceTypeName") String deviceTypeName);
+    DeviceTypeDto getByName(@Param("deviceTypeName") String deviceTypeName, @Param("deviceTypeModel") String deviceTypeModel);
 
     DeviceTypeDto getById(@Param("id") Integer id);
 }

+ 12 - 10
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/archives/PayBaseCustomerandmeterrelaMapper.java

@@ -39,16 +39,16 @@ public interface PayBaseCustomerandmeterrelaMapper {
     public PayPayRechargeaccount findByAccount(@Param("accountId")BigInteger accountId);
 
     public int updateCustomerState(@Param("state")Integer state, @Param("updateBy")Integer updateBy, @Param("date")Date date,
-                                    @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("id")BigInteger id);
+                                   @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("id")BigInteger id);
 
     public int updateRechargeAccountState(@Param("state")Integer state, @Param("updateBy")Integer updateBy, @Param("date")Date date,
-                                    @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("id")BigInteger id);
+                                          @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("id")BigInteger id);
 
     public int updateAccountState(@Param("state")Integer state, @Param("updateBy")Integer updateBy, @Param("date")Date date,
-                                    @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("id")BigInteger id);
+                                  @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("id")BigInteger id);
 
     public int updateDeviceState(@Param("state")Integer state, @Param("updateBy")Integer updateBy, @Param("date")Date date,
-                                  @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("metercode") String metercode);
+                                 @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("metercode") String metercode);
 
     public List<PayBaseCustomerandmeterrela> getList (@Param("condition")String condition,@Param("waterPropertyId")BigInteger waterPropertyId,
                                                       @Param("businessstate")Integer businessstate,@Param("calculateway")Integer calculateway,@Param("siteId") Integer siteId, @Param("customerId")Integer customerId);
@@ -63,14 +63,14 @@ public interface PayBaseCustomerandmeterrelaMapper {
     public List<PayAccountInfo> selectAccountMeterInfo (@Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("metercode")String metercode);
 
     public int updateAccountInfo(@Param("accountname")String accountname,@Param("accountnumber")String accountnumber,@Param("metercode")String metercode,@Param("idtype")Integer idtype,
-                              @Param("idcardno")String idcardno,@Param("telephone")String telephone,@Param("officeId")BigInteger officeId,
-                              @Param("housetype")Integer housetype,@Param("customergroup")Integer customergroup,@Param("updateBy")Integer updateBy,
-                              @Param("date")Date date,@Param("siteId") Integer siteId, @Param("customerId")Integer customerId);
+                                 @Param("idcardno")String idcardno,@Param("telephone")String telephone,@Param("officeId")BigInteger officeId,
+                                 @Param("housetype")Integer housetype,@Param("customergroup")Integer customergroup,@Param("updateBy")Integer updateBy,
+                                 @Param("date")Date date,@Param("siteId") Integer siteId, @Param("customerId")Integer customerId);
 
     public int updateCustomerInfo(@Param("accountname")String accountname,@Param("accountnumber")String accountnumber,@Param("metercode")String metercode,@Param("idtype")Integer idtype,
-                              @Param("idcardno")String idcardno,@Param("telephone")String telephone,@Param("officeId")BigInteger officeId,
-                              @Param("housetype")Integer housetype,@Param("customergroup")Integer customergroup,@Param("updateBy")Integer updateBy,
-                              @Param("date")Date date,@Param("siteId") Integer siteId, @Param("customerId")Integer customerId);
+                                  @Param("idcardno")String idcardno,@Param("telephone")String telephone,@Param("officeId")BigInteger officeId,
+                                  @Param("housetype")Integer housetype,@Param("customergroup")Integer customergroup,@Param("updateBy")Integer updateBy,
+                                  @Param("date")Date date,@Param("siteId") Integer siteId, @Param("customerId")Integer customerId);
 
     public List<PayCustomerDto> getAll (PayBaseCustomerandmeterrela payBaseCustomerandmeterrela);
 
@@ -95,4 +95,6 @@ public interface PayBaseCustomerandmeterrelaMapper {
                                                        @Param("accountnumber")String accountnumber,@Param("metercode")String metercode);
 
     public Integer queryMeterState( @Param("customerId")Integer customerId,@Param("accountId")BigInteger accountId);
+
+    public Organization getParentOfficeId( @Param("siteId")Integer siteId,@Param("id")Integer id,@Param("name") String name);
 }

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceDataDto.java

@@ -42,4 +42,8 @@ public class DeviceDataDto {
 
     @ApiModelProperty(value = "客户id", position = 12)
     private Integer customerId;
+    @ApiModelProperty(value = "agent名称", position = 13)
+    private String agentIdentifier;
+    @ApiModelProperty(value = "站点id", position = 14)
+    private Integer siteId;
 }

+ 12 - 12
smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceDto.java

@@ -40,25 +40,25 @@ public class DeviceDto extends Device {
 
     @ApiModelProperty(value = "省", position = 107)
     private Integer province;
-    
+
     @ApiModelProperty(value = "省名称", position = 107)
-    private String provinceName ; 
-    
+    private String provinceName ;
+
     @ApiModelProperty(value = "市", position = 108)
     private Integer city;
-    
+
     @ApiModelProperty(value = "市名称", position = 108)
-    private String cityName ; 
-    
+    private String cityName ;
+
     @ApiModelProperty(value = "区", position = 109)
     private Integer region ;
 
     @ApiModelProperty(value = "区名称", position = 109)
-    private String regionName ; 
-    
+    private String regionName ;
+
     @ApiModelProperty(value = "小区", position = 110)
     private Integer community;
-    
+
     @ApiModelProperty(value = "小区", position = 110)
     private String communityName;
 
@@ -91,13 +91,13 @@ public class DeviceDto extends Device {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "验收时间", position = 119)
     private LocalDateTime acceptTime;
-    
+
     @ApiModelProperty(value = "新表起度", position = 120)
     private String newMeterStart;
 
     @ApiModelProperty(value = "水表读数", position = 121)
     private String meterReading;
-    
+
     @ApiModelProperty(value = "安装主键", position = 122)
     private Integer installId ;
 
@@ -109,5 +109,5 @@ public class DeviceDto extends Device {
 
     @ApiModelProperty(value="阀门按钮状态 0:关阀 1:开阀",position = 125)
     private Integer valveButtonStatus = 1;
-    
+
 }

+ 11 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/UserArchivesInfo.java

@@ -0,0 +1,11 @@
+package com.bz.smart_city.entity;
+
+import com.bz.smart_city.dto.DeviceDataDto;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class UserArchivesInfo {
+    private List<DeviceDataDto> list;
+}

+ 16 - 14
smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java

@@ -26,7 +26,7 @@ public interface DeviceService{
     int insertList(List<Device> devices);
 
     int updateByPrimaryKeySelective(Device device);
-    
+
     int countDeviceNumber();
 
     String  getMeterCode(String deviceCode) ;
@@ -34,7 +34,7 @@ public interface DeviceService{
     String  getDeviceCode(String meterCode);
 
     List<DeviceDto> getDeviceList( int pageNum, int pageSize);
-    
+
     DeviceDto getDeviceLastReceiveTime(Long deviceId);
 
     Pagination<DeviceDto> getList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor,
@@ -49,21 +49,23 @@ public interface DeviceService{
 
 
     void exportDeviceListAsXML(Integer sysId,
-                                      Integer buildingId,
-                                      String deviceNo,
-                                      Integer status,
-                                      String locDesc,
-                                      Integer province,
-                                      Integer city,
-                                      Integer region,
-                                      Integer community,
-                                      String errorType,
-                                      Integer customerId,
-                                      Integer days,
-                                      HttpServletResponse httpServletResponse);
+                               Integer buildingId,
+                               String deviceNo,
+                               Integer status,
+                               String locDesc,
+                               Integer province,
+                               Integer city,
+                               Integer region,
+                               Integer community,
+                               String errorType,
+                               Integer customerId,
+                               Integer days,
+                               HttpServletResponse httpServletResponse);
 
     void add(DeviceDataDto deviceDataDto);
 
+    String synArchives(String jsonStirig);
+
     void edit(DeviceDataDto deviceDataDto);
 
     void delete(Long id);

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

@@ -37,5 +37,5 @@ public interface DeviceTypeService {
     
     boolean isWaterChannel(Integer channelId);
 
-    DeviceTypeDto getByName(String deviceTypeName);
+    DeviceTypeDto getByName(String deviceTypeName,String deviceTypeModel);
 }

+ 132 - 34
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java

@@ -107,6 +107,15 @@ public  class DeviceServiceImpl implements DeviceService {
         return deviceMapper.insert(device);
     }
 
+
+    public int insertSynArchives(Device device) {
+        device.setCreateBy("admin");
+        device.setDateCreate(LocalDateTime.now());
+        device.setUpdateBy("admin");
+        device.setDateUpdate(LocalDateTime.now());
+        return deviceMapper.insert(device);
+    }
+
     @Override
     public int insertSelective(Device device) {
         device.setCreateBy(UserUtil.getCurrentUser().getUsername());
@@ -393,6 +402,95 @@ public  class DeviceServiceImpl implements DeviceService {
         log.info("end addDevice,result = " + result);
     }
 
+
+    @Override
+    @Transactional
+    public String synArchives(String jsonStirig){
+        log.info("begin addDevice,deviceDataDto = " + jsonStirig);
+        UserArchivesInfo userArchivesInfo = JSON.parseObject(jsonStirig.toString(),UserArchivesInfo.class);
+        int succ =0;//成功条数
+        int fail =0;//失败条数
+        String failMsg="";//返回失败消息体
+        for(int i=0; i<userArchivesInfo.getList().size(); i++){
+            DeviceDataDto deviceDataDto = userArchivesInfo.getList().get(i);
+            //查询设备类型
+            DeviceType deviceType = deviceTypeMapper.findByid(deviceDataDto.getDeviceType());
+
+            //1、添加设备
+            //LoginUser loginUser = UserUtil.getCurrentUser();
+            int resultDeviceNo = deviceMapper.findByDeviceNoUnique(null, deviceDataDto.getDeviceNo());
+            if (resultDeviceNo > 0) {
+                fail++;
+                failMsg += "【"+deviceDataDto.getDeviceNo()+"】设备编号已经存在";
+                continue;
+            }
+           /* if (deviceDataDto.getWaterMeterNo() != null && !StringUtils.equals("",deviceDataDto.getWaterMeterNo())) {
+                int resultWaterMeterNo = deviceMapper.findByWaterMeterNoUnique(null, deviceDataDto.getWaterMeterNo());
+                if (resultWaterMeterNo > 0) {
+                    fail++;
+                    throw new ServiceException(-900, "水表电子号已经存在");
+                }
+            }*/
+
+            //新增udip平台集成元
+            DeviceTypeDto deviceTypeDto = deviceTypeMapper.getById(deviceDataDto.getDeviceType());
+            String udipId = udipUnitService.saveUdipUnit(deviceDataDto.getDeviceNo(),deviceDataDto.getCustomerId(),deviceTypeDto);
+
+            Device device = new Device();
+            device.setId(idWorker.nextId());
+            device.setDeviceNo(StringUtils.lowerCase(deviceDataDto.getDeviceNo().trim()));
+            device.setDeviceType(deviceDataDto.getDeviceType());
+            device.setSysId(deviceDataDto.getSysId());
+            device.setSiteId(deviceDataDto.getSiteId());
+            device.setBuildingId(deviceDataDto.getBuildingId());
+            device.setFloor(deviceDataDto.getFloor());
+            device.setLocDesc(deviceDataDto.getLocDesc());
+            device.setManufacturerId(deviceType.getManufacturerId());
+            device.setDeviceStatus(5);//未启用
+            device.setStatus(1);
+            device.setXCoordinates(deviceDataDto.getXCoordinates());
+            device.setYCoordinates(deviceDataDto.getYCoordinates());
+            device.setIsTag(deviceDataDto.getXCoordinates() != null && deviceDataDto.getYCoordinates() != null ? 1 : 0);
+            device.setWaterMeterNo(deviceDataDto.getWaterMeterNo());
+            device.setWaterMeterFileNo(deviceDataDto.getWaterMeterFileNo());
+            device.setCustomerId(deviceDataDto.getCustomerId());
+            device.setWaterMeterNo(deviceDataDto.getWaterMeterNo());
+            device.setUdipId(udipId);
+            int result = this.insertSynArchives(device);
+
+
+            Building building = buildingMapper.getBuilding(device.getBuildingId());
+            //2、同步设备维度关系
+            DeviceDimension deviceDimension = new DeviceDimension();
+            deviceDimension.setDeviceId(device.getId());
+            deviceDimension.setProvince(String.valueOf(building.getProvince()));
+            deviceDimension.setCity(String.valueOf(building.getCity()));
+            deviceDimension.setRegion(String.valueOf(building.getRegion()));
+            deviceDimension.setCommunity(String.valueOf(building.getCommunity()));
+            deviceDimension.setBuilding(String.valueOf(building.getId()));
+            deviceDimension.setFloor(String.valueOf(device.getFloor()));
+            deviceDimension.setDevice(device.getDeviceNo());
+            deviceDimension.setCustomer(String.valueOf(device.getCustomerId()));
+            deviceDimension.setStatus(1);
+            deviceDimension.setCreateBy("admin");
+            deviceDimension.setUpdateBy("admin");
+            deviceDimension.setDateCreate(LocalDateTime.now());
+            deviceDimension.setDateUpdate(LocalDateTime.now());
+
+            deviceDimensionMapper.insertSelective(deviceDimension);
+            succ++;
+            log.info("end addDevice,result = " + result);
+        }
+        String msg = "";
+        if(fail >0){
+            msg = "同步档案信息成功【"+succ+"】条,失败【"+fail+"】条,失败原因:"+failMsg+"";
+        }else{
+            msg = "同步档案信息成功【"+succ+"】条";
+        }
+        log.info("synArchives,result = "+msg);
+        return msg;
+    }
+
     @Override
     @Transactional
     public void edit(DeviceDataDto deviceDataDto) {
@@ -1142,40 +1240,40 @@ public  class DeviceServiceImpl implements DeviceService {
     }
 
     @Override
-	public int countDeviceNumber() {
-		Device param = new Device();
-		List<Integer>  statusList = new ArrayList<Integer>(); 
-		statusList.add(1); // 正常
-		statusList.add(2); // 故障
-		statusList.add(4); // 预警
-		param.setDeviceStatusList(statusList);
-		return deviceMapper.countDevice(param);
-	}
-
-	@Override
-	public List<DeviceDto> getDeviceList(int pageNum, int pageSize) {
-		Device param = new Device();
-		List<Integer>  statusList = new ArrayList<Integer>(); 
-		statusList.add(1); // 正常
-		statusList.add(2); // 故障
-		statusList.add(4); // 预警
-		param.setDeviceStatusList(statusList);
-		return deviceMapper.getDeviceList(param, pageNum, pageSize);
-	}
-
-	@Override
-	public DeviceDto getDeviceLastReceiveTime(Long deviceId) {
-		
-		return null;
-	}
-	@Override
-	public Pagination<DeviceDto> simpleQueryDeviceList(Integer siteId, Integer channelId, String deviceNo,
-			String waterMeterNo, int pageNum, int pageSize) {
-    	LoginUser loginUser = UserUtil.getCurrentUser();
+    public int countDeviceNumber() {
+        Device param = new Device();
+        List<Integer>  statusList = new ArrayList<Integer>();
+        statusList.add(1); // 正常
+        statusList.add(2); // 故障
+        statusList.add(4); // 预警
+        param.setDeviceStatusList(statusList);
+        return deviceMapper.countDevice(param);
+    }
+
+    @Override
+    public List<DeviceDto> getDeviceList(int pageNum, int pageSize) {
+        Device param = new Device();
+        List<Integer>  statusList = new ArrayList<Integer>();
+        statusList.add(1); // 正常
+        statusList.add(2); // 故障
+        statusList.add(4); // 预警
+        param.setDeviceStatusList(statusList);
+        return deviceMapper.getDeviceList(param, pageNum, pageSize);
+    }
+
+    @Override
+    public DeviceDto getDeviceLastReceiveTime(Long deviceId) {
+
+        return null;
+    }
+    @Override
+    public Pagination<DeviceDto> simpleQueryDeviceList(Integer siteId, Integer channelId, String deviceNo,
+                                                       String waterMeterNo, int pageNum, int pageSize) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
         PageHelper.startPage(pageNum, pageSize);
         List<DeviceDto> list =  deviceMapper.queryDeviceByNo(siteId,channelId,deviceNo,waterMeterNo,UserUtil.getCurrentSiteProgramItems(loginUser));
-		return new Pagination<>(list);
-	}
+        return new Pagination<>(list);
+    }
     @Override
     public Device deviceDetail(Long deviceId) {
         Device device = deviceMapper.findByDeviceId(deviceId);
@@ -1207,8 +1305,8 @@ public  class DeviceServiceImpl implements DeviceService {
 
     @Override
     public List<Device> findByAccountId(BigInteger accountId) {
-       List<Device> result = deviceMapper.findByAccountId(accountId);
-       return  result;
+        List<Device> result = deviceMapper.findByAccountId(accountId);
+        return  result;
     }
 
     @Override

+ 3 - 3
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceTypeServiceImpl.java

@@ -233,8 +233,8 @@ public class DeviceTypeServiceImpl implements DeviceTypeService {
     }
 
     @Override
-    @Cacheable(value = "deviceTypeName", key = "#deviceTypeName")
-    public DeviceTypeDto getByName(String deviceTypeName) {
-        return deviceTypeMapper.getByName(deviceTypeName);
+    @Cacheable(value = "deviceTypeName", key = "#deviceTypeName + #deviceTypeModel")
+    public DeviceTypeDto getByName(String deviceTypeName,String deviceTypeModel) {
+        return deviceTypeMapper.getByName(deviceTypeName,deviceTypeModel);
     }
 }

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

@@ -212,11 +212,14 @@ public class AsyncTaskImportService {
                             dto.setDoorNo(doorNo);
                             dto.setLocation(doorNo);
 
-                            String deviceTypeName = c_deviceType.getStringCellValue();
-                            if(StringUtils.isBlank(deviceTypeName)) {
+                            String deviceTypeNameTemp = c_deviceType.getStringCellValue();
+                            if(StringUtils.isBlank(deviceTypeNameTemp)) {
                                 continue;
                             }
-                            DeviceTypeDto dt = deviceTypeService.getByName(deviceTypeName);
+                            String[] temp = deviceTypeNameTemp.split("/");
+                            String deviceTypeName = temp[1];
+                            String deviceTypeModel = temp[2];
+                            DeviceTypeDto dt = deviceTypeService.getByName(deviceTypeName,deviceTypeModel);
                             if(dt == null) {
                                 //throw new ServiceException(ResultStatus.DEVICE_TYPE_NOT_EXISTED);
                                 failTime++ ;
@@ -285,12 +288,12 @@ public class AsyncTaskImportService {
                                     c_remark.setCellValue(ResultStatus.DELETE_AND_DOOR_EXISTED.getMessage());
                                 }
                             } catch (ServiceException e){
-                                    if(e.getStatus() == ResultStatus.DEVICE_NO_IS_EXISTED.getStatus()){
-                                        failTime++ ;
-                                        c_remark.setCellValue(e.getMessage());
-                                    }else {
-                                        failTime++ ;
-                                    }
+                                if(e.getStatus() == ResultStatus.DEVICE_NO_IS_EXISTED.getStatus()){
+                                    failTime++ ;
+                                    c_remark.setCellValue(e.getMessage());
+                                }else {
+                                    failTime++ ;
+                                }
                             }catch (Exception e){
                                 failTime++ ;
                                 c_remark.setCellValue("导入异常");
@@ -964,8 +967,14 @@ public class AsyncTaskImportService {
                             //根据用水性质名称寻找用水性质id
                             PayBaseCustomerandmeterrela property = payBaseCustomerandmeterrelaMapper.getWaterPropertyId(loginUser.getSiteId(),loginUser.getCustomerId(),propertyName);
                             //根据机构名称寻找机构id
-                            Organization office = payBaseCustomerandmeterrelaMapper.getOfficeId(loginUser.getSiteId(),officeName);
-
+                            Organization office =  null;
+                            if(StringUtils.isNotBlank(officeName)){
+                                String[] number = officeName.split("/");
+                                office = payBaseCustomerandmeterrelaMapper.getOfficeId(loginUser.getSiteId(), number[0]);
+                                for (int i=1; i<number.length; i++){
+                                    office = payBaseCustomerandmeterrelaMapper.getParentOfficeId(loginUser.getSiteId(),office.getId(),number[i]);
+                                }
+                            }
 
                             if(property == null){
                                 failTime++ ;
@@ -1009,51 +1018,88 @@ public class AsyncTaskImportService {
                                 //c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户未验收,");
                                 continue;
                             }
+                            Integer value = 0;
+                            //判断客户是否销户后在开户
+                            PayBaseCustomerandmeterrela baseCustomer = payBaseCustomerandmeterrelaMapper.queryCancelInfo(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber,metercode);
+                            if(baseCustomer != null && baseCustomer.getBusinessstate() != 1){
+                                //修改开户信息开户状态为已开户
+                                customer.setId(baseCustomer.getId());
+                                customer.setAccountId(accounts.getId());
+                                customer.setAccountnumber(accountnumber);
+                                customer.setAccountname(accountname);
+                                customer.setBusinessstate(1);//1已开户 2 销户 3未开户
+                                value = paySysDictService.getDictValue("结算方式",calculateway,new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                customer.setCalculateway(value);//结算方式
+                                if(value != null && value == 2){
+                                    if(StringUtils.isBlank(fixedamount)){
+                                        failTime++ ;
+                                        msg += "【"+accountnumber+"】添加开户失败,结算水量不能为空,";
+                                        log.info("【"+accountnumber+"】添加开户失败,结算水量不能为空,");
+                                        //c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户已存在,");
+                                        continue;
+                                    }
+                                    customer.setFixedamount(BigDecimal.valueOf(Double.valueOf(fixedamount)));//固定量
+                                }
+                                customer.setWatermeterId(device.getId());
+                                customer.setMetercode(metercode);
+                                customer.setOfficeId(BigInteger.valueOf(office.getId()));
+                                customer.setUpdateBy(loginUser.getId());
+                                customer.setUpdateDate(LocalDateTime.now());
+                                value = paySysDictService.getDictValue("住房类型",housetypeCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                customer.setHousetype(value);//住房类型
+                                value = paySysDictService.getDictValue("开户分组",customergroupCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                customer.setCustomergroup(value);//开户分组
+
+                                customer.setOpendate(LocalDateTime.now());
+                                customer.setWaterPropertyId(property.getWaterPropertyId());
+                                payBaseCustomerandmeterrelaMapper.update(customer);
+                            }else{
+                                //判断该客户编码跟水表档案是否已经存在开户信息中
+                                Integer count = payBaseCustomerandmeterrelaMapper.queryCustomerInfo(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber,metercode);
+                                if(count != null && count >0){
 
-                            //判断该客户编码跟水表档案是否已经存在开户信息中
-                            Integer count = payBaseCustomerandmeterrelaMapper.queryCustomerInfo(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber,metercode);
-                            if(count != null && count >0){
-                                failTime++ ;
-                                msg += "【"+accountnumber+"】添加开户失败,该客户已存在,";
-                                log.info("【"+accountnumber+"】添加开户失败,该客户已存在,");
-                                //c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户已存在,");
-                                continue;
-                            }
-
-                            customer.setAccountId(accounts.getId());
-                            customer.setAccountname(accountname);
-                            customer.setAccountnumber(accountnumber);
-                            customer.setBusinessstate(1);//1已开户 2 销户 3未开户
-                            Integer value = paySysDictService.getDictValue("结算方式",calculateway,new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
-                            customer.setCalculateway(value);//结算方式
-                            if(value != null && value == 2){
-                                if(StringUtils.isBlank(fixedamount)){
                                     failTime++ ;
-                                    msg += "【"+accountnumber+"】添加开户失败,结算水量不能为空,";
-                                    log.info("【"+accountnumber+"】添加开户失败,结算水量不能为空,");
+                                    msg += "【"+accountnumber+"】添加开户失败,该客户已存在,";
+                                    log.info("【"+accountnumber+"】添加开户失败,该客户已存在,");
                                     //c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户已存在,");
                                     continue;
                                 }
-                                customer.setFixedamount(BigDecimal.valueOf(Double.valueOf(fixedamount)));//固定量
+
+                                customer.setAccountId(accounts.getId());
+                                customer.setAccountname(accountname);
+                                customer.setAccountnumber(accountnumber);
+                                customer.setBusinessstate(1);//1已开户 2 销户 3未开户
+                                value = paySysDictService.getDictValue("结算方式",calculateway,new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                customer.setCalculateway(value);//结算方式
+                                if(value != null && value == 2){
+                                    if(StringUtils.isBlank(fixedamount)){
+                                        failTime++ ;
+                                        msg += "【"+accountnumber+"】添加开户失败,结算水量不能为空,";
+                                        log.info("【"+accountnumber+"】添加开户失败,结算水量不能为空,");
+                                        //c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户已存在,");
+                                        continue;
+                                    }
+                                    customer.setFixedamount(BigDecimal.valueOf(Double.valueOf(fixedamount)));//固定量
+                                }
+                                customer.setWatermeterId(device.getId());
+                                customer.setMetercode(metercode);
+                                customer.setOfficeId(BigInteger.valueOf(office.getId()));
+                                customer.setUpdateBy(loginUser.getId());
+                                customer.setUpdateDate(LocalDateTime.now());
+                                customer.setCreateBy(loginUser.getId());
+                                customer.setCreateDate(LocalDateTime.now());
+                                customer.setDelFlag("0");
+                                customer.setRemarks("");
+                                customer.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
+                                customer.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
+                                value = paySysDictService.getDictValue("住房类型",housetypeCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                customer.setHousetype(value);//住房类型
+                                value = paySysDictService.getDictValue("开户分组",customergroupCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                customer.setCustomergroup(value);//开户分组
+                                customer.setOpendate(LocalDateTime.now());
+                                customer.setWaterPropertyId(property.getWaterPropertyId());
+                                customerList.add(customer);
                             }
-                            customer.setWatermeterId(device.getId());
-                            customer.setMetercode(metercode);
-                            customer.setOfficeId(new BigInteger(String.valueOf(office.getId())));
-                            customer.setUpdateBy(loginUser.getId());
-                            customer.setUpdateDate(LocalDateTime.now());
-                            customer.setCreateBy(loginUser.getId());
-                            customer.setCreateDate(LocalDateTime.now());
-                            customer.setDelFlag("0");
-                            customer.setRemarks("");
-                            customer.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
-                            customer.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
-                            value = paySysDictService.getDictValue("住房类型",housetypeCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
-                            customer.setHousetype(value);//住房类型
-                            value = paySysDictService.getDictValue("开户分组",customergroupCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
-                            customer.setCustomergroup(value);//开户分组
-                            customer.setOpendate(LocalDateTime.now());
-                            customer.setWaterPropertyId(property.getWaterPropertyId());
-                            customerList.add(customer);
 
                             //计算可用水量
                             if(property.getWaterPropertyId() != null){

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


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

@@ -304,7 +304,7 @@
     </select>
     <select id="getByName" resultType="com.bz.smart_city.dto.DeviceTypeDto">
         select id,equipment_type,model,manufacturer_id,device_type from sc_device_type where status = 1
-        and equipment_type = #{deviceTypeName} limit 1
+        and equipment_type = #{deviceTypeName} and model =#{deviceTypeModel} limit 1
     </select>
 
     <select id="getById" resultType="com.bz.smart_city.dto.DeviceTypeDto">

+ 164 - 160
smart-city-platform/src/main/resources/mapper/PayBaseCustomerandmeterrelaMapper.xml

@@ -23,19 +23,19 @@
 
     <select id="findList" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
         select
-            customer.id as "id",
-            customer.watermeter_id as "watermeterId",
-            account.id as "accountId",
-            account.accountnumber as "accountnumber",
-            customer.office_id as "officeId",
-            account.name as "name",
-            account.telephone as "telephone",
-            customer.metercode as "metercode",
-            pro.name as "propertyName",
-            account.address as "address",
-            customer.opendate as "opendate",
-            customer.businessstate as "businessstate",
-            customer.calculateway as "calculateway"
+        customer.id as "id",
+        customer.watermeter_id as "watermeterId",
+        account.id as "accountId",
+        account.accountnumber as "accountnumber",
+        customer.office_id as "officeId",
+        account.name as "name",
+        account.telephone as "telephone",
+        customer.metercode as "metercode",
+        pro.name as "propertyName",
+        account.address as "address",
+        customer.opendate as "opendate",
+        customer.businessstate as "businessstate",
+        customer.calculateway as "calculateway"
         from pay_base_customerandmeterrela customer
         left join pay_base_account account on customer.account_id = account.id
         left join pay_base_waterproperty pro on pro.id = customer.waterproperty_id
@@ -58,7 +58,7 @@
 
     <select id="getAccountId" resultType="com.bz.smart_city.entity.pay.PayBaseAccount">
         select
-            id as "id"
+        id as "id"
         from pay_base_account
         <where>
             <if test="siteId != null">
@@ -112,69 +112,69 @@
     <insert id="insertList">
         INSERT INTO pay_base_customerandmeterrela
         (
-            id,
-            account_id,
-            watermeter_id,
-            accountname,
-            accountnumber,
-            metercode,
-            businessstate,
-            office_id,
-            housetype,
-            calculateway,
-            customercategory,
-            customergroup,
-            fixedamount,
-            vatno,
-            bankaccount,
-            invoicetitle,
-            address,
-            opendate,
-            waterproperty_id,
-            watertype,
-            canceldate,
-            create_by,
-            create_date,
-            update_by,
-            update_date,
-            remarks,
-            del_flag,
-            site_id,
-            customer_id
+        id,
+        account_id,
+        watermeter_id,
+        accountname,
+        accountnumber,
+        metercode,
+        businessstate,
+        office_id,
+        housetype,
+        calculateway,
+        customercategory,
+        customergroup,
+        fixedamount,
+        vatno,
+        bankaccount,
+        invoicetitle,
+        address,
+        opendate,
+        waterproperty_id,
+        watertype,
+        canceldate,
+        create_by,
+        create_date,
+        update_by,
+        update_date,
+        remarks,
+        del_flag,
+        site_id,
+        customer_id
         )
         values
         <foreach collection="customers" item="customer" index="index" separator=",">
-        (
-             #{customer.id,jdbcType=BIGINT},
-             #{customer.accountId,jdbcType=BIGINT},
-             #{customer.watermeterId,jdbcType=BIGINT},
-             #{customer.accountname,jdbcType=VARCHAR},
-             #{customer.accountnumber,jdbcType=VARCHAR},
-             #{customer.metercode,jdbcType=VARCHAR},
-             #{customer.businessstate,jdbcType=INTEGER},
-             #{customer.officeId,jdbcType=BIGINT},
-             #{customer.housetype,jdbcType=INTEGER},
-             #{customer.calculateway,jdbcType=INTEGER},
-             #{customer.customercategory,jdbcType=INTEGER},
-             #{customer.customergroup,jdbcType=INTEGER},
-             #{customer.fixedamount,jdbcType=VARCHAR},
-             #{customer.vatno,jdbcType=VARCHAR},
-             #{customer.bankaccount,jdbcType=VARCHAR},
-             #{customer.invoicetitle,jdbcType=VARCHAR},
-             #{customer.address,jdbcType=VARCHAR},
-             #{customer.opendate,jdbcType=TIMESTAMP},
-             #{customer.waterPropertyId,jdbcType=BIGINT},
-             #{customer.watertype,jdbcType=INTEGER},
-             #{customer.canceldate,jdbcType=TIMESTAMP},
-             #{customer.createBy,jdbcType=VARCHAR},
-             #{customer.createDate,jdbcType=TIMESTAMP},
-             #{customer.updateBy,jdbcType=VARCHAR},
-             #{customer.updateDate,jdbcType=TIMESTAMP},
-             #{customer.remarks,jdbcType=VARCHAR},
-             #{customer.delFlag,jdbcType=VARCHAR},
-             #{customer.siteId,jdbcType=BIGINT},
-             #{customer.customerId,jdbcType=BIGINT}
-        )
+            (
+            #{customer.id,jdbcType=BIGINT},
+            #{customer.accountId,jdbcType=BIGINT},
+            #{customer.watermeterId,jdbcType=BIGINT},
+            #{customer.accountname,jdbcType=VARCHAR},
+            #{customer.accountnumber,jdbcType=VARCHAR},
+            #{customer.metercode,jdbcType=VARCHAR},
+            #{customer.businessstate,jdbcType=INTEGER},
+            #{customer.officeId,jdbcType=BIGINT},
+            #{customer.housetype,jdbcType=INTEGER},
+            #{customer.calculateway,jdbcType=INTEGER},
+            #{customer.customercategory,jdbcType=INTEGER},
+            #{customer.customergroup,jdbcType=INTEGER},
+            #{customer.fixedamount,jdbcType=VARCHAR},
+            #{customer.vatno,jdbcType=VARCHAR},
+            #{customer.bankaccount,jdbcType=VARCHAR},
+            #{customer.invoicetitle,jdbcType=VARCHAR},
+            #{customer.address,jdbcType=VARCHAR},
+            #{customer.opendate,jdbcType=TIMESTAMP},
+            #{customer.waterPropertyId,jdbcType=BIGINT},
+            #{customer.watertype,jdbcType=INTEGER},
+            #{customer.canceldate,jdbcType=TIMESTAMP},
+            #{customer.createBy,jdbcType=VARCHAR},
+            #{customer.createDate,jdbcType=TIMESTAMP},
+            #{customer.updateBy,jdbcType=VARCHAR},
+            #{customer.updateDate,jdbcType=TIMESTAMP},
+            #{customer.remarks,jdbcType=VARCHAR},
+            #{customer.delFlag,jdbcType=VARCHAR},
+            #{customer.siteId,jdbcType=BIGINT},
+            #{customer.customerId,jdbcType=BIGINT}
+            )
         </foreach>
     </insert>
 
@@ -214,7 +214,7 @@
 
     <select id="findByAccount" resultType="com.bz.smart_city.entity.pay.PayPayRechargeaccount">
         select
-            rech.*
+        rech.*
         from pay_pay_rechargeaccount rech
         <where>
             <if test="accountId != null">
@@ -237,28 +237,28 @@
 
     <select id="getAll" resultType="com.bz.smart_city.dto.pay.PayCustomerDto">
         select
-            customer.fixedamount as "fixedamount",
-            customer.id as "id",
-            account.accountnumber as "accountnumber",
-            account.name as "accountname",
-            account.telephone as "telephone",
-            customer.metercode as "metercode",
-            property.id as "waterPropertyId",
-            property.name as "waterPropertyName",
-            account.address as "address",
-            customer.opendate as "opendate",
-            customer.office_id as "officeId",
-            customer.businessstate as "businessstate",
-            (select label from pay_sys_dict where type = '开户状态' and value = customer.businessstate and site_id = #{siteId} and customer_id =#{customerId}) as "businessName",
-            customer.calculateway as "calculateway",
-            (select label from pay_sys_dict where type = '结算方式' and value = customer.calculateway and site_id = #{siteId} and customer_id =#{customerId}) as "calculatewayName",
-            account.idtype as "idtype",
-            (select label from pay_sys_dict where type = '证件类型' and value = account.idtype and site_id = #{siteId} and customer_id =#{customerId}) as "idtypeName",
-            account.idcardno as "idcardno",
-            customer.housetype as "housetype",
-            (select label from pay_sys_dict where type = '住房类型' and value = customer.housetype and site_id = #{siteId} and customer_id =#{customerId}) as "housetypeName",
-            customer.customergroup as "customergroup",
-            (select label from pay_sys_dict where type = '开户分组' and value = customer.customergroup and site_id = #{siteId} and customer_id =#{customerId}) as "customergroupName"
+        customer.fixedamount as "fixedamount",
+        customer.id as "id",
+        account.accountnumber as "accountnumber",
+        account.name as "accountname",
+        account.telephone as "telephone",
+        customer.metercode as "metercode",
+        property.id as "waterPropertyId",
+        property.name as "waterPropertyName",
+        account.address as "address",
+        customer.opendate as "opendate",
+        customer.office_id as "officeId",
+        customer.businessstate as "businessstate",
+        (select label from pay_sys_dict where type = '开户状态' and value = customer.businessstate and site_id = #{siteId} and customer_id =#{customerId}) as "businessName",
+        customer.calculateway as "calculateway",
+        (select label from pay_sys_dict where type = '结算方式' and value = customer.calculateway and site_id = #{siteId} and customer_id =#{customerId}) as "calculatewayName",
+        account.idtype as "idtype",
+        (select label from pay_sys_dict where type = '证件类型' and value = account.idtype and site_id = #{siteId} and customer_id =#{customerId}) as "idtypeName",
+        account.idcardno as "idcardno",
+        customer.housetype as "housetype",
+        (select label from pay_sys_dict where type = '住房类型' and value = customer.housetype and site_id = #{siteId} and customer_id =#{customerId}) as "housetypeName",
+        customer.customergroup as "customergroup",
+        (select label from pay_sys_dict where type = '开户分组' and value = customer.customergroup and site_id = #{siteId} and customer_id =#{customerId}) as "customergroupName"
         from pay_base_customerandmeterrela customer
         left join pay_base_account account on account.id = customer.account_id
         left join pay_base_waterproperty property on property.id = customer.waterproperty_id
@@ -272,11 +272,11 @@
             <if test="condition != null">
                 and
                 (
-                    account.accountnumber like concat('%',#{condition},'%')
-                    or account.name like concat('%',#{condition},'%')
-                    or customer.metercode like  concat('%',#{condition},'%')
-                    or account.address  like concat('%',#{condition},'%')
-                    or account.telephone like concat('%',#{condition},'%')
+                account.accountnumber like concat('%',#{condition},'%')
+                or account.name like concat('%',#{condition},'%')
+                or customer.metercode like  concat('%',#{condition},'%')
+                or account.address  like concat('%',#{condition},'%')
+                or account.telephone like concat('%',#{condition},'%')
                 )
             </if>
             <if test="waterPropertyId != null">
@@ -301,15 +301,15 @@
 
     <select id="getList" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
         select
-            account.accountnumber as "accountnumber",
-            account.name as "accountname",
-            account.telephone as "telephone",
-            customer.metercode as "metercode",
-            property.name as "propertyName",
-            device.loc_desc as "address",
-            customer.opendate as "opendate",
-            customer.businessstate as "businessstate",
-            customer.calculateway as "calculateway"
+        account.accountnumber as "accountnumber",
+        account.name as "accountname",
+        account.telephone as "telephone",
+        customer.metercode as "metercode",
+        property.name as "propertyName",
+        device.loc_desc as "address",
+        customer.opendate as "opendate",
+        customer.businessstate as "businessstate",
+        customer.calculateway as "calculateway"
         from pay_base_customerandmeterrela customer
         left join pay_base_account account on account.id = customer.account_id
         left join pay_base_waterproperty property on property.id = customer.waterproperty_id
@@ -324,11 +324,11 @@
             <if test="condition != null">
                 and
                 (
-                    account.accountnumber like concat('%',#{condition},'%')
-                    or account.name like concat('%',#{condition},'%')
-                    or customer.metercode like  concat('%',#{condition},'%')
-                    or account.address  like concat('%',#{condition},'%')
-                    or account.telephone like concat('%',#{condition},'%')
+                account.accountnumber like concat('%',#{condition},'%')
+                or account.name like concat('%',#{condition},'%')
+                or customer.metercode like  concat('%',#{condition},'%')
+                or account.address  like concat('%',#{condition},'%')
+                or account.telephone like concat('%',#{condition},'%')
                 )
             </if>
             <if test="waterPropertyId != null">
@@ -347,7 +347,7 @@
 
     <select id="queryNoOpenAccount" resultType="com.bz.smart_city.entity.pay.archives.DeviceListInfo">
         select
-            account.accountnumber as "accountnumber"
+        account.accountnumber as "accountnumber"
         from pay_base_account account
         <where>
             <if test="siteId != null">
@@ -362,7 +362,7 @@
 
     <select id="selectAccountInfo" resultType="com.bz.smart_city.entity.pay.archives.MeterListInfo">
         select
-            device.metercode as "metercode"
+        device.metercode as "metercode"
         from pay_base_account account
         inner join sc_device device on account.id = device.account_id
         <where>
@@ -370,9 +370,9 @@
             <if test="accountnumber != null">
                 and account.accountnumber =#{accountnumber}
             </if>
-           <!-- <if test="siteId != null">
-                and  account.site_id = #{siteId}
-            </if>-->
+            <!-- <if test="siteId != null">
+                 and  account.site_id = #{siteId}
+             </if>-->
             <if test="customerId != null">
                 and account.customer_id = #{customerId}
             </if>
@@ -382,10 +382,10 @@
 
     <select id="selectAccountMeterInfo" resultType="com.bz.smart_city.entity.pay.archives.PayAccountInfo">
         select
-            account.accountnumber as "accountnumber",
-            account.calculateway as "calculateway",
-            account.waterproperty_id as "waterPropertyId",
-            device.metercode as "metercode"
+        account.accountnumber as "accountnumber",
+        account.calculateway as "calculateway",
+        account.waterproperty_id as "waterPropertyId",
+        device.metercode as "metercode"
         from pay_base_account account
         inner join sc_device device on account.id = device.account_id
         <where>
@@ -405,9 +405,9 @@
 
     <select id="selectAccountWater" resultType="com.bz.smart_city.entity.pay.archives.CustomerListInfo">
         select
-            accountnumber as "accountnumber",
-            calculateway as "calculateway" ,
-            waterproperty_id as "waterPropertyId"
+        accountnumber as "accountnumber",
+        calculateway as "calculateway" ,
+        waterproperty_id as "waterPropertyId"
         from pay_base_account account
         inner join sc_device device on account.id = device.account_id
         <where>
@@ -427,7 +427,7 @@
 
     <select id="queryMetercode" resultType="com.bz.smart_city.entity.pay.archives.MeterListInfo">
         select
-            metercode from sc_device deivce
+        metercode from sc_device deivce
         <where>
             deivce.metercode not in (select metercode from pay_base_customerandmeterrela) and deivce.metercode is not null
             <!--<if test="siteId != null">
@@ -498,7 +498,7 @@
         from pay_base_customerandmeterrela a
 
         <where>
-                a.id =#{id}
+            a.id =#{id}
         </where>
     </select>
 
@@ -544,36 +544,36 @@
     </select>
 
     <select id="queryCancelInfo" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
-         select
-            a.id,
-            a.account_id AS "accountId",
-            a.watermeter_id AS "watermeterId",
-            a.accountname,
-            a.accountnumber,
-            a.metercode,
-            a.businessstate,
-            a.office_id AS "officeId",
-            a.housetype,
-            a.calculateway,
-            a.customercategory,
-            a.customergroup,
-            a.fixedamount,
-            a.vatno,
-            a.bankaccount,
-            a.invoicetitle,
-            a.address,
-            a.opendate,
-            a.waterproperty_id AS "waterpropertyId",
-            a.watertype,
-            a.canceldate,
-            a.create_by AS "createBy",
-            a.create_date AS "createDate",
-            a.update_by AS "updateBy",
-            a.update_date AS "updateDate",
-            a.remarks AS "remarks",
-            a.del_flag AS "delFlag",
-            a.site_id as "siteId",
-            a.customer_id as "customerId"
+        select
+        a.id,
+        a.account_id AS "accountId",
+        a.watermeter_id AS "watermeterId",
+        a.accountname,
+        a.accountnumber,
+        a.metercode,
+        a.businessstate,
+        a.office_id AS "officeId",
+        a.housetype,
+        a.calculateway,
+        a.customercategory,
+        a.customergroup,
+        a.fixedamount,
+        a.vatno,
+        a.bankaccount,
+        a.invoicetitle,
+        a.address,
+        a.opendate,
+        a.waterproperty_id AS "waterpropertyId",
+        a.watertype,
+        a.canceldate,
+        a.create_by AS "createBy",
+        a.create_date AS "createDate",
+        a.update_by AS "updateBy",
+        a.update_date AS "updateDate",
+        a.remarks AS "remarks",
+        a.del_flag AS "delFlag",
+        a.site_id as "siteId",
+        a.customer_id as "customerId"
         from pay_base_customerandmeterrela a
         <where>
             <if test="siteId != null">
@@ -594,4 +594,8 @@
     <select id="queryMeterState" resultType="java.lang.Integer">
         select is_accepted as "isAccepted" from sc_install_list where account_id =#{accountId}  and customer_id =#{customerId}
     </select>
+
+    <select id="getParentOfficeId" resultType="com.bz.smart_city.entity.Organization">
+        select id from sc_organization where site_id =#{siteId} and parent_id =#{id} and name =#{name}
+    </select>
 </mapper>

+ 21 - 20
smart-city-platform/src/main/resources/mapper/pay/PayRechargeaccountMapper.xml

@@ -20,16 +20,17 @@
     </sql>
     <select id="findList" resultType="com.bz.smart_city.dto.pay.PayRechargeaccountDto">
         select
-            <include refid="mainColumnInfo"/>
-            ,cust.accountname as "accountname"
+        <include refid="mainColumnInfo"/>
+        ,cust.accountname as "accountname"
         from pay_pay_rechargeaccount a
         left join pay_base_customerandmeterrela cust on a.account_id=cust.account_id
 
 
         <where>
+            cust.businessstate = 1
             <if test="accountnumber != null and accountnumber != ''">
-              and  (cust.accountnumber like concat('%',#{accountnumber},'%')
-               or  cust.accountname like concat('%',#{accountnumber},'%'))
+                and  (cust.accountnumber like concat('%',#{accountnumber},'%')
+                or  cust.accountname like concat('%',#{accountnumber},'%'))
             </if>
             <if test="siteId != null">
                 and a.site_id=#{siteId}
@@ -41,11 +42,11 @@
                 and a.account_id =#{accountId}
             </if>
             <if test="programItems != null and programItems.size() != 0">
-              and  <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
-                    <if test="item.dimensionId == 10">
-                        cust.${item.dimensionCode} = #{item.dimensionValue}
-                    </if>
-                </foreach>
+                and  <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
+                <if test="item.dimensionId == 10">
+                    cust.${item.dimensionCode} = #{item.dimensionValue}
+                </if>
+            </foreach>
             </if>
         </where>
         order by a.create_date desc
@@ -61,7 +62,7 @@
                 and id=#{id}
             </if>
             <if test="accountId != null">
-              and account_id=#{accountId}
+                and account_id=#{accountId}
             </if>
         </where>
     </select>
@@ -111,36 +112,36 @@
             </if>
 
             <if test="businessstate != null ">
-            businessstate = #{businessstate},
+                businessstate = #{businessstate},
             </if>
 
             <if test="accountnumber != null and accountnumber!='' ">
-            accountnumber = #{accountnumber},
+                accountnumber = #{accountnumber},
             </if>
             <if test="accountname != null and accountname!='' ">
-            accountname = #{accountname},
+                accountname = #{accountname},
             </if>
 
             <if test="remaining != null ">
-            remaining = #{remaining},
+                remaining = #{remaining},
             </if>
 
             <if test="updateDate != null ">
-            update_date = #{updateDate},
+                update_date = #{updateDate},
             </if>
 
             <if test="updateBy != null ">
-            update_by = #{updateBy},
+                update_by = #{updateBy},
             </if>
             <if test="customerId != null">
-            customer_id = #{customerId},
+                customer_id = #{customerId},
             </if>
 
             <if test="siteId != null ">
-            site_id = #{siteId},
+                site_id = #{siteId},
             </if>
             <if test="officeId != null ">
-            office_id = #{officeId}
+                office_id = #{officeId}
             </if>
         </set>
         <where>
@@ -171,7 +172,7 @@
         insert INTO
         pay_pay_rechargeaccount
         (id,
-         account_id,
+        account_id,
         businessstate,
         accountnumber,
         accountname,