Parcourir la source

水表档案同步

oppadmin il y a 4 ans
Parent
commit
8efb8ddfc0

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/DeviceMapper.java

@@ -23,5 +23,8 @@ public interface DeviceMapper {
     //同步水表信息
     int updateSync(@Param("devices") MeterSyncDto devices);
 
+    //更新水表档案号
+    int updateMeterCode(@Param("customerId") Integer customerId,@Param("oldMeterCode") String oldMeterCode,@Param("newMeterCode") String newMeterCode);
+
 }
 

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/MeterSyncDto.java

@@ -34,6 +34,9 @@ public class MeterSyncDto {
     @ApiModelProperty(value = "水表档案号")
     private	String	fileNo;
 
+    @ApiModelProperty(value = "计费系统水表档案号")
+    private	String	meterCode ;
+
     @ApiModelProperty(value = "水表起度")
     private	String	initialData;
 

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/entity/SyncValveResult.java

@@ -10,7 +10,7 @@ import lombok.Data;
 @Data
 @ApiModel(value = "同步结果")
 public class SyncValveResult {
-    @ApiModelProperty("返回状态,成功000000")
+    @ApiModelProperty("返回状态,成功0")
     private String status;
 
     @ApiModelProperty("提示")

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

@@ -13,6 +13,7 @@ import com.bz.smart_city.dto.MeterSyncInputDto;
 import com.bz.smart_city.dto.pay.PayBaseConfigDto;
 import com.bz.smart_city.entity.Customer;
 import com.bz.smart_city.entity.Device;
+import com.bz.smart_city.entity.SyncValveResult;
 import com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela;
 import com.bz.smart_city.quartz.entity.QuartzEntity;
 import com.bz.smart_city.quartz.job.DeviceSyncJob;
@@ -138,10 +139,49 @@ public class DeviceSyncServiceImpl implements DeviceSyncService, InitializingBea
                         //更新水表信息
                         if(ajaxMessage.getStatus() == 0){
                             List<MeterSyncDto> meterSyncDtoList = ajaxMessage.getData();
+                            if(meterSyncDtoList != null){
+                                for(MeterSyncDto meterSyncDto:meterSyncDtoList){
+                                    //水表档案号变更
+                                    if(!meterSyncDto.getMeterCode().equals(meterSyncDto.getFileNo())){
+                                        //修改计费系统水表档案号
+                                        if(deviceMapper.updateMeterCode(null,meterSyncDto.getMeterCode(),meterSyncDto.getFileNo()) > 0){
+                                            try {
+                                                meterSyncDto.setMeterCode(meterSyncDto.getFileNo());
+                                                //更改营业系统水表档案号
+                                                String updateMeterNoUrl = url + "/api/platform/updateMeterNo";
+                                                String params = String.format("?customerNo=%s&meterNo=%s&meterCode=%s",customerId,meterSyncDto.getFileNo(),meterSyncDto.getMeterCode());
+                                                updateMeterNoUrl += params;
+                                                String postResult = HttpRequest.doPost(updateMeterNoUrl ,"");
+                                                SyncValveResult syncValveResult = JacksonUtil.string2Obj(postResult, SyncValveResult.class);
+                                                Integer getResult = Integer.parseInt(syncValveResult.getStatus());
+                                            }
+                                            catch (Exception e){
+                                                e.printStackTrace();
+                                            }
+                                        }
+                                        else
+                                            continue;
+                                    }
+
+
+                                    String strList = JacksonUtil.obj2String(meterSyncDto);
+                                    MeterSyncDto resultMeterSyncDto = JacksonUtil.string2Obj(strList,MeterSyncDto.class);
+                                    resultMeterSyncDto.setCurrStatus(1);
+
+                                    if(StringUtils.isBlank(resultMeterSyncDto.getInitialData()))
+                                        resultMeterSyncDto.setInitialData("0");
+                                    deviceMapper.updateSync(resultMeterSyncDto);
+                                }
+                            }
 
                             for(int i=0;i<meterSyncDtoList.size();i++){
 
-                                //通知营业系统更新水表编号
+                                //水表档案号变更
+                                if(!meterSyncDtoList.get(i).getMeterCode().equals(meterSyncDtoList.get(i).getFileNo())){
+                                    //修改计费系统水表档案号
+
+
+                                }
 
                                 String strList = JacksonUtil.obj2String(meterSyncDtoList.get(i));
                                 MeterSyncDto meterSyncDto = JacksonUtil.string2Obj(strList,MeterSyncDto.class);

+ 29 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayControlRuleServiceImpl.java

@@ -411,6 +411,35 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
         List<PayControlRule> payControlRules = payControlRuleMapper.findList(id,null,null);
         if(payControlRules.size() ==1){
             String condition= payControlRules.get(0).getOperator();
+            int conditionValue= Integer.valueOf(condition);
+            switch (conditionValue){
+                case 1:{
+                    condition = "=";
+                    break;
+                }
+                case 2:{
+                    condition = "<>";
+                    break;
+                }
+                case 3:{
+                    condition = ">";
+                    break;
+                }
+                case 4:{
+                    condition = "<";
+                    break;
+                }
+                case 5:{
+                    condition = ">=";
+                    break;
+                }
+                case 6:{
+                    condition = "<=";
+                    break;
+                }
+            }
+
+
             String value = payControlRules.get(0).getValue();
             boolean bl = false;
             switch (payControlRules.get(0).getConditionId()){

+ 7 - 0
smart-city-platform/src/main/resources/mapper/DeviceMapper.xml

@@ -96,6 +96,13 @@
         where metercode = #{devices.fileNo,jdbcType=VARCHAR}
     </update>
 
+    <update id="updateMeterCode">
+        update sc_device
+        set metercode=#{newMeterCode}
+        where metercode = #{newMeterCode}
+        <if test="customerId != null and customerId != ''"> and customer_id=#{customerId}</if>
+    </update>
+
     <select id="getNoSyncList" resultType="com.bz.smart_city.entity.Device">
         select
         id,

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

@@ -66,7 +66,7 @@
             del_flag = 0
             <if test="customerId != null"> and customer_id = #{customerId} </if>
             <if test="id != null"> and id = #{id}</if>
-            <if test="name != null"> and name = #{name}</if>
+            <if test="name != null and name != ''"> and name = #{name}</if>
         </where>
     </select>
 
@@ -92,7 +92,7 @@
         <where>
             del_flag = 0 and customer_id = #{customerId}
             <if test="id != null"> and id = #{id}</if>
-            <if test="name != null"> and name = #{name}</if>
+            <if test="name != null and name != ''"> and name = #{name}</if>
         </where>
 
     </select>