Map
1. Use Map
2. Define multiple input and output of dto classes, looks clear, but very troublesome,
But I wrote 2 this kind of method, and then tested, found that performance is not much difference, have who can explain to me?
Labeled as part of the code below, if have bad place, please point out,
This is to use Map
@ PostMapping (path="/gettimebymember")
Public MapGetTimeByAdAccountAndMember (@ RequestBody Map Obj) {
MapRet=new HashMap (a);
MapData=https://bbs.csdn.net/topics/new HashMap ();
Try {
//find out the account all subordinates
String date=(String) obj. Get (" date ");
String adAccount=(String) obj. Get (" adAccount ");
The UserInfo supervisor=userInfoService. GetUserInfoByAdAccount (adAccount);
Int yearInt=Integer. ParseInt (date. The substring (0, date. IndexOf (' - ')));
ListList=userInfoService. ListAllActive ();
ListMembers=new ArrayList (a);
Members. The add (supervisor);
For (the UserInfo user: list)
{
String name1=user. GetSupervisor ();
String name2=adAccount;
If (name1==null)
continue;
If (name1. Equals (name2))
{
Members. The add (user);
}
}
If (members. IsEmpty ())
{
Ret. Put (" data ", "0");
return ret;
}
//to find every subordinate this year monthly time
String [] monthName={" Jan ", "Feb.", "Mar.," "Apr.," "May,", "Jun.", "Jul.," ". ", "Sep.", "Oct., Nov., Dec." "};
For (the UserInfo m: members)
{
Double [] memberTime=new double [12].
MapMember=new HashMap (a);
String AD=m.g etAdAccount ();
for(int i=1; I & lt;=12; I++)
{
The Date firstDate=Helper. GetFirstDayOfMonth (yearInt, I);
The Date lastDate=Helper. GetLastDayOfMonth (yearInt, I);
The Date firstMondy=Helper. GetMondyDayOfDate (firstDate);
The Date lastMondy=Helper. GetMondyDayOfDate (lastDate);
ListWBSList=taskService. GetWBSList (AD);
The Date startDate=firstMondy;
Double monthtime=0;
While (startDate. GetTime () & lt; .=lastMondy getTime ())
{
Double the daytime=0;
For (String WBS: WBSList)
{
List
This is a custom class
@ PostMapping (path="/gettimebymembermirror")
Public MapGetTimeByAdAccountAndMemberMirror (@ RequestBody InputDto InputDto) {
MapRet=new HashMap (a);
ListData=https://bbs.csdn.net/topics/new ArrayList ();
Try {
//find out the account all subordinates
String date=inputDto. GetDate ();
String adAccount=inputDto. GetAdAccount ();
The UserInfo supervisor=userInfoService. GetUserInfoByAdAccount (adAccount);
Int yearInt=Integer. ParseInt (date. The substring (0, date. IndexOf (' - ')));
ListList=userInfoService. ListAllActive ();
ListMembers=new ArrayList (a);
Members. The add (supervisor);
For (the UserInfo user: list)
{
String name1=user. GetSupervisor ();
String name2=adAccount;
If (name1==null)
continue;
If (name1. Equals (name2))
{
Members. The add (user);
}
}
If (members. IsEmpty ())
{
Ret. Put (" data ", "0");
return ret;
}
//to find every subordinate this year monthly time
String [] monthName={" Jan ", "Feb.", "Mar.," "Apr.," "May,", "Jun.", "Jul.," ". ", "Sep.", "Oct., Nov., Dec." "};
For (the UserInfo m: members)
{
OutputDto outDto=new OutputDto ();
Double [] memberTime=new double [12].
MapMember=new HashMap (a);
String AD=m.g etAdAccount ();
for(int i=1; I & lt;=12; I++)
{
The Date firstDate=Helper. GetFirstDayOfMonth (yearInt, I);
The Date lastDate=Helper. GetLastDayOfMonth (yearInt, I);
The Date firstMondy=Helper. GetMondyDayOfDate (firstDate);
The Date lastMondy=Helper. GetMondyDayOfDate (lastDate);
ListWBSList=taskService. GetWBSList (AD);
The Date startDate=firstMondy;
Double monthtime=0;
While (startDate. GetTime () & lt; .=lastMondy getTime ())
{
Double the daytime=0;
For (String WBS: WBSList)
{
Listnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull