提交 f72a4206 authored 作者: 133's avatar 133

feat(清退模块): 添加历史退役,退回接口

添加历史退役,退回接口
上级 1faedea4
package com.tykj.dev.device.sendback.controller;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.repair.service.HistoryPepairService;
import com.tykj.dev.device.repair.subject.vo.HistorySelectVo;
import com.tykj.dev.device.sendback.entity.vo.HistorySelectSendBillVo;
import com.tykj.dev.device.sendback.service.HistorySendBillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
/**
* @author zjm
* @version 1.0.0
* @ClassName HistoryPepairContriller.java
* @Description TODO
* @createTime 2021年09月17日 10:21:00
*/
@RestController
@RequestMapping(value = "/historySend")
@AutoDocument
@Api(tags = "历史1。退回 2。退役模块", description = "历史1。退回 2。退役模块")
public class HistorySendBillContriller {
@Autowired
HistorySendBillService historySendBillService;
@ApiOperation(value = "采集文件")
@GetMapping("/read")
public ResponseEntity test(){
historySendBillService.toDb();
return ResponseEntity.ok("ok");
}
@ApiOperation(value = "转数据库")
@GetMapping("/todb")
public ResponseEntity toDb(){
historySendBillService.toDb2();
return ResponseEntity.ok("ok");
}
@ApiOperation(value = "历史数据查询接口")
@PostMapping("/select/bill")
public ResponseEntity findByPageHistoryRepairBill(@RequestBody HistorySelectSendBillVo historySelectSendBillVo){
return ResponseEntity.ok(historySendBillService.findByPageHistoryRepairBill(historySelectSendBillVo));
}
}
package com.tykj.dev.device.sendback.entity.domain;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.repair.subject.domin.HistoryRepairBill;
import com.tykj.dev.misc.base.BaseEntity;
import com.tykj.dev.misc.utils.JacksonUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName HistorySendBill.java
* @Description TODO
* @createTime 2021年09月22日 13:23:00
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@ApiModel("清退详情")
@NoArgsConstructor
@AllArgsConstructor
@Where(clause = "delete_tag = 0")
public class HistorySendBill {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
private Integer oid;
@JsonProperty("title")
private String title;
@JsonProperty("docNo")
private String docNo;
@JsonProperty("applyTime")
private String applyTime;
@JsonProperty("handleTime")
private String handleTime;
@JsonProperty("applyUnitName")
private String applyUnitName;
@JsonProperty("applyUserName")
private String applyUserName;
@JsonProperty("applyConfirmUserName")
private String applyConfirmUserName;
@JsonProperty("handleUnitName")
private String handleUnitName;
@JsonProperty("handleUserName")
private String handleUserName;
@JsonProperty("handleConfirmUserName")
private String handleConfirmUserName;
@Column(name = "file_rets_send",columnDefinition = "text")
private String fileRetsSend;
@Column(name = "file_rets_handle",columnDefinition = "text")
private String fileRetsHandle;
/**
* 1 为退回 2。退役
*/
private Integer type;
@Transient
private List<FileRet> fileRetSendList;
@Transient
private List<FileRet> fileRetHandleList;
/**
* 删除标记(0:未删除,1:已删除)
*/
private Integer deleteTag = 0;
public String toDo(){
return JacksonUtil.toJSon(this);
}
public static HistorySendBill toDb(String data){
return JacksonUtil.readValue(data,HistorySendBill.class);
}
}
package com.tykj.dev.device.sendback.entity.vo;
import com.tykj.dev.misc.base.CustomPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author zjm
* @version 1.0.0
* @ClassName HistorySelectSendBillVo.java
* @Description TODO
* @createTime 2021年09月22日 15:09:00
*/
@Data
@ApiModel("历史维修单查询接口")
@AllArgsConstructor
@NoArgsConstructor
public class HistorySelectSendBillVo extends CustomPage {
@ApiModelProperty(name = "时间条件")
private String timeDim;
@ApiModelProperty(name = "批复文号")
private String docNumDim;
private Integer type;
}
package com.tykj.dev.device.sendback.entity.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.sendback.entity.domain.HistorySendBill;
import com.tykj.dev.misc.base.BeanHelper;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.modelmapper.ModelMapper;
import javax.persistence.*;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName HistorySendBill.java
* @Description TODO
* @createTime 2021年09月22日 13:23:00
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Slf4j
public class HistorySendBillVo {
@ApiModelProperty(name = "主键id")
@Excel(name = "ID", orderNum = "1", width = 30, needMerge = true)
private Integer oid;
@JsonProperty("docNo")
@Excel(name = "单号", orderNum = "1", width = 30, needMerge = true)
private String docNo;
@JsonProperty("applyTime")
@Excel(name = "发送时间", orderNum = "1", width = 30, needMerge = true)
private String applyTime;
@JsonProperty("handleTime")
@Excel(name = "签收时间", orderNum = "1", width = 30, needMerge = true)
private String handleTime;
@JsonProperty("applyUnitName")
@Excel(name = "发送单位", orderNum = "1", width = 30, needMerge = true)
private String applyUnitName;
@JsonProperty("applyUserName")
@Excel(name = "发送经办人", orderNum = "1", width = 30, needMerge = true)
private String applyUserName;
@JsonProperty("applyConfirmUserName")
@Excel(name = "发送签发", orderNum = "1", width = 30, needMerge = true)
private String applyConfirmUserName;
@JsonProperty("handleUnitName")
@Excel(name = "接收单位", orderNum = "1", width = 30, needMerge = true)
private String handleUnitName;
@JsonProperty("handleUserName")
@Excel(name = "签收", orderNum = "1", width = 30, needMerge = true)
private String handleUserName;
@JsonProperty("handleConfirmUserName")
@Excel(name = "经办", orderNum = "1", width = 30, needMerge = true)
private String handleConfirmUserName;
@Excel(name = "发送单据", orderNum = "1", width = 30, needMerge = true)
private Integer applyFileId;
@Excel(name = "签收单据", orderNum = "1", width = 30, needMerge = true)
private Integer handleFileId;
@Transient
private List<FileRet> fileRetSendList;
@Transient
private List<FileRet> fileRetHandleList;
public HistorySendBill toHistorySendBillVo() {
ModelMapper mapper = BeanHelper.getUserMapper();
HistorySendBill historySendBill= mapper.map(this, HistorySendBill.class);
return historySendBill;
}
}
package com.tykj.dev.device.sendback.repository;
import com.tykj.dev.device.sendback.entity.domain.HistorySendBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author zjm
* @version 1.0.0
* @ClassName HistorySendBillDao.java
* @Description TODO
* @createTime 2021年09月22日 14:10:00
*/
public interface HistorySendBillDao extends JpaRepository<HistorySendBill, Integer>, JpaSpecificationExecutor<HistorySendBill> {
}
package com.tykj.dev.device.sendback.service;
import com.tykj.dev.device.repair.subject.domin.HistoryRepairBill;
import com.tykj.dev.device.repair.subject.vo.HistorySelectVo;
import com.tykj.dev.device.sendback.entity.domain.HistorySendBill;
import com.tykj.dev.device.sendback.entity.vo.HistorySelectSendBillVo;
import org.springframework.data.domain.Page;
public interface HistorySendBillService {
void toDb();
void toDb2();
Page<HistorySendBill> findByPageHistoryRepairBill(HistorySelectSendBillVo historySelectSendBillVo);
}
package com.tykj.dev.device.sendback.service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.device.file.service.FilesUtil;
import com.tykj.dev.device.repair.subject.domin.HistoryRepairBill;
import com.tykj.dev.device.repair.subject.vo.HistorySelectVo;
import com.tykj.dev.device.sendback.entity.domain.HistorySendBill;
import com.tykj.dev.device.sendback.entity.vo.HistorySelectSendBillVo;
import com.tykj.dev.device.sendback.repository.HistorySendBillDao;
import com.tykj.dev.device.sendback.service.HistorySendBillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.util.ResourceUtils;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author zjm
* @version 1.0.0
* @ClassName HistorySendBillServiceImpl.java
* @Description TODO
* @createTime 2021年09月22日 15:05:00
*/
@Service
@Slf4j
public class HistorySendBillServiceImpl implements HistorySendBillService {
@Autowired
HistorySendBillDao historySendBillDao;
@Override
public void toDb() {
Path path= Paths.get("file1.txt");
List<String> list=historySendBillDao.findAll().stream().map(HistorySendBill::toDo).collect(Collectors.toList());
try {
Files.write(path,list);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void toDb2() {
try {
List<String> list = Files.readAllLines(Paths.get(ResourceUtils.getURL("classpath:").getPath()+"file1.txt"));
List<HistorySendBill> historyRepairBills = list
.stream()
.map(HistorySendBill::toDb)
.collect(Collectors.toList());
historyRepairBills.forEach(
historyRepairBill -> {
historySendBillDao.save(historyRepairBill);
}
);
} catch (IOException e) {
log.error("[toDb2] 找不到文件路径");
}
}
@Override
public Page<HistorySendBill> findByPageHistoryRepairBill(HistorySelectSendBillVo historySelectSendBillVo) {
return historySendBillDao.findAll(getSpecificationHistoryRepairBill(historySelectSendBillVo),historySelectSendBillVo.getPageable()).map(historyRepairBill -> {
historyRepairBill.setFileRetSendList(FilesUtil.stringFileToList(historyRepairBill.getFileRetsSend()));
historyRepairBill.setFileRetHandleList(FilesUtil.stringFileToList(historyRepairBill.getFileRetsHandle()));
return historyRepairBill;
});
}
private Specification<HistorySendBill> getSpecificationHistoryRepairBill(HistorySelectSendBillVo historySelectSendBillVo) {
PredicateBuilder<HistorySendBill> predicateBuilder = Specifications.and();
if (historySelectSendBillVo.getDocNumDim() != null) {
predicateBuilder.like("docNo","%"+historySelectSendBillVo.getDocNumDim()+"%" );
}
if (historySelectSendBillVo.getTimeDim() != null) {
predicateBuilder.like("applyTime","%"+historySelectSendBillVo.getTimeDim()+"%");
}
predicateBuilder.eq("type",historySelectSendBillVo.getType());
return predicateBuilder.build();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论