Commit 45f1a14d authored by chenhao's avatar chenhao

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents d70ed6f9 6dc4c21a
......@@ -14,6 +14,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -36,7 +37,6 @@ public class PersonIdentifyAspect {
@Autowired
JCSFeignClient jcsFeignClient;
final int HTTP_OK_STATUS = 200;
@Before(value = "@annotation(com.yeejoin.amos.maintenance.core.framework.PersonIdentify) && @annotation(permission)")
public void personIdentity(JoinPoint joinPoint, PersonIdentify permission) throws PermissionException {
......@@ -45,7 +45,7 @@ public class PersonIdentifyAspect {
//调用jcs,进行人员身份判断,是维保公司人员还是业主单位人员
String userId = reginParam.getUserModel().getUserId();
FeignClientResult responseModel = jcsFeignClient.getUserUnit(userId);
if (ObjectUtils.isEmpty(responseModel.getResult()) || responseModel.getStatus() != HTTP_OK_STATUS) {
if (ObjectUtils.isEmpty(responseModel.getResult()) || responseModel.getStatus() != HttpStatus.OK.value()) {
throw new RuntimeException(responseModel.getDevMessage());
}
ReginParams.PersonIdentity personIdentity = (ReginParams.PersonIdentity) Bean.mapToBean((Map<String, Object>) responseModel.getResult(), ReginParams.PersonIdentity.class);
......
......@@ -6,6 +6,7 @@ import com.yeejoin.amos.supervision.business.dto.HiddenDangerImportDto;
import com.yeejoin.amos.supervision.business.service.intfc.IHiddenDangerService;
import com.yeejoin.amos.supervision.business.util.FileHelper;
import com.yeejoin.amos.supervision.core.common.dto.DangerDto;
import com.yeejoin.amos.supervision.core.framework.PersonIdentify;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -79,13 +80,14 @@ public class HiddenDangerController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PersonIdentify
@ApiOperation(value = "导入隐患", notes = "导入隐患")
@RequestMapping(value = "/import", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public ResponseModel importDanger(
@RequestParam(value = "planId") Long planId,
@ApiParam(value = "导入数据文件", required = true) @RequestBody MultipartFile file) {
List<HiddenDangerImportDto> list = FileHelper.importExcel(file, 0, 1, HiddenDangerImportDto.class);
iHiddenDangerService.importDanger(planId, list);
iHiddenDangerService.importDanger(getSelectedOrgInfo(),planId, list);
return ResponseHelper.buildResponse("导入成功");
}
......
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.excel.DataSources;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
......@@ -22,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.restful.exception.instance.DataNotFound;
......@@ -142,8 +142,9 @@ public class HiddenDangerServiceImpl implements IHiddenDangerService {
}
@Override
public void importDanger(Long planId, List<HiddenDangerImportDto> list) {
public void importDanger(ReginParams reginParams, Long planId, List<HiddenDangerImportDto> list) {
//1.调用创建隐患
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
List<DangerDto> dtoList = list.stream().map(s -> {
String[] dangerArray = s.getDangerLevelName().split("@");
String[] reformTypeArray = s.getReformTypeName().split("@");
......@@ -164,7 +165,7 @@ public class HiddenDangerServiceImpl implements IHiddenDangerService {
//2.保存隐患关系表
List<HiddenDanger> hiddenDangers = dangerDbs.stream().map(d -> {
HiddenDanger hiddenDanger = new HiddenDanger();
hiddenDanger.setCreateBy(RequestContext.getExeUserId());
hiddenDanger.setCreateBy(personIdentity.getPersonSeq());
hiddenDanger.setPlanId(planId);
hiddenDanger.setLatentDangerId(d.getId());
hiddenDanger.setCheckInputId(d.getBizId());
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.supervision.business.service.intfc;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.supervision.business.dto.HiddenDangerExportDataDto;
import com.yeejoin.amos.supervision.business.dto.HiddenDangerImportDto;
import com.yeejoin.amos.supervision.core.common.dto.DangerDto;
......@@ -56,10 +57,11 @@ public interface IHiddenDangerService {
/**
* 导入
* @param selectedOrgInfo 用户信息
* @param planId 计划id
* @param list 数据
*/
void importDanger(Long planId, List<HiddenDangerImportDto> list);
void importDanger(ReginParams selectedOrgInfo, Long planId, List<HiddenDangerImportDto> list);
/**
* 下载模板
......
......@@ -11,7 +11,7 @@ import java.lang.annotation.*;
public @interface PersonIdentify {
/**
* 是否进行人员校验
* @return
* @return boolean
*/
boolean isNeedIdentity() default true;
}
......
......@@ -14,11 +14,11 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.ResponseBody;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import java.util.List;
import java.util.Map;
......@@ -37,8 +37,6 @@ public class PersonIdentifyAspect {
@Autowired
JCSFeignClient jcsFeignClient;
final int HTTP_OK_STATUS = 200;
@Before(value = "@annotation(com.yeejoin.amos.supervision.core.framework.PersonIdentify) && @annotation(permission)")
public void personIdentity(JoinPoint joinPoint, PersonIdentify permission) throws PermissionException {
ReginParams reginParam = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
......@@ -46,15 +44,15 @@ public class PersonIdentifyAspect {
//调用jcs,进行人员身份判断,是维保公司人员还是业主单位人员
String userId = reginParam.getUserModel().getUserId();
FeignClientResult responseModel = jcsFeignClient.getUserUnit(userId);
if (ObjectUtils.isEmpty(responseModel.getResult()) || responseModel.getStatus() != HTTP_OK_STATUS) {
if (ObjectUtils.isEmpty(responseModel.getResult()) || responseModel.getStatus() != HttpStatus.OK.value()) {
throw new RuntimeException(responseModel.getDevMessage());
}
List result = (List)responseModel.getResult();
List result = (List) responseModel.getResult();
ReginParams.PersonIdentity personIdentity = new ReginParams.PersonIdentity();
if (!ObjectUtils.isEmpty(result)) {
Map map = (Map)result.get(0);
Map other = (Map)map.get("DEPARTMENT");
Map person = (Map)map.get("PERSON");
Map map = (Map) result.get(0);
Map other = (Map) map.get("DEPARTMENT");
Map person = (Map) map.get("PERSON");
if (!ObjectUtils.isEmpty(person)) {
personIdentity.setPersonSeq((String) person.get("sequenceNbr"));
personIdentity.setPersonName((String) person.get("recUserName"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment