提交 01a96377 authored 作者: 133's avatar 133

[考题的bug] 代码提交

上级 ed69d5c6
......@@ -90,6 +90,18 @@ public class FileController {
return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdf(content,url,preview,"workHandover/"));
}
/**
* 生成决算清单
*/
@ApiOperation(value = "生成决算清单")
@PostMapping("/revenue")
public ResponseEntity wordHandover(@RequestBody RevenueEntity revenueEntity) {
String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRenderRevenue(revenueEntity,url+"htmlModel/");
log.info("[file] 生成决算清单");
return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdf(content,url,preview,"workHandover/"));
}
/**
* 生成单据 确认单据
* @return
......
......@@ -19,6 +19,8 @@ import java.util.List;
@ApiModel(value = "决算vo")
public class Revenue {
private Integer code;
@ApiModelProperty(value = "型号")
private String model;
......@@ -41,12 +43,15 @@ public class Revenue {
private Integer total;
@ApiModelProperty(value = "代管")
private String escrow;
private Integer escrow;
@ApiModelProperty(value = "收到")
private String received;
@ApiModelProperty(value = "发出")
private Integer giveOut;
@ApiModelProperty(value = "报废")
private String scrapped;
private Integer scrapped;
}
......@@ -32,4 +32,7 @@ public class RevenueEntity {
@ApiModelProperty(name = "决算专管员B")
private String revenueUserB;
@ApiModelProperty(name = "决算时间")
private String time;
}
......@@ -769,6 +769,9 @@ public class JavaToPdfHtmlFreeMarker {
return lists;
}
private static int String_length(String value) {
int valueLength = 0;
String chinese = "[\u4e00-\u9fa5]";
......@@ -999,4 +1002,110 @@ public class JavaToPdfHtmlFreeMarker {
}
}
/**
* freemarker渲染html
*/
public static String[] freeMarkerRenderRevenue(RevenueEntity revenueEntity,String htmlPath) {
Writer out = new StringWriter();
String [] strings=new String[100000];
int index=0;
try {
// 获取模板,并设置编码方式
Template template = freemarkerCfg.getTemplate("bill4.html");
template.setEncoding("UTF-8");
List<Revenue> list=revenueEntity.getRevenueList();
List<List<Revenue>> listList=toRevenueList(list);
int count=listList.size();
Integer page=1;
for (List<Revenue> list1:listList) {
String htmlname=htmlPath+ UUID.randomUUID().toString()+".html";
// 合并数据模型与模板
FileWriter fileWriter = new FileWriter(new File(htmlname));
template.process(toMapRevenue(revenueEntity,list1,page,count),fileWriter);
out.flush();
strings[index]=htmlname;
index++;
page++;
}
return strings;
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
return null;
}
private static Map<String,Object> toMapRevenue(RevenueEntity revenueEntity,List<Revenue> list,Integer page,Integer count){
Map<String,Object> data = new HashMap();
data.put("title",revenueEntity.getTitle());
data.put("revenueUnit",revenueEntity.getRevenueUnit());
data.put("page",page);
data.put("count",count);
data.put("time",revenueEntity.getTime());
List<Revenue> list1=new ArrayList<>();
AtomicInteger i= new AtomicInteger(1);
list.forEach(
revenue -> {
revenue.setCode(i.get());
i.set(i.get() + 1);
list1.add(revenue);
}
);
data.put("revenues",list1);
return data;
}
private static List<List<Revenue>> toRevenueList(List<Revenue> deviceList){
List<List<Revenue>> lists=new ArrayList<>();
List<Revenue> revenues=new ArrayList<>();
int i=0;
for (Revenue revenue : deviceList) {
int max = toRevenueMax(revenue);
if (i + max == 20) {
revenues.add(revenue);
lists.add(revenues);
revenues = new ArrayList<>();
i = 0;
} else if (i + max > 20) {
lists.add(revenues);
revenues = new ArrayList<>();
revenues.add(revenue);
i = max;
} else {
revenues.add(revenue);
i = i + max;
}
}
if (revenues.size()!=0){
lists.add(revenues);
}
return lists;
}
private static Integer toRevenueMax(Revenue revenue){
int partsCount=String_length(revenue.getPart());
int modelCount=String_length(revenue.getModel());
int parts = (partsCount%11>0) ? partsCount/11 + 1 : partsCount/11;
int model=(modelCount%11>0) ? modelCount/11 + 1 : modelCount/11;
int max=parts;
//求最大
if(max<model){
max=model;
}
return max;
}
}
......@@ -75,13 +75,13 @@ public class ProblemServiceImpl implements ProblemService {
PredicateBuilder<Problem> predicateBuilder = Specifications.and();
if (problemPageVo!=null){
if (problemPageVo.getDesDim()!=null){
predicateBuilder.like("","%"+problemPageVo.getDesDim()+"%");
predicateBuilder.like("des","%"+problemPageVo.getDesDim()+"%");
}
if (problemPageVo.getLevel()!=null){
predicateBuilder.eq("",problemPageVo.getLevel());
predicateBuilder.eq("problemLevel",problemPageVo.getLevel());
}
if (problemPageVo.getType()!=null){
predicateBuilder.eq("",problemPageVo.getType());
predicateBuilder.eq("problemType",problemPageVo.getType());
}
}
return predicateBuilder.build();
......
......@@ -242,26 +242,23 @@ public class TrainJobController {
trainUser.setArriveTime(signUpUser.getArriveTime());
trainUser.setLeaveMeal(signUpUser.getLeaveMeal());
trainUser.setLeaveTime(signUpUser.getLeaveTime());
TaskLogBto taskLogBto = new TaskLogBto(taskId, "报名", null);
userLogService.save(new UserLog(securityUser.getCurrentUserInfo().getUserId(),new Date(),"报名参加培训"));
taskLogService.addLog(taskLogBto);
} else {
trainUser.setIsSignUp(2);
trainUser.setNote(signUpUser.getNote());
TaskLogBto taskLogBto = new TaskLogBto(taskId, "不报名", null);
taskLogService.addLog(taskLogBto);
userLogService.save(new UserLog(securityUser.getCurrentUserInfo().getUserId(),new Date(),"不参加培训"));
}
trainUser.setUnitsName(unitsDao.findById(trainUser.getUnitsId()).get().getName());
saveTrainUser(trainUser);
});
TaskLogBto taskLogBto = new TaskLogBto(taskId, "提交了培训名单", null);
taskLogService.addLog(taskLogBto);
userLogService.save(new UserLog(securityUser.getCurrentUserInfo().getUserId(),new Date(),"不参加培训"));
taskBto.setCreateUserId(securityUser.getCurrentUserInfo().getUserId());
taskBto = taskService.moveToSpecial(taskBto, StatusEnum.TRAIN1003, -1);
trainUnitDao.save(trainUnit);
List<Integer> userIds=userService.findAllByUnite(securityUser.getCurrentUserInfo().getUnitsId()).stream().map(User::getUserId).collect(Collectors.toList());
userIds.addAll(userService.findAllByUnite(trainTheme.getUnitsId()).stream().map(User::getUserId).collect(Collectors.toList()));
userIds.remove(securityUser.getCurrentUserInfo().getUserId());
messageService.add(new MessageBto(taskBto.getId(),BusinessEnum.TRAIN.id,securityUser.getUsername()+"提交了培训名单",userIds,trainTheme.getTrainId().toString()));
return ResponseEntity.ok(taskBto);
}
......
......@@ -210,7 +210,7 @@ public class TrainUser {
trainUserExcelVo.setLeaveTime(LeaveTime.format(df));
int daysNum=(int)(LeaveTime.toLocalDate().toEpochDay() - ArriveTime.toLocalDate().toEpochDay());
if (daysNum>1){
if (daysNum > 0){
trainUserExcelVo.setDayNum(daysNum);
}else {
trainUserExcelVo.setDayNum(0);
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
body,span,p,tr,td {
font-size: 15px;
font-family: SimHei;
margin: 0;
padding: 0;
}
/*@page{size:297mm 210mm;}<!-- 设置PDF页面大小,此配置只对生成PDF文件有效,不会对页面显示生效 -->*/
@page {
size: 297mm 210mm;
}
.bottomTxt {
text-align: center;
font-size: 15px;
color: #000;
height: 16px;
margin-top: 4px;
line-height: 16px;
}
.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; */
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: 15px;
color: #000;
}
/* .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: 15px;
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: #000;
display: inline-block;
margin-left: 5px;
}
.returnTablePrint .line2 {
height: 100%;
/* padding: 20px; */
border-bottom: 1px solid #7f7f7f;
}
.returnTablePrint .tableList {
height:508px;
border-bottom: none;
}
.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 {
border: 1px solid #7f7f7f;
border-top: none;
width: 100%;
height: 94px;
/* box-sizing: border-box; */
/*height:150px;*/
/*display: flex;*/
/* height:170px; */
/* padding:20px 0 20px 0; */
}
.returnTablePrint .line3 .left {
display: inline-block;
width: 49.5%;
box-sizing: border-box;
/*padding-left: 20px;*/
position: relative;
line-height: 94px;
}
.returnTablePrint .line3 .left {
border-right: 1px solid #7f7f7f;
/*padding-bottom: 40px;*/
}
.returnTablePrint .line3 .left:last-child {
/*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: #000;
display: inline-block;
margin-left: 20px;
}
.returnTablePrint>>>.el-table tbody .cell {
color: #141414;
}
.returnTablePrint .label {
color: #000;
font-size: 15px;
}
.returnTablePrint .value {
color: #000;
font-size: 15px;
}
.returnTablePrint .main-title span{
font-size: 22px;
color: #333;
font-weight: bold;
}
.returnTablePrint .main-title {
font-size: 17px;
color: #000000;
line-height: 17px;
text-align: center;
margin-top: 9px;
}
.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: #000;
border-width: 0px;
border-color: #a9c6c9;
border-collapse: collapse;
text-align: center;
table-layout: fixed;
word-break: break-all;
}
table.altrowstable th {
border-style: solid;
background-color: #dedede;
border: 1px solid #bebebe;
height: 24px;
line-height: 24px;
font-size: 15px;
}
table.altrowstable td {
border-width: 0px;
height: 24px;
line-height: 24px;
font-size: 15px;
/*border-style: solid;*/
/*border-color: #a9c6c9;*/
/*border: 1px solid #bebebe;*/
word-break: break-all;
word-wrap: break-word;
width: 100%;
}
table.altrowstable tr:nth-child(odd){
background-color: #f8f8f8;
}
.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>
${title}
</span>
</div>
<div style="width:100%;text-align:left;font-size: 1px;margin-bottom:2px">
<div style="text-align:left;display: inline-block; width: 49%" class="number">
<span class="number">决算单位:${revenueUnit}</span>
</div>
<!-- <div style="text-align:center;display: inline-block; width: 34%" class="number">
<span></span>
</div> -->
<div style="text-align:right;display: inline-block; width: 50%" class="number">
<span>决算时间:${time}</span>
</div>
</div>
</div>
<div class="listCon">
<div class="line2 tableList">
<table class="altrowstable" id="alternatecolor">
<tr>
<th width="70px">序号</th>
<th>型号</th>
<th>部件</th>
<th>纵向</th>
<th>横向</th>
<th>委托</th>
<th>其他</th>
<th>合计</th>
<th>代管</th>
<th>收到</th>
<th>发出</th>
<th>报废</th>
</tr>
<#list revenues as dev>
<tr>
<td>
${dev.code!}
</td>
<td>${dev.model!}</td>
<td>${dev.part!}</td>
<td>${dev.vertical!}</td>
<td>${dev.horizontal!}</td>
<td>${dev.consign!}</td>
<td>${dev.others!}</td>
<td>${dev.total!}</td>
<td>${dev.escrow!}</td>
<td>${dev.received!}</td>
<td>${dev.giveOut!}</td>
<td>${dev.scrapped!}</td>
</tr>
</#list>
</table>
</div>
</div>
<div class="line3" style="position: relative;">
<span class="left">
<span>
<span style="position: absolute; top: 0px; left: 8px;"
class="label">专管员签名:</span>
<span class="value"></span>
</span>
</span>
<span class="left">
<span>
<span style="position: absolute; top: 0px; left: 8px;"
class="label">专管员签名:</span>
<span class="value"></span>
</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="bottomTxt">第${page}页/共${count}页</p>
</body>
</html>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论