项目部授权
This commit is contained in:
parent
108d3c7d95
commit
249330f6bb
|
|
@ -265,4 +265,10 @@ public class LeasePublishInfo extends BaseEntity{
|
|||
|
||||
@ApiModelProperty(value = "公司名称")
|
||||
private String companyName;
|
||||
|
||||
@ApiModelProperty(value = "授权id")
|
||||
private Long authId;
|
||||
|
||||
@ApiModelProperty(value = "关联外部(第三方)的工程ID")
|
||||
private String externalId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,6 +112,12 @@
|
|||
<version>5.5.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.12.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
@ -127,7 +133,7 @@
|
|||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.bonus.material.basic.domain.BmProject;
|
|||
import com.bonus.material.basic.domain.BmUnit;
|
||||
import com.bonus.material.common.domain.dto.SelectDto;
|
||||
import com.bonus.material.common.service.SelectService;
|
||||
import com.bonus.material.materialStation.domain.ProAuthorizeInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -160,4 +161,10 @@ public class SelectController {
|
|||
public AjaxResult getUseType(@RequestBody BackApplyInfo bean) {
|
||||
return service.getUseType(bean);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "班组下拉选")
|
||||
@PostMapping("getTeamList")
|
||||
public AjaxResult getTeamList(@RequestBody ProAuthorizeInfo bean) {
|
||||
return service.getTeamList(bean);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.bonus.material.basic.domain.BmUnit;
|
|||
import com.bonus.material.common.domain.dto.SelectDto;
|
||||
import com.bonus.material.common.domain.vo.AgreementVo;
|
||||
import com.bonus.material.common.domain.vo.SelectVo;
|
||||
import com.bonus.material.materialStation.domain.ProAuthorizeInfo;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -178,4 +179,11 @@ public interface SelectMapper {
|
|||
* @return
|
||||
*/
|
||||
List<SelectVo> getBranchProject();
|
||||
|
||||
/**
|
||||
* 获取班组下拉选
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<SelectVo> getTeamList(ProAuthorizeInfo bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.bonus.material.back.domain.BackApplyInfo;
|
|||
import com.bonus.material.basic.domain.BmProject;
|
||||
import com.bonus.material.basic.domain.BmUnit;
|
||||
import com.bonus.material.common.domain.dto.SelectDto;
|
||||
import com.bonus.material.materialStation.domain.ProAuthorizeInfo;
|
||||
|
||||
/**
|
||||
* @author 10488
|
||||
|
|
@ -212,4 +213,11 @@ public interface SelectService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult getBranchProject();
|
||||
|
||||
/**
|
||||
* 班组下拉选
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getTeamList(ProAuthorizeInfo bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.bonus.material.common.domain.vo.AgreementVo;
|
|||
import com.bonus.material.common.domain.vo.SelectVo;
|
||||
import com.bonus.material.common.mapper.SelectMapper;
|
||||
import com.bonus.material.common.service.SelectService;
|
||||
import com.bonus.material.materialStation.domain.ProAuthorizeInfo;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
|
@ -147,6 +148,16 @@ public class SelectServiceImpl implements SelectService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getTeamList(ProAuthorizeInfo bean) {
|
||||
try {
|
||||
return AjaxResult.success(mapper.getTeamList(bean));
|
||||
} catch (Exception e) {
|
||||
log.error("班组-查询失败", e);
|
||||
return AjaxResult.success(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public AjaxResult getDictByPidCbx(SelectDto dto) {
|
||||
// List<SelectVo> list = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,102 @@
|
|||
package com.bonus.material.materialStation.controller;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.bonus.common.biz.config.ListPagingUtil;
|
||||
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||
import com.bonus.common.biz.domain.lease.LeasePublishInfo;
|
||||
import com.bonus.common.core.utils.ServletUtils;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.material.materialStation.domain.ProAuthorizeInfo;
|
||||
import com.bonus.material.materialStation.service.ProAuthorizeService;
|
||||
import com.bonus.material.repair.domain.vo.RepairDeviceVO;
|
||||
import com.bonus.system.api.RemoteFileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @author hay
|
||||
* @description 项目部授权
|
||||
* @date 2025/6/18 21:54
|
||||
*/
|
||||
@Api(tags = " 项目部授权")
|
||||
@RestController
|
||||
@RequestMapping("/authorize")
|
||||
public class ProAuthorizeController extends BaseController {
|
||||
|
||||
@Resource(name = "proAuthorizeService")
|
||||
private ProAuthorizeService service;
|
||||
|
||||
@Resource
|
||||
private RemoteFileService sysFileService;
|
||||
|
||||
/**
|
||||
* 列表展示
|
||||
*/
|
||||
@ApiOperation(value = "列表展示")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult getPublishList(LeaseApplyInfo leaseApplyInfo) {
|
||||
Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
|
||||
Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
|
||||
try {
|
||||
List<LeasePublishInfo> list = service.getPublishList(leaseApplyInfo);
|
||||
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list));
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, new ArrayList<>()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传与识别身份证文件
|
||||
*/
|
||||
@ApiOperation(value = "上传与识别身份证文件")
|
||||
@PostMapping("/uploadPhoto")
|
||||
public AjaxResult uploadPhoto(MultipartFile file,Long type) {
|
||||
try {
|
||||
AjaxResult result = sysFileService.upload(file);
|
||||
if (!result.isSuccess()){
|
||||
return AjaxResult.error("文件上传失败");
|
||||
}
|
||||
Map<String, Object> jsonObject = (Map<String, Object>) result.get("data");
|
||||
String fileName = file.getOriginalFilename();
|
||||
String filePath = jsonObject.get("url").toString();
|
||||
return service.uploadPhoto(filePath,type);
|
||||
} catch (Exception e) {
|
||||
logger.error("上传退料单PDF文件失败", e);
|
||||
return AjaxResult.error("领料单档案保存失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权提交
|
||||
*/
|
||||
@ApiOperation(value = "授权提交")
|
||||
@PostMapping("/authorizeSubmit")
|
||||
public AjaxResult authorizeSubmit(@RequestBody ProAuthorizeInfo bean) {
|
||||
return service.authorizeSubmit(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权信息查看
|
||||
*/
|
||||
@ApiOperation(value = "授权信息查看")
|
||||
@PostMapping("/authorizeView")
|
||||
public AjaxResult authorizeView(@RequestBody ProAuthorizeInfo bean) {
|
||||
return service.authorizeView(bean);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package com.bonus.material.materialStation.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目部授权信息
|
||||
*
|
||||
* @author hay
|
||||
*/
|
||||
@Data
|
||||
public class ProAuthorizeDetails {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
*/
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 正面照片
|
||||
*/
|
||||
private String frontUrl;
|
||||
|
||||
/**
|
||||
* 身份证反面照片
|
||||
*/
|
||||
private String backUrl;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
package com.bonus.material.materialStation.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目部授权信息
|
||||
*
|
||||
* @author hay
|
||||
*/
|
||||
@Data
|
||||
public class ProAuthorizeInfo {
|
||||
private Long id;
|
||||
|
||||
private Long authId;
|
||||
|
||||
/**
|
||||
* 领料id
|
||||
*/
|
||||
private Long leaseId;
|
||||
|
||||
private Long[] leaseIds;
|
||||
|
||||
/**
|
||||
* 班组id
|
||||
*/
|
||||
private Long teamId;
|
||||
|
||||
/**
|
||||
* 班组名称
|
||||
*/
|
||||
private String teamName;
|
||||
|
||||
/**
|
||||
* 委托书路径
|
||||
*/
|
||||
private String url;
|
||||
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
private List<ProAuthorizeDetails> detailsList;
|
||||
|
||||
/**
|
||||
* 关联外部(第三方)的工程ID
|
||||
*/
|
||||
private String externalId;
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.bonus.material.materialStation.mapper;
|
||||
|
||||
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||
import com.bonus.common.biz.domain.lease.LeasePublishInfo;
|
||||
import com.bonus.material.materialStation.domain.ProAuthorizeDetails;
|
||||
import com.bonus.material.materialStation.domain.ProAuthorizeInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hay
|
||||
* @description 项目部授权
|
||||
* @date 2025/6/18 21:54
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProAuthorizeMapper {
|
||||
|
||||
/**
|
||||
* 获取项目部授权列表
|
||||
* @param leaseApplyInfo
|
||||
* @return
|
||||
*/
|
||||
List<LeasePublishInfo> getPublishList(LeaseApplyInfo leaseApplyInfo);
|
||||
|
||||
/**
|
||||
* 添加项目部授权信息
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
int insertProAuthorizeInfo(ProAuthorizeInfo bean);
|
||||
|
||||
/**
|
||||
* 添加项目部授权详情信息
|
||||
* @param details
|
||||
* @return
|
||||
*/
|
||||
int insertProAuthorizeDetails(ProAuthorizeDetails details);
|
||||
|
||||
/**
|
||||
* 获取项目部授权信息
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
ProAuthorizeInfo selectProAuthorizeInfo(ProAuthorizeInfo bean);
|
||||
|
||||
/**
|
||||
* 获取项目部授权详情信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<ProAuthorizeDetails> getDetailsList(Long id);
|
||||
|
||||
/**
|
||||
* 删除项目部授权详情信息
|
||||
* @param authId
|
||||
* @return
|
||||
*/
|
||||
int deleteProAuthorizeDetails(Long authId);
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.bonus.material.materialStation.service;
|
||||
|
||||
|
||||
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||
import com.bonus.common.biz.domain.lease.LeasePublishInfo;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.materialStation.domain.ProAuthorizeInfo;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hay
|
||||
* @description 项目部授权
|
||||
* @date 2025/6/18 21:54
|
||||
*/
|
||||
public interface ProAuthorizeService {
|
||||
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
* @param leaseApplyInfo
|
||||
* @return
|
||||
*/
|
||||
List<LeasePublishInfo> getPublishList(LeaseApplyInfo leaseApplyInfo);
|
||||
|
||||
/**
|
||||
* 上传与识别图片
|
||||
* @param filePath
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
AjaxResult uploadPhoto(String filePath, Long type);
|
||||
|
||||
/**
|
||||
* 授权提交
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
AjaxResult authorizeSubmit(ProAuthorizeInfo bean);
|
||||
|
||||
/**
|
||||
* 授权信息查看
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
AjaxResult authorizeView(ProAuthorizeInfo bean);
|
||||
}
|
||||
|
|
@ -0,0 +1,328 @@
|
|||
package com.bonus.material.materialStation.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||
import com.bonus.common.biz.domain.lease.LeasePublishInfo;
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.materialStation.domain.ProAuthorizeDetails;
|
||||
import com.bonus.material.materialStation.domain.ProAuthorizeInfo;
|
||||
import com.bonus.material.materialStation.mapper.ProAuthorizeMapper;
|
||||
import com.bonus.material.materialStation.service.ProAuthorizeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.hibernate.validator.internal.util.StringHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author hay
|
||||
* @description 项目部授权
|
||||
* @date 2025/6/18 21:54
|
||||
*/
|
||||
@Service(value = "proAuthorizeService")
|
||||
@Slf4j
|
||||
public class ProAuthorizeServiceImpl implements ProAuthorizeService {
|
||||
/** 应用1 */
|
||||
public static final String API_KEY = "YVXaH3odMID2QRJZFkJaL8yx";
|
||||
/** 应用1 */
|
||||
public static final String SECRET_KEY = "YWnUheHHXsqwbR1Pt0ZfaZxrh40uUW99";
|
||||
|
||||
/** 应用2 */
|
||||
public static final String API_KEY_2 = "Ugm22rvfLDADxr9sT6H2muSG";
|
||||
/** 应用2 */
|
||||
public static final String SECRET_KEY_2 = "w1jfLoSLFpxdIJpQriJXWpoNF1YOWTdJ";
|
||||
|
||||
static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
|
||||
|
||||
@Resource
|
||||
private ProAuthorizeMapper mapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<LeasePublishInfo> getPublishList(LeaseApplyInfo leaseApplyInfo) {
|
||||
try {
|
||||
List<LeasePublishInfo> list = mapper.getPublishList(leaseApplyInfo);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
String keyWord = leaseApplyInfo.getKeyWord();
|
||||
// 如果关键字不为空,进行过滤
|
||||
if (!StringUtils.isBlank(keyWord)) {
|
||||
list = list.stream()
|
||||
.filter(item -> containsKeyWord(item, keyWord))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
} catch (Exception e){
|
||||
log.error("项目部授权列表查询", e.getMessage());
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult uploadPhoto(String filePath, Long type) {
|
||||
try {
|
||||
String base64 = encodeImageFromUrlToBase64(filePath);
|
||||
String types="";
|
||||
if (type == 1){
|
||||
types="front";
|
||||
} else if (type == 2){
|
||||
types="back";
|
||||
}
|
||||
if (!StringHelper.isNullOrEmptyString(base64)) {
|
||||
String image = URLEncoder.encode(base64, "utf-8");
|
||||
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
||||
RequestBody body = RequestBody.create(mediaType, "image=" + image + "&id_card_side="+types);
|
||||
Request request = new Request.Builder()
|
||||
.url("https://aip.baidubce.com/rest/2.0/ocr/v1/idcard?access_token=" + getAccessToken())
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/x-www-form-urlencoded")
|
||||
.addHeader("Accept", "application/json")
|
||||
.build();
|
||||
Response response = HTTP_CLIENT.newCall(request).execute();
|
||||
String jsonString = response.body().string();
|
||||
System.err.println(jsonString);
|
||||
JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
||||
JSONObject resultObject = jsonObject.getJSONObject("words_result");
|
||||
ProAuthorizeDetails bean = new ProAuthorizeDetails();
|
||||
if (type==1){
|
||||
String name = resultObject.getJSONObject("姓名").getString("words");
|
||||
String idNumber = resultObject.getJSONObject("公民身份号码").getString("words");
|
||||
String sex = resultObject.getJSONObject("性别").getString("words");
|
||||
String birth = resultObject.getJSONObject("出生").getString("words");
|
||||
String address = resultObject.getJSONObject("住址").getString("words");
|
||||
String nation = resultObject.getJSONObject("民族").getString("words");
|
||||
bean.setName(name);
|
||||
bean.setIdNumber(idNumber);
|
||||
bean.setFrontUrl(filePath);
|
||||
} else if (type==2){
|
||||
String time = resultObject.getJSONObject("失效日期").getString("words");
|
||||
bean.setBackUrl(filePath);
|
||||
}
|
||||
return AjaxResult.success(bean);
|
||||
} else {
|
||||
return AjaxResult.error("图片识别失败,请重试");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("图片识别失败", e.getMessage());
|
||||
return AjaxResult.error("图片识别失败,请重试");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult authorizeSubmit(ProAuthorizeInfo bean) {
|
||||
try {
|
||||
String userId = SecurityUtils.getLoginUser().getUserid().toString();
|
||||
bean.setCreateBy(userId);
|
||||
if (bean != null) {
|
||||
if (bean.getAuthId() != null) {
|
||||
//修改
|
||||
//删除详情数据
|
||||
int res = mapper.deleteProAuthorizeDetails(bean.getAuthId());
|
||||
if (res <= 0) {
|
||||
throw new RuntimeException("授权信息删除失败");
|
||||
}
|
||||
insertProAuthorizeDetails(bean.getDetailsList(),bean.getAuthId());
|
||||
} else {
|
||||
for (Long lesaeId : bean.getLeaseIds()){
|
||||
bean.setLeaseId(lesaeId);
|
||||
//新增
|
||||
int res = mapper.insertProAuthorizeInfo(bean);
|
||||
if (res > 0 && bean.getId() != null) {
|
||||
bean.setAuthId(bean.getId());
|
||||
} else {
|
||||
throw new RuntimeException("授权信息插入失败");
|
||||
}
|
||||
insertProAuthorizeDetails(bean.getDetailsList(),bean.getAuthId());
|
||||
}
|
||||
}
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
throw new RuntimeException("授权信息插入失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("授权提交失败", e.getMessage());
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error("授权提交失败");
|
||||
}
|
||||
}
|
||||
|
||||
private void insertProAuthorizeDetails(List<ProAuthorizeDetails> detailsList,Long authId){
|
||||
String userId = SecurityUtils.getLoginUser().getUserid().toString();
|
||||
if (detailsList.size() > 0) {
|
||||
for (ProAuthorizeDetails details : detailsList) {
|
||||
details.setParentId(authId);
|
||||
details.setCreateBy(userId);
|
||||
int re = mapper.insertProAuthorizeDetails(details);
|
||||
if (re <= 0) {
|
||||
throw new RuntimeException("授权信息插入失败");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("没有领料人信息");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult authorizeView(ProAuthorizeInfo bean) {
|
||||
try {
|
||||
if (bean.getLeaseId()!= null){
|
||||
//查询授权信息
|
||||
ProAuthorizeInfo info = mapper.selectProAuthorizeInfo(bean);
|
||||
if (info != null){
|
||||
List<ProAuthorizeDetails> detailsList = mapper.getDetailsList(info.getId());
|
||||
info.setDetailsList(detailsList);
|
||||
}
|
||||
return AjaxResult.success(info);
|
||||
} else {
|
||||
log.error("授权查看没有id");
|
||||
return AjaxResult.error("授权信息查看失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("授权信息查看失败", e.getMessage());
|
||||
return AjaxResult.error("授权信息查看失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断关键字是否包含在item中
|
||||
* @param item
|
||||
* @param keyWord
|
||||
* @return
|
||||
*/
|
||||
private boolean containsKeyWord(LeasePublishInfo item, String keyWord) {
|
||||
return (item.getMaTypeNames() != null && item.getMaTypeNames().contains(keyWord)) ||
|
||||
(item.getUnitName() != null && item.getUnitName().contains(keyWord)) ||
|
||||
(item.getProjectName() != null && item.getProjectName().contains(keyWord)) ||
|
||||
(item.getCode() != null && item.getCode().contains(keyWord)) ||
|
||||
(item.getCreateBy() != null && item.getCreateBy().contains(keyWord)) ||
|
||||
(item.getLeasePerson() != null && item.getLeasePerson().contains(keyWord)) ||
|
||||
(item.getPhone() != null && item.getPhone().contains(keyWord)) ||
|
||||
(item.getImpUnitName() != null && item.getImpUnitName().contains(keyWord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 从用户的AK,SK生成鉴权签名(Access Token)
|
||||
*
|
||||
* @return 鉴权签名(Access Token)
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
static String getAccessToken() throws IOException {
|
||||
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
||||
RequestBody body=null;
|
||||
//生成随机数获取应用key
|
||||
Random random = new Random();
|
||||
int i = random.nextInt(2);
|
||||
if (i == 0){
|
||||
body = RequestBody.create(mediaType, "grant_type=client_credentials&client_id=" + API_KEY
|
||||
+ "&client_secret=" + SECRET_KEY);
|
||||
} else {
|
||||
body = RequestBody.create(mediaType, "grant_type=client_credentials&client_id=" + API_KEY_2
|
||||
+ "&client_secret=" + SECRET_KEY_2);
|
||||
}
|
||||
Request request = new Request.Builder()
|
||||
.url("https://aip.baidubce.com/oauth/2.0/token")
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/x-www-form-urlencoded")
|
||||
.build();
|
||||
Response response = HTTP_CLIENT.newCall(request).execute();
|
||||
String jsonString = response.body().string();
|
||||
JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
||||
String accessToken = jsonObject.getString("access_token");
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件base64编码
|
||||
*
|
||||
* @param file MultipartFile 文件对象
|
||||
* 如果Content-Type是application/x-www-form-urlencoded时,传true
|
||||
* @return base64编码信息,不带文件头
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
static String getFileContentAsBase64(MultipartFile file) throws IOException {
|
||||
return getFileContentAsBase64(file, true);
|
||||
}
|
||||
|
||||
public static String encodeImageToBase64(String imagePath) throws IOException {
|
||||
// 创建一个File对象,指向图片所在的路径
|
||||
File file = new File(imagePath);
|
||||
// 检查文件是否存在
|
||||
if (!file.exists()) {
|
||||
throw new IOException("文件未找到: " + imagePath);
|
||||
}
|
||||
// 读取文件为字节数组
|
||||
byte[] fileContent = Files.readAllBytes(file.toPath());
|
||||
// 将字节数组编码为Base64字符串
|
||||
String encodedString = Base64.getEncoder().encodeToString(fileContent);
|
||||
encodedString=URLEncoder.encode(encodedString, "utf-8");
|
||||
|
||||
return encodedString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重载方法,可以指定是否进行URL编码
|
||||
*/
|
||||
static String getFileContentAsBase64(MultipartFile file, boolean urlEncode) throws IOException {
|
||||
byte[] b = file.getBytes();
|
||||
String base64 = Base64.getEncoder().encodeToString(b);
|
||||
if (urlEncode) {
|
||||
base64 = URLEncoder.encode(base64, "utf-8");
|
||||
}
|
||||
return base64;
|
||||
}
|
||||
|
||||
|
||||
public static String encodeImageFromUrlToBase64(String imageUrl) throws IOException {
|
||||
System.err.println("imageUrl-=========:" + imageUrl);
|
||||
URL url = new URL(imageUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
// 设置请求方法为GET
|
||||
connection.setRequestMethod("GET");
|
||||
// 检查状态码是否为200 OK
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
try (InputStream inputStream = connection.getInputStream();
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
byte[] imageBytes = outputStream.toByteArray();
|
||||
// 将字节数组编码为Base64字符串
|
||||
String encodedString = Base64.getEncoder().encodeToString(imageBytes);
|
||||
// System.err.println("encodedString-=========:" + encodedString);
|
||||
// encodedString=URLEncoder.encode(encodedString, "utf-8");
|
||||
// System.err.println("encodedString222-=========:" + encodedString);
|
||||
return encodedString;
|
||||
}
|
||||
} else {
|
||||
throw new IOException("Failed to fetch image: HTTP status code " + responseCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -428,4 +428,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE dict_type = 'branch_project'
|
||||
and `status` = 0
|
||||
</select>
|
||||
<!-- <select id="getTeamList" resultType="com.bonus.material.common.domain.vo.SelectVo">-->
|
||||
<!-- /*根据工程id查询班组*/-->
|
||||
<!-- select bzgl_bz.id,-->
|
||||
<!-- bzgl_bz.bzmc as name,-->
|
||||
<!-- bzgl_bz.bzz_name as teamLeaderName,-->
|
||||
<!-- bzgl_bz.bzz_idcard as teamLeaderIdCard,-->
|
||||
<!-- bzgl_bz.bz as remark,-->
|
||||
<!-- bzgl_bz.bz_status as teamStatus,-->
|
||||
<!-- bzgl_bz.project_id as projectId,-->
|
||||
<!-- bzgl_bz.project_name as projectName,-->
|
||||
<!-- org_user.mobile as teamLeaderPhone-->
|
||||
<!-- from `micro-tool`.bzgl_bz bzgl_bz-->
|
||||
<!-- left join `uni_org`.org_user org_user on bzgl_bz.bzz_idcard = org_user.id_card-->
|
||||
<!-- WHERE bzgl_bz.project_id = #{externalId}-->
|
||||
<!-- </select>-->
|
||||
<!-- <select id="getTeamList" resultType="com.bonus.material.common.domain.vo.SelectVo">-->
|
||||
<!-- /*查询所有班组*/-->
|
||||
<!-- select bzgl_bz.id,-->
|
||||
<!-- bzgl_bz.bzmc as name,-->
|
||||
<!-- bzgl_bz.bzz_name as teamLeaderName,-->
|
||||
<!-- bzgl_bz.bzz_idcard as teamLeaderIdCard,-->
|
||||
<!-- bzgl_bz.bz as remark,-->
|
||||
<!-- bzgl_bz.bz_status as teamStatus,-->
|
||||
<!-- bzgl_bz.project_id as projectId,-->
|
||||
<!-- bzgl_bz.project_name as projectName-->
|
||||
<!-- from `micro-tool`.bzgl_bz bzgl_bz-->
|
||||
<!-- </select>-->
|
||||
<select id="getTeamList" resultType="com.bonus.material.common.domain.vo.SelectVo">
|
||||
SELECT id,
|
||||
team_name as `name`
|
||||
FROM `lease_team_info`
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,131 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.material.materialStation.mapper.ProAuthorizeMapper">
|
||||
|
||||
<resultMap type="com.bonus.common.biz.domain.lease.LeasePublishInfo" id="LeasePublishInfoResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="code" column="code"/>
|
||||
<result property="taskId" column="task_id"/>
|
||||
<result property="leasePerson" column="lease_person"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="companyAuditBy" column="company_audit_by"/>
|
||||
<result property="companyAuditTime" column="company_audit_time"/>
|
||||
<result property="companyAuditRemark" column="company_audit_remark"/>
|
||||
<result property="deptAuditBy" column="dept_audit_by"/>
|
||||
<result property="deptAuditTime" column="dept_audit_time"/>
|
||||
<result property="deptAuditRemark" column="dept_audit_remark"/>
|
||||
<result property="directAuditBy" column="direct_audit_by"/>
|
||||
<result property="directAuditTime" column="direct_audit_time"/>
|
||||
<result property="directAuditRemark" column="direct_audit_remark"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="companyId" column="company_id"/>
|
||||
<result property="directId" column="direct_id"/>
|
||||
<result property="leaseType" column="lease_type"/>
|
||||
<result property="estimateLeaseTime" column="estimate_lease_time"/>
|
||||
<result property="costBearingParty" column="cost_bearing_party"/>
|
||||
<result property="leaseProject" column="pro_name"/>
|
||||
<result property="leaseProjectId" column="project_id"/>
|
||||
<result property="leaseUnit" column="unit_name"/>
|
||||
<result property="leaseUnitId" column="unit_id"/>
|
||||
<result property="agreementId" column="agreement_id"/>
|
||||
<result property="agreementCode" column="agreement_code"/>
|
||||
<result property="leaseSignUrl" column="lease_sign_url"/>
|
||||
<result property="leaseSignType" column="lease_sign_type"/>
|
||||
<result property="applyCode" column="apply_code"/>
|
||||
</resultMap>
|
||||
<insert id="insertProAuthorizeInfo" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into pro_authorize_info(lease_id, team_id,team_name,url,file_name, status, create_by, create_time)
|
||||
values (#{leaseId}, #{teamId},#{teamName}, #{url}, #{fileName}, 1, #{createBy}, NOW())
|
||||
</insert>
|
||||
|
||||
<insert id="insertProAuthorizeDetails">
|
||||
insert into pro_authorize_user(parent_id, name, id_number, front_url, back_url, create_by,
|
||||
create_time, update_by, update_time)
|
||||
values (#{parentId}, #{name}, #{idNumber}, #{frontUrl}, #{backUrl}, #{createBy}, NOW(),#{createBy},NOW())
|
||||
</insert>
|
||||
|
||||
<delete id="deleteProAuthorizeDetails">
|
||||
delete
|
||||
from pro_authorize_user
|
||||
where parent_id = #{authId}
|
||||
</delete>
|
||||
|
||||
<select id="getPublishList" resultType="com.bonus.common.biz.domain.lease.LeasePublishInfo"
|
||||
resultMap="LeasePublishInfoResult">
|
||||
select
|
||||
lai.id, lai.code, lai.task_id, lai.lease_person, lai.phone, lai.type, lai.company_audit_by,lai.apply_code,
|
||||
lai.company_audit_time, lai.company_audit_remark, lai.dept_audit_by, lai.dept_audit_time,
|
||||
lai.dept_audit_remark, lai.direct_audit_by, lai.direct_audit_time, lai.direct_audit_remark,
|
||||
lai.create_by, lai.create_time, lai.update_by, lai.update_time, lai.remark, lai.company_id,
|
||||
lai.direct_id, lai.lease_type, lai.estimate_lease_time, lai.cost_bearing_party, lai.lease_sign_url,
|
||||
lai.lease_sign_type,tt.task_id as taskId,
|
||||
lai.unit_id,lai.project_id,bu.unit_name, bp.pro_name, tt.task_status as taskStatus,bp.external_id as externalId,
|
||||
|
||||
case tt.task_status
|
||||
when 1 then '未完成'
|
||||
when 2 then '已终止'
|
||||
when 3 then '已完成'
|
||||
end as taskStatusName,
|
||||
IFNULL(sum(lad.pre_num),0) as preCountNum,
|
||||
IFNULL(sum(lad.al_num),0) as alNum,
|
||||
GROUP_CONCAT(DISTINCT mt1.type_name) AS maTypeNames,
|
||||
bp.contract_part as contractPart,
|
||||
sd.dept_name as impUnitName,
|
||||
pai.id as authId
|
||||
from
|
||||
lease_apply_info lai
|
||||
left join tm_task tt on lai.task_id = tt.task_id
|
||||
left join lease_apply_details lad on lai.id = lad.parent_id
|
||||
left join tm_task_agreement tta on lai.task_id = tta.task_id
|
||||
left join bm_unit bu on bu.unit_id = lai.unit_id
|
||||
left join bm_project bp on bp.pro_id = lai.project_id
|
||||
left join sys_dept sd on sd.dept_id = bp.imp_unit
|
||||
left join sys_dict_data sda on tt.task_status = sda.dict_value
|
||||
and sda.dict_type = 'lease_task_status'
|
||||
left join ma_type mt on lad.type_id = mt.type_id and mt.del_flag = '0'
|
||||
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||||
LEFT JOIN pro_authorize_info pai on pai.lease_id=lai.id and pai.del_flag='0'
|
||||
where tt.task_type = '19'
|
||||
and tt.task_status in (1, 2, 3)
|
||||
<if test="taskStatus != null">
|
||||
<if test="taskStatus==0">
|
||||
and pai.id is null
|
||||
</if>
|
||||
<if test="taskStatus==1">
|
||||
and pai.id is not null
|
||||
</if>
|
||||
</if>
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
|
||||
</if>
|
||||
GROUP BY lai.id
|
||||
ORDER BY tt.task_status,tt.create_time desc
|
||||
</select>
|
||||
<select id="selectProAuthorizeInfo"
|
||||
resultType="com.bonus.material.materialStation.domain.ProAuthorizeInfo">
|
||||
SELECT pai.id,
|
||||
pai.lease_id as leaseId,
|
||||
pai.team_id as teamId,
|
||||
pai.team_name as teamName,
|
||||
pai.url,
|
||||
pai.file_name as fileName
|
||||
FROM pro_authorize_info pai
|
||||
WHERE pai.lease_id = #{leaseId}
|
||||
</select>
|
||||
<select id="getDetailsList" resultType="com.bonus.material.materialStation.domain.ProAuthorizeDetails">
|
||||
SELECT id,
|
||||
`name`,
|
||||
id_number as idNumber,
|
||||
front_url as frontUrl,
|
||||
back_url as backUrl
|
||||
FROM pro_authorize_user
|
||||
WHERE parent_id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue