瀏覽代碼

天津迁移代码提交 PengDi@2021/1/16

pengdi@zoniot.com 4 年之前
父節點
當前提交
7e244afa2f

+ 1 - 1
meter-reading-common/src/main/java/com/huaxu/zoniot/dao/CommunityMapper.java

@@ -24,7 +24,7 @@ public interface CommunityMapper {
 
 
     Community findCommunityWithName(@Param("name") String name,
     Community findCommunityWithName(@Param("name") String name,
                             @Param("siteId") Integer siteId ,
                             @Param("siteId") Integer siteId ,
-                            @Param("customerId") Integer customerId ,
+                            //@Param("customerId") Integer customerId ,
                             @Param("province")Integer province,
                             @Param("province")Integer province,
                             @Param("city") Integer city ,
                             @Param("city") Integer city ,
                             @Param("region") Integer region);
                             @Param("region") Integer region);

+ 29 - 0
meter-reading-common/src/main/java/com/huaxu/zoniot/dao/CustomerMapper.java

@@ -0,0 +1,29 @@
+package com.huaxu.zoniot.dao;
+
+import com.huaxu.zoniot.entity.Customer;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * <p></p>
+ * @Author wilian.peng
+ * @Date 2021/1/14 15:59
+ * @Version 1.0
+ */
+@Mapper
+public interface CustomerMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(Customer record);
+
+    int insertSelective(Customer record);
+
+    Customer selectByPrimaryKey(Integer id);
+
+    List<Customer> selectByParentId(Integer parentId);
+
+    int updateByPrimaryKeySelective(Customer record);
+
+    int updateByPrimaryKey(Customer record);
+}

+ 12 - 0
meter-reading-common/src/main/java/com/huaxu/zoniot/dao/WaterMeterMapper.java

@@ -42,6 +42,15 @@ public interface WaterMeterMapper {
 
 
     WaterMeter findWaterMeterByDeviceNo(@Param("deviceNo") String deviceNo);
     WaterMeter findWaterMeterByDeviceNo(@Param("deviceNo") String deviceNo);
 
 
+    /**
+     * 在多个客户下查询水表是否存在
+     * @param deviceNo
+     * @param customerList
+     * @return
+     */
+    WaterMeter findWaterMeterByDeviceNoAndCustomerList(@Param("deviceNo") String deviceNo,
+                                                     @Param("customerList") List<Integer> customerList);
+
     WaterMeter findWaterMeterByDeviceNoAndCustomerId(@Param("deviceNo") String deviceNo,
     WaterMeter findWaterMeterByDeviceNoAndCustomerId(@Param("deviceNo") String deviceNo,
                                                      @Param("customerId") Integer customerId);
                                                      @Param("customerId") Integer customerId);
 
 
@@ -58,4 +67,7 @@ public interface WaterMeterMapper {
                                                      @Param("start") Integer start, @Param("offset") Integer offset);
                                                      @Param("start") Integer start, @Param("offset") Integer offset);
 
 
     List<WaterMeter> findWaterMeterByDeviceNoList(@Param("deviceNoList")List<String> deviceNoList , @Param("customerId") Integer customerId);
     List<WaterMeter> findWaterMeterByDeviceNoList(@Param("deviceNoList")List<String> deviceNoList , @Param("customerId") Integer customerId);
+
+    List<WaterMeter> findWaterMeterByDeviceNoAndChildrenCustomer(@Param("deviceNoList")List<String> deviceNoList , @Param("customerList") List<Integer> customerList);
+
 }
 }

+ 110 - 0
meter-reading-common/src/main/java/com/huaxu/zoniot/entity/Customer.java

@@ -0,0 +1,110 @@
+package com.huaxu.zoniot.entity;
+
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * <p></p>
+ * @Author wilian.peng
+ * @Date 2021/1/14 15:59
+ * @Version 1.0
+ */
+@Data
+public class Customer {
+    /**
+    * 主键
+    */
+    private Integer id;
+
+    /**
+    * 站点,参考sc_site主键
+    */
+    private Integer siteId;
+
+    /**
+    * 客户名称
+    */
+    private String customerName;
+
+    /**
+    * 客户联系方式
+    */
+    private String customerPhone;
+
+    /**
+    * 客户联系人
+    */
+    private String customerContactPerson;
+
+    /**
+    * 推送地址
+    */
+    private String pushUrl;
+
+    /**
+    * 客户编号
+    */
+    private String customerNo;
+
+    /**
+    * 客户token
+    */
+    private String token;
+
+    /**
+    * 备注
+    */
+    private String remark;
+
+    /**
+    * 状态
+    */
+    private Integer status;
+
+    /**
+    * 客户对应机构,每个客户都会有个对应的机构
+    */
+    private Integer customerOrgId;
+
+    /**
+    * 创建时间
+    */
+    private Date dateCreate;
+
+    /**
+    * 更新时间
+    */
+    private Date dateUpdate;
+
+    /**
+    * 创建人
+    */
+    private String createBy;
+
+    /**
+    * 更新人
+    */
+    private String updateBy;
+
+    /**
+    * 用水阶段类型 1:年 2:月 3:日
+    */
+    private Integer stageType;
+
+    /**
+    * 价格图
+    */
+    private String pictureUrl;
+
+    private Integer parentId;
+
+    /**
+    * childrenNum
+    */
+    private Integer childrenNum;
+
+    /**
+    * 收据类型:0:默认 1:开鲁 2:盖州
+    */
+    private Integer payInvoiceType;
+}

+ 0 - 2
meter-reading-common/src/main/java/com/huaxu/zoniot/service/CommunityService.java

@@ -15,7 +15,6 @@ public interface CommunityService {
      * 默认规则:一个区下面小区名称是不相同
      * 默认规则:一个区下面小区名称是不相同
      * @param name
      * @param name
      * @param siteId
      * @param siteId
-     * @param customerId
      * @param provinceCode
      * @param provinceCode
      * @param cityCode
      * @param cityCode
      * @param regionCode
      * @param regionCode
@@ -24,7 +23,6 @@ public interface CommunityService {
     Community findCommunity(
     Community findCommunity(
             String name ,
             String name ,
             Integer siteId ,
             Integer siteId ,
-            Integer customerId ,
             Integer provinceCode ,
             Integer provinceCode ,
             Integer cityCode ,
             Integer cityCode ,
             Integer regionCode
             Integer regionCode

+ 2 - 0
meter-reading-common/src/main/java/com/huaxu/zoniot/service/WaterMeterService.java

@@ -23,4 +23,6 @@ public interface WaterMeterService {
     WaterMeter findWaterMeterByMeterNo(Integer customerId ,String meterNo);
     WaterMeter findWaterMeterByMeterNo(Integer customerId ,String meterNo);
 
 
     List<WaterMeter> findWaterMeterList(List<String> deviceNoList , Integer customerId ) ;
     List<WaterMeter> findWaterMeterList(List<String> deviceNoList , Integer customerId ) ;
+
+    List<WaterMeter> findWaterMeterListWithChildrenCustomer(List<String> deviceNoList , Integer customerId ) ;
 }
 }

+ 2 - 5
meter-reading-common/src/main/java/com/huaxu/zoniot/service/impl/CommunityServiceImpl.java

@@ -31,19 +31,17 @@ public class CommunityServiceImpl implements CommunityService, ModelValidate<Com
     @Override
     @Override
     public Community findCommunity(String name,
     public Community findCommunity(String name,
                                    Integer siteId ,
                                    Integer siteId ,
-                                   Integer customerId ,
                                    Integer provinceCode,
                                    Integer provinceCode,
                                    Integer cityCode,
                                    Integer cityCode,
                                    Integer regionCode) {
                                    Integer regionCode) {
         Community object = new Community();
         Community object = new Community();
         object.setSiteId(siteId);
         object.setSiteId(siteId);
-        object.setCustomerId(customerId);
         object.setName(name);
         object.setName(name);
         object.setProvince(provinceCode);
         object.setProvince(provinceCode);
         object.setCity(cityCode);
         object.setCity(cityCode);
         object.setRegion(regionCode);
         object.setRegion(regionCode);
-        validate(object);
-        Community community = communityMapper.findCommunityWithName(name, siteId  , customerId, provinceCode, cityCode, regionCode);
+        //validate(object);
+        Community community = communityMapper.findCommunityWithName(name, siteId , provinceCode, cityCode, regionCode);
         return community;
         return community;
     }
     }
 
 
@@ -52,7 +50,6 @@ public class CommunityServiceImpl implements CommunityService, ModelValidate<Com
         validate(community);
         validate(community);
         Community exist = findCommunity(community.getName(),
         Community exist = findCommunity(community.getName(),
                 community.getSiteId(),
                 community.getSiteId(),
-                community.getCustomerId() ,
                 community.getProvince(),
                 community.getProvince(),
                 community.getCity(),
                 community.getCity(),
                 community.getRegion());
                 community.getRegion());

+ 26 - 4
meter-reading-common/src/main/java/com/huaxu/zoniot/service/impl/WaterMeterServiceImpl.java

@@ -4,10 +4,7 @@ import com.huaxu.zoniot.common.Constants;
 import com.huaxu.zoniot.common.ModelValidate;
 import com.huaxu.zoniot.common.ModelValidate;
 import com.huaxu.zoniot.common.ResultStatus;
 import com.huaxu.zoniot.common.ResultStatus;
 import com.huaxu.zoniot.common.ServiceException;
 import com.huaxu.zoniot.common.ServiceException;
-import com.huaxu.zoniot.dao.DeviceDimensionMapper;
-import com.huaxu.zoniot.dao.DeviceTypeMapper;
-import com.huaxu.zoniot.dao.WaterMeterMapper;
-import com.huaxu.zoniot.dao.WaterMeterTypeMapper;
+import com.huaxu.zoniot.dao.*;
 import com.huaxu.zoniot.entity.*;
 import com.huaxu.zoniot.entity.*;
 import com.huaxu.zoniot.service.WaterMeterService;
 import com.huaxu.zoniot.service.WaterMeterService;
 import com.huaxu.zoniot.utils.SnowflakeIdWorker;
 import com.huaxu.zoniot.utils.SnowflakeIdWorker;
@@ -45,6 +42,9 @@ public class WaterMeterServiceImpl implements WaterMeterService, ModelValidate<W
     @Autowired
     @Autowired
     DeviceDimensionMapper deviceDimensionMapper ;
     DeviceDimensionMapper deviceDimensionMapper ;
 
 
+    @Autowired
+    CustomerMapper customerMapper ;
+
     @Override
     @Override
     public int saveWaterWaterMeterList(List<WaterMeter> waterMeterList) {
     public int saveWaterWaterMeterList(List<WaterMeter> waterMeterList) {
         List<DeviceDimension> dimensionList = new ArrayList<>();
         List<DeviceDimension> dimensionList = new ArrayList<>();
@@ -129,6 +129,13 @@ public class WaterMeterServiceImpl implements WaterMeterService, ModelValidate<W
         return waterMeterMapper.findWaterMeterByDeviceNoList(deviceNoList,customerId);
         return waterMeterMapper.findWaterMeterByDeviceNoList(deviceNoList,customerId);
     }
     }
 
 
+    @Override
+    public List<WaterMeter> findWaterMeterListWithChildrenCustomer(List<String> deviceNoList, Integer customerId) {
+        List<Integer> customerIdsWithChildren = findCustomerIdsWithChildren(customerId);
+        return waterMeterMapper.findWaterMeterByDeviceNoAndChildrenCustomer(deviceNoList,customerIdsWithChildren);
+    }
+
+
     protected  WaterMeterType findWaterMeterType(Integer deviceTypeId){
     protected  WaterMeterType findWaterMeterType(Integer deviceTypeId){
         WaterMeterType waterMeterType = waterMeterTypeMapper.findByDeviceTypeId(deviceTypeId);
         WaterMeterType waterMeterType = waterMeterTypeMapper.findByDeviceTypeId(deviceTypeId);
         return waterMeterType ;
         return waterMeterType ;
@@ -167,4 +174,19 @@ public class WaterMeterServiceImpl implements WaterMeterService, ModelValidate<W
         }
         }
         return true;
         return true;
     }
     }
+
+    /**
+     * 查询公司及其分公司的ID
+     * @param customerCode
+     * @return
+     */
+    protected  List<Integer> findCustomerIdsWithChildren(Integer customerCode){
+        List<Integer> customerIds = new ArrayList<>();
+        customerIds.add(customerCode);
+        List<Customer> customers = customerMapper.selectByParentId(customerCode);
+        customers.forEach(customer -> {
+            customerIds.add(customer.getId());
+        });
+        return customerIds ;
+    }
 }
 }

+ 1 - 1
meter-reading-common/src/main/resources/mapper/CommunityMapper.xml

@@ -270,7 +270,7 @@
     where status = 1
     where status = 1
       and name = #{name,jdbcType=VARCHAR}
       and name = #{name,jdbcType=VARCHAR}
       and site_id = #{siteId,jdbcType=INTEGER}
       and site_id = #{siteId,jdbcType=INTEGER}
-      and customer_id = #{customerId,jdbcType=INTEGER}
+      <!-- and customer_id = #{customerId,jdbcType=INTEGER} -->
       and province = #{province,jdbcType=INTEGER}
       and province = #{province,jdbcType=INTEGER}
       and city = #{city,jdbcType=INTEGER}
       and city = #{city,jdbcType=INTEGER}
       and region = #{region,jdbcType=INTEGER}
       and region = #{region,jdbcType=INTEGER}

+ 280 - 0
meter-reading-common/src/main/resources/mapper/CustomerMapper.xml

@@ -0,0 +1,280 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.huaxu.zoniot.dao.CustomerMapper">
+  <resultMap id="BaseResultMap" type="com.huaxu.zoniot.entity.Customer">
+    <!--@mbg.generated-->
+    <!--@Table sc_customer-->
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="site_id" jdbcType="INTEGER" property="siteId" />
+    <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
+    <result column="customer_phone" jdbcType="VARCHAR" property="customerPhone" />
+    <result column="customer_contact_person" jdbcType="VARCHAR" property="customerContactPerson" />
+    <result column="push_url" jdbcType="VARCHAR" property="pushUrl" />
+    <result column="customer_no" jdbcType="VARCHAR" property="customerNo" />
+    <result column="token" jdbcType="VARCHAR" property="token" />
+    <result column="remark" jdbcType="VARCHAR" property="remark" />
+    <result column="status" jdbcType="INTEGER" property="status" />
+    <result column="customer_org_id" jdbcType="INTEGER" property="customerOrgId" />
+    <result column="date_create" jdbcType="TIMESTAMP" property="dateCreate" />
+    <result column="date_update" jdbcType="TIMESTAMP" property="dateUpdate" />
+    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
+    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
+    <result column="stage_type" jdbcType="INTEGER" property="stageType" />
+    <result column="picture_url" jdbcType="VARCHAR" property="pictureUrl" />
+    <result column="parent_id" jdbcType="INTEGER" property="parentId" />
+    <result column="children_num" jdbcType="INTEGER" property="childrenNum" />
+    <result column="pay_invoice_type" jdbcType="INTEGER" property="payInvoiceType" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, site_id, customer_name, customer_phone, customer_contact_person, push_url, customer_no, 
+    token, remark, `status`, customer_org_id, date_create, date_update, create_by, update_by, 
+    stage_type, picture_url, parent_id, children_num, pay_invoice_type
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    <!--@mbg.generated-->
+    select 
+    <include refid="Base_Column_List" />
+    from sc_customer
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <select id="selectByParentId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from sc_customer
+    where parent_id = #{parentId,jdbcType=INTEGER}
+    and status = 1
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    <!--@mbg.generated-->
+    delete from sc_customer
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.huaxu.zoniot.entity.Customer" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_customer (site_id, customer_name, customer_phone, 
+      customer_contact_person, push_url, customer_no, 
+      token, remark, `status`, 
+      customer_org_id, date_create, date_update, 
+      create_by, update_by, stage_type, 
+      picture_url, parent_id, children_num, 
+      pay_invoice_type)
+    values (#{siteId,jdbcType=INTEGER}, #{customerName,jdbcType=VARCHAR}, #{customerPhone,jdbcType=VARCHAR}, 
+      #{customerContactPerson,jdbcType=VARCHAR}, #{pushUrl,jdbcType=VARCHAR}, #{customerNo,jdbcType=VARCHAR}, 
+      #{token,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, 
+      #{customerOrgId,jdbcType=INTEGER}, #{dateCreate,jdbcType=TIMESTAMP}, #{dateUpdate,jdbcType=TIMESTAMP}, 
+      #{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR}, #{stageType,jdbcType=INTEGER}, 
+      #{pictureUrl,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER}, #{childrenNum,jdbcType=INTEGER}, 
+      #{payInvoiceType,jdbcType=INTEGER})
+  </insert>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.huaxu.zoniot.entity.Customer" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_customer
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="siteId != null">
+        site_id,
+      </if>
+      <if test="customerName != null">
+        customer_name,
+      </if>
+      <if test="customerPhone != null">
+        customer_phone,
+      </if>
+      <if test="customerContactPerson != null">
+        customer_contact_person,
+      </if>
+      <if test="pushUrl != null">
+        push_url,
+      </if>
+      <if test="customerNo != null">
+        customer_no,
+      </if>
+      <if test="token != null">
+        token,
+      </if>
+      <if test="remark != null">
+        remark,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="customerOrgId != null">
+        customer_org_id,
+      </if>
+      <if test="dateCreate != null">
+        date_create,
+      </if>
+      <if test="dateUpdate != null">
+        date_update,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+      <if test="stageType != null">
+        stage_type,
+      </if>
+      <if test="pictureUrl != null">
+        picture_url,
+      </if>
+      <if test="parentId != null">
+        parent_id,
+      </if>
+      <if test="childrenNum != null">
+        children_num,
+      </if>
+      <if test="payInvoiceType != null">
+        pay_invoice_type,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="siteId != null">
+        #{siteId,jdbcType=INTEGER},
+      </if>
+      <if test="customerName != null">
+        #{customerName,jdbcType=VARCHAR},
+      </if>
+      <if test="customerPhone != null">
+        #{customerPhone,jdbcType=VARCHAR},
+      </if>
+      <if test="customerContactPerson != null">
+        #{customerContactPerson,jdbcType=VARCHAR},
+      </if>
+      <if test="pushUrl != null">
+        #{pushUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="customerNo != null">
+        #{customerNo,jdbcType=VARCHAR},
+      </if>
+      <if test="token != null">
+        #{token,jdbcType=VARCHAR},
+      </if>
+      <if test="remark != null">
+        #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
+      <if test="customerOrgId != null">
+        #{customerOrgId,jdbcType=INTEGER},
+      </if>
+      <if test="dateCreate != null">
+        #{dateCreate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="dateUpdate != null">
+        #{dateUpdate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createBy != null">
+        #{createBy,jdbcType=VARCHAR},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy,jdbcType=VARCHAR},
+      </if>
+      <if test="stageType != null">
+        #{stageType,jdbcType=INTEGER},
+      </if>
+      <if test="pictureUrl != null">
+        #{pictureUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="parentId != null">
+        #{parentId,jdbcType=INTEGER},
+      </if>
+      <if test="childrenNum != null">
+        #{childrenNum,jdbcType=INTEGER},
+      </if>
+      <if test="payInvoiceType != null">
+        #{payInvoiceType,jdbcType=INTEGER},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.huaxu.zoniot.entity.Customer">
+    <!--@mbg.generated-->
+    update sc_customer
+    <set>
+      <if test="siteId != null">
+        site_id = #{siteId,jdbcType=INTEGER},
+      </if>
+      <if test="customerName != null">
+        customer_name = #{customerName,jdbcType=VARCHAR},
+      </if>
+      <if test="customerPhone != null">
+        customer_phone = #{customerPhone,jdbcType=VARCHAR},
+      </if>
+      <if test="customerContactPerson != null">
+        customer_contact_person = #{customerContactPerson,jdbcType=VARCHAR},
+      </if>
+      <if test="pushUrl != null">
+        push_url = #{pushUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="customerNo != null">
+        customer_no = #{customerNo,jdbcType=VARCHAR},
+      </if>
+      <if test="token != null">
+        token = #{token,jdbcType=VARCHAR},
+      </if>
+      <if test="remark != null">
+        remark = #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=INTEGER},
+      </if>
+      <if test="customerOrgId != null">
+        customer_org_id = #{customerOrgId,jdbcType=INTEGER},
+      </if>
+      <if test="dateCreate != null">
+        date_create = #{dateCreate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="dateUpdate != null">
+        date_update = #{dateUpdate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createBy != null">
+        create_by = #{createBy,jdbcType=VARCHAR},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy,jdbcType=VARCHAR},
+      </if>
+      <if test="stageType != null">
+        stage_type = #{stageType,jdbcType=INTEGER},
+      </if>
+      <if test="pictureUrl != null">
+        picture_url = #{pictureUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="parentId != null">
+        parent_id = #{parentId,jdbcType=INTEGER},
+      </if>
+      <if test="childrenNum != null">
+        children_num = #{childrenNum,jdbcType=INTEGER},
+      </if>
+      <if test="payInvoiceType != null">
+        pay_invoice_type = #{payInvoiceType,jdbcType=INTEGER},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.huaxu.zoniot.entity.Customer">
+    <!--@mbg.generated-->
+    update sc_customer
+    set site_id = #{siteId,jdbcType=INTEGER},
+      customer_name = #{customerName,jdbcType=VARCHAR},
+      customer_phone = #{customerPhone,jdbcType=VARCHAR},
+      customer_contact_person = #{customerContactPerson,jdbcType=VARCHAR},
+      push_url = #{pushUrl,jdbcType=VARCHAR},
+      customer_no = #{customerNo,jdbcType=VARCHAR},
+      token = #{token,jdbcType=VARCHAR},
+      remark = #{remark,jdbcType=VARCHAR},
+      `status` = #{status,jdbcType=INTEGER},
+      customer_org_id = #{customerOrgId,jdbcType=INTEGER},
+      date_create = #{dateCreate,jdbcType=TIMESTAMP},
+      date_update = #{dateUpdate,jdbcType=TIMESTAMP},
+      create_by = #{createBy,jdbcType=VARCHAR},
+      update_by = #{updateBy,jdbcType=VARCHAR},
+      stage_type = #{stageType,jdbcType=INTEGER},
+      picture_url = #{pictureUrl,jdbcType=VARCHAR},
+      parent_id = #{parentId,jdbcType=INTEGER},
+      children_num = #{childrenNum,jdbcType=INTEGER},
+      pay_invoice_type = #{payInvoiceType,jdbcType=INTEGER}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+</mapper>

+ 16 - 0
meter-reading-common/src/main/resources/mapper/WaterMeterMapper.xml

@@ -216,6 +216,22 @@
         and d.customer_id = #{customerId,jdbcType=INTEGER}
         and d.customer_id = #{customerId,jdbcType=INTEGER}
         and d.device_no  in <foreach collection="deviceNoList" item="deviceNo" open="(" close=")" separator=",">#{deviceNo}</foreach>
         and d.device_no  in <foreach collection="deviceNoList" item="deviceNo" open="(" close=")" separator=",">#{deviceNo}</foreach>
     </select>
     </select>
+    <select id="findWaterMeterByDeviceNoAndChildrenCustomer" resultMap="BaseResultMap">
+        <include refid="Base_Meter_Query" />
+        and d.device_no in <foreach collection="deviceNoList" item="deviceNo" open="(" close=")" separator=",">#{deviceNo}</foreach>
+        and d.customer_id  in
+        <foreach collection="customerList" item="customerId" open="(" close=")" separator=",">
+            #{customerId}
+        </foreach>
+    </select>
+    <select id="findWaterMeterByDeviceNoAndCustomerList" resultMap="BaseResultMap">
+        <include refid="Base_Meter_Query" />
+        and d.device_no = #{deviceNo,jdbcType=INTEGER}
+        and d.customer_id  in
+        <foreach collection="customerList" item="customerId" open="(" close=")" separator=",">
+            #{customerId}
+        </foreach>
+    </select>
 
 
     <insert id="batchInsert" keyProperty="waterMeter.id" parameterType="map">
     <insert id="batchInsert" keyProperty="waterMeter.id" parameterType="map">
         INSERT INTO sc_device (
         INSERT INTO sc_device (

+ 30 - 10
meter-reading-tianjin/src/main/java/com/huaxu/zoniot/service/impl/TianJinMeterReadingServiceImpl.java

@@ -5,14 +5,12 @@ import com.huaxu.zoniot.common.Constants;
 import com.huaxu.zoniot.common.ErrorConstants;
 import com.huaxu.zoniot.common.ErrorConstants;
 import com.huaxu.zoniot.common.ResultStatus;
 import com.huaxu.zoniot.common.ResultStatus;
 import com.huaxu.zoniot.common.ServiceException;
 import com.huaxu.zoniot.common.ServiceException;
+import com.huaxu.zoniot.dao.CustomerMapper;
 import com.huaxu.zoniot.dao.WaterMeterMapper;
 import com.huaxu.zoniot.dao.WaterMeterMapper;
 import com.huaxu.zoniot.dto.RegistIMEIRequest;
 import com.huaxu.zoniot.dto.RegistIMEIRequest;
 import com.huaxu.zoniot.dto.RespData;
 import com.huaxu.zoniot.dto.RespData;
 import com.huaxu.zoniot.dto.RtnData;
 import com.huaxu.zoniot.dto.RtnData;
-import com.huaxu.zoniot.entity.Building;
-import com.huaxu.zoniot.entity.Community;
-import com.huaxu.zoniot.entity.MeterReadRecord;
-import com.huaxu.zoniot.entity.WaterMeter;
+import com.huaxu.zoniot.entity.*;
 import com.huaxu.zoniot.repository.MeterReadRecordRepository;
 import com.huaxu.zoniot.repository.MeterReadRecordRepository;
 import com.huaxu.zoniot.service.BuildingService;
 import com.huaxu.zoniot.service.BuildingService;
 import com.huaxu.zoniot.service.CommunityService;
 import com.huaxu.zoniot.service.CommunityService;
@@ -43,6 +41,9 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
     @Autowired
     @Autowired
     WaterMeterMapper  waterMeterMapper ;
     WaterMeterMapper  waterMeterMapper ;
 
 
+    @Autowired
+    CustomerMapper  customerMapper ;
+
     @Value("${province.code}")
     @Value("${province.code}")
     Integer provinceCode ;
     Integer provinceCode ;
 
 
@@ -150,7 +151,9 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
         }
         }
         RespData  respData = new RespData();
         RespData  respData = new RespData();
         List<String> deviceNoList = Arrays.asList(imeiArray);
         List<String> deviceNoList = Arrays.asList(imeiArray);
-        List<WaterMeter> waterMeterList = waterMeterService.findWaterMeterList(deviceNoList, customerCode);
+        List<Integer> customerIds = findCustomerIdsWithChildren(customerCode);
+        List<WaterMeter> waterMeterList = waterMeterService.findWaterMeterListWithChildrenCustomer(deviceNoList,
+                customerCode);
         Criteria criteria = Criteria.where("readDate").is(readDay)
         Criteria criteria = Criteria.where("readDate").is(readDay)
                 .and("status").is(1)
                 .and("status").is(1)
                 .and("readStatus").is("2")
                 .and("readStatus").is("2")
@@ -169,7 +172,7 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
             WaterMeter waterMeter = waterMeterMap.get(imei);
             WaterMeter waterMeter = waterMeterMap.get(imei);
             if(waterMeter != null){
             if(waterMeter != null){
                 MeterReadRecord meterReadRecord = meterReadRecordMap.get(imei);
                 MeterReadRecord meterReadRecord = meterReadRecordMap.get(imei);
-                rtnData.setECURegDate(DateUtil.format(waterMeter.getDateCreate(), "yyyy-MM-dd"));
+                rtnData.setECURegDate(DateUtil.format(waterMeter.getDateCreate(), "yyyy-MM-dd HH:mm:ss"));
                 if(meterReadRecord != null){
                 if(meterReadRecord != null){
                     buildRtnData(meterReadRecord,rtnData);
                     buildRtnData(meterReadRecord,rtnData);
                 }
                 }
@@ -217,13 +220,14 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
 
 
         // 获取抄表时间,格式:yyyy-MM-dd
         // 获取抄表时间,格式:yyyy-MM-dd
         Date readTime = meterReadRecord.getReadTime();
         Date readTime = meterReadRecord.getReadTime();
-        rtnData.setRXDDate(DateUtil.format(readTime, "yyyy-MM-dd"));
+        rtnData.setRXDDate(DateUtil.format(readTime, "yyyy-MM-dd HH:mm:ss"));
         // 表盘读数,原数据
         // 表盘读数,原数据
         rtnData.setRXDReading(meterReadRecord.getReadData());
         rtnData.setRXDReading(meterReadRecord.getReadData());
         // 抄表止度,向下取整
         // 抄表止度,向下取整
         rtnData.setReading(String.valueOf(
         rtnData.setReading(String.valueOf(
-                Math.floor(
-                        Double.parseDouble(meterReadRecord.getReadData()))));
+                ((Double)Math.floor(
+                        Double.parseDouble(meterReadRecord.getReadData()))).intValue()));
+        rtnData.setMessage("正常");
     }
     }
     /**
     /**
      * 返回数据格式第一位为是否告警,0:正常,1:有告警
      * 返回数据格式第一位为是否告警,0:正常,1:有告警
@@ -297,7 +301,8 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
     @Override
     @Override
     public RespData queryImei(String imei) {
     public RespData queryImei(String imei) {
         RespData respData = new RespData();
         RespData respData = new RespData();
-        WaterMeter waterMeter = waterMeterMapper.findWaterMeterByDeviceNoAndCustomerId(imei,customerCode);
+        List<Integer> customerIds = findCustomerIdsWithChildren(customerCode);
+        WaterMeter waterMeter = waterMeterMapper.findWaterMeterByDeviceNoAndCustomerList(imei,customerIds);
         if(waterMeter == null){
         if(waterMeter == null){
             // 设备未注册
             // 设备未注册
             respData.setRtnId(RespData.SUCCESS);
             respData.setRtnId(RespData.SUCCESS);
@@ -309,4 +314,19 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
         }
         }
         return respData;
         return respData;
     }
     }
+
+    /**
+     * 查询公司及其分公司的ID
+     * @param customerCode
+     * @return
+     */
+    protected  List<Integer> findCustomerIdsWithChildren(Integer customerCode){
+        List<Integer> customerIds = new ArrayList<>();
+        customerIds.add(customerCode);
+        List<Customer> customers = customerMapper.selectByParentId(customerCode);
+        customers.forEach(customer -> {
+            customerIds.add(customer.getId());
+        });
+        return customerIds ;
+    }
 }
 }

+ 1 - 0
meter-reading-tianjin/src/main/resources/application-tianjin-dev.properties

@@ -10,5 +10,6 @@ meterBore=NB_IOT_20mm
 province.code=120000
 province.code=120000
 city.code=120100
 city.code=120100
 region.code=120112
 region.code=120112
+#ÅäÖýòÄÏ×ܹ«Ë¾µÄ¿Í»§ID
 customer.code=54
 customer.code=54
 device.type.code=20
 device.type.code=20

+ 15 - 0
meter-reading-tianjin/src/main/resources/application-tianjin-sit.properties

@@ -0,0 +1,15 @@
+server.port=8001
+logging.level.root=info
+logging.file.path=./logs
+server.servlet.context-path=/readmeter
+spring.application.name=meter-reading-tianjin
+##############################################业务配置##########################################
+api.key=hauxureadmeter
+netcode=20191118
+meterBore=NB_IOT_20mm
+province.code=120000
+city.code=120100
+region.code=120112
+#配置津南总公司的客户ID
+customer.code=54
+device.type.code=20