| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.annotation.ValueAuth; |
| | | import com.yuanchu.mom.annotation.ValueClassify; |
| | | import com.yuanchu.mom.dto.DataConfigDto; |
| | | import com.yuanchu.mom.dto.DeviceDto; |
| | | import com.yuanchu.mom.pojo.DataConfig; |
| | | import com.yuanchu.mom.pojo.Device; |
| | | import com.yuanchu.mom.pojo.PkMaster; |
| | | import com.yuanchu.mom.service.DataConfigService; |
| | | import com.yuanchu.mom.service.DeviceService; |
| | | import com.yuanchu.mom.service.PkMasterService; |
| | | import com.yuanchu.mom.utils.DataAcquisition; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | @Autowired |
| | | private DataConfigService dataConfigService; |
| | | |
| | | @Autowired |
| | | private PkMasterService pkMasterService; |
| | | /** |
| | | * 获取人员信息 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @ValueAuth |
| | | @GetMapping("/selectUserList") |
| | | public Result selectUserList() { |
| | | return Result.success(deviceService.selectUserList()); |
| | | } |
| | | |
| | | @ValueClassify("设备") |
| | | @ApiOperation(value = "查询设备详情列表") |
| | | @PostMapping("/selectDeviceParameter") |
| | | public Result selectDeviceParameter(@RequestBody Map<String, Object> data) throws Exception { |
| | | public Result selectDeviceParameter(@RequestBody Map<String, Object> data,@RequestParam(value = "laboratoryNameIsNull", required = false) Boolean laboratoryNameIsNull) throws Exception { |
| | | Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class); |
| | | DeviceDto itemParameter = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), DeviceDto.class); |
| | | return Result.success(deviceService.selectDeviceParameter(page, itemParameter)); |
| | | return Result.success(deviceService.selectDeviceParameter(page, itemParameter,laboratoryNameIsNull)); |
| | | } |
| | | |
| | | @ValueClassify("设备") |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "通过设备编号获取设备列表") |
| | | @PostMapping("/selectDeviceByCode") |
| | | @GetMapping("/selectDeviceByCode") |
| | | @ValueAuth |
| | | public Result selectDeviceByCode(String code) { |
| | | return Result.success(deviceService.selectDeviceByCode(code)); |
| | | public Result selectDeviceByCode(Integer id) { |
| | | return Result.success(deviceService.selectDeviceByCode(id)); |
| | | } |
| | | |
| | | // @ValueClassify("设备") |
| | | // @ApiOperation(value = "查询数采配置") |
| | | // @PostMapping("/getNumberCollect") |
| | | // public Result<?> getNumberCollect(Integer id) { |
| | | // DeviceDto1 deviceDto1 = new DeviceDto1(); |
| | | // BeanUtils.copyProperties(deviceService.getById(id),deviceDto1); |
| | | // return Result.success(deviceDto1); |
| | | // } |
| | | // |
| | | // @ValueClassify("设备") |
| | | // @ApiOperation(value = "维护数采配置") |
| | | // @PostMapping("/numberCollect") |
| | | // public Result<?> numberCollect(@RequestBody DeviceDto1 deviceDto1) { |
| | | // Device device = new Device(); |
| | | // BeanUtils.copyProperties(deviceDto1,device); |
| | | // return Result.success(deviceService.updateById(device)); |
| | | // } |
| | | |
| | | @ValueAuth |
| | | @ValueClassify("设备") |
| | |
| | | @ApiOperation(value = "判断该设备是否可以数采") |
| | | @GetMapping("/determineWhetherToCollectData") |
| | | public Result<?> determineWhetherToCollectData(@RequestParam("managementNumber") String managementNumber, HttpServletRequest request) { |
| | | String ip = DataAcquisition.getIp(request); |
| | | Device device = deviceService.getOne(Wrappers.<Device>lambdaQuery() |
| | | .eq(Device::getManagementNumber, managementNumber) |
| | | .eq(Device::getIp, ip)); |
| | | if (ObjectUtils.isEmpty(device)) { |
| | | return Result.success(false); |
| | | } |
| | | if (ObjectUtils.isEmpty(device.getFileType()) || ObjectUtils.isEmpty(device.getCollectUrl())) { |
| | | return Result.success(false); |
| | | } else { |
| | | return Result.success(true); |
| | | } |
| | | return deviceService.determineWhetherToCollectData(managementNumber, request); |
| | | } |
| | | |
| | | @ValueClassify("设备") |
| | | @ApiOperation(value = "维护数采配置") |
| | | @PostMapping("/saveDataAcquisitionConfiguration") |
| | | public Result<?> saveDataAcquisitionConfiguration(@RequestParam(value = "deviceId") Integer deviceId, @RequestBody DataConfigDto dataConfigList) { |
| | | if (dataConfigList.getIsDevice()) { |
| | | Device device = new Device(); |
| | | device.setId(deviceId); |
| | | device.setCollectUrl(dataConfigList.getCollectUrl()); |
| | | device.setStorageUrl(dataConfigList.getStorageUrl()); |
| | | device.setIp(dataConfigList.getIp()); |
| | | device.setFileType(dataConfigList.getFileType()); |
| | | device.setMdbEntrustCode(dataConfigList.getMdbEntrustCode()); |
| | | device.setMdbSampleCode(dataConfigList.getMdbSampleCode()); |
| | | deviceService.updateById(device); |
| | | } else { |
| | | dataConfigService.saveOrUpdateBatch(dataConfigList.getDataConfigList()); |
| | | } |
| | | dataConfigService.saveDataAcquisitionConfiguration(deviceId, dataConfigList); |
| | | return Result.success(); |
| | | } |
| | | |
| | | // @ValueClassify("设备") |
| | | // @ApiOperation(value = "查询数采配置") |
| | | // @GetMapping("/queryDataAcquisitionConfiguration") |
| | | // public Result<?> queryDataAcquisitionConfiguration(@RequestParam("deviceId") Integer deviceId, @RequestParam("insProductItem") String insProductItem) { |
| | | // List<DataConfig> list = dataConfigService.list(Wrappers.<DataConfig>lambdaQuery() |
| | | // .eq(DataConfig::getDeviceId, deviceId) |
| | | // .eq(DataConfig::getInsProductItem, insProductItem)); |
| | | // return Result.success(list); |
| | | // } |
| | | |
| | | @ValueClassify("设备") |
| | | @ApiOperation(value = "查询数采配置") |
| | |
| | | @RequestParam("isDevice") Boolean isDevice, |
| | | @RequestParam(value = "inspectionItem", required = false) String inspectionItem, |
| | | @RequestParam(value = "inspectionItemSubclass", required = false) String inspectionItemSubclass) { |
| | | if (isDevice) { |
| | | List<DataConfig> list = dataConfigService.list(Wrappers.<DataConfig>lambdaQuery() |
| | | .eq(DataConfig::getDeviceId, deviceId) |
| | | .eq(DataConfig::getInspectionItem, inspectionItem) |
| | | .eq(DataConfig::getInspectionItemSubclass, inspectionItemSubclass)); |
| | | return Result.success(list); |
| | | } else { |
| | | return Result.success(dataConfigService.selectDataConfigList(deviceId)); |
| | | } |
| | | return dataConfigService.queryDataAcquisitionConfiguration(deviceId, isDevice, inspectionItem, inspectionItemSubclass); |
| | | } |
| | | |
| | | @ValueClassify("设备") |
| | |
| | | } |
| | | |
| | | |
| | | @ValueClassify("设备") |
| | | @ApiOperation(value = "温度循环数采") |
| | | @PostMapping("/temDataAcquisition") |
| | | public Result<?> temDataAcquisition(@RequestBody PkMaster pkMaster) { |
| | | return Result.success(pkMasterService.temDataAcquisition(pkMaster)); |
| | | } |
| | | |
| | | @ApiOperation(value = "左侧设备树形栏") |
| | | @GetMapping("/treeDevice") |
| | | @ValueAuth |
| | | public Result treeDevice(String deviceName) { |
| | | return Result.success(deviceService.treeDevice(deviceName)); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "设备档案导出") |
| | | @GetMapping("/exportDeviceFile") |
| | | @ValueAuth |
| | | public void exportDeviceFile(@RequestParam Integer deviceId, HttpServletResponse response) throws Exception { |
| | | deviceService.exportDeviceFile(deviceId,response); |
| | | } |
| | | |
| | | @ApiOperation(value = "仪器设备一览表导出") |
| | | @GetMapping("/exportEquipmentDetails") |
| | | @ValueAuth |
| | | public void exportEquipmentDetails(HttpServletResponse response) throws Exception { |
| | | deviceService.exportEquipmentDetails(response); |
| | | } |
| | | |
| | | } |