Skip to content

Commit

Permalink
aaaa
Browse files Browse the repository at this point in the history
  • Loading branch information
李广 committed Jun 21, 2018
1 parent 3ab31ef commit e1bba1c
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 63 deletions.
1 change: 1 addition & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/resources/File.java=UTF-8
encoding//src/main/resources/file.txt=UTF-8
Empty file added newClientPolicy.java
Empty file.
Empty file added newFile.java
Empty file.
90 changes: 85 additions & 5 deletions src/main/java/files/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang3.StringUtils;

Expand All @@ -17,6 +19,7 @@

public class FileUtils {

private static String space=" ";
/**
* transter dto to json
*/
Expand Down Expand Up @@ -51,18 +54,95 @@ public static void dto2json(String file) throws Exception {
System.out.println(withNullobject.toString());
}

public static void annotationConvert(String file) throws Exception{
//将多行注释改为一行注释
public static void multy2singleAnno(String file) throws Exception{
String classFile=FileUtils.class.getClassLoader().getResource(file).getFile();
BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(new File(file)), Charset.forName("UTF-8")));
new InputStreamReader(new FileInputStream(new File(classFile)), Charset.forName("UTF-8")));
BufferedWriter writer =new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(new File(file)),Charset.forName("UTF-8")));
new OutputStreamWriter(new FileOutputStream(new File("new"+file)),Charset.forName("UTF-8")));

StringBuilder sBuilder=new StringBuilder();
String anno="";
//开始记录注释标志
boolean annoFlag=false;
//注释已经被写入body的标志
boolean annoRead=false;
String temp=reader.readLine();

while (temp!=null) {

//注释开头
if (temp.indexOf("/*")>=0) {
annoFlag=true;
}
//注释结尾
if (temp.indexOf("*/")>=0) {
annoFlag=false;
}
if (annoFlag) {
anno+=temp+"\n";
annoRead=false;
} else {
if (temp.indexOf("*/")<0) {
//假如非注释行,则直接添加
sBuilder.append(temp+"\n");
}
if (!annoRead) {
//sBuilder.append("\n");
annoRead=true;
}

}
int markPos=temp.indexOf("*");
if (temp.indexOf("*/")<0 && temp.indexOf("/*")<0 && markPos>=0 && markPos<temp.length()) {
sBuilder.append(" //"+temp.substring(markPos+1, temp.length())+"\n");
}
temp=reader.readLine();
}
String result=sBuilder.toString();
System.out.println(result);
}

public static void single2multiAnno(String file) throws Exception{
String classFile=FileUtils.class.getClassLoader().getResource(file).getFile();
BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(new File(classFile)), Charset.forName("UTF-8")));

StringBuilder sBuilder=new StringBuilder();
String anno="";
String temp=reader.readLine();
int annoCount=0;
while (temp!=null) {

int markPos=temp.indexOf("//");
//注释开头
if (markPos>=0 && markPos+2<temp.length()) {
annoCount++;
anno+=space+" * "+temp.substring(markPos+2, temp.length())+"\n";
} else {
if(annoCount>0) {
sBuilder.append(space+"/**\n"+anno+space+" */\n");
anno="";
annoCount=0;
sBuilder.append(temp+"\n");
} else {
sBuilder.append(temp+"\n");
}
}
temp=reader.readLine();
}
String result=sBuilder.toString();
System.out.println(result);
}

public static void main(String[] args) throws Exception {
System.out.println("=====Dto to Json transter======");
dto2json("D:\\file.txt");
//System.out.println("=====Dto to Json transter======");
//dto2json("D:\\file.txt");
String file="File.java";
//System.out.println("/*****".indexOf("*/*"));
multy2singleAnno(file);
//single2multiAnno(file);

}
}
111 changes: 53 additions & 58 deletions src/main/resources/ClientPolicy.java → src/main/resources/File.java
Original file line number Diff line number Diff line change
@@ -1,105 +1,97 @@
package com.cmft.mcc.rpc.dto;

import java.io.Serializable;
import java.math.BigDecimal;

import org.springframework.format.annotation.DateTimeFormat;

/**
* 客户保单
*/
public class ClientPolicy implements Serializable {

public static final String TABLE_POLICY = "客户承保保单信息";
public static final String ALIAS_CLIENT_TYPE = "客户类型代码";
public static final String ALIAS_CLIENT_TYPE_DESC = "客户类型";
public static final String ALIAS_APPLY_BAR_CODE = "投保单号";
public static final String ALIAS_POLICY_NO = "保单号";
public static final String ALIAS_EFFECT_DATE = "生效日期";
public static final String ALIAS_MAIN_PRODUCT_PLAN = "主险名称";

public static final String ALIAS_DUTY_STATUS = "保单状态代码";
public static final String ALIAS_DUTY_STATUS_DESC = "保单状态";
public static final String ALIAS_UNDERWRITE_INFO = "核保信息";
public static final String ALIAS_CLAIM_INFO = "理赔信息";
public static final String ALIAS_POS_INFO = "保全信息";
public static final String ALIAS_POLICY_INFO = "保单信息";

public static final String ALIAS_APPLY_DATE = "投保日期";
public static final String ALIAS_APPLY_STATUS = "投保单状态代码";
public static final String ALIAS_APPLY_STATUS_DESC = "投保单状态";
public static final String ALIAS_APPLY_INFO = "投保单信息";


//客户类型 01投保人/02被保人/03投被保人
/**
* 客户类型 01投保人/02被保人/03投被保人
*/
private String clientType;
//客户类型描述
/**
* 客户类型描述
*/
private String clientTypeDesc;
//投保单系统编号
/**
* 投保单系统编号
*/
private String applyNo;
//投保单号
/**
* 投保单号
*
*/
private String applyBarCode;
//保单号
/**
* 保单号
*/
private String policyNo;
//主险名称
/**
* 主险名称
*/
private String mainProductPlan;
//生效日期
/**
* 生效日期
*/
private java.util.Date effectDate;
//保单状态
/**
* 保单状态
*/
private String dutyStatus;
//保单状态描述
/**
* 保单状态描述
*/
private String dutyStatusDesc;
//投保单状态
/**
* 投保单状态
*/
private String applyStatus;
//投保单状态描述
/**
* 投保单状态描述
*/
private String applyStatusDesc;
//投保日期
/**
* 投保日期
*/
private java.util.Date applyDate;
/**
* 投保人姓名
* 投保人姓名
*/
private String appClientName;
/**
* 投保人客户号
* 投保人客户号
*/
private String appClientNo;
/**
* 投保人姓名描述
* 投保人姓名描述
*/
private String appClientSexDesc;
/**
* 被保人姓名
* 被保人姓名
*/
private String insClientName;
/**
* 被保人客户号
* 被保人客户号
*/
private String insClientNo;
/**
* 保单渠道
* 保单渠道
*/
private String channleType;
/**
* 保单渠道描述信息
* 保单渠道描述信息
*/
private String channelTypeDesc;

/**
* 业务员信息
* 业务员信息
*/
private EmployeeInfoManage employeeInfoManage;

/**
* 合计保费
* 合计保费
*/
private BigDecimal modalTotalPrem;

/**
* 保单所属机构名称
* 保单所属机构名称
*/
private String policyBranchName;
/**
* 保单所属机构代码
* 保单所属机构代码
*/
private String policyBranchCode;

Expand Down Expand Up @@ -256,14 +248,14 @@ public String getApplyStatusDesc() {
}

/**
* @param mainProductPlan the mainProductPlan to set
* @param mainProductPlan the mainProductPlan to set
*/
public void setMainProductPlan(String mainProductPlan) {
this.mainProductPlan = mainProductPlan;
}

/**
* @return the mainProductPlan
* @return the mainProductPlan
*/
public String getMainProductPlan() {
return mainProductPlan;
Expand Down Expand Up @@ -303,3 +295,6 @@ public void setInsClientNo(String insClientNo) {


}



0 comments on commit e1bba1c

Please sign in to comment.