更新了逻辑

master
土豆兄弟 4 years ago
parent 491c9d4d76
commit 844e522620

@ -0,0 +1,76 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.remoterec.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://el-admin.vip
* @description /
* @author x
* @date 2021-01-07
**/
@Entity
@Data
@Table(name="tb_remote_record")
public class RemoteRecord implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
@ApiModelProperty(value = "id")
private Integer id;
@Column(name = "upload_time",nullable = false)
@NotNull
@ApiModelProperty(value = "上传时间")
private Timestamp uploadTime;
@Column(name = "operation",nullable = false)
@NotBlank
@ApiModelProperty(value = "上传人/公司")
private String operation;
@Column(name = "file_trans_success_count",nullable = false)
@NotNull
@ApiModelProperty(value = "成功保存数量")
private Integer fileTransSuccessCount;
@Column(name = "tag")
@ApiModelProperty(value = "发送状态标识")
private Integer tag;
@Column(name = "localSavePath",nullable = false)
@NotBlank
@ApiModelProperty(value = "文件上传保存路径")
private String localsavepath;
@Column(name = "weight",nullable = false)
@NotNull
@ApiModelProperty(value = "权重值")
private Integer weight;
public void copy(RemoteRecord source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

@ -0,0 +1,28 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.remoterec.repository;
import me.zhengjie.modules.remoterec.domain.RemoteRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://el-admin.vip
* @author x
* @date 2021-01-07
**/
public interface RemoteRecordRepository extends JpaRepository<RemoteRecord, Integer>, JpaSpecificationExecutor<RemoteRecord> {
}

@ -0,0 +1,87 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.remoterec.rest;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.remoterec.domain.RemoteRecord;
import me.zhengjie.modules.remoterec.service.RemoteRecordService;
import me.zhengjie.modules.remoterec.service.dto.RemoteRecordQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://el-admin.vip
* @author x
* @date 2021-01-07
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "远程上传记录管理")
@RequestMapping("/api/remoteRecord")
public class RemoteRecordController {
private final RemoteRecordService remoteRecordService;
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('remoteRecord:list')")
public void download(HttpServletResponse response, RemoteRecordQueryCriteria criteria) throws IOException {
remoteRecordService.download(remoteRecordService.queryAll(criteria), response);
}
@GetMapping
@Log("查询远程上传记录")
@ApiOperation("查询远程上传记录")
@PreAuthorize("@el.check('remoteRecord:list')")
public ResponseEntity<Object> query(RemoteRecordQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(remoteRecordService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@Log("新增远程上传记录")
@ApiOperation("新增远程上传记录")
@PreAuthorize("@el.check('remoteRecord:add')")
public ResponseEntity<Object> create(@Validated @RequestBody RemoteRecord resources){
return new ResponseEntity<>(remoteRecordService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改远程上传记录")
@ApiOperation("修改远程上传记录")
@PreAuthorize("@el.check('remoteRecord:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody RemoteRecord resources){
remoteRecordService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除远程上传记录")
@ApiOperation("删除远程上传记录")
@PreAuthorize("@el.check('remoteRecord:del')")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
remoteRecordService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

@ -0,0 +1,83 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.remoterec.service;
import me.zhengjie.modules.remoterec.domain.RemoteRecord;
import me.zhengjie.modules.remoterec.service.dto.RemoteRecordDto;
import me.zhengjie.modules.remoterec.service.dto.RemoteRecordQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://el-admin.vip
* @description
* @author x
* @date 2021-01-07
**/
public interface RemoteRecordService {
/**
*
* @param criteria
* @param pageable
* @return Map<String,Object>
*/
Map<String,Object> queryAll(RemoteRecordQueryCriteria criteria, Pageable pageable);
/**
*
* @param criteria
* @return List<RemoteRecordDto>
*/
List<RemoteRecordDto> queryAll(RemoteRecordQueryCriteria criteria);
/**
* ID
* @param id ID
* @return RemoteRecordDto
*/
RemoteRecordDto findById(Integer id);
/**
*
* @param resources /
* @return RemoteRecordDto
*/
RemoteRecordDto create(RemoteRecord resources);
/**
*
* @param resources /
*/
void update(RemoteRecord resources);
/**
*
* @param ids /
*/
void deleteAll(Integer[] ids);
/**
*
* @param all
* @param response /
* @throws IOException /
*/
void download(List<RemoteRecordDto> all, HttpServletResponse response) throws IOException;
}

@ -0,0 +1,51 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.remoterec.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://el-admin.vip
* @description /
* @author x
* @date 2021-01-07
**/
@Data
public class RemoteRecordDto implements Serializable {
/** id */
private Integer id;
/** 上传时间 */
private Timestamp uploadTime;
/** 上传人/公司 */
private String operation;
/** 成功保存数量 */
private Integer fileTransSuccessCount;
/** 发送状态标识 */
private Integer tag;
/** 文件上传保存路径 */
private String localsavepath;
/** 权重值 */
private Integer weight;
}

@ -0,0 +1,41 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.remoterec.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.util.List;
import me.zhengjie.annotation.Query;
/**
* @website https://el-admin.vip
* @author x
* @date 2021-01-07
**/
@Data
public class RemoteRecordQueryCriteria{
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private String operation;
/** 精确 */
@Query
private Integer tag;
/** BETWEEN */
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> uploadTime;
}

@ -0,0 +1,109 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.remoterec.service.impl;
import me.zhengjie.modules.remoterec.domain.RemoteRecord;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.remoterec.repository.RemoteRecordRepository;
import me.zhengjie.modules.remoterec.service.RemoteRecordService;
import me.zhengjie.modules.remoterec.service.dto.RemoteRecordDto;
import me.zhengjie.modules.remoterec.service.dto.RemoteRecordQueryCriteria;
import me.zhengjie.modules.remoterec.service.mapstruct.RemoteRecordMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://el-admin.vip
* @description
* @author x
* @date 2021-01-07
**/
@Service
@RequiredArgsConstructor
public class RemoteRecordServiceImpl implements RemoteRecordService {
private final RemoteRecordRepository remoteRecordRepository;
private final RemoteRecordMapper remoteRecordMapper;
@Override
public Map<String,Object> queryAll(RemoteRecordQueryCriteria criteria, Pageable pageable){
Page<RemoteRecord> page = remoteRecordRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(remoteRecordMapper::toDto));
}
@Override
public List<RemoteRecordDto> queryAll(RemoteRecordQueryCriteria criteria){
return remoteRecordMapper.toDto(remoteRecordRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
@Transactional
public RemoteRecordDto findById(Integer id) {
RemoteRecord remoteRecord = remoteRecordRepository.findById(id).orElseGet(RemoteRecord::new);
ValidationUtil.isNull(remoteRecord.getId(),"RemoteRecord","id",id);
return remoteRecordMapper.toDto(remoteRecord);
}
@Override
@Transactional(rollbackFor = Exception.class)
public RemoteRecordDto create(RemoteRecord resources) {
return remoteRecordMapper.toDto(remoteRecordRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(RemoteRecord resources) {
RemoteRecord remoteRecord = remoteRecordRepository.findById(resources.getId()).orElseGet(RemoteRecord::new);
ValidationUtil.isNull( remoteRecord.getId(),"RemoteRecord","id",resources.getId());
remoteRecord.copy(resources);
remoteRecordRepository.save(remoteRecord);
}
@Override
public void deleteAll(Integer[] ids) {
for (Integer id : ids) {
remoteRecordRepository.deleteById(id);
}
}
@Override
public void download(List<RemoteRecordDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (RemoteRecordDto remoteRecord : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("上传时间", remoteRecord.getUploadTime());
map.put("上传人/公司", remoteRecord.getOperation());
map.put("成功保存数量", remoteRecord.getFileTransSuccessCount());
map.put("发送状态标识", remoteRecord.getTag());
map.put("文件上传保存路径", remoteRecord.getLocalsavepath());
map.put("权重值", remoteRecord.getWeight());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

@ -0,0 +1,32 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.remoterec.service.mapstruct;
import me.zhengjie.base.BaseMapper;
import me.zhengjie.modules.remoterec.domain.RemoteRecord;
import me.zhengjie.modules.remoterec.service.dto.RemoteRecordDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://el-admin.vip
* @author x
* @date 2021-01-07
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface RemoteRecordMapper extends BaseMapper<RemoteRecordDto, RemoteRecord> {
}

@ -20,7 +20,6 @@ import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.annotation.Log;
import me.zhengjie.common.http.CommonResponse;
import me.zhengjie.common.http.ResponseCode;
import me.zhengjie.modules.buildrecord.task.dto.SendBigDataDTO;
import me.zhengjie.modules.taskrecord.domain.TaskRecord;
import me.zhengjie.modules.taskrecord.rest.vo.TaskBuildRecordVO;
import me.zhengjie.modules.taskrecord.rest.vo.TaskRecordMergeVO;

@ -77,7 +77,7 @@
<root level="INFO">
<!-- TODO prod 环境去掉std -->
<appender-ref ref="stdAppender"/>
<!--<appender-ref ref="fileAppender"/>-->
<!--<appender-ref ref="stdAppender"/>-->
<appender-ref ref="fileAppender"/>
</root>
</configuration>

@ -20,15 +20,19 @@ public class StreamTest {
static {
uids = new HashSet<>(50_0000);
uids.add("111111111111111111111111");
uids.add("111111111111111111111112");
for (int i = 0; i < 500000; i++) {
uids.add(RandomUtil.randomString(24));
}
uids.add("111111111111111111111113");
base = new ArrayList<>(2000_0000);
base.add("111111111111111111111111");
base.add("111111111111111111111112");
for (int i = 0; i < 2000_0000; i++) {
base.add(RandomUtil.randomString(24));
}
base.add("111111111111111111111113");
}
/**

Loading…
Cancel
Save