添加文件导入功能
黑名单功能修改完成
This commit is contained in:
@ -99,6 +99,14 @@ public class SynchronousController {
|
||||
return BaseResponse.success(coscoBlacklistService.receiveApprove(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 黑白名单恢复审批
|
||||
*/
|
||||
@PostMapping("/blacklistRestoreApprove")
|
||||
public BaseResponse blacklistRestoreApprove(@RequestBody CoscoBlacklist list) {
|
||||
return BaseResponse.success(coscoBlacklistService.blacklistRestoreApprove(list));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 供应商变更审批回调接口
|
||||
@ -109,4 +117,6 @@ public class SynchronousController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Value("${file.upload-dir}")
|
||||
private String uploadDir;
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
String absolutePath = Paths.get(uploadDir).toAbsolutePath().toUri().toString();
|
||||
registry.addResourceHandler("/files/**")
|
||||
.addResourceLocations(absolutePath);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.config.controller;
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.config.service.FileStorageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/fileConfig/files")
|
||||
public class FileController {
|
||||
|
||||
@Autowired
|
||||
private FileStorageService fileStorageService;
|
||||
|
||||
@Value("${file.upload-dir}")
|
||||
private String uploadDir;
|
||||
|
||||
|
||||
|
||||
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public Map<String, Object> upload(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
String baseUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
|
||||
|
||||
String filename = fileStorageService.storeFile(file);
|
||||
String fileUrl = baseUrl+"/files/" + filename;
|
||||
|
||||
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("fileName", filename);
|
||||
response.put("fileType", file.getContentType());
|
||||
response.put("fileSize", file.getSize());
|
||||
response.put("url", fileUrl);
|
||||
response.put("filePath", uploadDir + "/"+filename);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.config.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class FileStorageService {
|
||||
|
||||
@Value("${file.upload-dir}")
|
||||
private String uploadDir;
|
||||
|
||||
public String storeFile(MultipartFile file) {
|
||||
try {
|
||||
String originalName = StringUtils.cleanPath(file.getOriginalFilename());
|
||||
String ext = "";
|
||||
|
||||
int i = originalName.lastIndexOf(".");
|
||||
if (i >= 0) {
|
||||
ext = originalName.substring(i);
|
||||
}
|
||||
|
||||
String filename = UUID.randomUUID().toString() + ext;
|
||||
Path copyLocation = Paths.get(uploadDir).toAbsolutePath().normalize().resolve(filename);
|
||||
|
||||
Files.createDirectories(copyLocation.getParent());
|
||||
Files.copy(file.getInputStream(), copyLocation, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
return filename;
|
||||
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException("Could not store file: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -81,4 +81,17 @@ public class CoscoBlacklistController extends BaseController {
|
||||
}
|
||||
return BaseResponse.success(coscoBlacklistService.submit(listVo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交恢复审批
|
||||
*/
|
||||
@PostMapping("/restoreSubmit")
|
||||
public BaseResponse restoreSubmit(@RequestBody AddBlackListVo listVo) {
|
||||
BlackListInfoVo blackListInfoVo = coscoBlacklistService.selectCoscoBlacklistById(listVo.getId());
|
||||
if(blackListInfoVo.getRestoreApproveStatus() !=null){
|
||||
return BaseResponse.fail("该申请已提交");
|
||||
}
|
||||
return BaseResponse.success(coscoBlacklistService.restoreSubmit(listVo));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,10 +17,20 @@
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="lastUpdateTime" column="last_update_time"/>
|
||||
<result property="timelimitType" column="timelimit_type"/>
|
||||
<result property="startTime" column="start_time"/>
|
||||
<result property="endTime" column="end_time"/>
|
||||
<result property="restoreApproveStatus" column="restore_approve_status"/>
|
||||
<result property="restoreWorkFlowId" column="restore_work_flow_id"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCoscoBlacklistVo">
|
||||
select id,
|
||||
timelimit_type,
|
||||
start_time,
|
||||
end_time,
|
||||
restore_approve_status,
|
||||
restore_work_flow_id,
|
||||
blacklist_reason,
|
||||
dept_id,
|
||||
backlist_type,
|
||||
@ -89,6 +99,11 @@
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="lastUpdateTime != null">last_update_time,</if>
|
||||
<if test="timelimitType != null">timelimit_type,</if>
|
||||
<if test="startTime != null">start_time,</if>
|
||||
<if test="endTime != null">end_time,</if>
|
||||
<if test="restoreApproveStatus != null">restore_approve_status,</if>
|
||||
<if test="restoreWorkFlowId != null">restore_work_flow_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
@ -103,17 +118,24 @@
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="lastUpdateTime != null">#{lastUpdateTime},</if>
|
||||
<if test="timelimitType != null">#{timelimitType},</if>
|
||||
<if test="startTime != null">#{startTime},</if>
|
||||
<if test="endTime != null">#{endTime},</if>
|
||||
<if test="restoreApproveStatus != null">#{restoreApproveStatus},</if>
|
||||
<if test="restoreWorkFlowId != null">#{restoreWorkFlowId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<insert id="batchCoscoBlacklist" parameterType="java.util.List">
|
||||
insert into cosco_blacklist
|
||||
( id, blacklist_reason, dept_id, backlist_type, approve_status, work_flow_id, del_flag, create_by, create_time,
|
||||
update_by, update_time, last_update_time)
|
||||
update_by, update_time, last_update_time,timelimit_type,start_time,
|
||||
end_time,restore_approve_status,restore_work_flow_id)
|
||||
values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
( #{item.id}, #{item.blacklistReason}, #{item.deptId}, #{item.backlistType}, #{item.approveStatus},
|
||||
#{item.workFlowId}, #{item.delFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy},
|
||||
#{item.updateTime}, #{item.lastUpdateTime})
|
||||
#{item.updateTime}, #{item.lastUpdateTime},#{item.timelimitType},#{item.startTime},
|
||||
#{item.endTime},#{item.restoreApproveStatus},#{item.restoreWorkFlowId})
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="updateCoscoBlacklist"
|
||||
@ -153,6 +175,21 @@
|
||||
<if test="lastUpdateTime != null">last_update_time =
|
||||
#{lastUpdateTime},
|
||||
</if>
|
||||
<if test="timelimitType != null">timelimit_type =
|
||||
#{timelimitType},
|
||||
</if>
|
||||
<if test="startTime != null">start_time =
|
||||
#{startTime},
|
||||
</if>
|
||||
<if test="endTime != null">end_time =
|
||||
#{endTime},
|
||||
</if>
|
||||
<if test="restoreApproveStatus != null">restore_approve_status =
|
||||
#{restoreApproveStatus},
|
||||
</if>
|
||||
<if test="restoreWorkFlowId != null">restore_work_flow_id =
|
||||
#{restoreWorkFlowId},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
@ -26,7 +26,7 @@ public class CoscoBlacklist extends BaseEntity {
|
||||
private String deptId;
|
||||
|
||||
/** 黑灰名单类型(0.黑名单、1.灰名单) */
|
||||
private Long backlistType;
|
||||
private Long backlistType =0L;
|
||||
|
||||
/** 审批状态(0.待审批、1.通过、2.驳回) */
|
||||
private Long approveStatus;
|
||||
@ -36,6 +36,26 @@ public class CoscoBlacklist extends BaseEntity {
|
||||
|
||||
/** 删除标识(normal.正常、deleted.已删除) */
|
||||
private String delFlag="normal";
|
||||
/**
|
||||
* 时限类型(数据字典 3年、5年、10年)
|
||||
*/
|
||||
private String timelimitType;
|
||||
/**
|
||||
* 时限开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
/**
|
||||
* 时限结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 恢复审批状态(0.待审批、1.通过、2.驳回)
|
||||
*/
|
||||
private Long restoreApproveStatus;
|
||||
/**
|
||||
* 恢复审批工作流id
|
||||
*/
|
||||
private String restoreWorkFlowId;
|
||||
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
|
@ -81,4 +81,18 @@ public interface ICoscoBlacklistService {
|
||||
* @return
|
||||
*/
|
||||
int receiveApprove(CoscoBlacklist list);
|
||||
|
||||
/**
|
||||
* 黑白名单恢复审批回调
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
int blacklistRestoreApprove(CoscoBlacklist list);
|
||||
|
||||
/**
|
||||
* 恢复审批提交
|
||||
* @param listVo
|
||||
* @return
|
||||
*/
|
||||
int restoreSubmit(AddBlackListVo listVo);
|
||||
}
|
||||
|
@ -14,11 +14,14 @@ import com.chinaunicom.zyhy.ebtp.supplier.coscoBlack.vo.BlackListInfoVo;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.coscoBlack.vo.BlackListVo;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.coscosupplier.dao.mapper.CoscoSupplierBaseMapper;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.coscosupplier.entity.CoscoSupplierBase;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.util.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -148,12 +151,61 @@ public class CoscoBlacklistServiceImpl implements ICoscoBlacklistService {
|
||||
return coscoBlacklistMapper.updateCoscoBlacklist(coscoBlacklist);
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复审批提交
|
||||
* @param listVo
|
||||
* @return
|
||||
*/
|
||||
public int restoreSubmit(AddBlackListVo listVo){
|
||||
CoscoBlacklist coscoBlacklist = new CoscoBlacklist();
|
||||
coscoBlacklist.setRestoreApproveStatus(CoscoCategoryConstant.APPROVE_STATUS_WAIT);
|
||||
coscoBlacklist.setId(listVo.getId());
|
||||
coscoBlacklist.setRestoreWorkFlowId(PropertyUtils.getSnowflakeId());
|
||||
|
||||
return coscoBlacklistMapper.updateCoscoBlacklist(coscoBlacklist);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int receiveApprove(CoscoBlacklist list) {
|
||||
CoscoBlacklist coscoBlacklist = coscoBlacklistMapper.selectByWorkFlowId(list.getWorkFlowId());
|
||||
if(CoscoCategoryConstant.APPROVE_STATUS_WAIT.equals(coscoBlacklist.getApproveStatus())){
|
||||
coscoBlacklist.setApproveStatus(list.getApproveStatus());
|
||||
coscoBlacklist.setStartTime(new Date());
|
||||
//获取加入黑名单时间
|
||||
coscoBlacklist.setEndTime(DateUtils.plusYears(5));
|
||||
coscoBlacklistMapper.updateCoscoBlacklist(coscoBlacklist);
|
||||
if(CoscoCategoryConstant.APPROVE_STATUS_PASS.equals(list.getApproveStatus())){
|
||||
CoscoBlacklistSupplier coscoBlacklistSupplier = new CoscoBlacklistSupplier();
|
||||
coscoBlacklistSupplier.setBlacklistId(coscoBlacklist.getId());
|
||||
List<CoscoBlacklistSupplier> coscoBlacklistSuppliers = coscoBlacklistSupplierService.selectCoscoBlacklistSupplierList(coscoBlacklistSupplier);
|
||||
coscoBlacklistSuppliers.forEach(cosupplier ->{
|
||||
//判断黑名单
|
||||
if(coscoBlacklist.getBacklistType().equals(CoscoCategoryConstant.BLACKLIST_TYPE_BLACK)){
|
||||
CoscoSupplierBase coscoSupplierBase = new CoscoSupplierBase();
|
||||
coscoSupplierBase.setId(cosupplier.getSupplierId());
|
||||
coscoSupplierBase.setBlacklistStatus(CoscoCategoryConstant.ISTRUE);
|
||||
coscoSupplierBaseMapper.updateCoscoSupplierBase(coscoSupplierBase);
|
||||
}
|
||||
//判断灰名单
|
||||
if(coscoBlacklist.getBacklistType().equals(CoscoCategoryConstant.BLACKLIST_TYPE_BLACK)){
|
||||
CoscoSupplierBase coscoSupplierBase = new CoscoSupplierBase();
|
||||
coscoSupplierBase.setId(cosupplier.getSupplierId());
|
||||
coscoSupplierBase.setGreylistStatus(CoscoCategoryConstant.ISTRUE);
|
||||
coscoSupplierBaseMapper.updateCoscoSupplierBase(coscoSupplierBase);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int blacklistRestoreApprove(CoscoBlacklist list) {
|
||||
CoscoBlacklist coscoBlacklist = coscoBlacklistMapper.selectByWorkFlowId(list.getRestoreWorkFlowId());
|
||||
if(CoscoCategoryConstant.APPROVE_STATUS_WAIT.equals(coscoBlacklist.getRestoreApproveStatus())){
|
||||
coscoBlacklist.setRestoreApproveStatus(list.getRestoreApproveStatus());
|
||||
coscoBlacklistMapper.updateCoscoBlacklist(coscoBlacklist);
|
||||
if(CoscoCategoryConstant.APPROVE_STATUS_PASS.equals(list.getApproveStatus())){
|
||||
CoscoBlacklistSupplier coscoBlacklistSupplier = new CoscoBlacklistSupplier();
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.util;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
|
||||
public class DateUtils {
|
||||
|
||||
public static Date plusYears(int year){
|
||||
LocalDate currentDate = LocalDate.now(); // 获取当前日期
|
||||
int yearsToAdd = 5; // 要添加的年数
|
||||
LocalDate futureDate = currentDate.plusYears(yearsToAdd); // 加年限
|
||||
return Date.from(futureDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -2,7 +2,9 @@ server:
|
||||
port: 18012
|
||||
servlet:
|
||||
context-path: /
|
||||
|
||||
# 文件存储配置
|
||||
file:
|
||||
upload-dir: D:/Temp_Spaces/ljlq-web/ruoyi/uploadPath
|
||||
seata:
|
||||
service:
|
||||
vgroup-mapping:
|
||||
@ -27,7 +29,7 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 10.0.0.125:8848
|
||||
aop:
|
||||
auto: true #开启spring的aop配置
|
||||
proxy-target-class: true
|
||||
@ -117,7 +119,7 @@ mybatis-plus:
|
||||
auto-mapping-behavior: full
|
||||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
mapper-locations: classpath*:com/chinaunicom/mall/ebtp/**/mapper/*Mapper.xml
|
||||
mapper-locations: classpath*:com/chinaunicom/**/mapper/*Mapper.xml
|
||||
global-config:
|
||||
# 逻辑删除配置
|
||||
db-config:
|
||||
@ -182,4 +184,4 @@ management:
|
||||
include: "*"
|
||||
cors:
|
||||
allowed-origins: "*"
|
||||
allowed-methods: "*"
|
||||
allowed-methods: "*"
|
||||
|
Reference in New Issue
Block a user