Browse Source

在工单中换表后同步新表起度和旧表止度到sc_install_list

zhoujiangyuan 4 years ago
parent
commit
23e18f25d1

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

@@ -38,6 +38,8 @@ public interface InstallListMapper {
 
     int updateByPrimaryKey(InstallList record);
 
+    int updateByDeviceId2(InstallList record);
+
     List<InstallListDTO> queryUnPlanedList(@Param("customerId") Integer customerId,
                                            @Param("meterCode") String meterCode,
                                            @Param("communityId") Integer communityId,

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

@@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSON;
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dao.*;
+import com.bz.smart_city.dao.assistant.InstallListMapper;
 import com.bz.smart_city.dto.DeviceErrorDto;
 import com.bz.smart_city.dto.WaterMeterMaintenanceLogDto;
 import com.bz.smart_city.entity.*;
+import com.bz.smart_city.entity.assistant.InstallList;
 import com.bz.smart_city.service.WorkOrderService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -43,6 +45,8 @@ public class WaterMeterMaintenanceLogServiceImpl implements WaterMeterMaintenanc
     private DeviceMapper deviceMapper;
     @Autowired
     private WorkOrderService workOrderService;
+    @Resource
+    private InstallListMapper installListMapper;
 
     @Override
     public int insert(WaterMeterMaintenanceLog waterMeterMaintenanceLog) {
@@ -160,6 +164,15 @@ public class WaterMeterMaintenanceLogServiceImpl implements WaterMeterMaintenanc
 
                 //完成工单任务
                 workOrderService.handle(waterMeterMaintenanceLog.getTaskId(), "换表", null);
+
+                //更新安装列表中的初始读数和旧表读数
+                InstallList installList = new InstallList();
+                installList.setDeviceId(waterMeterMaintenanceLog.getDeviceId());
+                installList.setNewMeterStart(waterMeterMaintenanceLog.getNewBeginWsv());
+                installList.setOldMeterEnd(waterMeterMaintenanceLog.getOldEndWsv());
+                installList.setDateUpdate(LocalDateTime.now());
+                installListMapper.updateByDeviceId2(installList);
+
             }
             //4、更新设备信息
             Device newDevice = new Device();

+ 17 - 0
smart-city-platform/src/main/resources/mapper/InstallListMapper.xml

@@ -761,6 +761,23 @@
     </set>
     where id = #{id}
   </update>
+
+  <update id="updateByDeviceId2" parameterType="com.bz.smart_city.entity.assistant.InstallList">
+    update sc_install_list
+    <set>
+      <if test="newMeterStart != null">
+        new_meter_start = #{newMeterStart},
+      </if>
+      <if test="oldMeterEnd != null">
+        old_meter_end = #{oldMeterEnd},
+      </if>
+      <if test="dateUpdate != null">
+        date_update = #{dateUpdate},
+      </if>
+
+    </set>
+    where device_id = #{deviceId}
+  </update>
   
   <select id="queryUnPlanedList" resultType="com.bz.smart_city.dto.assistant.InstallListDTO">
 		SELECT