正在显示
5 个修改的文件
包含
42 行增加
和
41 行删除
| 1 | package com.sunyo.energy.location.controller; | 1 | package com.sunyo.energy.location.controller; |
| 2 | 2 | ||
| 3 | import com.github.pagehelper.PageInfo; | 3 | import com.github.pagehelper.PageInfo; |
| 4 | -import com.sunyo.energy.location.controller.response.ResultJson; | ||
| 5 | import com.sunyo.energy.location.model.ElectricityInfo; | 4 | import com.sunyo.energy.location.model.ElectricityInfo; |
| 6 | import com.sunyo.energy.location.service.EeInfoService; | 5 | import com.sunyo.energy.location.service.EeInfoService; |
| 7 | import io.swagger.annotations.ApiOperation; | 6 | import io.swagger.annotations.ApiOperation; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | import org.springframework.stereotype.Component; | 8 | import org.springframework.stereotype.Component; |
| 10 | -import org.springframework.stereotype.Controller; | ||
| 11 | import org.springframework.web.bind.annotation.RequestMapping; | 9 | import org.springframework.web.bind.annotation.RequestMapping; |
| 12 | import org.springframework.web.bind.annotation.RequestParam; | 10 | import org.springframework.web.bind.annotation.RequestParam; |
| 13 | import org.springframework.web.bind.annotation.ResponseBody; | 11 | import org.springframework.web.bind.annotation.ResponseBody; |
| 14 | -import sun.jvm.hotspot.debugger.Page; | ||
| 15 | - | ||
| 16 | -import java.util.List; | ||
| 17 | 12 | ||
| 18 | /** | 13 | /** |
| 19 | * @author shenhailong | 14 | * @author shenhailong |
| @@ -6,24 +6,18 @@ import com.github.pagehelper.PageHelper; | @@ -6,24 +6,18 @@ import com.github.pagehelper.PageHelper; | ||
| 6 | import com.github.pagehelper.PageInfo; | 6 | import com.github.pagehelper.PageInfo; |
| 7 | import com.sunyo.energy.location.controller.response.ResultJson; | 7 | import com.sunyo.energy.location.controller.response.ResultJson; |
| 8 | import com.sunyo.energy.location.dao.LocationMapper; | 8 | import com.sunyo.energy.location.dao.LocationMapper; |
| 9 | -import com.sunyo.energy.location.dao.WaterMeterMapper; | ||
| 10 | import com.sunyo.energy.location.dao.WaterMeterSaccMapper; | 9 | import com.sunyo.energy.location.dao.WaterMeterSaccMapper; |
| 11 | import com.sunyo.energy.location.model.Location; | 10 | import com.sunyo.energy.location.model.Location; |
| 12 | import com.sunyo.energy.location.model.WaterMeter; | 11 | import com.sunyo.energy.location.model.WaterMeter; |
| 13 | import com.sunyo.energy.location.model.WaterMeterSacc; | 12 | import com.sunyo.energy.location.model.WaterMeterSacc; |
| 14 | import com.sunyo.energy.location.service.WaterMeterService; | 13 | import com.sunyo.energy.location.service.WaterMeterService; |
| 15 | -import com.sunyo.energy.location.utils.AllUtils; | ||
| 16 | import com.sunyo.energy.location.utils.HttpsUtils; | 14 | import com.sunyo.energy.location.utils.HttpsUtils; |
| 17 | import io.swagger.annotations.ApiOperation; | 15 | import io.swagger.annotations.ApiOperation; |
| 18 | -import lombok.extern.log4j.Log4j; | ||
| 19 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
| 20 | -import org.apache.ibatis.annotations.Param; | ||
| 21 | -import org.omg.CORBA.OBJECT_NOT_EXIST; | ||
| 22 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 23 | import org.springframework.util.StringUtils; | 18 | import org.springframework.util.StringUtils; |
| 24 | import org.springframework.web.bind.annotation.*; | 19 | import org.springframework.web.bind.annotation.*; |
| 25 | 20 | ||
| 26 | -import java.math.BigDecimal; | ||
| 27 | import java.util.HashMap; | 21 | import java.util.HashMap; |
| 28 | import java.util.List; | 22 | import java.util.List; |
| 29 | import java.util.Map; | 23 | import java.util.Map; |
| @@ -126,29 +120,37 @@ public class LocationController { | @@ -126,29 +120,37 @@ public class LocationController { | ||
| 126 | public ResultJson editLocation(@RequestBody Location location) throws Exception { | 120 | public ResultJson editLocation(@RequestBody Location location) throws Exception { |
| 127 | 121 | ||
| 128 | ResultJson resultJson = new ResultJson(); | 122 | ResultJson resultJson = new ResultJson(); |
| 123 | + // 旧表 表号 | ||
| 129 | String wmId = locationMapper.findWmId(location.getAdrname()); | 124 | String wmId = locationMapper.findWmId(location.getAdrname()); |
| 125 | + // 水表 累计充值量记录表 | ||
| 130 | WaterMeterSacc waterMeterSacc = new WaterMeterSacc(); | 126 | WaterMeterSacc waterMeterSacc = new WaterMeterSacc(); |
| 131 | - waterMeterSacc.setOrderWmId(wmId); | 127 | + // 判断是否存在 存在修改楼层 不存在修改水表 |
| 128 | + if (!StringUtils.isEmpty(wmId)){ | ||
| 129 | + // 修改 房间号 | ||
| 130 | + int i1 = locationMapper.updateByPrimaryKeySelective(location); | ||
| 131 | + log.info("楼层编辑:{}", i1); | ||
| 132 | + }else { | ||
| 133 | + // 查询旧表 实时数据 | ||
| 134 | + WaterMeter realTime = waterMeterService.findRealTime(wmId); | ||
| 135 | + log.info("旧表累计充值量:{}",realTime.getWmSacc()); | ||
| 136 | + // 充值新表 | ||
| 137 | + Map<String, Object> datas = new HashMap<>(); | ||
| 138 | + datas.put("MtId", location.getWmid()); | ||
| 139 | + datas.put("Add_sacc", realTime.getWmSacc()); | ||
| 140 | + datas.put("Add_lacc", realTime.getWmLacc()); | ||
| 141 | + datas.put("Add_addmode", "3"); | ||
| 142 | + String status = HttpsUtils.httpRequest("http://123.56.159.203:8023/mtfmset/allWMadd", datas); | ||
| 143 | + datas.put("status", status); | ||
| 144 | + log.info("新表充值:{}",status); | ||
| 145 | + log.info("充值成功更新水表"); | ||
| 146 | + } | ||
| 132 | waterMeterSacc.setWmId(location.getWmid()); | 147 | waterMeterSacc.setWmId(location.getWmid()); |
| 133 | - // 查询旧表实施数据 | ||
| 134 | - WaterMeter realTime = waterMeterService.findRealTime(wmId); | ||
| 135 | - // 计算旧表余量 新表累计充值量 = 旧表余量 | ||
| 136 | -// String newWmIdSacc = AllUtils.nubmerSubtraction(realTime.getWmSacc(), realTime.getWmLacc()); | ||
| 137 | - log.info("旧表累计充值量:{}",realTime.getWmSacc()); | ||
| 138 | -// waterMeterSacc.setWmSacc(new BigDecimal(newWmIdSacc)); | ||
| 139 | - // 充值新表水量 | ||
| 140 | - Map<String, Object> datas = new HashMap<>(); | ||
| 141 | - datas.put("MtId", wmId); | ||
| 142 | - datas.put("Add_sacc", realTime.getWmSacc()); | ||
| 143 | - datas.put("Add_addmode", "2"); | ||
| 144 | - String status = HttpsUtils.httpRequest("http://123.56.159.203:8023/mtfmset/allWMadd", datas); | ||
| 145 | - datas.put("status", status); | ||
| 146 | - log.info("新表充值:{}",status); | ||
| 147 | - log.info("充值成功更新水表"); | ||
| 148 | - if (locationMapper.updateByPrimaryKeySelective(location) > 0 && waterMeterSaccMapper.updateWater(waterMeterSacc) > 0) { | 148 | + waterMeterSacc.setOrderWmId(wmId); |
| 149 | + // 更新表号 累计充值量 记录表 | ||
| 150 | + if (waterMeterSaccMapper.updateWater(waterMeterSacc) > 0) { | ||
| 149 | log.info("更新成功"); | 151 | log.info("更新成功"); |
| 150 | resultJson.setCode("200"); | 152 | resultJson.setCode("200"); |
| 151 | - } else { | 153 | + }else { |
| 152 | resultJson.setCode("201"); | 154 | resultJson.setCode("201"); |
| 153 | } | 155 | } |
| 154 | return resultJson; | 156 | return resultJson; |
| @@ -40,7 +40,10 @@ public interface LocationMapper { | @@ -40,7 +40,10 @@ public interface LocationMapper { | ||
| 40 | 40 | ||
| 41 | String eeId(String roomNumber); | 41 | String eeId(String roomNumber); |
| 42 | 42 | ||
| 43 | + int adrNameWmId(@Param(value = "adrName") String adrName, | ||
| 44 | + @Param(value = "wmId") String wmId); | ||
| 45 | + | ||
| 43 | int editEeId(@Param(value = "name") String name, | 46 | int editEeId(@Param(value = "name") String name, |
| 44 | @Param(value = "deviceId") String deviceId); | 47 | @Param(value = "deviceId") String deviceId); |
| 45 | 48 | ||
| 46 | -} | ||
| 49 | +} |
| @@ -88,14 +88,18 @@ | @@ -88,14 +88,18 @@ | ||
| 88 | select ee_id from location where adrname = #{value} | 88 | select ee_id from location where adrname = #{value} |
| 89 | </select> | 89 | </select> |
| 90 | 90 | ||
| 91 | + <select id="adrNameWmId" parameterType="string" resultType="int"> | ||
| 92 | + select count(*) from location where adrname = #{adrName} and wmId = #{wmId} | ||
| 93 | + </select> | ||
| 94 | + | ||
| 91 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> | 95 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> |
| 92 | delete from location | 96 | delete from location |
| 93 | where id = #{id,jdbcType=INTEGER} | 97 | where id = #{id,jdbcType=INTEGER} |
| 94 | </delete> | 98 | </delete> |
| 95 | <insert id="insert" parameterType="com.sunyo.energy.location.model.Location"> | 99 | <insert id="insert" parameterType="com.sunyo.energy.location.model.Location"> |
| 96 | - insert into location (id, adrName, parent, | 100 | + insert into location (id, adrName, parent, |
| 97 | type) | 101 | type) |
| 98 | - values (#{id,jdbcType=INTEGER}, #{adrname,jdbcType=VARCHAR}, #{parent,jdbcType=INTEGER}, | 102 | + values (#{id,jdbcType=INTEGER}, #{adrname,jdbcType=VARCHAR}, #{parent,jdbcType=INTEGER}, |
| 99 | #{type,jdbcType=INTEGER}) | 103 | #{type,jdbcType=INTEGER}) |
| 100 | </insert> | 104 | </insert> |
| 101 | <insert id="insertSelective" parameterType="com.sunyo.energy.location.model.Location"> | 105 | <insert id="insertSelective" parameterType="com.sunyo.energy.location.model.Location"> |
| @@ -163,4 +167,4 @@ | @@ -163,4 +167,4 @@ | ||
| 163 | set ee_id = #{deviceId,jdbcType=VARCHAR} | 167 | set ee_id = #{deviceId,jdbcType=VARCHAR} |
| 164 | where adrName = #{name,jdbcType=INTEGER} | 168 | where adrName = #{name,jdbcType=INTEGER} |
| 165 | </update> | 169 | </update> |
| 166 | -</mapper> | ||
| 170 | +</mapper> |
| @@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
| 11 | wm_id, ardname, unit_price, wm_sacc | 11 | wm_id, ardname, unit_price, wm_sacc |
| 12 | </sql> | 12 | </sql> |
| 13 | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" > | 13 | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" > |
| 14 | - select | 14 | + select |
| 15 | <include refid="Base_Column_List" /> | 15 | <include refid="Base_Column_List" /> |
| 16 | from water_meter_sacc | 16 | from water_meter_sacc |
| 17 | where wm_id = #{wmId,jdbcType=VARCHAR} | 17 | where wm_id = #{wmId,jdbcType=VARCHAR} |
| @@ -31,9 +31,9 @@ | @@ -31,9 +31,9 @@ | ||
| 31 | where wm_id = #{wmId,jdbcType=VARCHAR} | 31 | where wm_id = #{wmId,jdbcType=VARCHAR} |
| 32 | </delete> | 32 | </delete> |
| 33 | <insert id="insert" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" > | 33 | <insert id="insert" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" > |
| 34 | - insert into water_meter_sacc (wm_id, ardname, unit_price, | 34 | + insert into water_meter_sacc (wm_id, ardname, unit_price, |
| 35 | wm_sacc) | 35 | wm_sacc) |
| 36 | - values (#{wmId,jdbcType=VARCHAR}, #{ardname,jdbcType=VARCHAR}, #{unitPrice,jdbcType=DECIMAL}, | 36 | + values (#{wmId,jdbcType=VARCHAR}, #{ardname,jdbcType=VARCHAR}, #{unitPrice,jdbcType=DECIMAL}, |
| 37 | #{wmSacc,jdbcType=DECIMAL}) | 37 | #{wmSacc,jdbcType=DECIMAL}) |
| 38 | </insert> | 38 | </insert> |
| 39 | <insert id="insertSelective" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" > | 39 | <insert id="insertSelective" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" > |
| @@ -87,10 +87,7 @@ | @@ -87,10 +87,7 @@ | ||
| 87 | update water_meter_sacc | 87 | update water_meter_sacc |
| 88 | <set > | 88 | <set > |
| 89 | <if test="wmId != null" > | 89 | <if test="wmId != null" > |
| 90 | - wm_id = #{wmId,jdbcType=VARCHAR}, | ||
| 91 | - </if> | ||
| 92 | - <if test="wmSacc != null" > | ||
| 93 | - wm_sacc = #{wmSacc,jdbcType=VARCHAR} | 90 | + wm_id = #{wmId,jdbcType=VARCHAR} |
| 94 | </if> | 91 | </if> |
| 95 | </set> | 92 | </set> |
| 96 | where wm_id = #{orderWmId,jdbcType=VARCHAR} | 93 | where wm_id = #{orderWmId,jdbcType=VARCHAR} |
| @@ -103,4 +100,4 @@ | @@ -103,4 +100,4 @@ | ||
| 103 | wm_sacc = #{wmSacc,jdbcType=DECIMAL} | 100 | wm_sacc = #{wmSacc,jdbcType=DECIMAL} |
| 104 | where wm_id = #{wmId,jdbcType=VARCHAR} | 101 | where wm_id = #{wmId,jdbcType=VARCHAR} |
| 105 | </update> | 102 | </update> |
| 106 | -</mapper> | ||
| 103 | +</mapper> |
-
请 注册 或 登录 后发表评论