| | |
| | | package com.zy.sc.manager.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.sc.common.service.GeoService; |
| | | import com.zy.sc.common.web.BaseController; |
| | | import com.zy.sc.manager.controller.param.MobileIssueParam; |
| | | import com.zy.sc.manager.entity.Issue; |
| | | import com.zy.sc.manager.entity.IssueType; |
| | | import com.zy.sc.manager.service.IssueService; |
| | | import com.zy.sc.manager.service.IssueTypeService; |
| | | import com.zy.sc.system.entity.Host; |
| | | import com.zy.sc.system.service.HostService; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @RequestMapping("app") |
| | | public class AppController extends BaseController { |
| | | |
| | | public static final String REGEX_MOBILE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$"; |
| | | |
| | | @Autowired |
| | | private HostService hostService; |
| | | @Autowired |
| | | private IssueTypeService issueTypeService; |
| | | @Autowired |
| | | private IssueService issueService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private GeoService geoService; |
| | | |
| | |
| | | return R.ok().add(issueTypes); |
| | | } |
| | | |
| | | // @RequestMapping("/sensor/save/auth") |
| | | // @ManagerAuth(memo = "移动端添加设备") |
| | | // public R issueSave(MobileSensorParam param){ |
| | | // Long hostId = getHostId(); |
| | | // if (hostId == null) { |
| | | // return R.error("请使用正确账号登录"); |
| | | // } |
| | | // if (Cools.isEmpty(param.getUuid())) { |
| | | // return R.error("请填写设备编号"); |
| | | // } |
| | | // if (Cools.isEmpty(param.getSensorType())) { |
| | | // return R.error("请选择设备类型"); |
| | | // } |
| | | // SensorType sensorType = sensorTypeService.selectById(param.getSensorType()); |
| | | // if (sensorType == null) { |
| | | // return R.error("请选择正确的设备类型"); |
| | | // } |
| | | // Sensor sensor = sensorService.selectByCode(param.getUuid()); |
| | | // if (sensor != null) { |
| | | // return R.error("设备编号已存在,请联系管理员"); |
| | | // } else { |
| | | // sensor = new Sensor(); |
| | | // } |
| | | // Date now = new Date(); |
| | | // sensor.setUuid(param.getUuid()); |
| | | // sensor.setHostId(hostId); |
| | | // sensor.setSensorType(param.getSensorType()); |
| | | // sensor.setCcid(param.getCcid()); |
| | | // sensor.setAddr(param.getAddr()); |
| | | // sensor.setDesc(param.getDesc()); |
| | | // sensor.setThreshold(String.valueOf(param.getThreshold())); |
| | | // List<String> imgArr = param.getImgArr(); |
| | | // if (!Cools.isEmpty(imgArr)) { |
| | | // sensor.setImg(JSONArray.toJSONString(imgArr)); |
| | | // } |
| | | // if (!Cools.isEmpty(param.getLocationObj())) { |
| | | // LocationObj locationObj = JSON.parseObject(param.getLocationObj(), LocationObj.class); |
| | | // sensor.setLon(Double.parseDouble(locationObj.getLongitude())); |
| | | // sensor.setLat(Double.parseDouble(locationObj.getLatitude())); |
| | | // GeoCodeDto geoCode = geoService.getGeoCode(sensor.getLon(), sensor.getLat()); |
| | | // if (geoCode != null && geoCode.getAddressComponent() != null) { |
| | | // sensor.setProvince(geoCode.getAddressComponent().getProvince()); |
| | | // sensor.setCity(geoCode.getAddressComponent().getCity()); |
| | | // sensor.setDistrict(geoCode.getAddressComponent().getDistrict()); |
| | | // sensor.setTownship(geoCode.getAddressComponent().getTownship()); |
| | | // } |
| | | // } |
| | | // sensor.setStatus(1); |
| | | // sensor.setCreateBy(getUserId()); |
| | | // sensor.setCreateTime(now); |
| | | // sensor.setUpdateBy(getUserId()); |
| | | // sensor.setUpdateTime(now); |
| | | // sensor.setMemo(param.getMemo()); |
| | | // if (!sensorService.insert(sensor)) { |
| | | // throw new CoolException("添加失败,请联系管理员"); |
| | | // } |
| | | // return R.ok("添加设备成功"); |
| | | // } |
| | | @RequestMapping("/issue/save/auth") |
| | | @ManagerAuth(memo = "故障上报") |
| | | public R issueSave(MobileIssueParam param){ |
| | | if (Cools.isEmpty(param.getHostName())) { |
| | | return R.error("请选择所属项目"); |
| | | } |
| | | Host host = hostService.selectByName(param.getHostName()); |
| | | if (Cools.isEmpty(param.getIssueTypeName())) { |
| | | return R.error("请选择故障类型"); |
| | | } |
| | | IssueType issueType = issueTypeService.selectByName(param.getIssueTypeName()); |
| | | if (Cools.isEmpty(param.getTel())) { |
| | | return R.error("请输入联系方式"); |
| | | } |
| | | if (Cools.isEmpty(param.getTitle())) { |
| | | return R.error("请输入问题概述"); |
| | | } |
| | | Date now = new Date(); |
| | | Date startTime = DateUtils.convert(param.getStartTime(), DateUtils.yyyyMMdd_F); |
| | | // 保存故障 |
| | | Issue issue = new Issue( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 故障编号 |
| | | host.getId(), // 所属项目 |
| | | issueType.getId(), // 故障类型 |
| | | param.getTitle(), // 问题概述 |
| | | null, // 故障原因 |
| | | null, // 解决办法 |
| | | null, // 文件列表 |
| | | JSONArray.toJSONString(param.getImgArr()), // 图片 |
| | | startTime, // 发生日期 |
| | | null, // 处理日期 |
| | | null, // 更新日期 |
| | | param.getDiscoverer(), // 发现人 |
| | | param.getTel(), // 联系方式 |
| | | null, // 供应商 |
| | | null, // |
| | | 1, // 状态 |
| | | getUserId(), // 添加人员 |
| | | now, // 添加时间 |
| | | getUserId(), // 修改人员 |
| | | now, // 修改时间 |
| | | param.getMemo() // 备注 |
| | | ); |
| | | if (!issueService.insert(issue)) { |
| | | throw new CoolException("反馈失败,请联系管理员"); |
| | | } |
| | | return R.ok("问题上报成功"); |
| | | } |
| | | // |
| | | // @RequestMapping("/sensor/list/auth") |
| | | // @ManagerAuth |