ard-work/src/main/java/com/ruoyi/sy/controller/ArdTankLockController.java
@@ -4,9 +4,12 @@ import java.util.Map; import javax.servlet.http.HttpServletResponse; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.sy.domain.ArdTankWall; import com.ruoyi.sy.service.IArdTankWallLockService; import com.ruoyi.sy.service.IArdTankWallService; import com.ruoyi.utils.result.Results; import io.swagger.annotations.Api; @@ -45,6 +48,9 @@ @Autowired private IArdTankWallService ardTankWallService; @Autowired private IArdTankWallLockService ardTankWallLockService; /** * 查询电磁锁列表 @@ -142,12 +148,24 @@ @ApiOperation("查询全部电磁锁") @PreAuthorize("@ss.hasPermi('sy:lock:getAll')") @GetMapping("/getAll") public TableDataInfo getAll() { startPage(); //@GetMapping("/getAll") @PostMapping("/getAll") public TableDataInfo getAll(@RequestBody Map<String,Integer> para) { /*startPage(); String userId = SecurityUtils.getUserId(); List<Map<String,Object>> result = ardTankLockService.getAll(userId); return getDataTable(result); return getDataTable(result);*/ PageHelper.startPage((Integer) para.get("pageNum"), (Integer) para.get("pageSize")); String userId = SecurityUtils.getUserId(); List<Map<String,Object>> result = ardTankLockService.getAll(userId); TableDataInfo dataTable = new TableDataInfo(); dataTable.setRows(result); dataTable.setTotal(result.size()); dataTable.setCode(200); dataTable.setMsg("查询成功"); return dataTable; } /** @@ -223,10 +241,23 @@ @ApiOperation("查询全部电子围栏") @PreAuthorize("@ss.hasPermi('sy:lock:getAllArdTankWall')") @PostMapping("/getAllArdTankWall") public TableDataInfo getAllArdTankWall(@RequestBody ArdTankWall ardTankWall) { startPage(); public TableDataInfo getAllArdTankWall(@RequestBody Map<String,Object> para) { /*startPage(); ArdTankWall ardTankWall = new ArdTankWall(); ardTankWall.setWallName((String) para.get("wallName")); List<ArdTankWall> list = ardTankWallService.selectArdTankWallList(ardTankWall); return getDataTable(list); return getDataTable(list);*/ PageHelper.startPage((Integer) para.get("pageNum"), (Integer) para.get("pageSize")); ArdTankWall ardTankWall = new ArdTankWall(); ardTankWall.setWallName((String) para.get("wallName")); List<ArdTankWall> list = ardTankWallService.selectArdTankWallList(ardTankWall); TableDataInfo dataTable = new TableDataInfo(); dataTable.setRows(list); dataTable.setTotal(list.size()); dataTable.setCode(200); dataTable.setMsg("查询成功"); return dataTable; } @ApiOperation("根据主键获取电磁锁电子围栏") @@ -242,10 +273,49 @@ @ApiOperation("模糊查询电磁锁及挂接的车辆") @PreAuthorize("@ss.hasPermi('sy:lock:getLockByCarPlate')") @PostMapping("/getLockByCarPlate") public TableDataInfo getLockByCarPlate(@RequestBody Map<String,String> para) { startPage(); public TableDataInfo getLockByCarPlate(@RequestBody Map<String,Object> para) { /*startPage(); String userId = SecurityUtils.getUserId(); List<Map<String,String>> result = ardTankLockService.getLockByCarPlate(userId,para.get("carPlate")); return getDataTable(result); return getDataTable(result);*/ PageHelper.startPage((Integer) para.get("pageNum"), (Integer) para.get("pageSize")); String userId = SecurityUtils.getUserId(); List<Map<String,Object>> result = ardTankLockService.getLockByCarPlate(userId, (String) para.get("carPlate")); TableDataInfo dataTable = new TableDataInfo(); dataTable.setRows(result); dataTable.setTotal(result.size()); dataTable.setCode(200); dataTable.setMsg("查询成功"); return dataTable; } @ApiOperation("根据锁主键获取电子围栏") @PreAuthorize("@ss.hasPermi('sy:tankWall:getArdTankWallByLockId')") @GetMapping(value = "/getArdTankWallByLockId/{id}") public AjaxResult getArdTankWallByLockId(@PathVariable String id) { return success(ardTankWallService.getArdTankWallByLockId(id)); } /** * 挂接电磁锁及电子围栏 */ @ApiOperation("挂接电磁锁及电子围栏") @PreAuthorize("@ss.hasPermi('sy:lock:insertWallLock')") @PostMapping("/insertWallLock") public AjaxResult insertWallLock(@RequestBody Map<String,Object> para) { int result = ardTankWallLockService.insertWallLock(para); return toAjax(result); } /** * 根据锁主键删除挂接的电子围栏 */ @ApiOperation("根据锁主键删除挂接的电子围栏") @PreAuthorize("@ss.hasPermi('sy:lock:deleteArdTankWallLockByLockId')") @Log(title = "电磁锁" , businessType = BusinessType.DELETE) @DeleteMapping("/deleteArdTankWallLockByLockId/{id}") public AjaxResult deleteArdTankWallLockByLockId(@PathVariable String id) { return toAjax(ardTankWallLockService.deleteArdTankWallLockByLockId(id)); } } ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankWallLockMapper.java
@@ -62,4 +62,6 @@ public int deleteArdTankWallLockByLockId(String lockId); public int deleteArdTankWallLockByWallId(String wallId); public int updateArdTankWallLockByWallIdAndLockId(ArdTankWallLock ardTankWallLock); } ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankWallMapper.java
@@ -1,6 +1,8 @@ package com.ruoyi.sy.mapper; import java.util.List; import java.util.Map; import com.ruoyi.sy.domain.ArdTankWall; /** @@ -60,4 +62,6 @@ public int deleteArdTankWallByIds(String[] ids); public List<ArdTankWall> getAllArdTankWall(); public List<Map<String,String>> getArdTankWallByLockId(String id); } ard-work/src/main/java/com/ruoyi/sy/service/IArdTankLockService.java
@@ -71,5 +71,5 @@ public int updateLockByCarId(Map<String,Object> para); public List<Map<String, String>> getLockByCarPlate(String usersId, String carPlate); public List<Map<String, Object>> getLockByCarPlate(String usersId, String carPlate); } ard-work/src/main/java/com/ruoyi/sy/service/IArdTankWallLockService.java
@@ -1,6 +1,8 @@ package com.ruoyi.sy.service; import java.util.List; import java.util.Map; import com.ruoyi.sy.domain.ArdTankWallLock; /** @@ -58,4 +60,8 @@ * @return 结果 */ public int deleteArdTankWallLockByProcessType(String processType); public int insertWallLock(Map<String,Object> para); public int deleteArdTankWallLockByLockId(String id); } ard-work/src/main/java/com/ruoyi/sy/service/IArdTankWallService.java
@@ -1,6 +1,8 @@ package com.ruoyi.sy.service; import java.util.List; import java.util.Map; import com.ruoyi.sy.domain.ArdTankWall; /** @@ -60,4 +62,6 @@ public int deleteArdTankWallById(String id); public List<ArdTankWall> getAllArdTankWall(); public List<Map<String,String>> getArdTankWallByLockId(String id); } ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockServiceImpl.java
@@ -320,7 +320,8 @@ } @Override public List<Map<String, String>> getLockByCarPlate(String usersId, String carPlate) { public List<Map<String, Object>> getLockByCarPlate(String usersId, String carPlate) { List<ArdTankLock> ardTankLockList = ardTankLockMapper.getAll(); ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); if(ardSyUser == null){ return new ArrayList(); @@ -335,8 +336,8 @@ String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId()); String sessionId = (String) LogInResult.get("sessionId"); List<ArdTankLock> ardTankLockList = ardTankLockMapper.getAll(); List<Map<String,String>> result = new ArrayList(); //List<ArdTankLock> ardTankLockList = ardTankLockMapper.getAll(); List<Map<String,Object>> result = new ArrayList(); if(!carPlate.equals("")){ Map<String,Object> carMap = sYClient.getCarListByPlate(syURL,carPlate,ardSyUser.getUserId(),sessionId);//车牌号模糊搜索车辆 List<Map<String,Object>> carList = new ArrayList(); @@ -351,7 +352,7 @@ } for(ArdTankLock ardTankLock : ardTankLockList){ if(carIdList.contains(ardTankLock.getCarId())){//返回的车辆包含数据库录入的车辆 Map<String,String> map = new HashMap(); Map<String,Object> map = new HashMap(); map.put("id",ardTankLock.getId()); map.put("lockNum",ardTankLock.getLockNum()); map.put("lockName",ardTankLock.getLockName()); @@ -378,7 +379,7 @@ } }else{ for(ArdTankLock ardTankLock : ardTankLockList){ Map<String,String> map = new HashMap(); Map<String,Object> map = new HashMap(); map.put("id",ardTankLock.getId()); map.put("lockNum",ardTankLock.getLockNum()); map.put("lockName",ardTankLock.getLockName()); ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankWallLockServiceImpl.java
@@ -6,11 +6,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Map; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.sy.mapper.ArdTankWallLockMapper; import com.ruoyi.sy.domain.ArdTankWallLock; import com.ruoyi.sy.service.IArdTankWallLockService; import javax.annotation.Resource; /** * 电子围栏电磁锁Service业务层处理 @@ -20,7 +24,7 @@ */ @Service public class ArdTankWallLockServiceImpl implements IArdTankWallLockService { @Autowired @Resource private ArdTankWallLockMapper ardTankWallLockMapper; /** @@ -89,4 +93,33 @@ public int deleteArdTankWallLockByProcessType(String processType) { return ardTankWallLockMapper.deleteArdTankWallLockByProcessType(processType); } @Override public int insertWallLock(Map<String, Object> para) { String id = (String) para.get("id");//锁主键 List<Map<String,String>> tankWallLockList = (List<Map<String, String>>) para.get("tankWallLockList"); //List<ArdTankWallLock> tankWallLocks = new ArrayList(); int result = 0; for(Map<String,String> map : tankWallLockList){ ArdTankWallLock ardTankWallLock = new ArdTankWallLock(); ardTankWallLock.setWallId(map.get("wallId")); ardTankWallLock.setLockId(id); List<ArdTankWallLock> ardTankWallLockList = ardTankWallLockMapper.selectArdTankWallLockList(ardTankWallLock); if(ardTankWallLockList.size() != 0){ ardTankWallLock.setProcessType(map.get("processType")); result = result + ardTankWallLockMapper.updateArdTankWallLockByWallIdAndLockId(ardTankWallLock); }else{ ardTankWallLock.setProcessType(map.get("processType")); ardTankWallLock.setId(IdUtils.simpleUUID()); result = result + ardTankWallLockMapper.insertArdTankWallLock(ardTankWallLock); } } return result; } @Override public int deleteArdTankWallLockByLockId(String id) { int result = ardTankWallLockMapper.deleteArdTankWallLockByLockId(id); return result; } } ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankWallServiceImpl.java
@@ -7,6 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Map; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.sy.mapper.ArdTankWallMapper; @@ -105,4 +107,10 @@ List<ArdTankWall> result = ardTankWallMapper.getAllArdTankWall(); return result; } @Override public List<Map<String,String>> getArdTankWallByLockId(String id) { List<Map<String,String>> result = ardTankWallMapper.getArdTankWallByLockId(id); return result; } } ard-work/src/main/resources/mapper/sy/ArdTankWallLockMapper.xml
@@ -73,4 +73,12 @@ <delete id="deleteArdTankWallLockByWallId" parameterType="java.lang.String"> delete from ard_tank_wall_lock where wall_id = #{wallId} </delete> <update id="updateArdTankWallLockByWallIdAndLockId" parameterType="ArdTankWallLock"> update ard_tank_wall_lock <trim prefix="SET" suffixOverrides=","> <if test="processType != null">process_type = #{processType},</if> </trim> where wall_id = #{wallId} and lock_id = #{lockId} </update> </mapper> ard-work/src/main/resources/mapper/sy/ArdTankWallMapper.xml
@@ -65,4 +65,13 @@ <select id="getAllArdTankWall" resultMap="ArdTankWallResult"> select * from ard_tank_wall order by wall_name </select> <select id="getArdTankWallByLockId" resultType="java.util.Map" parameterType="java.lang.String"> select atw.id,atw.wall_name as "wallName",atw.wall_poi as "wallPoi", atwl.process_type as "processType",case process_type when '-1' then '关动作' when '0' then '无动作' when '1' then '开动作' end as process from ard_tank_wall_lock atwl inner join ard_tank_wall atw on atwl.wall_id = atw.id where atwl.lock_id = #{id} </select> </mapper>