lin 4 سال پیش
والد
کامیت
427985ecf6

+ 8 - 1
src/main/java/com/zcxk/meterreadingsystemv2/controller/MssqlController.java

@@ -21,9 +21,16 @@ public class MssqlController {
     private MssqlService mssqlService;
 
     @GetMapping("addCustomer")
-    @ApiOperation("添加监利客户信息")
+    @ApiOperation("添加客户信息")
     public AjaxMessage addCustomer(){
         mssqlService.addCustomer();
         return new AjaxMessage<>(ResultStatus.OK);
     }
+
+    @GetMapping("addHuichuanCustomer")
+    @ApiOperation("添加客户信息")
+    public AjaxMessage addHuichuanCustomer(){
+        mssqlService.addHuichuanCustomer();
+        return new AjaxMessage<>(ResultStatus.OK);
+    }
 }

+ 6 - 0
src/main/java/com/zcxk/meterreadingsystemv2/dto/DeviceCustomerInfo.java

@@ -40,6 +40,12 @@ public class DeviceCustomerInfo implements Serializable {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date installTime;
 
+    @ApiModelProperty(value = "小区名称",position = 3)
+    private String communityName;
+
+    @ApiModelProperty(value = "建筑名称",position = 4)
+    private String buildingName;
+
     public DeviceCustomerInfo(String deviceNo, String waterMeterNo, String location, String userName, String userPhone, String idCard, String waterFileNo) {
         this.deviceNo = deviceNo;
         this.waterMeterNo = waterMeterNo;

+ 1 - 1
src/main/java/com/zcxk/meterreadingsystemv2/kafka/AddAccountReceiver.java

@@ -168,7 +168,7 @@ public class AddAccountReceiver {
                             ycblhb.setSbdz(acceptListData.getBuildingName() + acceptListData.getLocation());
                             ycblhb.setBc("001");
                             ycblhb.setBsm(acceptListData.getWaterMeterNo());
-                            ycblhb.setZdsj("010101");
+                            ycblhb.setZdsj("0101");
                             ycblhb.setYys("020101");
                             ycblhb.setBw(acceptListData.getBuildingName() + acceptListData.getLocation());
                             ycblhb.setBxh("4");

+ 47 - 0
src/main/java/com/zcxk/meterreadingsystemv2/service/MssqlService.java

@@ -1,14 +1,19 @@
 package com.zcxk.meterreadingsystemv2.service;
 
+import com.zcxk.meterreadingsystemv2.common.JacksonUtil;
 import com.zcxk.meterreadingsystemv2.dao.DeviceMapper;
 import com.zcxk.meterreadingsystemv2.dao.TRemoteCustomerMapper;
+import com.zcxk.meterreadingsystemv2.dao.YcblhbMapper;
 import com.zcxk.meterreadingsystemv2.dbs.DynamicDataSourceContextHolder;
 import com.zcxk.meterreadingsystemv2.dto.DeviceCustomerInfo;
 import com.zcxk.meterreadingsystemv2.entity.TRemoteCustomer;
+import com.zcxk.meterreadingsystemv2.entity.Ycblhb;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -21,6 +26,8 @@ public class MssqlService {
     private DeviceMapper deviceMapper;
     @Resource
     private TRemoteCustomerMapper tRemoteCustomerMapper;
+    @Resource
+    YcblhbMapper ycblhbMapper;
 
     public void addCustomer() {
         String originName = "jl";
@@ -71,4 +78,44 @@ public class MssqlService {
             log.info("=======================end list size="+list.size()+"-count="+count.get());
         }
     }
+
+    public void addHuichuanCustomer() {
+        String originName = "huichuan";
+        String commOrgLevel = "10001002";
+        String commOrgIdenty = "10001002";
+        AtomicInteger count = new AtomicInteger(0);
+        DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
+        log.info("=====service当前连接的数据库是:" + DynamicDataSourceContextHolder.getDataSourceKey());
+        List<DeviceCustomerInfo> list = deviceMapper.getDeviceCustomerInfoByCustomerId(38);
+
+        DynamicDataSourceContextHolder.setDataSourceKey(originName);
+        //log.info("=====service当前连接的数据库是:" + DynamicDataSourceContextHolder.getDataSourceKey());
+        if (list != null && list.size() > 0) {
+            log.info("=======================list size="+list.size());
+            for (DeviceCustomerInfo info : list) {
+                Ycblhb ycblhb = new Ycblhb();
+                ycblhb.setYhdz(info.getBuildingName() + info.getLocation());
+                ycblhb.setSbdz(info.getBuildingName() + info.getLocation());
+                ycblhb.setBc("001");
+                ycblhb.setBsm(info.getWaterMeterNo());
+                ycblhb.setZdsj("0101");//汇川0101
+                ycblhb.setYys("020101");
+                ycblhb.setBw(info.getBuildingName() + info.getLocation());
+                ycblhb.setBxh("4");
+                //ycblhb.setBqds(acceptListData.getReadData());
+                ycblhb.setBqds(BigDecimal.ZERO);
+                ycblhb.setNhrq(info.getInstallTime());
+                ycblhb.setLdh(info.getBuildingName());
+                ycblhb.setDyh(info.getCommunityName());
+                ycblhb.setMph(info.getLocation());
+                ycblhb.setBcj("31");
+                ycblhb.setCommOrgLevel(commOrgLevel);
+                ycblhb.setCommOrgIdenty(commOrgIdenty);
+                log.info(JacksonUtil.obj2String(ycblhb));
+                ycblhbMapper.insertSelective(ycblhb);
+                count.incrementAndGet();
+            }
+            log.info("=======================end list size="+list.size()+"-count="+count.get());
+        }
+    }
 }

+ 5 - 3
src/main/resources/mapper/DeviceMapper.xml

@@ -25,16 +25,18 @@
         sd.device_no as device_no,
         sd.water_meter_no,
         sd.water_meter_file_no as water_file_no,
-        CONCAT(sc.`name`,sb.`name`,sd.loc_desc)  as location,
+        sd.loc_desc  as location,
         sil.user_name,
         sil.user_phone,
         sil.id_card,
-        sil.install_time
+        sil.install_time,
+        sb.name as building_name,
+        sc.name as community_name
         from sc_device sd
         left join sc_install_list sil on (sil.device_id = sd.id and sil.status = 1)
         left join sc_building sb on (sb.id = sd.building_id )
         left join sc_community sc on (sc.id = sb.community)
-        where sd.status = 1
+        where sd.status = 1 and sd.sys_id != -99
         <if test="customerId != null"> and sd.customer_id = #{customerId}</if>
     </select>