瀏覽代碼

服务器部署

jz.kai 1 年之前
父節點
當前提交
147ec40d99

+ 1 - 1
common/src/main/java/com/jpsoft/printing/modules/base/dao/AccountDAO.java

@@ -20,5 +20,5 @@ public interface AccountDAO {
 	List<Account> search(Map<String,Object> searchParams,List<Sort> sortList);
 	BigDecimal getBalance(String customerId, String deadline);
 	Account getByWorkId(String workId);
-	List<NameValueDTO> findTransactionRanking(String startDay, String endDay, Integer limit);
+	List<Account> findTransactionList(Integer type, String startDay, String endDay, String order, Integer limit);
 }

+ 1 - 1
common/src/main/java/com/jpsoft/printing/modules/base/service/AccountService.java

@@ -19,5 +19,5 @@ public interface AccountService {
 	Page<Account> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
 	BigDecimal getBalance(String customerId, String deadline);
 	Account getByWorkId(String workId);
-	List<NameValueDTO> findTransactionRanking(String startDay, String endDay, Integer limit);
+	List<Account> findTransactionList(Integer type, String startDay, String endDay, String order, Integer limit);
 }

+ 2 - 2
common/src/main/java/com/jpsoft/printing/modules/base/service/impl/AccountServiceImpl.java

@@ -82,7 +82,7 @@ public class AccountServiceImpl implements AccountService {
 	}
 
 	@Override
-	public List<NameValueDTO> findTransactionRanking(String startDay, String endDay, Integer limit) {
-		return accountDAO.findTransactionRanking(startDay, endDay, limit);
+	public List<Account> findTransactionList(Integer type, String startDay, String endDay, String order, Integer limit) {
+		return accountDAO.findTransactionList(type, startDay, endDay, order, limit);
 	}
 }

+ 40 - 15
common/src/main/resources/mapper/base/Account.xml

@@ -125,7 +125,7 @@ id_,customer_id,work_id,type_,plan_number,actual_amount,cloth_amount,roll_amount
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
-	<select id="getBalance" parameterType="string" resultType="int">
+	<select id="getBalance" parameterType="string" resultType="decimal">
 		<![CDATA[
 			SELECT SUM(amount_) FROM base_account
 			WHERE del_flag = 0
@@ -137,20 +137,45 @@ id_,customer_id,work_id,type_,plan_number,actual_amount,cloth_amount,roll_amount
 		select * from base_account
 		where work_id = #{0}
 	</select>
-	<resultMap id="NameValueDTOMap" type="com.jpsoft.printing.modules.base.dto.NameValueDTO">
-		<result property="name" column="name_" />
-		<result property="value" column="value_" />
-	</resultMap>
-	<select id="findTransactionRanking" parameterType="string" resultMap="NameValueDTOMap">
-		<![CDATA[
-			SELECT customer_id AS name_, ABS(SUM(total_amount)) AS value_ FROM base_account
-			WHERE del_flag = 0
-			AND type_ = 0
-			AND create_time >= #{startDay}
-			AND create_time < #{endDay}
-			GROUP BY customer_id
-			ORDER BY value_ DESC
+	<select id="findTransactionList" parameterType="string" resultMap="AccountMap">
+		SELECT a.customer_id, a.type_, SUM(actual_amount) AS actual_amount, SUM(cloth_amount) AS cloth_amount, SUM(roll_amount) AS roll_amount, SUM(total_amount) AS total_amount FROM base_account a
+		LEFT JOIN base_customer b ON a.customer_id = b.id_
+		<where>
+			a.del_flag = 0
+			<if test="type != null">
+				AND a.type_ = ${type}
+			</if>
+			<if test="startDay != null">
+				AND a.create_time >= #{startDay}
+			</if>
+			<if test="endDay != null">
+				<![CDATA[
+				AND a.create_time < #{endDay}
+				]]>
+			</if>
+		</where>
+			GROUP BY a.customer_id, a.type_
+		<if test="order != null">
+			ORDER BY ${order}
+		</if>
+		<if test="limit != null">
 			LIMIT ${limit}
-		]]>
+		</if>
 	</select>
+<!--	<resultMap id="NameValueDTOMap" type="com.jpsoft.printing.modules.base.dto.NameValueDTO">-->
+<!--		<result property="name" column="name_" />-->
+<!--		<result property="value" column="value_" />-->
+<!--	</resultMap>-->
+<!--	<select id="findTransactionRanking" parameterType="string" resultMap="NameValueDTOMap">-->
+<!--		<![CDATA[-->
+<!--			SELECT customer_id AS name_, ABS(SUM(total_amount)) AS value_ FROM base_account-->
+<!--			WHERE del_flag = 0-->
+<!--			AND type_ = 0-->
+<!--			AND create_time >= #{startDay}-->
+<!--			AND create_time < #{endDay}-->
+<!--			GROUP BY customer_id-->
+<!--			ORDER BY value_ DESC-->
+<!--			LIMIT ${limit}-->
+<!--		]]>-->
+<!--	</select>-->
 </mapper>

+ 51 - 15
web/src/main/java/com/jpsoft/printing/modules/ReportController.java

@@ -3,6 +3,7 @@ package com.jpsoft.printing.modules;
 import com.github.pagehelper.Page;
 import com.jpsoft.printing.config.OSSConfig;
 import com.jpsoft.printing.modules.base.dto.NameValueDTO;
+import com.jpsoft.printing.modules.base.entity.Account;
 import com.jpsoft.printing.modules.base.entity.Customer;
 import com.jpsoft.printing.modules.base.service.AccountService;
 import com.jpsoft.printing.modules.base.service.CustomerService;
@@ -48,9 +49,11 @@ public class ReportController {
     public MessageResult transactionRanking(String startDay, String endDay, Integer limit){
         MessageResult msgResult = new MessageResult<>();
 
-        List<NameValueDTO> list = accountService.findTransactionRanking(startDay, endDay, limit);
-        for(NameValueDTO dto : list){
-            Customer customer = customerService.get(dto.getName());
+        List<Account> list = accountService.findTransactionList(0, startDay, endDay, "total_amount ASC", limit);
+        for(Account account : list){
+            account.setTotalAmount(account.getTotalAmount().negate());
+
+            Customer customer = customerService.get(account.getCustomerId());
             if(customer != null) {
                 String allName = "";
                 if (StringUtils.isNotEmpty(customer.getCompany())) {
@@ -58,10 +61,10 @@ public class ReportController {
                 } else {
                     allName = customer.getName();
                 }
-                dto.setName(allName);
+                account.setCustomerName(allName);
             }
             else {
-                dto.setName(null);
+                account.setCustomerName(null);
             }
         }
 
@@ -76,9 +79,11 @@ public class ReportController {
     public MessageResult transactionRankingXls(String startDay, String endDay, Integer limit, String title) throws Exception {
         MessageResult msgResult = new MessageResult<>();
 
-        List<NameValueDTO> list = accountService.findTransactionRanking(startDay, endDay, limit);
-        for(NameValueDTO dto : list){
-            Customer customer = customerService.get(dto.getName());
+        List<Account> list = accountService.findTransactionList(0, startDay, endDay, "total_amount ASC", limit);
+        for(Account account : list){
+            account.setTotalAmount(account.getTotalAmount().negate());
+
+            Customer customer = customerService.get(account.getCustomerId());
             if(customer != null) {
                 String allName = "";
                 if (StringUtils.isNotEmpty(customer.getCompany())) {
@@ -86,10 +91,10 @@ public class ReportController {
                 } else {
                     allName = customer.getName();
                 }
-                dto.setName(allName);
+                account.setCustomerName(allName);
             }
             else {
-                dto.setName(null);
+                account.setCustomerName(null);
             }
         }
 
@@ -104,12 +109,12 @@ public class ReportController {
         int rowNum = 2;
 
         for(int i=0; i<list.size(); i++) {
-            NameValueDTO dto = list.get(i);
+            Account account = list.get(i);
 
             Row row = sheet.createRow(rowNum);
             row.createCell(0).setCellValue(i+1);
-            row.createCell(1).setCellValue(dto.getName());
-            row.createCell(2).setCellValue(dto.getValue().toString());
+            row.createCell(1).setCellValue(account.getCustomerName());
+            row.createCell(2).setCellValue(account.getTotalAmount().toString());
 
             rowNum++;
         }
@@ -119,7 +124,7 @@ public class ReportController {
         ByteArrayOutputStream output = new ByteArrayOutputStream();
         wb.write(output);
         String fileName = title + "(" + sdf.format(new Date()) + ").xls";
-        String name = "D:\\" + fileName;
+        String name = "D:\\JpSoft\\Tomcat 8.5\\webapps\\printing-portal\\xls\\" + fileName;
         File file = new File(name);
         FileOutputStream file1 = new FileOutputStream(file);
         wb.write(file1);
@@ -128,7 +133,38 @@ public class ReportController {
         output.close();
 
         msgResult.setResult(true);
-        msgResult.setData(name);
+        msgResult.setMessage("报表生成完成。");
+        msgResult.setData("/printing-portal/xls/" + fileName);
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="交易报表-老板")
+    @RequestMapping(value = "transactionReportBoss",method = RequestMethod.POST)
+    public MessageResult transactionReportBoss(String startDay, String endDay){
+        MessageResult msgResult = new MessageResult<>();
+
+        List<Account> list = accountService.findTransactionList(0, startDay, endDay, "b.name_ ASC", null);
+        for(Account account : list){
+            account.setTotalAmount(account.getTotalAmount().negate());
+
+            Customer customer = customerService.get(account.getCustomerId());
+            if(customer != null) {
+                String allName = "";
+                if (StringUtils.isNotEmpty(customer.getCompany())) {
+                    allName = customer.getName() + "(" + customer.getCompany() + ")";
+                } else {
+                    allName = customer.getName();
+                }
+                account.setCustomerName(allName);
+            }
+            else {
+                account.setCustomerName(null);
+            }
+        }
+
+        msgResult.setResult(true);
+        msgResult.setData(list);
 
         return msgResult;
     }

+ 8 - 7
web/src/main/java/com/jpsoft/printing/modules/base/controller/AccountController.java

@@ -179,14 +179,15 @@ public class AccountController {
         Page<Account> page = accountService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
         for(Account account : page.getResult()) {
             Customer customer = customerService.get(account.getCustomerId());
-            String allName = "";
-            if(StringUtils.isNotEmpty(customer.getCompany())){
-                allName = customer.getName() + "(" + customer.getCompany() + ")";
-            }
-            else{
-                allName = customer.getName();
+            if(customer != null) {
+                String allName = "";
+                if (StringUtils.isNotEmpty(customer.getCompany())) {
+                    allName = customer.getName() + "(" + customer.getCompany() + ")";
+                } else {
+                    allName = customer.getName();
+                }
+                account.setCustomerName(allName);
             }
-            account.setCustomerName(allName);
         }
 
         msgResult.setResult(true);

+ 2 - 2
web/src/main/resources/application-dev.yml

@@ -5,9 +5,9 @@ server:
 
 spring:
   datasource:
-    url: jdbc:log4jdbc:mysql://192.168.77.122:3306/printing?useSSL=false&autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+    url: jdbc:log4jdbc:mysql://47.92.161.104:3336/printing?useSSL=false&autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
     username: root
-    password: 123456
+    password: jpsoft8121234
 
 logger:
   level: WARN

+ 4 - 3
web/src/main/resources/application-production.yml

@@ -1,11 +1,12 @@
 spring:
   datasource:
-    url: jdbc:log4jdbc:mysql://47.92.161.104:3336/printing?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+    url: jdbc:log4jdbc:mysql://192.168.77.111:3306/printing?useSSL=false&autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
     username: root
-    password: jpsoft8121234
+    password: jpsoft2023
   devtools:
     restart:
       enabled: true
+
 logger:
   level: WARN
-  dir: C:\JPsoft\Logs\insurance-server
+  dir: D:\Logs\printing-server