|
@@ -2,17 +2,17 @@ package com.jpsoft.smart.modules.base.controller;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.jpsoft.smart.modules.base.dto.CompanyInfoDTO;
|
|
|
-import com.jpsoft.smart.modules.base.entity.CompanyPosition;
|
|
|
-import com.jpsoft.smart.modules.base.entity.PersonInfo;
|
|
|
+import com.jpsoft.smart.modules.base.entity.*;
|
|
|
+import com.jpsoft.smart.modules.base.service.CompanyDeviceRelationService;
|
|
|
import com.jpsoft.smart.modules.base.service.CompanyPositionService;
|
|
|
import com.jpsoft.smart.modules.base.service.PersonInfoService;
|
|
|
import com.jpsoft.smart.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.smart.modules.common.dto.Sort;
|
|
|
import com.jpsoft.smart.modules.common.dto.MessageResult;
|
|
|
-import com.jpsoft.smart.modules.base.entity.CompanyInfo;
|
|
|
import com.jpsoft.smart.modules.base.service.CompanyInfoService;
|
|
|
import com.jpsoft.smart.modules.sys.entity.User;
|
|
|
import com.jpsoft.smart.modules.sys.service.UserService;
|
|
|
+import com.rabbitmq.client.AMQP;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
@@ -21,6 +21,8 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -47,6 +49,9 @@ public class CompanyInfoController {
|
|
|
@Autowired
|
|
|
private PersonInfoService personInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CompanyDeviceRelationService companyDeviceRelationService;
|
|
|
+
|
|
|
@ApiOperation(value="创建空记录")
|
|
|
@GetMapping("create")
|
|
|
public MessageResult<CompanyInfoDTO> create(){
|
|
@@ -369,4 +374,58 @@ public class CompanyInfoController {
|
|
|
|
|
|
return msgResult;
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping("queryBindDeviceList")
|
|
|
+ public MessageResult<List> queryBindDeviceList(String companyId){
|
|
|
+ MessageResult<List> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<DeviceInfo> deviceList = companyDeviceRelationService.findDeviceByCompanyId(companyId);
|
|
|
+
|
|
|
+ messageResult.setData(deviceList);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @PostMapping("bindDevice")
|
|
|
+ public MessageResult<String> bindDevice(String companyId,String deviceIds,@ModelAttribute String subject){
|
|
|
+ MessageResult<String> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ String[] arr = deviceIds.split(",");
|
|
|
+
|
|
|
+ companyDeviceRelationService.deleteByCompanyId(companyId);
|
|
|
+
|
|
|
+ for (String deviceId : arr) {
|
|
|
+ CompanyDeviceRelation cdr = new CompanyDeviceRelation();
|
|
|
+ cdr.setId(UUID.randomUUID().toString());
|
|
|
+ cdr.setCompanyId(companyId);
|
|
|
+ cdr.setDeviceId(deviceId);
|
|
|
+
|
|
|
+ cdr.setCreateBy(subject);
|
|
|
+ cdr.setCreateTime(new Date());
|
|
|
+
|
|
|
+ companyDeviceRelationService.insert(cdr);
|
|
|
+ }
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
}
|