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

[user file] 代码添加

上级 4bb8c2e2
......@@ -12,11 +12,12 @@
<artifactId>dev-file</artifactId>
<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.10</version>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.1.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.xhtmlrenderer/flying-saucer-pdf-itext5 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
......
......@@ -56,8 +56,20 @@ public class FileController {
@PostMapping("/printDocuments")
public ResponseEntity printDocuments(@RequestBody Documents documents) throws IOException, DocumentException {
String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRender(documents,url+"htmlModel/");
log.info("[file] 调用了生成出入单据对接口");
return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdf(content,url,preview));
log.info("[file] 调用了生成出入单据对接口 documents");
return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdf(content,url,preview,"documents/"));
}
/**
* 生成工作交接的单据
* @return
*/
@ApiOperation(value = "生成工作交接的单据")
@PostMapping("/wordHandover")
public ResponseEntity wordHandover(@RequestBody WorkHandoverDoc workHandoverDoc) {
String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRenderWorkHandover(workHandoverDoc,url+"htmlModel/");
log.info("[file] 生成工作交接的单据");
return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdf(content,url,preview,"workHandover/"));
}
/**
......@@ -68,8 +80,8 @@ public class FileController {
@PostMapping("/printConfirm")
public ResponseEntity printConfirm(@RequestBody Confirm confirm) {
String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRenderConfirm(confirm,url+"htmlModel/");
log.info("[file] 调用了生成确认单据对接口");
return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdfConfirm(content,url,preview));
log.info("[file] 调用了生成确认单据对接口 confirm");
return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdf(content,url,preview,"confirm/"));
}
/**
......@@ -81,7 +93,7 @@ public class FileController {
public ResponseEntity printDestruction(@RequestBody Destruction destruction){
String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRenderDestruction(destruction,url+"htmlModel/");
log.info("[file] 调用了生成销毁单据对接口");
return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdfDestruction(content,url,preview));
return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdf(content,url,preview,"destruction/"));
}
/**
......@@ -114,7 +126,7 @@ public class FileController {
documents.setDocumentDevices(documentDevices);
String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRender(documents,url+"htmlModel/");
showPdf(response,JavaToPdfHtmlFreeMarker.createPdf(content,url,preview).getFilePath());
showPdf(response,JavaToPdfHtmlFreeMarker.createPdf(content,url,preview,"documents/").getFilePath());
return ResponseEntity.ok("ok");
}
......
......@@ -2,6 +2,7 @@ package com.tykj.dev.device.file.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -19,11 +20,14 @@ import lombok.NoArgsConstructor;
@ApiModel(value = "工作交接单据", description = "工作交接单据提供数据")
public class WorkHandoverDevice {
@ApiModelProperty(value = "序列号" ,example = "1")
private Integer code;
@ApiModelProperty(value = "型号", example = "bmxx")
public String model;
private String model;
@ApiModelProperty(value = "名称", example = "BM-1")
public String name;
private String name;
@ApiModelProperty(value = "装备类型总数", example = "100")
private Integer deviceNumber;
......@@ -49,6 +53,13 @@ public class WorkHandoverDevice {
@ApiModelProperty(value = "使用数量", example = "10")
private Integer useNum;
@ApiModelProperty(value = "其他数据",example = "10")
private Integer otherNum=0;
@ApiModelProperty(value = "序列号区间")
public String seqs;
public Integer getLen(){
return seqs.length();
}
}
......@@ -71,10 +71,6 @@ public class JavaToPdfHtmlFreeMarker {
public static void main(String[] args) throws IOException, DocumentException {
// List<user> userList=new ArrayList<>();
// userList.add(new user("占金名",19,1));
// userList.add(new user("占金名1",19,1));
// userList.add(new user("占金名2",19,1));
Documents documents=new Documents();
documents.setNumber("NO:第221321134号");
documents.setReceiveUnit("杭州机要");
......@@ -97,25 +93,25 @@ public class JavaToPdfHtmlFreeMarker {
}
documents.setDocumentDevices(documentDevices);
String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRender(documents,"/Users/zjm/code/test-tu/htmlModel/");
JavaToPdfHtmlFreeMarker.createPdf(content,"/Users/zjm/code/test-tu/","12313");
JavaToPdfHtmlFreeMarker.createPdf(content,"/Users/zjm/code/test-tu/","12313","documents/");
}
public static FileRet createPdf(String[] htmlFiles,String path,String preview){
public static FileRet createPdf(String[] htmlFiles,String path,String preview,String folderName){
Long startTime = System.currentTimeMillis();
Document document = new Document();
String name=UUID.randomUUID().toString()+".pdf";
String pdfPath=path+"documents/"+name;
String pdfPath=path+folderName+name;
PdfCopy pdfCopy = null; //创建一个新文件
try {
pdfCopy = new PdfCopy(document, new FileOutputStream(pdfPath));
document.open();
for (String htmlFile : htmlFiles) {
if (htmlFile != null) {
String url = new File(htmlFile).toURI().toURL().toString();
ByteArrayOutputStream os = new ByteArrayOutputStream();
ITextRenderer renderer = new ITextRenderer();
......@@ -135,8 +131,8 @@ public class JavaToPdfHtmlFreeMarker {
}
Long endTime = System.currentTimeMillis();
System.out.print("Itext parse Html to Pdf End -> " + (endTime - startTime));
return new FileRet("", pdfPath, preview +"documents/"+ name);
} catch (IOException | DocumentException e) {
return new FileRet("", pdfPath, preview +folderName+ name);
} catch (IOException | DocumentException | com.lowagie.text.DocumentException e) {
e.printStackTrace();
} finally {
document.close();
......@@ -199,7 +195,7 @@ public class JavaToPdfHtmlFreeMarker {
data.put("page",page);
data.put("count",count);
if (documents.getSrcA()==null||documents.getSrcA().equals("")){
data.put("srcA","1");
data.put("srcA","\""+1+"\"");
data.put("nameA"," ");
}else {
data.put("srcA","\""+documents.getSrcA()+"\"");
......@@ -227,6 +223,8 @@ public class JavaToPdfHtmlFreeMarker {
}
private static Map<String,Object> toConfirmMap(Confirm confirm, List<DocumentDevice> list,Integer page,Integer count){
Map<String,Object> data = new HashMap();
data.put("title",confirm.getTitle());
......@@ -401,73 +399,114 @@ public class JavaToPdfHtmlFreeMarker {
return null;
}
// /**
// * 确认单据页面调用接口
// */
// public static FileRet createPdfConfirm(String[] htmlFiles,String path,String preview,){
//
// Long startTime = System.currentTimeMillis();
// Document document = new Document();
// String name=UUID.randomUUID().toString()+".pdf";
// String pdfPath=path+"confirm/"+name;
// PdfCopy pdfCopy = null; //创建一个新文件
// try {
// pdfCopy = new PdfCopy(document, new FileOutputStream(pdfPath));
// document.open();
// for (String htmlFile : htmlFiles) {
// if (htmlFile != null) {
//
// String url = new File(htmlFile).toURI().toURL().toString();
// ByteArrayOutputStream os = new ByteArrayOutputStream();
// ITextRenderer renderer = new ITextRenderer();
// renderer.setDocument(htmlFile);
// // 解决中文不显示问题
// ITextFontResolver fontResolver = renderer.getFontResolver();
// fontResolver.addFont(path+"fond/"+"simhei.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
// renderer.layout();
// renderer.createPDF(os);
// PdfReader pdfReader = new PdfReader(os.toByteArray());
// for (int i = 1; i <= pdfReader.getNumberOfPages(); i++) {
// PdfImportedPage importedPage = pdfCopy.getImportedPage(pdfReader, i);
// pdfCopy.addPage(importedPage);
// }
// os.close();
// }
// }
// Long endTime = System.currentTimeMillis();
// System.out.print("Itext parse Html to Confirm Pdf End -> " + (endTime - startTime));
// return new FileRet("", pdfPath, preview +"confirm/"+ name);
// } catch (IOException | DocumentException e) {
// e.printStackTrace();
// } finally {
// document.close();
// }
// return new FileRet();
// }
/**
* 确认单据页面调用接口
* freemarker渲染html 销毁
*/
public static FileRet createPdfConfirm(String[] htmlFiles,String path,String preview){
Long startTime = System.currentTimeMillis();
Document document = new Document();
String name=UUID.randomUUID().toString()+".pdf";
String pdfPath=path+"confirm/"+name;
PdfCopy pdfCopy = null; //创建一个新文件
public static String[] freeMarkerRenderDestruction(Destruction destruction,String htmlPath) {
Writer out = new StringWriter();
String [] strings=new String[100000];
int index=0;
try {
pdfCopy = new PdfCopy(document, new FileOutputStream(pdfPath));
document.open();
for (String htmlFile : htmlFiles) {
if (htmlFile != null) {
String url = new File(htmlFile).toURI().toURL().toString();
ByteArrayOutputStream os = new ByteArrayOutputStream();
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(htmlFile);
// 解决中文不显示问题
ITextFontResolver fontResolver = renderer.getFontResolver();
fontResolver.addFont(path+"fond/"+"simhei.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
renderer.layout();
renderer.createPDF(os);
PdfReader pdfReader = new PdfReader(os.toByteArray());
for (int i = 1; i <= pdfReader.getNumberOfPages(); i++) {
PdfImportedPage importedPage = pdfCopy.getImportedPage(pdfReader, i);
pdfCopy.addPage(importedPage);
}
os.close();
// 获取模板,并设置编码方式
Template template = freemarkerCfg.getTemplate("bill1.html");
template.setEncoding("UTF-8");
List<DocumentDevice> list=destruction.getConfirmDevices();
List<List<DocumentDevice>> listList=toList(list);
Integer count=listList.size();
for (int i=1; i<=3; i++){
Integer page=1;
for (List<DocumentDevice> list1:listList) {
String htmlname=htmlPath+ UUID.randomUUID().toString()+".html";
// 合并数据模型与模板
FileWriter fileWriter = new FileWriter(new File(htmlname));
template.process(toDestructionMap(destruction,list1,MAP1.get(i),page,count),fileWriter);
out.flush();
strings[index]=htmlname;
index++;
page++;
}
}
Long endTime = System.currentTimeMillis();
System.out.print("Itext parse Html to Confirm Pdf End -> " + (endTime - startTime));
return new FileRet("", pdfPath, preview +"confirm/"+ name);
} catch (IOException | DocumentException e) {
return strings;
} catch (Exception e) {
e.printStackTrace();
} finally {
document.close();
try {
out.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
return new FileRet();
return null;
}
/**
* freemarker渲染html 销毁
* freemarker渲染html workHandoverDoc
*/
public static String[] freeMarkerRenderDestruction(Destruction destruction,String htmlPath) {
public static String[] freeMarkerRenderWorkHandover(WorkHandoverDoc workHandoverDoc,String htmlPath) {
Writer out = new StringWriter();
String [] strings=new String[100000];
int index=0;
try {
// 获取模板,并设置编码方式
Template template = freemarkerCfg.getTemplate("bill1.html");
Template template = freemarkerCfg.getTemplate("bill3.html");
template.setEncoding("UTF-8");
List<DocumentDevice> list=destruction.getConfirmDevices();
List<List<DocumentDevice>> listList=toList(list);
List<WorkHandoverDevice> list = workHandoverDoc.getWorkHandoverDeviceList();
List<List<WorkHandoverDevice>> listList=toListWorkHandoverDevice(list);
Integer count=listList.size();
for (int i=1; i<=3; i++){
Integer page=1;
for (List<DocumentDevice> list1:listList) {
for (List<WorkHandoverDevice> list1:listList) {
String htmlname=htmlPath+ UUID.randomUUID().toString()+".html";
// 合并数据模型与模板
FileWriter fileWriter = new FileWriter(new File(htmlname));
template.process(toDestructionMap(destruction,list1,MAP.get(i),page,count),fileWriter);
template.process(toMapWork(workHandoverDoc,list1,MAP1.get(i),page,count),fileWriter);
out.flush();
strings[index]=htmlname;
index++;
......@@ -487,12 +526,33 @@ public class JavaToPdfHtmlFreeMarker {
return null;
}
public static FileRet createPdfDestruction(String[] htmlFiles,String path,String preview){
private static Map<String,Object> toMapWork(WorkHandoverDoc workHandoverDoc,List<WorkHandoverDevice> list,String test,Integer page,Integer count){
Map<String,Object> data = new HashMap();
Instant instant = workHandoverDoc.getTime().toInstant();
String local1 = LocalDateTime.ofInstant(instant, ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
data.put("time",local1);
data.put("page",page);
data.put("count",count);
AtomicInteger i= new AtomicInteger(1);
list.forEach(
workHandoverDevice -> {
workHandoverDevice.setCode(i.get());
i.set(i.get()+1);
}
);
data.put("documentDevices",list);
return data;
}
public static FileRet createPdfDestruction(String[] htmlFiles,String path,String preview,String folderName){
Long startTime = System.currentTimeMillis();
Document document = new Document();
String name=UUID.randomUUID().toString()+".pdf";
String pdfPath=path+"destruction/"+name;
String pdfPath=path+folderName+name;
PdfCopy pdfCopy = null; //创建一个新文件
try {
pdfCopy = new PdfCopy(document, new FileOutputStream(pdfPath));
......@@ -519,8 +579,8 @@ public class JavaToPdfHtmlFreeMarker {
}
Long endTime = System.currentTimeMillis();
System.out.print("Itext parse Html to Destruction Pdf End -> " + (endTime - startTime));
return new FileRet("", pdfPath, preview +"destruction/"+ name);
} catch (IOException | DocumentException e) {
return new FileRet("", pdfPath, preview +folderName+ name);
} catch (IOException | DocumentException | com.lowagie.text.DocumentException e) {
e.printStackTrace();
} finally {
document.close();
......@@ -528,6 +588,50 @@ public class JavaToPdfHtmlFreeMarker {
return new FileRet();
}
// public static FileRet createPdfWordHandover(String[] htmlFiles,String path,String preview){
//
// Long startTime = System.currentTimeMillis();
// Document document = new Document();
// String name=UUID.randomUUID().toString()+".pdf";
// String pdfPath=path+"wordHandover/"+name;
// PdfCopy pdfCopy = null; //创建一个新文件
// try {
// pdfCopy = new PdfCopy(document, new FileOutputStream(pdfPath));
// document.open();
// for (String htmlFile : htmlFiles) {
// if (htmlFile != null) {
//
// String url = new File(htmlFile).toURI().toURL().toString();
// ByteArrayOutputStream os = new ByteArrayOutputStream();
// ITextRenderer renderer = new ITextRenderer();
// renderer.setDocument(htmlFile);
// // 解决中文不显示问题
// ITextFontResolver fontResolver = renderer.getFontResolver();
// fontResolver.addFont(path+"fond/"+"simhei.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
// renderer.layout();
// renderer.createPDF(os);
// PdfReader pdfReader = new PdfReader(os.toByteArray());
// for (int i = 1; i <= pdfReader.getNumberOfPages(); i++) {
// PdfImportedPage importedPage = pdfCopy.getImportedPage(pdfReader, i);
// pdfCopy.addPage(importedPage);
// }
// os.close();
// }
// }
// Long endTime = System.currentTimeMillis();
// System.out.print("Itext parse Html to Destruction Pdf End -> " + (endTime - startTime));
// return new FileRet("", pdfPath, preview +"wordHandover/"+ name);
// } catch (IOException | DocumentException e) {
// e.printStackTrace();
// } finally {
// document.close();
// }
// return new FileRet();
// }
/**
* 计算每一页打印的内容
* 判断是否超过一页展示的最多的内容
......@@ -575,4 +679,75 @@ public class JavaToPdfHtmlFreeMarker {
}
/**
* 计算每一页打印的内容
* 判断是否超过一页展示的最多的内容
* 如大于
* 直接生成一个页面的数据 放入到集合中 List<List<DocumentDevice>>
* 不大于则计算相关的值,下一个内容
* @param workHandoverDevices 装备数据信息
* @return
*/
private static List<List<WorkHandoverDevice>> toListWorkHandoverDevice(List<WorkHandoverDevice> workHandoverDevices) {
workHandoverDevices=workHandoverDevices.stream().sorted(Comparator.comparing(WorkHandoverDevice::getLen).reversed()).collect(Collectors.toList());
List<List<WorkHandoverDevice>> lists=new ArrayList<>();
List<WorkHandoverDevice> list=new ArrayList<>();
AtomicInteger count = new AtomicInteger();
for (int i=0;i<workHandoverDevices.size();i++){
WorkHandoverDevice workHandoverDevice=workHandoverDevices.get(i);
int len=workHandoverDevice.getSeqs().length();
if (len>=3500){
workHandoverDevice.setSeqs(toString(workHandoverDevice.getSeqs()));
list.add(workHandoverDevice);
lists.add(list);
list=new ArrayList<>();
}else {
int totle=count.get()+54+len;
if (totle>3510){
WorkHandoverDevice workHandoverDevice1=new WorkHandoverDevice();
workHandoverDevice1.setSeqs(toString(workHandoverDevice1.getSeqs().substring(3510-count.get(),len)));
workHandoverDevice.setSeqs(toString(workHandoverDevice1.getSeqs().substring(0,3510-count.get())));
list.add(workHandoverDevice);
lists.add(list);
list=new ArrayList<>();
list.add(workHandoverDevice1);
count.set(totle-3510);
}else {
workHandoverDevice.setSeqs(toString(workHandoverDevice.getSeqs()));
list.add(workHandoverDevice);
int yu=len%54;
int s=54-yu;
count.set(totle+s);
}
}
if (i==workHandoverDevices.size()-1){
workHandoverDevice.setSeqs(toString(workHandoverDevice.getSeqs()));
lists.add(list);
}
}
return lists;
}
private static String toString(String str){
int len=54;
StringBuilder stringBuilder=new StringBuilder();
if (str.length()>54){
boolean falg=true;
int i=0;
while (falg){
if ((i+1)*len>str.length()) {
stringBuilder.append(str.substring(i * len)).toString();
falg=false;
}else {
stringBuilder.append(str, i*len, (i+1)*len).append("<br/>");
i++;
}
}
return stringBuilder.toString();
}else {
return str;
}
}
}
......@@ -47,9 +47,9 @@ public class RepelQueryServiceImpl implements RepelQueryService {
RepelDeviceUnitService deviceUnitService;
@Override
public RepelStatisticsVo findRepelTaskStatisticals(Integer taskId, Integer billId) {
DeviceRepelDetail deviceRepelDetail= repelDetailService.findDeviceRepelDetailNoDev(billId);
DeviceRepel deviceRepel=deviceRepelService.findDeviceRepel(deviceRepelDetail.getRepelId());
return new RepelStatisticsVo(deviceRepel.getInitiateName(),deviceRepel.getTime(),repelTaskStatisticalService.findAllRepelTaskStatistical(taskId,deviceRepelDetail.getRepelId()));
// DeviceRepelDetail deviceRepelDetail= repelDetailService.findDeviceRepelDetailNoDev(billId);
DeviceRepel deviceRepel=deviceRepelService.findDeviceRepel(billId);
return new RepelStatisticsVo(deviceRepel.getInitiateName(),deviceRepel.getTime(),repelTaskStatisticalService.findAllRepelTaskStatistical(taskId,billId));
}
@Override
......
......@@ -14,6 +14,8 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.stream.Collectors;
/**
* @author zjm
* @version 1.0.0
......@@ -80,4 +82,15 @@ public class HandoverController {
return ResponseEntity.ok(workHandoverService.handover(workHandoverAddVo.getTurnOverUserAId()));
}
/**
* 工作交接-查询交接人下拉
*/
@GetMapping(value = "/userList")
@ApiOperation(value = "工作交接-查询交接人下拉")
public ResponseEntity userList(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser) {
return ResponseEntity.ok(userService.findByUniteId1(securityUser.getCurrentUserInfo().getUnitsId()).stream().filter(userShenRe -> userShenRe.getTrainStatus()!=5).collect(Collectors.toList()));
}
}
package com.tykj.dev.device.train.dao;
import com.tykj.dev.device.train.entity.WorkHandoverDev;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
public interface WorkHandoverDevDao extends JpaRepository<WorkHandoverDev, Integer>, JpaSpecificationExecutor<WorkHandoverDev> {
List<WorkHandoverDev> findAllByWordId(Integer wordId);
}
......@@ -11,8 +11,10 @@ import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
/**
......@@ -26,12 +28,13 @@ import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Entity
@EntityListeners(AuditingEntityListener.class)
public class WorkHandover {
/**
* 工作交接id
*/
@Id
@GeneratedValue
@GeneratedValue()
@ApiModelProperty(value = "工作交接id")
@Column(columnDefinition = "integer NOT NULL AUTO_INCREMENT")
private Integer workHandoverId;
......@@ -84,17 +87,19 @@ public class WorkHandover {
* 创建时间
*/
@CreatedDate
private Integer createTime;
private Date createTime;
/**
* 更新时间
*/
@LastModifiedDate
private Integer updateTime;
private Date updateTime;
@ApiModelProperty(value = "区块链RID",name = "recordId")
private String recordId;
/**
* 发起用户集合
*/
......@@ -112,4 +117,10 @@ public class WorkHandover {
*/
@Transient
private List<FileRet> fileRets;
/**
* 本次交接装备信息清单
*/
@Transient
private List<WorkHandoverDev> workHandoverDevs;
}
package com.tykj.dev.device.train.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName WorkHandoverDevice.java
* @Description TODO
* @createTime 2021年03月09日 15:52:00
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class WorkHandoverDev {
@Id
@GeneratedValue
@ApiModelProperty(value = "数据id")
private Integer id;
@ApiModelProperty(value = "业务数据id")
private Integer wordId;
@ApiModelProperty(value = "型号", example = "bmxx")
private String model;
@ApiModelProperty(value = "名称", example = "BM-1")
private String name;
@ApiModelProperty(value = "所属单位", example = "省机要局")
private String ownUnit;
@ApiModelProperty(value = "装备类型总数", example = "100")
private Integer deviceNumber;
@ApiModelProperty(value = "在库数量", example = "10")
private Integer inLibraryNum;
@ApiModelProperty(value = "维修数量", example = "10")
private Integer repairNum;
@ApiModelProperty(value = "销毁数量", example = "10")
private Integer destoryNum;
@ApiModelProperty(value = "退役数量", example = "10")
private Integer retiredNum;
@ApiModelProperty(value = "报废数量", example = "10")
private Integer scrappedNum;
@ApiModelProperty(value = "运输中数量", example = "10")
private Integer allotNum;
@ApiModelProperty(value = "使用数量", example = "10")
private Integer useNum;
// @ApiModelProperty(value = "该型号所有装备Id列表")
// @Transient
// private List<Integer> deviceIds = new ArrayList<>();
//
// @Transient
// @ApiModelProperty(value = "该型号在库装备Id列表")
// private List<Integer> inLibraryIds = new ArrayList<>();
//
// @Transient
// @ApiModelProperty(value = "该型号维修装备Id列表")
// private List<Integer> repairIds = new ArrayList<>();
//
// @Transient
// @ApiModelProperty(value = "该型号销毁装备Id列表")
// private List<Integer> destoryIds = new ArrayList<>();
//
// @Transient
// @ApiModelProperty(value = "该型号退役装备Id列表")
// private List<Integer> retiredIds = new ArrayList<>();
//
// @Transient
// @ApiModelProperty(value = "该型号报废装备Id列表")
// private List<Integer> scrappedIds = new ArrayList<>();
//
// @Transient
// @ApiModelProperty(value = "该型号运输中装备Id列表")
// private List<Integer> allotIds = new ArrayList<>();
//
// @Transient
// @ApiModelProperty(value = "该型号使用中装备Id列表")
// private List<Integer> useIds = new ArrayList<>();
@ApiModelProperty(value = "序列号区间")
@Column(name = "seq_s" ,columnDefinition = "TEXT")
public String seqs;
}
package com.tykj.dev.device.train.entity.vo;
import com.tykj.dev.device.library.subject.vo.DeviceStatisticsVo;
import com.tykj.dev.device.train.entity.WorkHandover;
import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.device.train.entity.WorkHandoverDev;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -27,6 +28,9 @@ public class WorkHandoverAddVo {
private List<Integer> turnOverUserAId;
/**
* 单据装备数据统计数据
*/
List<WorkHandoverDev> workHandoverDevices;
}
......@@ -7,7 +7,9 @@ import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import com.tykj.dev.device.train.dao.WorkHandoverDao;
import com.tykj.dev.device.train.dao.WorkHandoverDevDao;
import com.tykj.dev.device.train.entity.WorkHandover;
import com.tykj.dev.device.train.entity.WorkHandoverDev;
import com.tykj.dev.device.train.entity.vo.WorkHandoverAddVo;
import com.tykj.dev.device.train.entity.vo.WorkHandoverEndAddVo;
import com.tykj.dev.device.train.entity.vo.WorkHandoverVo;
......@@ -29,6 +31,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collector;
......@@ -59,12 +62,15 @@ public class WorkHandoverServiceImpl implements WorkHandoverService {
@Autowired
UnitsService unitsService;
@Autowired
WorkHandoverDevDao workHandoverDevDao;
@Override
public WorkHandover createWorkHandover(WorkHandoverAddVo workHandoverAddVo, SecurityUser securityUser) {
log.info("[workHandover] 新建工作交接");
// WorkHandover
List<User> users= userService.findAllByUnite(securityUser.getCurrentUserInfo().getUnitsId());
List<Integer> handoverIds= users.stream().map(User::getUserId).collect(Collectors.toList());
List<Integer> handoverIds= users.stream().filter(user -> user.getTrainStatus()!=5).map(User::getUserId).collect(Collectors.toList());
WorkHandover workHandover=new WorkHandover();
workHandover.setStatus(1);
workHandover.setTurnOverUserIds(StringSplitUtil.ListToString(workHandoverAddVo.getTurnOverUserAId()));
......@@ -72,6 +78,12 @@ public class WorkHandoverServiceImpl implements WorkHandoverService {
workHandover.setInitiateUserId(securityUser.getCurrentUserInfo().getUserId());
//创建workHandoverDB 存储数据库
workHandover = workHandoverDao.save(workHandover);
Integer id=workHandover.getWorkHandoverId();
List<WorkHandoverDev> workHandoverDevs=workHandoverAddVo.getWorkHandoverDevices();
workHandoverDevs.forEach(
workHandoverDev -> workHandoverDev.setWordId(id)
);
workHandoverDevDao.saveAll(workHandoverDevs);
List<Integer> integers = new ArrayList<>();
integers.add(securityUser.getCurrentUserInfo().getUserId());
taskService.start(new TaskBto(StatusEnum.WORKHANDOVER1011.id, "工作交接", null, null, workHandover.getWorkHandoverId(), BusinessEnum.WORK_HANDOVER.id, securityUser.getCurrentUserInfo().getUnitsId(), 0, null, integers));
......@@ -114,6 +126,7 @@ public class WorkHandoverServiceImpl implements WorkHandoverService {
workHandover.setHandoverUserList(userService.findAllUserIdInUser(StringSplitUtil.stringToList(workHandover.getHandoverUserIds())));
workHandover.setTurnOverUserList(userService.findAllUserIdInUser(StringSplitUtil.stringToList(workHandover.getTurnOverUserIds())));
workHandover.setFileRets(FilesUtil.stringFileToList(workHandover.getFile()));
workHandover.setWorkHandoverDevs(workHandoverDevDao.findAllByWordId(workHandover.getWorkHandoverId()));
return workHandover;
} else {
throw new ApiException(ResponseEntity.status(500).body("没有这个id:" + workHandoverId));
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Document</title>
<style>
body{
font-family:SimHei;
margin: 0;
padding: 0;
}
/*@page{size:297mm 210mm;}<!-- 设置PDF页面大小,此配置只对生成PDF文件有效,不会对页面显示生效 -->*/
@page {
size:297mm 210mm;
}
.bottomTxt {
text-align: center;
font-size: 10px;
color: #646464;
height: 10px;
line-height: 10px;
}
.returnTablePrint{
width: 100%;
height: 100%;
overflow: hidden;
color: #000;
cursor: default;
}
.returnTablePrint .content{
width: 100%;
height: 100%;
}
.returnTablePrint .content>div{
width: 100%;
height: 100%;
background: #fff;
/* padding: 30px; */
box-sizing: border-box;
}
/* .returnTablePrint .content>p{
width: 100%;
text-align: center;
font-size: 22px;
font-weight: bold;
color: #4a475d;
} */
.returnTablePrint .listWrapper{
/*margin: 0 auto;*/
/* height: calc(100% - 40px); */
box-sizing: border-box;
}
.returnTablePrint .list{
/*margin: 0 auto;*/
height:calc(100% - 12px)
}
.returnTablePrint .title{
width: 100%;
font-size: 22px;
text-align: center;
position: relative;
/* margin: 0 0 15px; */
padding:0 20px;
box-sizing: border-box;
}
/* .returnTablePrint .title span:nth-child(2){
font-size: 28px;
color: #000000;
}
.returnTablePrint .title span:nth-child(2) span{
font-size: 20px;
color: #141414;
} */
.returnTablePrint .title .number{
font-size: 12px;
color: #646464;
}
/* .returnTablePrint .other{
width: 100%;
color: #141414;
font-size: 20px;
margin-top: 20px;
padding-left: 50px;
position: relative;
box-sizing: border-box;
margin-bottom: 20px;
}
.returnTablePrint .other>span span:nth-child(2){
display: inline-block;
margin:0 40px 0 10px;
} */
.returnTablePrint .listCon{
height: 100%;
border: 1px solid #7f7f7f;
}
.returnTablePrint .line1{
width: 100%;
font-size: 12px;
box-sizing: border-box;
border-bottom: 1px solid #7f7f7f;
color:#000;
line-height: 20px;
}
.returnTablePrint .line1 .sendTo {
display: inline-block;
width: 49%;
text-indent: 5px;
box-sizing: border-box;
/*padding-left: 20px;*/
}
.returnTablePrint .line1 .sendNum {
display: inline-block;
width: 49%;
box-sizing: border-box;
/*padding-left: 20px;*/
}
.returnTablePrint .line1 .sendTo{
border-right: 1px solid #7f7f7f;
}
.returnTablePrint .line1 .sendTo span:nth-child(2),.returnTablePrint .line1 .sendNum span:nth-child(2){
color: #4a475d;
display: inline-block;
margin-left: 5px;
}
.returnTablePrint .line2{
height: 100%;
/* padding: 20px; */
border-bottom: 1px solid #7f7f7f;
}
.returnTablePrint .tableList{
height: 546px;
}
.returnTablePrint .line2>>>.el-table tbody tr:nth-child(odd) {
background-color:#fff;
}
.returnTablePrint .line2>>>.el-table tbody tr:nth-child(even) {
background-color:#fff;
}
.returnTablePrint .line3{
width: 100%;
height:70px;
/* box-sizing: border-box; */
/*height:150px;*/
/*display: flex;*/
/* height:170px; */
/* padding:20px 0 20px 0; */
}
.returnTablePrint .line3 .left {
display: inline-block;
width: 25%;
box-sizing: border-box;
/*padding-left: 20px;*/
position: relative;
line-height: 70px;
}
.returnTablePrint .line3 .left{
border-right: 1px solid #7f7f7f;
/*padding-bottom: 40px;*/
}
.returnTablePrint .line3 .left:last-child{
border-right: none;
/*padding-bottom: 40px;*/
}
.returnTablePrint .line3 .left>span{
display: block;
/* margin: 15px 0px; */
}
.returnTablePrint .line3 .left>span>span:nth-child(2){
display: inline-block;
margin-left: 10px;
}
.returnTablePrint>>>.el-scrollbar__wrap {
overflow-x: hidden;
margin-bottom:0;
}
.returnTablePrint .checkName span:nth-child(2){
color: #4a475d;
display: inline-block;
margin-left: 20px;
}
.returnTablePrint>>>.el-table tbody .cell{
color: #141414;
}
.returnTablePrint .label{
color: #646464;
font-size: 12px;
}
.returnTablePrint .value{
color: #000;
font-size: 12px;
}
.returnTablePrint .main-title {
font-size: 20px;
color: #000000;
line-height: 20px;
text-align: center;
}
.returnTablePrint .footer{
display: flex;
justify-content:flex-end;
padding:0 40px;
box-sizing: border-box;
}
.button-submit{
margin-left:50px;
}
table.altrowstable {
width: 100%;
font-size: 11px;
color:#141414;
border-width: 0px;
border-color: #a9c6c9;
border-collapse: collapse;
text-align: center;
table-layout: fixed;
word-break: break-all;
}
table.altrowstable th {
border-width: 0px;
padding: 5px;
border-style: solid;
border-color: #a9c6c9;
background-color: #dedede;
word-break:break-all;
}
table.altrowstable td {
border-width: 0px;
padding: 5px;
/*border-style: solid;*/
/*border-color: #a9c6c9;*/
word-break: break-all;
word-wrap: break-word;
border-bottom: 1px solid #bebebe;
}
.oddrowcolor{
background-color:#fff;
}
.evenrowcolor{
background-color:#fafafa;
}
/*tr:nth-child(odd) {*/
/* background: #fafafa;*/
/*}*/
</style>
</head>
<body>
<div class="returnTablePrint">
<div class="content">
<div>
<div class="listWrapper">
<div class="list">
<div class="title">
<div class="main-title">
<span>
工作交接单2
</span>
</div>
<div style="width:100%;text-align:left">
<div style="text-align:left;display: inline-block; width: 32%" class="number">
<span class="number">时间:${time}</span>
</div>
<div style="text-align:center;display: inline-block; width: 32%" class="number">
<span></span>
</div>
<div style="text-align:right;display: inline-block; width: 28%" class="number">
<span>机密</span>
</div>
</div>
</div>
<div class="listCon">
<div class="line2 tableList">
<table class="altrowstable" id="alternatecolor">
<tr>
<th>序号</th><th>型号</th><th>名称</th><th>在库</th><th>维修</th><th>报废</th><th>清退</th><th>其他</th><th style="width: 420px;">装备序列号</th>
</tr>
<#list documentDevices as dev>
<tr>
<td>
<#if dev.code != 0>
${dev.code}
</#if>
</td>
<td>${dev.model}</td><td>${dev.name}</td><td>${dev.inLibraryNum}</td><td>${dev.repairNum}</td><td>${dev.scrappedNum}</td><td>${dev.retiredNum}</td><td>${dev.otherNum}</td><td>${dev.seqs}</td>
</tr>
</#list>
</table>
</div>
<div class="line3" style="position: relative;">
<span class="left">
<span>
<span style="position: absolute; top: -20px; left: 8px;" class="label">交接人:</span>
<span class="value"></span>
</span>
</span>
<span class="left">
<span>
<span style="position: absolute; top: -20px; left: 8px;" class="label" >移交人:</span>
<span class="value"></span>
</span>
</span>
<span class="left" style="width: 23%;">
<span>
<span style="position: absolute; top: -20px; left: 8px;" class="label">监交人:</span>
<span class="value"></span>
</span>
</span>
<span class="left" style="width: 23%;">
<span>
<span style="position: absolute; top: -20px; left: 8px;" class="label" >上级领导:</span>
<span class="value"></span>
</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="bottomTxt">第${page}页/共${count}页</p>
</div>
<!--<script type="text/javascript">-->
<!--function altRows(id){-->
<!--if(document.getElementsByTagName){-->
<!--var table = document.getElementById(id);-->
<!--var rows = table.getElementsByTagName("tr");-->
<!--for(i = 0; i < rows.length; i++){-->
<!--if(i % 2 == 0){-->
<!--rows[i].className = "evenrowcolor";-->
<!--}else{-->
<!--rows[i].className = "oddrowcolor";-->
<!--}-->
<!--}-->
<!--}-->
<!--}-->
<!--window.onload=function(){-->
<!--altRows('alternatecolor');-->
<!--}-->
<!--</script>-->
</body>
</html>
\ No newline at end of file
......@@ -130,7 +130,7 @@ public class User {
private Integer position;
/**
* 培训状态 0.已培训 1.已过期 2.未培训 3.快过期
* 培训状态 0.已培训 1.已过期 2.未培训 3.快过期 5.不是专管员
*/
private Integer trainStatus=2;
/**
......
......@@ -42,6 +42,12 @@ public interface UserService extends PublicService<User> {
List<UserShenRe> findByUniteId(Integer unitsId);
/**
* 根据单位ID查询人员列表(包括自己)
*/
List<UserShenRe> findByUniteId1(Integer unitsId);
/**
* 根据单位id查询用户
*/
......
......@@ -168,6 +168,11 @@ public class UserServiceImpl implements UserService {
return userDao.findAllByUnitsId(unitsId).stream().map(User::toRe).sorted(Comparator.comparing(UserShenRe::getShowOrder)).collect(Collectors.toList());
}
@Override
public List<UserShenRe> findByUniteId1(Integer unitsId) {
return userDao.findAllByUnitsId(unitsId).stream().map(User::toRe).sorted(Comparator.comparing(UserShenRe::getShowOrder)).collect(Collectors.toList());
}
@Override
public List<User> findAllByUnite(Integer unitsId) {
return userDao.findAllByUnitsId(unitsId);
......@@ -189,6 +194,7 @@ public class UserServiceImpl implements UserService {
List<MemberThat> memberThats = new ArrayList<>();
userDao.findAllByUnitsId(userConditionsVo.getUnitsId())
.stream()
.filter(user -> user.getTrainStatus()!=5)
.filter(user ->{
boolean isNull=userConditionsVo.getDim()!=null;
if (isNull) {
......@@ -448,8 +454,8 @@ public class UserServiceImpl implements UserService {
user.setName(notIsUser.getName());
user.setUnitsId(notIsUser.getUnitId());
user.setShowOrder(3);
user.setTrainStatus(2);
return user;
user.setTrainStatus(5);
return userDao.save(user);
}
@Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论