| | |
| | | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.Battinf; |
| | | import com.whyc.pojo.PowerInf; |
| | | import com.whyc.pojo.UserInf; |
| | | import com.whyc.service.BattInfService; |
| | | import com.whyc.util.ActionUtil; |
| | |
| | | } |
| | | @GetMapping("/searchInform") |
| | | @ApiOperation(value = "电池组信息配置中查询所有的电池组信息") |
| | | public Response searchInform(@RequestParam(required = false)String stationName1,@RequestParam(required = false)String stationName2,@RequestParam(required = false)String stationName5,@RequestParam(required = false)String stationName3){ |
| | | public Response searchInform(@RequestParam int pageNum,@RequestParam int pageSize,@RequestParam(required = false)String stationName1,@RequestParam(required = false)String stationName2,@RequestParam(required = false)String stationName5,@RequestParam(required = false)String stationName3){ |
| | | UserInf userInf = (UserInf) ActionUtil.getUser(); |
| | | return service.searchInfo(userInf.getUId().intValue(),stationName1,stationName2,stationName5,stationName3); |
| | | return service.searchInfo(pageNum,pageSize,userInf.getUId().intValue(),stationName1,stationName2,stationName5,stationName3); |
| | | } |
| | | |
| | | |
| | |
| | | return new Response().setII(1,"删除成功"); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "更新电池组") |
| | | public Response update(@RequestBody Battinf battinf){ |
| | | return service.update(battinf); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | import com.baomidou.mybatisplus.extension.api.R; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.factory.BattinfGroupFactory; |
| | | import com.whyc.pojo.PowerInf; |
| | | import com.whyc.pojo.UserInf; |
| | | import com.whyc.service.PowerAppSysService; |
| | | import com.whyc.service.PowerInfService; |
| | | import com.whyc.util.ActionUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.util.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.PipedWriter; |
| | | import java.util.List; |
| | | |
| | | @RequestMapping("powerInf") |
| | |
| | | public class PowerInfController { |
| | | @Autowired |
| | | private PowerInfService service; |
| | | @Autowired |
| | | private PowerAppSysService powerAppSysService; |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加电源") |
| | | public Response add(@RequestBody PowerInf powerInf){ |
| | | if(StringUtils.isEmpty(powerInf.getStationId())){ |
| | | powerInf.setStationId(String.valueOf(BattinfGroupFactory.searchStationId())); |
| | | } |
| | | powerInf.setPowerDeviceId(BattinfGroupFactory.searchmaxdev_id(powerInf.getPowerDeviceType())); |
| | | service.add(powerInf); |
| | | //添加电源站点时,更新ReInit字段为1,通讯程序监控变化重新初始化 |
| | | if(powerInf.getPowerDeviceType()==BattinfGroupFactory.DEVICE_POWER) { |
| | | boolean flag = powerAppSysService.updateFlag("AppServer_Reinit_PowerData_EN"); |
| | | if (!flag) { |
| | | System.out.println("更新updateReInit接口失败"); |
| | | } |
| | | }else{ |
| | | //充电机和绝缘装置的,更新另一个ReInit字段为1 |
| | | boolean flag = powerAppSysService.updateFlag("AppServer_Reinit_BattGroupData_EN"); |
| | | if (!flag) { |
| | | System.out.println("更新updateReInit接口失败"); |
| | | } |
| | | } |
| | | return new Response().setII(1,"添加成功"); |
| | | } |
| | | @PutMapping |
New file |
| | |
| | | package com.whyc.mapper; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | public interface PowerAppSysMapper { |
| | | |
| | | int updateReInitPowerData(); |
| | | int updateFlag(@Param("column")String columnName); |
| | | } |
| | |
| | | |
| | | List<PowerInf> getStations(@Param("uId")Long uId,@Param("stationName5")String stationName5); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.factory.BattinfGroupFactory; |
| | | import com.whyc.mapper.BattInfMapper; |
| | |
| | | return new Response().set(1,battinf,"添加成功"); |
| | | } |
| | | |
| | | public Response searchInfo(Integer userId,String stationName1,String stationName2,String stationName5,String stationName3){ |
| | | public Response searchInfo(int pageNum,int pageSize,Integer userId,String stationName1,String stationName2,String stationName5,String stationName3){ |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List<Battinf> list = battInfMapper.searchInform(userId, stationName1, stationName2,stationName5, stationName3); |
| | | return new Response().set(1,list,"查询成功"); |
| | | PageInfo<Battinf> pageInfo = new PageInfo<>(list); |
| | | return new Response().set(1,pageInfo,"查询成功"); |
| | | } |
| | | |
| | | public void deleteByBattgroupId(Integer battgroupId){ |
| | |
| | | battInfMapper.delete(wrapper); |
| | | } |
| | | |
| | | public Response update(Battinf battinf){ |
| | | if (battInfMapper.updateById(battinf)>0){ |
| | | return new Response().set(1,"更新成功"); |
| | | }else { |
| | | return new Response().set(0,"更新失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public void addBatch(List<Battinf> battInfList){ |
New file |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.mapper.PowerAppSysMapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Service |
| | | public class PowerAppSysService { |
| | | @Resource |
| | | private PowerAppSysMapper mapper; |
| | | |
| | | public boolean updateReInitPowerData() { |
| | | |
| | | return mapper.updateReInitPowerData()>0; |
| | | } |
| | | |
| | | public boolean updateFlag(String columnName) { |
| | | return mapper.updateFlag(columnName)>0; |
| | | } |
| | | } |
New file |
| | |
| | | <?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.whyc.mapper.PowerAppSysMapper" > |
| | | |
| | | <!-- |
| | | 添加电源后的更新db_pwrdev_inf.tb_pwrapp_sys |
| | | --> |
| | | <update id="updateReInitPowerData"> |
| | | update db_pwrdev_inf.tb_pwrapp_sys set AppServer_Reinit_PowerData_EN=1 limit 1 |
| | | </update> |
| | | |
| | | <update id="updateFlag"> |
| | | update db_pwrdev_inf.tb_pwrapp_sys set #{columnName}=1 limit 1 |
| | | </update> |
| | | </mapper> |