提交 0f43dcbc authored 作者: 133's avatar 133

[清退、文件] 代码提交 0225

上级 917dd642
package com.tykj.dev.device.file.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -17,9 +18,10 @@ import java.util.List;
@NoArgsConstructor
@Data
public class Confirm {
@ApiModelProperty(name = "抬头")
private String title;
private List<ConfirmDevice> confirmDevices;
@ApiModelProperty(name = "装备信息")
private List<DocumentDevice> confirmDevices;
}
package com.tykj.dev.device.file.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author zjm
* @version 1.0.0
* @ClassName ConfirmDevice.java
* @Description TODO
* @createTime 2021年02月03日 16:06:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class ConfirmDevice {
@ApiModelProperty(name = "型号")
private String model;
@ApiModelProperty(name = "部件")
private String parts;
@ApiModelProperty(name = "类型")
private String category;
@ApiModelProperty(name = "密级")
private String securityClassification;
@ApiModelProperty(name = "应用领域")
private String applicationField;
@ApiModelProperty(name = "装备序列号")
private String deviceSerialNumber;
@ApiModelProperty(name = "备注")
private String remark;
public ConfirmDevice toConfirmDevice(){
switch (category){
case "1":
category="密码机";
break;
case "2":
category="密码模块";
break;
case "3":
category="密码芯片";
break;
case "4":
category="说明书";
break;
case "5":
category="U盘";
break;
case "6":
category="光盘";
break;
case "7":
category="密码软件";
break;
case "8":
category="密码卡";
default:
category="-";
break;
}
switch (securityClassification){
case "1":
securityClassification="绝密";
break;
case "2":
securityClassification="机密";
break;
case "3":
securityClassification="秘密";
break;
default:
securityClassification="无";
break;
}
switch (applicationField){
case "1":
applicationField="省一级";
break;
case "2":
applicationField="市一级";
break;
case "3":
applicationField="县一级";
break;
default:
applicationField="无";
break;
}
return this;
}
}
package com.tykj.dev.device.file.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -17,11 +18,18 @@ import java.util.List;
@NoArgsConstructor
@Data
public class Destruction {
@ApiModelProperty(name = "抬头")
private String title;
@ApiModelProperty(name = "销毁单位")
private String disposeUnitName;
private List<DestructionDevice> confirmDevices;
@ApiModelProperty(name = "报废时间")
private String time;
@ApiModelProperty(name = "单据号")
private String number;
private List<DocumentDevice> confirmDevices;
}
package com.tykj.dev.device.file.entity;
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 DestructionDevice.java
* @Description 销毁单据 装备对象
* @createTime 2021年02月03日 17:31:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel(value = "单据涉及装备实体", description = "单据涉及装备实体")
public class DestructionDevice {
@ApiModelProperty(name = "型号")
private String model;
@ApiModelProperty(name = "部件")
private String parts;
@ApiModelProperty(name = "类型")
private String category;
@ApiModelProperty(name = "密级")
private String securityClassification;
@ApiModelProperty(name = "应用领域")
private String applicationField;
@ApiModelProperty(name = "数量")
private Integer count;
@ApiModelProperty(name = "装备序列号")
private String deviceSerialNumber;
@ApiModelProperty(name = "生产序列号")
private String productionSerialNumber;
@ApiModelProperty(name = "备注")
private String remark;
public DestructionDevice toDestructionDevice(){
switch (category){
case "1":
category="密码机";
break;
case "2":
category="密码模块";
break;
case "3":
category="密码芯片";
break;
case "4":
category="说明书";
break;
case "5":
category="U盘";
break;
case "6":
category="光盘";
break;
case "7":
category="密码软件";
break;
case "8":
category="密码卡";
default:
category="-";
break;
}
switch (securityClassification){
case "1":
securityClassification="绝密";
break;
case "2":
securityClassification="机密";
break;
case "3":
securityClassification="秘密";
break;
default:
securityClassification="无";
break;
}
switch (applicationField){
case "1":
applicationField="省一级";
break;
case "2":
applicationField="市一级";
break;
case "3":
applicationField="县一级";
break;
default:
applicationField="无";
break;
}
return this;
}
}
......@@ -48,6 +48,10 @@ public class DocumentDevice {
@ApiModelProperty(name = "备注")
private String remark;
public Integer getLen(){
return deviceSerialNumber.length();
}
public DocumentDevice toDocumentDevice(){
switch (category){
case "1":
......
......@@ -153,42 +153,22 @@ public class JavaToPdfHtmlFreeMarker {
// 获取模板,并设置编码方式
Template template = freemarkerCfg.getTemplate("bill.html");
template.setEncoding("UTF-8");
List<DocumentDevice> list=documents.getDocumentDevices();
for (int i=1; i<=3; i++){
boolean falg=true;
Integer page=0;
int pageNum = page + 1;
int pageSize = 7;
Integer totalNum = list.size();
//默认从零分页,这里要考虑这种情况,下面要计算。
Integer totalPage = 0;
while (falg){
if (totalNum > 0) {
totalPage = totalNum % pageSize == 0 ? totalNum / pageSize : totalNum / pageSize + 1;
}
if (pageNum >= totalPage) {
pageNum = totalPage;
falg=false;
}
int startPoint = (pageNum - 1) * pageSize;
int endPoint = startPoint + pageSize;
if (totalNum <= endPoint) {
endPoint = totalNum;
}
List<DocumentDevice> list=documents.getDocumentDevices();
List<List<DocumentDevice>> listList=toList(list);
for (int i=1; i<=3; i++){
for (List<DocumentDevice> list1:listList) {
String htmlname=htmlPath+ UUID.randomUUID().toString()+".html";
// 合并数据模型与模板
FileWriter fileWriter = new FileWriter(new File(htmlname));
template.process(toMap(documents,list.subList(startPoint, endPoint),MAP.get(i)),fileWriter);
template.process(toMap(documents,list1,MAP.get(i)),fileWriter);
out.flush();
strings[index]=htmlname;
index++;
pageNum++;
}
}
return strings;
return strings;
} catch (Exception e) {
e.printStackTrace();
} finally {
......@@ -221,20 +201,36 @@ public class JavaToPdfHtmlFreeMarker {
}
private static Map<String,Object> toConfirmMap(Confirm confirm, List<ConfirmDevice> list){
private static Map<String,Object> toConfirmMap(Confirm confirm, List<DocumentDevice> list){
Map<String,Object> data = new HashMap();
data.put("title",confirm.getTitle());
data.put("documentDevices",list.stream().map(ConfirmDevice::toConfirmDevice).collect(Collectors.toList()));
AtomicInteger i= new AtomicInteger(1);
list.forEach(
documentDevice -> {
documentDevice.setCode(i.get());
i.set(i.get() + 1);
}
);
data.put("documentDevices",list.stream().map(DocumentDevice::toDocumentDevice).collect(Collectors.toList()));
return data;
}
private static Map<String,Object> toDestructionMap(Destruction destruction, List<DestructionDevice> list,String test){
private static Map<String,Object> toDestructionMap(Destruction destruction, List<DocumentDevice> list,String test){
Map<String,Object> data = new HashMap();
data.put("title",destruction.getTitle());
data.put("ul",test);
data.put("unitName",destruction.getDisposeUnitName());
data.put("documentDevices",list.stream().map(DestructionDevice::toDestructionDevice).collect(Collectors.toList()));
data.put("number",destruction.getNumber());
data.put("time",destruction.getTime());
AtomicInteger i= new AtomicInteger(1);
list.forEach(
documentDevice -> {
documentDevice.setCode(i.get());
i.set(i.get() + 1);
}
);
data.put("documentDevices",list.stream().map(DocumentDevice::toDocumentDevice).collect(Collectors.toList()));
return data;
}
......@@ -252,7 +248,7 @@ public class JavaToPdfHtmlFreeMarker {
// 获取模板,并设置编码方式
Template template = freemarkerCfg.getTemplate("bill2.html");
template.setEncoding("UTF-8");
List<ConfirmDevice> list=confirm.getConfirmDevices();
List<DocumentDevice> list=confirm.getConfirmDevices();
boolean falg=true;
Integer page=0;
int pageNum = page + 1;
......@@ -355,39 +351,17 @@ public class JavaToPdfHtmlFreeMarker {
// 获取模板,并设置编码方式
Template template = freemarkerCfg.getTemplate("bill1.html");
template.setEncoding("UTF-8");
List<DestructionDevice> list=destruction.getConfirmDevices();
List<DocumentDevice> list=destruction.getConfirmDevices();
List<List<DocumentDevice>> listList=toList(list);
for (int i=1; i<=3; i++){
boolean falg=true;
Integer page=0;
int pageNum = page + 1;
int pageSize = 7;
Integer totalNum = list.size();
//默认从零分页,这里要考虑这种情况,下面要计算。
Integer totalPage = 0;
while (falg){
if (totalNum > 0) {
totalPage = totalNum % pageSize == 0 ? totalNum / pageSize : totalNum / pageSize + 1;
}
if (pageNum >= totalPage) {
pageNum = totalPage;
falg=false;
}
int startPoint = (pageNum - 1) * pageSize;
int endPoint = startPoint + pageSize;
if (totalNum <= endPoint) {
endPoint = totalNum;
}
for (List<DocumentDevice> list1:listList) {
String htmlname=htmlPath+ UUID.randomUUID().toString()+".html";
// 合并数据模型与模板
FileWriter fileWriter = new FileWriter(new File(htmlname));
template.process(toDestructionMap(destruction,list.subList(startPoint, endPoint),MAP1.get(i)),fileWriter);
template.process(toDestructionMap(destruction,list1,MAP.get(i)),fileWriter);
out.flush();
strings[index]=htmlname;
index++;
pageNum++;
}
}
return strings;
......@@ -444,6 +418,52 @@ public class JavaToPdfHtmlFreeMarker {
return new FileRet();
}
/**
* 计算每一页打印的内容
* 判断是否超过一页展示的最多的内容
* 如大于
* 直接生成一个页面的数据 放入到集合中 List<List<DocumentDevice>>
* 不大于则计算相关的值,下一个内容
* @param documentDevices
* @return
*/
private static List<List<DocumentDevice>> toList(List<DocumentDevice> documentDevices) {
documentDevices=documentDevices.stream().sorted(Comparator.comparing(DocumentDevice::getLen).reversed()).collect(Collectors.toList());
List<List<DocumentDevice>> lists=new ArrayList<>();
List<DocumentDevice> list=new ArrayList<>();
AtomicInteger count = new AtomicInteger();
for (int i=0;i<documentDevices.size();i++){
DocumentDevice documentDevice=documentDevices.get(i);
int len=documentDevice.getDeviceSerialNumber().length();
if (len>=3500){
list.add(documentDevice);
lists.add(list);
list=new ArrayList<>();
}else {
int totle=count.get()+54+len;
if (totle>3510){
DocumentDevice documentDevice1=new DocumentDevice();
documentDevice1.setDeviceSerialNumber(documentDevice.getDeviceSerialNumber().substring(3510-count.get(),len));
documentDevice.setDeviceSerialNumber(documentDevice.getDeviceSerialNumber().substring(0,3510-count.get()));
list.add(documentDevice);
lists.add(list);
list=new ArrayList<>();
list.add(documentDevice1);
count.set(totle-3510);
}else {
list.add(documentDevice);
int yu=len%54;
int s=54-yu;
count.set(totle+s);
}
}
if (i==documentDevices.size()-1){
lists.add(list);
}
}
System.out.println("hah");
return lists;
}
}
......@@ -10,13 +10,16 @@ import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.vo.TaskSelectVo;
import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import com.tykj.dev.device.task.utils.TaskUtils;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.misc.utils.PageUtil;
import com.tykj.dev.misc.utils.ResultUtil;
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.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.stream.Collectors;
......@@ -153,8 +156,8 @@ public class RepelQueryController {
*/
@ApiOperation(value = "查询清退单列表")
@GetMapping("/getList")
public ResponseEntity getList() {
return ResponseEntity.ok(repelQueryService.getList());
public ResponseEntity getList(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser) {
return ResponseEntity.ok(repelQueryService.getList(securityUser));
}
......
......@@ -3,10 +3,14 @@ package com.tykj.dev.device.sendback.repository;
import com.tykj.dev.device.sendback.entity.domain.DeviceRepelDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.Date;
import java.util.List;
public interface DeviceRepelDetailDao extends JpaRepository<DeviceRepelDetail, Integer>, JpaSpecificationExecutor<DeviceRepelDetail> {
List<DeviceRepelDetail> findAllBySendTimeBetweenAndSendUnitIdAndRepelStatus(Date time,Date endTime, Integer unitId, Integer repelStatus);
@Query(value = "select d from DeviceRepelDetail as d where d.sendUnitId= ?1 or d.receiveUnitId = ?1")
List<DeviceRepelDetail> findAllBySendUnitIdOrReceiveUnitId(Integer unitId);
}
......@@ -33,4 +33,6 @@ public interface DeviceRepelDetailService {
* 根据年份以及单位 查询清退的装备列表
*/
List<DeviceLibrary> findYearAndUnitToDeviceList(Date time,Date endTime,Integer unitId);
List<DeviceRepelDetail> findUnitIdSendOrReceive(Integer unitId);
}
......@@ -4,6 +4,7 @@ import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.sendback.entity.domain.DeviceRepel;
import com.tykj.dev.device.sendback.entity.domain.DeviceRepelDetail;
import com.tykj.dev.device.sendback.entity.vo.*;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import java.util.List;
......@@ -87,7 +88,7 @@ public interface RepelQueryService {
/**
查询清退单
*/
List<DeviceRepelDetail> getList();
List<DeviceRepelDetail> getList(SecurityUser securityUser);
}
......@@ -79,6 +79,11 @@ public class DeviceRepelDetailServiceImpl implements DeviceRepelDetailService {
return new ArrayList<>(libraries);
}
@Override
public List<DeviceRepelDetail> findUnitIdSendOrReceive(Integer unitId) {
return deviceRepelDetailDao.findAllBySendUnitIdOrReceiveUnitId(unitId);
}
private List<DeviceLibrary> findInvoleDevice(String involeDevice){
if (involeDevice!=null && !involeDevice.equals(",") ) {
......
......@@ -10,6 +10,7 @@ import com.tykj.dev.device.sendback.service.*;
import com.tykj.dev.device.sendback.util.StringUtils;
import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.service.UnitsService;
import com.tykj.dev.misc.base.DeviceLifeStatus;
......@@ -194,9 +195,18 @@ public class RepelQueryServiceImpl implements RepelQueryService {
}
@Override
public List<DeviceRepelDetail> getList() {
public List<DeviceRepelDetail> getList(SecurityUser securityUser) {
List<DeviceRepelDetail> list=new ArrayList<>();
repelDetailService.findAll().stream().filter(i-> i.getRepelStatus()==2).forEach(
List<DeviceRepelDetail> deviceRepelDetails=new ArrayList<>();
Units units=securityUser.getCurrentUserInfo().getUnits();
if (securityUser.getCurrentUserInfo().getUnits().getLevel()!=1){
deviceRepelDetails=repelDetailService.findUnitIdSendOrReceive(units.getUnitId());
}else {
deviceRepelDetails=repelDetailService.findAll();
}
deviceRepelDetails.stream().filter(i-> i.getRepelStatus()!=null&&i.getRepelStatus()==2).forEach(
deviceRepelDetail -> {
if (deviceRepelDetail.getBillFile()!=null){
deviceRepelDetail.setBillFiles(FilesUtil.stringFileToList(deviceRepelDetail.getBillFile()));
......
......@@ -12,22 +12,6 @@
/*@page{size:297mm 210mm;}<!-- 设置PDF页面大小,此配置只对生成PDF文件有效,不会对页面显示生效 -->*/
@page {
size:210mm 297mm;
/*margin: 0.25in;*/
/*-fs-flow-bottom: "footer";*/
/*-fs-flow-left: "left";*/
/*-fs-flow-right: "right";*/
/*border: thin solid black;*/
/*padding: 1em;*/
}
#footer {
font-size: 90%; font-style: italic;
position: absolute; top: 0; left: 0;
-fs-move-to-flow: "footer";
}
#pagenumber:before {
content: counter(page);
}
#pagecount:before {content: counter(pages);
}
.returnTablePrint{
width: 100%;
......@@ -39,10 +23,6 @@
.returnTablePrint .content{
width: 100%;
height: 100%;
/* background: url("../../../assets/img/detailsBg.png") no-repeat; */
/*background-size: 100% 100%;*/
/*padding: 30px;*/
/*box-sizing: border-box;*/
}
.returnTablePrint .content>div{
width: 100%;
......@@ -51,13 +31,13 @@
/* padding: 30px; */
box-sizing: border-box;
}
.returnTablePrint .content>p{
/* .returnTablePrint .content>p{
width: 100%;
text-align: center;
font-size: 22px;
font-weight: bold;
color: #4a475d;
}
} */
.returnTablePrint .listWrapper{
/*margin: 0 auto;*/
......@@ -70,26 +50,26 @@
}
.returnTablePrint .title{
width: 100%;
font-size: 20px;
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){
/* .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: 10px;
font-size: 12px;
color: #646464;
}
.returnTablePrint .other{
/* .returnTablePrint .other{
width: 100%;
color: #141414;
font-size: 20px;
......@@ -103,14 +83,14 @@
.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: 10px;
font-size: 12px;
box-sizing: border-box;
border-bottom: 1px solid #7f7f7f;
color:#000;
......@@ -194,7 +174,7 @@
right: 5px;
bottom: 5px;
font-style: normal;
font-size: 10px;
font-size: 12px;
}
.returnTablePrint .line3 .right i{
font-style: normal;
......@@ -216,14 +196,14 @@
}
.returnTablePrint .label{
color: #646464;
font-size: 10px;
font-size: 12px;
}
.returnTablePrint .value{
color: #000;
font-size: 10px;
font-size: 12px;
}
.returnTablePrint .main-title {
font-size: 18px;
font-size: 20px;
color: #000000;
line-height: 20px;
text-align: center;
......@@ -239,12 +219,14 @@
}
table.altrowstable {
width: 100%;
font-size:9px;
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;
......@@ -257,6 +239,8 @@
padding: 5px;
border-style: solid;
border-color: #a9c6c9;
word-break: break-all;
word-wrap: break-word;
}
.oddrowcolor{
background-color:#fff;
......@@ -271,7 +255,6 @@
</head>
<body>
<!--<div id="footer" style=""> Page <span id="pagenumber"/> of <span id="pagecount"/> </div>-->
<div class="returnTablePrint">
<div class="content">
......@@ -310,12 +293,22 @@
<div class="line2 tableList">
<table class="altrowstable" id="alternatecolor">
<tr>
<th>序号</th><th>型号</th><th>形态</th><th>密级</th><th>应用领域</th><th>数量</th><th style="width: 300px">装备序列号</th>
<th>序号</th><th>型号</th><th>形态</th><th>密级</th><th>应用领域</th><th>数量</th><th style="width: 300px;">装备序列号</th>
</tr>
<#list documentDevices as dev>
<tr>
<td>${dev.code}</td><td>${dev.model}</td><td>${dev.category}</td><td>${dev.securityClassification}</td><td>${dev.applicationField}</td><td>${dev.count}</td><td>${dev.deviceSerialNumber}</td>
<!-- <td>${dev.model}</td><td>${dev.category}</td><td>密码</td><td>${dev.applicationField}</td><td>${dev.count}</td><td>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</td> -->
<td>
<#if dev.code != 0>
${dev.code}
</#if>
</td>
<td>${dev.model}</td><td>${dev.category}</td><td>${dev.securityClassification}</td><td>${dev.applicationField}</td>
<td>
<#if dev.count != 0>
${dev.count}
</#if>
</td>
<td style="text-align: left;">${dev.deviceSerialNumber}</td>
</tr>
</#list>
</table>
......
......@@ -17,16 +17,6 @@
/*border: thin solid black;*/
/*padding: 1em;*/
}
#footer {
font-size: 90%; font-style: italic;
position: absolute; top: 0; left: 0;
-fs-move-to-flow: "footer";
}
#pagenumber:before {
content: counter(page);
}
#pagecount:before {content: counter(pages);
}
.returnTablePrint{
width: 100%;
height: 100%;
......@@ -90,14 +80,14 @@
color: #141414;
}
.returnTablePrint .main-title {
font-size: 28px;
font-size: 22px;
color: #000000;
margin-bottom: 20px;
text-align: center;
}
table.altrowstable {
width: 100%;
font-size:20px;
font-size:14px;
color:#141414;
border-width: 0px;
border-color: #a9c6c9;
......@@ -129,7 +119,7 @@
.person{
color: #4a475b;
text-align: right;
font-size: 18pt;
font-size: 16px;
}
.person > span{
display: inline-block;
......@@ -142,7 +132,6 @@
</head>
<body>
<!--<div id="footer" style=""> Page <span id="pagenumber"/> of <span id="pagecount"/> </div>-->
<div class="returnTablePrint">
<div class="content">
......@@ -158,7 +147,7 @@
</p>
<table class="altrowstable" id="alternatecolor">
<tr>
<th>序号</th><th>型号</th><th>形态</th><th>密级</th><th>应用领域</th><th>装备序列号</th>
<th>序号</th><th style="width: 150px;">型号</th><th>形态</th><th>密级</th><th>应用领域</th><th style="width: 150px;">装备序列号</th>
</tr>
<#list documentDevices as dev>
<tr>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论