oppadmin 4 years ago
parent
commit
c4c48c4bd4

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/controller/common/ImportController.java

@@ -28,7 +28,7 @@ public class ImportController {
     @ApiOperation(value = "导入Execl", notes = "Execl")
     public AjaxMessage importExcel(
             @ApiParam(value = "系统id", required = false) @RequestParam(required = false) Integer sysId,
-            @ApiParam(value = "导入类型 1:新装水表 2:设备列表 3:建筑 4:批量开户 5:集中器 6:采集器", required = true) @RequestParam(required = true) Integer importType,
+            @ApiParam(value = "导入类型 1:新装水表 2:设备列表 3:建筑 4:批量开户 5:集中器 6:采集器 7:安装计划", required = true) @RequestParam(required = true) Integer importType,
             @ApiParam(value = "文件") @RequestParam MultipartFile file,
             HttpServletRequest request, HttpServletResponse response
     ) {

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/CommunityMapper.java

@@ -32,6 +32,8 @@ public interface CommunityMapper {
 
     List<Community> getBySiteId(@Param("siteId") Integer siteId);
 
+    List<Community> getByCustomerId(@Param("customer") Integer customer);
+
     List<Community> getMaxCodeBySiteId(@Param("siteId") Integer siteId);
 
     List<CommunityDto> getListByCustomerIds(@Param("siteId") Integer siteId, @Param("customerIds") List<Integer> customerIds, @Param("communityName") String communityName, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region);

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/Import.java

@@ -15,6 +15,9 @@ public class Import {
     @ApiModelProperty(value="站点id")
     private Integer siteId;
 
+    @ApiModelProperty(value="客户id")
+    private Integer customerId;
+
     @ApiModelProperty(value="用户id")
     private Integer userId;
 

+ 7 - 8
smart-city-platform/src/main/java/com/bz/smart_city/excel/download/template/InstallPlanDownloadExcelTemplate.java

@@ -59,7 +59,7 @@ public class InstallPlanDownloadExcelTemplate extends AbstractDownloadExcelTempl
 
 
         //1、获取小区列表数据
-        List<Community> communityList = communityService.findBySiteId(loginUser.getSiteId());
+        List<Community> communityList = communityService.findByCustomerId(loginUser.getCustomerId());
 
 
         //2、获取建筑列表数据
@@ -71,6 +71,12 @@ public class InstallPlanDownloadExcelTemplate extends AbstractDownloadExcelTempl
         List<Customer> customerList = customerService.getCustomerList(loginUser.getSiteId());
 
 
+        this.context = new Context();
+        this.context.putVar("communityList", communityList);
+        this.context.putVar("buildingList", newArrayList());
+        this.context.putVar("customerList", customerList);
+        //this.context.putVar("deviceTypeList", deviceTypeList);
+
         //4、获取水表类型数据
         AjaxMessage<List<DeviceTypeDto>> ajax =  paySyncDataService.queryWaterMeterType(null);
         if(ajax != null){
@@ -78,12 +84,5 @@ public class InstallPlanDownloadExcelTemplate extends AbstractDownloadExcelTempl
                 this.context.putVar("deviceTypeList", ajax.getData());
             }
         }
-
-
-        this.context = new Context();
-        this.context.putVar("communityList", communityList);
-        this.context.putVar("buildingList", newArrayList());
-        this.context.putVar("customerList", customerList);
-        //this.context.putVar("deviceTypeList", deviceTypeList);
     }
 }

+ 21 - 6
smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/InstallPlanResolverExcelTemplate.java

@@ -3,8 +3,10 @@ package com.bz.smart_city.excel.resolver;
 import com.alibaba.druid.sql.visitor.functions.Trim;
 import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.commom.util.JacksonUtil;
 import com.bz.smart_city.dao.CommunityMapper;
 import com.bz.smart_city.dao.CustomerMapper;
+import com.bz.smart_city.dto.CommunityDto;
 import com.bz.smart_city.dto.DeviceTypeDto;
 import com.bz.smart_city.dto.pay.InstallPlanDataDTO;
 import com.bz.smart_city.dto.pay.InstallPlanInputDTO;
@@ -80,19 +82,21 @@ public class InstallPlanResolverExcelTemplate extends AbstractResolverExcelTempl
                 messageContent.append(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
                 continue;
             }
-            Customer customer = customerMapper.findByName(record.getSiteId(),customerNameCell.getStringCellValue().trim());
-            if(customer==null){
+            //Customer customer = customerMapper.findByName(record.getSiteId(),customerNameCell.getStringCellValue().trim());
+            Customer customer = customerMapper.findById(record.getCustomerId());
+            if(customer==null || !customer.getCustomerName().equals(customerNameCell.getStringCellValue().trim())){
                 messageContent.append("导入失败,");
                 messageContent.append(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
                 continue;
             }
 
-            Community community = communityMapper.findByName(record.getSiteId(),communityNameCell.getStringCellValue().trim());
-            if (community == null) {
+            List<CommunityDto> communityDtos = communityMapper.getList(null,record.getCustomerId(),communityNameCell.getStringCellValue().trim(),null,null,null);
+            if (communityDtos == null || communityDtos.get(0) == null) {
                 messageContent.append("导入失败,");
                 messageContent.append(ResultStatus.COMMUNITY_IS_NOT_EXISTED.getMessage());
                 continue;
             }
+            Community community = communityDtos.get(0);
 
 
             Cell numberCell = hssfSheet.getRow(3).getCell(4);// 安装数字,只处理指定安装户数的数据
@@ -119,6 +123,9 @@ public class InstallPlanResolverExcelTemplate extends AbstractResolverExcelTempl
                 messageContent.append(ResultStatus.DEVICE_TYPE_NOT_EXISTED.getMessage());
                 continue;
             }
+            List<DeviceTypeDto> deviceTypeDtos = DeviceTypeAjax.getData();
+
+
 
             // 2,处理明细行数据
             for (int rowNum = 9; rowNum < 9+number ; rowNum++) {
@@ -189,12 +196,20 @@ public class InstallPlanResolverExcelTemplate extends AbstractResolverExcelTempl
                     String str = deviceTypeCell.getStringCellValue().trim();
                     String[] deviceType  = StringUtils.split(str,"/");
                     List<Integer> devieTypeId = new ArrayList();
-                    for (DeviceTypeDto type :DeviceTypeAjax.getData()){
+
+                    for(int i=0;i<deviceTypeDtos.size();i++){
+                        if (deviceTypeDtos.get(i).getEquipmentType().equals(deviceType[1])
+                                && deviceTypeDtos.get(i).getModel().equals(deviceType[2])){
+                            devieTypeId.add(deviceTypeDtos.get(i).getId());
+                            break;
+                        }
+                    }
+                   /* for (DeviceTypeDto type :deviceTypeDtos){
                         if(type.getEquipmentType().equals(deviceType[1]) && type.getModel().equals(deviceType[2])){
                             devieTypeId.add(type.getId());
                             break;
                         }
-                    }
+                    }*/
                     installPlanInput.setDeviceTypeIds(devieTypeId);
 
                     //地址

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/CommunityService.java

@@ -32,6 +32,8 @@ public interface CommunityService {
 
     List<Community> findBySiteId(Integer siteId);
 
+    List<Community> findByCustomerId(Integer customerId);
+
     Community findByNameV2(@Param("siteId") Integer siteId, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("communityName") String communityName);
 
     List<Community> getMaxCodeBySiteId(Integer siteId);

+ 6 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CommunityServiceImpl.java

@@ -193,6 +193,12 @@ public class CommunityServiceImpl implements CommunityService{
         return communityMapper.getBySiteId(siteId);
     }
 
+    @Override
+    public List<Community> findByCustomerId(Integer customerId)
+    {
+        return communityMapper.getByCustomerId(customerId);
+    }
+
     @Override
     public Community findByNameV2(Integer siteId, Integer province, Integer city, Integer region, String communityName) {
         return communityMapper.findByNameV2(siteId,province,city,region,communityName);

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ImportServiceImpl.java

@@ -81,6 +81,7 @@ public class ImportServiceImpl implements ImportService{
         //生成导入记录
         Import record = new Import();
         record.setSiteId(loginUser.getSiteId());
+        record.setCustomerId(loginUser.getCustomerId());
         record.setUserId(loginUser.getId());
         record.setType(importType);
         record.setImportFilePath(filePath);
@@ -98,7 +99,10 @@ public class ImportServiceImpl implements ImportService{
             //批量开户
             asyncTaskImportService.executeAsyncCustomerTask(loginUser,record,file);
         }
+        if(importType == 7){
 
+            asyncTaskImportService.executeAsyncInstallPlanTask(record);
+        }
         log.info("返回结果");
     }
 

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

@@ -2,6 +2,7 @@ package com.bz.smart_city.service.importfile;
 
 import com.bz.smart_city.commom.exception.ServiceException;
 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.PayBaseAccountMapper;
 import com.bz.smart_city.dao.pay.PayRechargeaccountMapper;
@@ -13,6 +14,7 @@ import com.bz.smart_city.entity.Message;
 import com.bz.smart_city.entity.Organization;
 import com.bz.smart_city.entity.pay.PayBaseAccount;
 import com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela;
+import com.bz.smart_city.excel.resolver.InstallPlanResolverExcelTemplate;
 import com.bz.smart_city.service.ImportService;
 import com.bz.smart_city.service.MessageService;
 import com.bz.smart_city.service.pay.PayBaseAccountService;
@@ -63,6 +65,8 @@ public class AsyncTaskImportService {
     private PayRechargeaccountMapper payRechargeaccountMapper;
     @Autowired
     private PayBaseAccountService payBaseAccountService;
+    @Autowired
+    private InstallPlanResolverExcelTemplate installPlanResolverExcelTemplate;
 
     @Value("${files.path}")
     private String filesPath;
@@ -489,4 +493,10 @@ public class AsyncTaskImportService {
         log.info("end executeAsyncCustomerTask!");
     }
 
+
+    @Async
+    public void executeAsyncInstallPlanTask(Import record){
+        installPlanResolverExcelTemplate.resolver(null,null,record,"装表计划-批量添加");
+    }
+
 }

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

@@ -329,7 +329,13 @@
         where status = 1 and id=#{id}
     </select>
     <select id="getBySiteId" resultMap="BaseResultMap">
-        select <include refid="Base_Column_List"></include> from sc_community where status = 1 and site_id = #{siteId}
+        select <include refid="Base_Column_List"></include> from sc_community where status = 1
+        and site_id = #{siteId}
+    </select>
+
+    <select id="getByCustomerId" resultMap="BaseResultMap">
+        select <include refid="Base_Column_List"></include> from sc_community where status = 1
+        and customer_id = #{customerId}
     </select>
 
     <select id="getMaxCodeBySiteId" resultMap="BaseResultMap">

+ 3 - 3
smart-city-platform/src/main/resources/mapper/pay/PayControlRecordMapper.xml

@@ -21,7 +21,7 @@
         from pay_control_record pcr
         left join pay_control_rule pcrule on pcr.control_rule_id = pcrule.id
         <where>
-            del_flag = 0
+            pcr.del_flag = 0
             <if test="payControlRecordDto.id != null"> and pcr.id = #{payControlRecordDto.id}</if>
             <if test="payControlRecordDto.accountId != null"> and pcr.account_id = #{payControlRecordDto.accountId}</if>
             <if test="payControlRecordDto.meterId != null"> and pcr.meter_id = #{payControlRecordDto.meterId}</if>
@@ -29,8 +29,8 @@
             <if test="payControlRecordDto.type != null"> and pcr.type = #{payControlRecordDto.type}</if>
             <if test="payControlRecordDto.result != null"> and pcr.result = #{payControlRecordDto.result}</if>
             <if test="payControlRecordDto.state != null"> and pcr.state = #{payControlRecordDto.state}</if>
-            <if test="payControlRecordDto.beginTime != null"> and pcr.updateDate >= #{payControlRecordDto.beginTime,jdbcType=TIMESTAMP}</if>
-            <if test="payControlRecordDto.endTime != null"> and pcr.updateDate &lt;= #{payControlRecordDto.endTime,jdbcType=TIMESTAMP}</if>
+            <if test="payControlRecordDto.beginTime != null"> and pcr.update_Date >= #{payControlRecordDto.beginTime,jdbcType=TIMESTAMP}</if>
+            <if test="payControlRecordDto.endTime != null"> and pcr.update_Date &lt;= #{payControlRecordDto.endTime,jdbcType=TIMESTAMP}</if>
         </where>
     </select>