-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hubin6
committed
Oct 31, 2017
1 parent
386b517
commit 507e4fa
Showing
19 changed files
with
419 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/DimQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.jd.logistics.cloud.data.domain; | ||
|
||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 15:39 | ||
*/ | ||
@Data | ||
public class DimQuery implements Serializable { | ||
private static final long serialVersionUID = -946299281247438489L; | ||
private String funcName; | ||
private String warehouse; | ||
private String dateCycle; | ||
private String dateStart; | ||
private String dateEnd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/GenericRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.jd.logistics.cloud.data.domain; | ||
|
||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
import java.text.DecimalFormat; | ||
import java.util.List; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 15:50 | ||
*/ | ||
@Data | ||
public class GenericRes implements Serializable{ | ||
private static final long serialVersionUID = 1902248647108008231L; | ||
private String funcName; | ||
private String funcValue; | ||
private String idxName1; | ||
private double idxValue1; | ||
private String idxName2; | ||
private double idxValue2; | ||
private String idxName3; | ||
private double idxValue3; | ||
private String idxName4; | ||
private double idxValue4; | ||
private String statDate; | ||
|
||
public String getFuncValue() { | ||
DecimalFormat df = new DecimalFormat("###,##0"); | ||
DecimalFormat df2 = new DecimalFormat("###,##0.00"); | ||
double tmp = Double.parseDouble(funcValue); | ||
if (tmp / 100000 >=1) | ||
funcValue = df.format(tmp/1000) + "K"; | ||
else if ((tmp * 10) % 10 == 0) // integer | ||
funcValue = df.format(tmp); | ||
else if (tmp <= 1 ) // 百分比 | ||
funcValue = df2.format(tmp * 100) + "%"; | ||
else funcValue = df2.format(tmp); | ||
return funcValue; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...rd-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/DimRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.jd.logistics.cloud.data.repository; | ||
|
||
import com.jd.logistics.cloud.data.domain.Dim; | ||
import com.jd.logistics.cloud.data.domain.DimQuery; | ||
import com.jd.logistics.cloud.data.domain.Function; | ||
import com.jd.logistics.cloud.data.domain.GenericRes; | ||
import org.apache.ibatis.annotations.Mapper; | ||
import org.apache.ibatis.annotations.Param; | ||
import org.apache.ibatis.annotations.Select; | ||
import org.apache.ibatis.annotations.Update; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/30 9:22 | ||
*/ | ||
@Mapper | ||
public interface DimRepository { | ||
@Select("SELECT * FROM T_WAREHOUSE") | ||
List<Dim> getWarehouses(); | ||
|
||
@Select("SELECT * FROM T_DATECYCLE") | ||
List<Dim> getDateCycles(); | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...d-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/FuncRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.jd.logistics.cloud.data.repository; | ||
|
||
import com.jd.logistics.cloud.data.domain.Function; | ||
import com.jd.logistics.cloud.data.domain.User; | ||
import org.apache.ibatis.annotations.*; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/30 9:22 | ||
*/ | ||
@Mapper | ||
public interface FuncRepository { | ||
|
||
@Select("SELECT id, name as funcName, type as funcType, seq FROM T_FUNCTION where type=#{type}order by seq") | ||
List<Function> getByType(@Param("type") int type); | ||
|
||
@Select("SELECT id, name as funcName, type as funcType, seq FROM T_FUNCTION order by seq") | ||
List<Function> getAll(); | ||
|
||
@Update("UPDATE T_FUNCTION SET type=#{func.funcType}, seq=#{func.seq} WHERE name=#{func.funcName}") | ||
void update(@Param("func") Function func); | ||
} |
37 changes: 37 additions & 0 deletions
37
...d-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/StatRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.jd.logistics.cloud.data.repository; | ||
|
||
import com.jd.logistics.cloud.data.domain.DimQuery; | ||
import com.jd.logistics.cloud.data.domain.GenericRes; | ||
import org.apache.ibatis.annotations.Mapper; | ||
import org.apache.ibatis.annotations.Param; | ||
import org.apache.ibatis.annotations.Select; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 17:41 | ||
*/ | ||
@Mapper | ||
public interface StatRepository { | ||
@Select("<script>" + | ||
"SELECT FUNC_NAME as funcName, FUNC_VALUE as funcValue, STAT_DATE as statDate, " + | ||
" '日环比' as idxName1," + | ||
" MAX(CASE WHEN IDX_NAME='日环比' then IDX_VALUE else NULL END) as idxValue1," + | ||
" '周同比' as idxName2," + | ||
" MAX(CASE WHEN IDX_NAME='周同比' then IDX_VALUE else NULL END) as idxValue2," + | ||
" '上周同日' as idxName3," + | ||
" MAX(CASE WHEN IDX_NAME='上周同日' then IDX_VALUE else NULL END) as idxValue3," + | ||
" '昨日全天' as idxName4," + | ||
" MAX(CASE WHEN IDX_NAME='昨日全天' then IDX_VALUE else NULL END) as idxValue4" + | ||
" FROM T_RESULT where 1=1" + | ||
"<if test='query.warehouse != null'> AND WAREHOUSE_NAME=#{query.warehouse}</if>" + | ||
"<if test='query.funcName != null'> AND FUNC_NAME=#{query.funcName}</if>" + | ||
"<if test='query.dateCycle != null'> AND DATE_CYCLE=#{query.dateCycle}</if>" + | ||
"<if test='query.dateStart != null and query.dateEnd != null'> AND STAT_DATE between #{query.dateStart} and #{query.dateEnd}</if>" + | ||
" GROUP BY FUNC_NAME, FUNC_VALUE, STAT_DATE" + | ||
"</script>" | ||
) | ||
List<GenericRes> getRes(@Param("query")DimQuery query); | ||
} |
16 changes: 6 additions & 10 deletions
16
...d-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/UserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,23 @@ | ||
package com.jd.logistics.cloud.data.repository; | ||
|
||
import com.jd.logistics.cloud.data.domain.DimQuery; | ||
import com.jd.logistics.cloud.data.domain.GenericRes; | ||
import com.jd.logistics.cloud.data.domain.User; | ||
import org.apache.ibatis.annotations.*; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/30 9:22 | ||
*/ | ||
@Mapper | ||
public interface UserRepository { | ||
@Insert("INSERT into T_USER (name,age,addr) VALUES(#{name}, #{age}, #{addr})") | ||
void add(User user); | ||
|
||
@Select("SELECT * FROM T_USER WHERE id = #{id}") | ||
User getById(@Param("id") Long id); | ||
|
||
@Select("SELECT * FROM T_USER WHERE name = #{name}") | ||
User getByName(@Param("name") String name); | ||
|
||
@Update("UPDATE T_USER SET name=#{user.name}, age=#{user.age}, addr=#{user.addr} WHERE id=#{user.id}") | ||
void update(@Param("user") User user); | ||
@Select("SELECT * FROM T_USER WHERE username = #{username}") | ||
User getByName(@Param("username") String username); | ||
|
||
@Delete("DELETE FROM T_USER WHERE id =#{id}") | ||
void delete(@Param("id") Long id); | ||
} |
16 changes: 16 additions & 0 deletions
16
dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/FuncService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.jd.logistics.cloud.data.service; | ||
|
||
import com.jd.logistics.cloud.data.domain.Function; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 10:17 | ||
*/ | ||
public interface FuncService { | ||
List<Function> getFuncByType(int type); | ||
List<Function> getAllFunc(); | ||
void updateFuncType(Function func); | ||
} |
33 changes: 33 additions & 0 deletions
33
...ard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/FuncServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.jd.logistics.cloud.data.service; | ||
|
||
import com.jd.logistics.cloud.data.domain.Function; | ||
import com.jd.logistics.cloud.data.repository.FuncRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @Author hubin | ||
* @Description: | ||
* @Date 2017/10/31 10:17 | ||
*/ | ||
@Service | ||
public class FuncServiceImpl implements FuncService { | ||
@Autowired | ||
FuncRepository funcRepository; | ||
@Override | ||
public List<Function> getFuncByType(int type) { | ||
return funcRepository.getByType(type); | ||
} | ||
|
||
@Override | ||
public List<Function> getAllFunc() { | ||
return funcRepository.getAll(); | ||
} | ||
|
||
@Override | ||
public void updateFuncType(Function func) { | ||
funcRepository.update(func); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.