| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | |
| | | return R.ok(deviceErrorService.selectById(String.valueOf(id))); |
| | | } |
| | | |
| | | // @RequestMapping(value = "/deviceError/list/auth") |
| | | // @ManagerAuth |
| | | // public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | | // @RequestParam(defaultValue = "10")Integer limit, |
| | | // @RequestParam(required = false)String orderByField, |
| | | // @RequestParam(required = false)String orderByType, |
| | | // @RequestParam Map<String, Object> param){ |
| | | // EntityWrapper<DeviceError> wrapper = new EntityWrapper<>(); |
| | | // excludeTrash(param); |
| | | // convert(param, wrapper); |
| | | // if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | // return R.ok(deviceErrorService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | // } |
| | | |
| | | @RequestMapping(value = "/deviceError/list/auth") |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam Map<String, Object> param){ |
| | | EntityWrapper<DeviceError> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | return R.ok(deviceErrorService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | try { |
| | | long id = 0; |
| | | String device = null; |
| | | Integer deviceId = null; |
| | | for (Map.Entry<String, Object> entry : param.entrySet()) { |
| | | String val = String.valueOf(entry.getValue()); |
| | | if (Cools.isEmpty(val)) { |
| | | continue; |
| | | } |
| | | if (entry.getKey().equals("id")) { |
| | | id = Long.getLong(val); |
| | | } else if (entry.getKey().equals("device")) { |
| | | device = val; |
| | | } else if (entry.getKey().equals("deviceId")) { |
| | | deviceId = Integer.valueOf(val); |
| | | } |
| | | } |
| | | List<DeviceError> deviceErrorList = deviceErrorService.selectDeviceErrorList(id,device,deviceId, curr, limit); |
| | | Page<DeviceError> page1 = new Page<DeviceError>(curr, limit).setRecords(deviceErrorList); |
| | | page1.setTotal(deviceErrorService.selectDeviceErrorListTotal(id,device,deviceId)); |
| | | return R.ok(page1); |
| | | } catch (Exception e) { |
| | | return R.error("异常" + e); |
| | | } |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | |
| | | import com.zy.asrs.entity.DeviceError; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | @Repository |
| | |
| | | |
| | | Integer deleteByDeviceAndDeviceId(String device, Integer deviceId); |
| | | |
| | | List<DeviceError> selectDeviceErrorList( |
| | | @Param("id")Long id, |
| | | @Param("device")String device, |
| | | @Param("deviceId")Integer deviceId, |
| | | @Param("pageNumber")Integer curr, |
| | | @Param("pageSize")Integer limit |
| | | ) ; |
| | | |
| | | Long selectDeviceErrorListTotal( |
| | | @Param("id")Long id, |
| | | @Param("device")String device, |
| | | @Param("deviceId")Integer deviceId |
| | | ) ; |
| | | |
| | | } |
| | |
| | | import com.zy.asrs.entity.DeviceError; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface DeviceErrorService extends IService<DeviceError> { |
| | | |
| | | DeviceError selectByDeviceAndDeviceId(String device, Integer deviceId); |
| | |
| | | |
| | | Integer deleteDeviceError(String device, Integer deviceId); |
| | | |
| | | List<DeviceError> selectDeviceErrorList(Long id, String device, Integer deviceId, Integer curr, Integer limit) ; |
| | | |
| | | Long selectDeviceErrorListTotal(Long id,String device, Integer deviceId) ; |
| | | } |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service("deviceErrorService") |
| | | public class DeviceErrorServiceImpl extends ServiceImpl<DeviceErrorMapper, DeviceError> implements DeviceErrorService { |
| | |
| | | public Integer deleteDeviceError(String device, Integer deviceId) { |
| | | return this.baseMapper.deleteByDeviceAndDeviceId(device, deviceId); |
| | | } |
| | | |
| | | @Override |
| | | public List<DeviceError> selectDeviceErrorList(Long id, String device, Integer deviceId, Integer curr, Integer limit) { |
| | | return this.baseMapper.selectDeviceErrorList(id,device, deviceId,curr,limit); |
| | | } |
| | | |
| | | @Override |
| | | public Long selectDeviceErrorListTotal(Long id,String device, Integer deviceId) { |
| | | return this.baseMapper.selectDeviceErrorListTotal(id,device, deviceId); |
| | | } |
| | | } |
| | |
| | | <result column="CREATE_TIME" property="createTime" /> |
| | | </resultMap> |
| | | |
| | | <sql id="batchSeq"> |
| | | <if test="id != null and id != 0"> |
| | | and a.ID = #{id} |
| | | </if> |
| | | <if test="device != null and device != ''"> |
| | | and a.DEVICE = #{device} |
| | | </if> |
| | | <if test="deviceId != null and deviceId != 0"> |
| | | and a.DEVICE_ID = #{deviceId} |
| | | </if> |
| | | </sql> |
| | | |
| | | <select id="selectByDeviceAndDeviceId" resultMap="BaseResultMap"> |
| | | select top 1 * from "SOURCE"."wcs_device_error" |
| | | where "DEVICE" = #{device} |
| | |
| | | and "DEVICE_ID" = #{deviceId} |
| | | </delete> |
| | | |
| | | <select id="selectDeviceErrorList" resultMap="BaseResultMap"> |
| | | SELECT * FROM "SOURCE"."wcs_device_error" |
| | | WHERE 1=1 |
| | | <include refid="batchSeq"></include> |
| | | ORDER BY CREATE_TIME DESC |
| | | LIMIT #{pageSize} OFFSET ((#{pageNumber} - 1) * #{pageSize}); |
| | | </select> |
| | | |
| | | <select id="selectDeviceErrorListTotal" resultType="Long"> |
| | | SELECT count(1) FROM "SOURCE"."wcs_device_error" |
| | | WHERE 1=1 |
| | | <include refid="batchSeq"></include> |
| | | </select> |
| | | |
| | | </mapper> |