段飞宇
1 year ago
14 changed files with 557 additions and 199 deletions
@ -0,0 +1,121 @@
|
||||
package com.hnac.hzims.ticket.standardTicket.utils; |
||||
|
||||
import com.hnac.hzims.ticket.twoTicket.utils.WordHelper; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
|
||||
/** |
||||
* @Author WL |
||||
* @Version v1.0 |
||||
* @Serial 1.0 |
||||
* @Date 2023/6/7 17:00 |
||||
*/ |
||||
public class OperationWordHelper { |
||||
|
||||
|
||||
/** |
||||
* map验证是value否为null |
||||
* |
||||
* @param workTicketInfoMap |
||||
* @return |
||||
*/ |
||||
public static Map<String, Object> resultMap(Map<String, Object> workTicketInfoMap) { |
||||
Map<String, Object> resultMap = new HashMap<>(); |
||||
for (Map.Entry<String, Object> entry : workTicketInfoMap.entrySet()) { |
||||
listEntryMap(resultMap, entry.getKey(), entry.getValue()); |
||||
} |
||||
return resultMap; |
||||
} |
||||
|
||||
/** |
||||
* 根据状态获取模板 |
||||
* @param status |
||||
* @return |
||||
*/ |
||||
public static String getWorkTicketStatus(Integer status) { |
||||
String result = null; |
||||
switch (status) { |
||||
case 0: |
||||
result = "电气操作票.docx"; |
||||
default: |
||||
result = "电气操作票.docx"; |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
|
||||
@Data |
||||
@AllArgsConstructor |
||||
static class Entry { |
||||
/** |
||||
* key值 |
||||
*/ |
||||
private String fileName; |
||||
|
||||
/** |
||||
* count |
||||
*/ |
||||
private Integer count; |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* 判断是否存在,如果不存在空格代替 |
||||
* @param resultMap |
||||
* @param key |
||||
* @param value |
||||
*/ |
||||
private static void listEntryMap(Map<String, Object> resultMap, String key, Object value) { |
||||
List<Entry> params = new ArrayList<>(); |
||||
paramsList(params); |
||||
for (Entry entry : params) { |
||||
isEntryMap(resultMap, entry.getFileName(), key, value, entry.getCount()); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 验证空格多少 |
||||
* @param resultMap |
||||
* @param fileName |
||||
* @param key |
||||
* @param value |
||||
* @param count |
||||
*/ |
||||
private static void isEntryMap(Map<String, Object> resultMap, String fileName, String key, Object value, Integer count) { |
||||
if (fileName.equals(key)) { |
||||
Object newValue = StringUtils.isNoneBlank(WordHelper.toString(value).trim()) ? value : |
||||
"\u00A0" + WordHelper.printSpace(count); |
||||
resultMap.put(key, newValue); |
||||
} else { |
||||
Object newValue = StringUtils.isNoneBlank(WordHelper.toString(value).trim()) ? value : |
||||
"\u00A0" + WordHelper.printSpace(5); |
||||
resultMap.put(key, newValue); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 存储数据,要加载多少空格 |
||||
* @param params |
||||
*/ |
||||
private static void paramsList(List<Entry> params) { |
||||
params.add(new Entry("projectName", 10)); |
||||
params.add(new Entry("classGroupName", 10)); |
||||
params.add(new Entry("code", 10)); |
||||
params.add(new Entry("accessOrderPersonName", 10)); |
||||
params.add(new Entry("guardianName", 10)); |
||||
params.add(new Entry("startTime", 10)); |
||||
params.add(new Entry("endTime", 10)); |
||||
params.add(new Entry("principalName", 10)); |
||||
params.add(new Entry("principalTime", 10)); |
||||
} |
||||
} |
Loading…
Reference in new issue