Browse Source

customer report

master
Anna Ho 3 years ago
parent
commit
d9a32c2d9e
6 changed files with 111 additions and 43 deletions
  1. +1
    -1
      src/main/java/com/ffii/tbms/api/service/CustomerApiService.java
  2. +46
    -9
      src/main/java/com/ffii/tbms/reports/service/CustomerReportService.java
  3. +14
    -5
      src/main/java/com/ffii/tbms/reports/web/CustomerReportController.java
  4. +5
    -16
      src/main/webapp/resources/js/store/ReportStore.js
  5. +0
    -1
      src/main/webapp/resources/js/view/Order/OrderForm.js
  6. +45
    -11
      src/main/webapp/resources/js/view/Report/Report_CustomerContainer.js

+ 1
- 1
src/main/java/com/ffii/tbms/api/service/CustomerApiService.java View File

@@ -83,7 +83,7 @@ public class CustomerApiService extends AbstractService {
} }
} }


sql.append(" ORDER BY ( 0 ");
sql.append(" ORDER BY ( 0+0 ");


if (args != null) { if (args != null) {
if (args.containsKey("searchStr")){ if (args.containsKey("searchStr")){


+ 46
- 9
src/main/java/com/ffii/tbms/reports/service/CustomerReportService.java View File

@@ -10,19 +10,18 @@
******************************************************************************/ ******************************************************************************/
package com.ffii.tbms.reports.service; package com.ffii.tbms.reports.service;


import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;


import com.ffii.core.dao.JdbcDao;
import com.ffii.core.utils.SecurityUtils;
import com.ffii.core.web.AbstractService;

import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;


import com.ffii.core.dao.JdbcDao;
import com.ffii.core.utils.SecurityUtils;
import com.ffii.core.web.AbstractService;



@Service @Service
public class CustomerReportService extends AbstractService { public class CustomerReportService extends AbstractService {
@@ -37,8 +36,8 @@ public class CustomerReportService extends AbstractService {


StringBuilder sql = new StringBuilder( " SELECT " StringBuilder sql = new StringBuilder( " SELECT "
+ " c.created, " + " c.created, "
+" CONCAT(IF(c.firstName IS NULL, '', CONCAT(c.firstName, ' ')), "
+" IF(c.surname IS NULL, '', CONCAT(c.surname, ' '))) AS customerName, "
+ " CONCAT(IF(c.firstName IS NULL, '', CONCAT(c.firstName, ' ')), "
+ " IF(c.surname IS NULL, '', CONCAT(c.surname, ' '))) AS customerName, "
+ " c.nameCh, " + " c.nameCh, "
+ " c.phone1, " + " c.phone1, "
+ " c.phone2, " + " c.phone2, "
@@ -66,10 +65,48 @@ public class CustomerReportService extends AbstractService {
if(args != null){ if(args != null){
if(args.containsKey("sysGroupId")) if(args.containsKey("sysGroupId"))
sql.append(" AND c.sysGroupId = :sysGroupId "); sql.append(" AND c.sysGroupId = :sysGroupId ");

if(args.containsKey("customerName")){
String str = args.get("customerName").toString();
String[] array = str.split(" ");
str = "";
for(int i = 0; i<array.length; i++){
str += " AND ( c.surname LIKE '"+array[i]+"%' ";
str += " OR c.nameCh LIKE '"+array[i]+"%' ";
str += " OR c.firstName LIKE '"+array[i]+"%' ) ";
}
sql.append(str);
}
if(args.containsKey("email"))
sql.append(" AND (c.email LIKE :email) ");
if(args.containsKey("address"))
sql.append(" AND (c.address LIKE :address) ");
if(args.containsKey("remarks"))
sql.append(" AND (c.remarks LIKE :remarks) ");
if(args.containsKey("dateFrom"))
sql.append(" AND (c.created > :dateFrom) ");
if(args.containsKey("dateTo"))
sql.append(" AND (c.created < :dateTo) ");
}

sql.append(" GROUP BY c.id HAVING 1=1 ");
if(args != null){
if(args.containsKey("amountFrom"))
sql.append(" AND (orderAmount >= :amountFrom) ");
if(args.containsKey("amountTo"))
sql.append(" AND (orderAmount <= :amountTo) ");
} }


sql.append(" GROUP BY c.id "
+ " ORDER BY c.created ");
sql.append(" ORDER BY (0+0 ");
if (args != null) {
if (args.containsKey("customerName")){
sql.append(" + IF( c.surname = :customerName,1,0) + IF( c.surname LIKE '"+args.get("customerName")+"%',1,0) ");
sql.append(" + IF( c.firstName = :customerName,1,0) + IF( c.firstName LIKE '"+args.get("customerName")+"%',1,0) ");
sql.append(" + IF( c.nameCh = :customerName,1,0) + IF( c.nameCh LIKE '"+args.get("customerName")+"%',1,0) ");
}
}
sql.append(" ) DESC, c.created ");
return jdbcDao.queryForList(sql.toString(), args); return jdbcDao.queryForList(sql.toString(), args);
} }


+ 14
- 5
src/main/java/com/ffii/tbms/reports/web/CustomerReportController.java View File

@@ -51,6 +51,13 @@ public class CustomerReportController extends AbstractController {
Map<String, Object> args = new HashMap<String, Object>(); Map<String, Object> args = new HashMap<String, Object>();
CriteriaUtils.addDate(request, args, "dateFrom"); CriteriaUtils.addDate(request, args, "dateFrom");
CriteriaUtils.addDateTo(request, args, "dateTo"); CriteriaUtils.addDateTo(request, args, "dateTo");
CriteriaUtils.addStringLike(request, args, "customerName");
CriteriaUtils.addStringLike(request, args, "phone");
CriteriaUtils.addStringLike(request, args, "email");
CriteriaUtils.addStringLike(request, args, "address");
CriteriaUtils.addStringLike(request, args, "remarks");
CriteriaUtils.addInteger(request, args, "amountFrom");
CriteriaUtils.addInteger(request, args, "amountTo");


List<Map<String, Object>> records = service.search(args); List<Map<String, Object>> records = service.search(args);


@@ -70,14 +77,16 @@ public class CustomerReportController extends AbstractController {
Map<String, Object> args = new HashMap<String, Object>(); Map<String, Object> args = new HashMap<String, Object>();
CriteriaUtils.addDate(request, args, "dateFrom"); CriteriaUtils.addDate(request, args, "dateFrom");
CriteriaUtils.addDateTo(request, args, "dateTo"); CriteriaUtils.addDateTo(request, args, "dateTo");

//CriteriaUtils.addInteger(request, args, "start");
//CriteriaUtils.addInteger(request, args, "limit");
CriteriaUtils.addString(request, args, "customerName");
CriteriaUtils.addStringLike(request, args, "phone");
CriteriaUtils.addStringLike(request, args, "email");
CriteriaUtils.addStringLike(request, args, "address");
CriteriaUtils.addStringLike(request, args, "remarks");
CriteriaUtils.addInteger(request, args, "amountFrom");
CriteriaUtils.addInteger(request, args, "amountTo");


List<Map<String, Object>> records = service.search(args); List<Map<String, Object>> records = service.search(args);


//Map<String, Object> count = service.count(args);
//model.addAttribute("total", NumberUtils.intValue(count.get("count")));
model.addAttribute(Params.RECORDS, records); model.addAttribute(Params.RECORDS, records);
model.addAttribute(Params.SUCCESS, Boolean.TRUE); model.addAttribute(Params.SUCCESS, Boolean.TRUE);




+ 5
- 16
src/main/webapp/resources/js/store/ReportStore.js View File

@@ -144,21 +144,7 @@ Ext.define('App.store.Report_OrderStore', {
idProperty: 'orderId' idProperty: 'orderId'
} }
}, },
reader: new Ext.data.JsonReader({}, [
{name: 'orderId'},
{name: 'date' },
{name: 'code'},
{name: 'orderNo'},
{name: 'customerName'},
{name: 'status'},
{name: 'remarks'},
{name: 'status'},
{name: 'item'},
{name: 'orderAmount'},
{name: 'outstanding'},
{name: 'paymentAmount'},
]),
/*
fields: [ fields: [
{ {
name: 'orderId', name: 'orderId',
@@ -209,7 +195,6 @@ Ext.define('App.store.Report_OrderStore', {
type: 'string' type: 'string'
}, },
], ],
*/
}, },
cfg)]); cfg)]);
} }
@@ -241,6 +226,10 @@ Ext.define('App.store.Report_CustomerStore', {
{ {
name: "created", name: "created",
type: 'date', type: 'date',
convert: function (value) {
var d = new Date(value);
return Ext.util.Format.date(d, 'Y/m/d')
},
}, },
{ {
name: "customerName", name: "customerName",


+ 0
- 1
src/main/webapp/resources/js/view/Order/OrderForm.js View File

@@ -186,7 +186,6 @@ Ext.define("App.view.OrderForm", {
field.isPressing = true; field.isPressing = true;
} }
} }
},{ },{
xtype: 'label', xtype: 'label',
html: '<i class="fas fa-spinner fa-pulse" style="color:white"></i>', html: '<i class="fas fa-spinner fa-pulse" style="color:white"></i>',


+ 45
- 11
src/main/webapp/resources/js/view/Report/Report_CustomerContainer.js View File

@@ -5,6 +5,7 @@ Ext.define('App.view.Report_CustomerContainer', {
focusable:true, focusable:true,
layout: 'vbox', layout: 'vbox',



defaults: { defaults: {
width: '100%', width: '100%',
margin: '2 4 2 4' margin: '2 4 2 4'
@@ -62,17 +63,48 @@ Ext.define('App.view.Report_CustomerContainer', {
{ {
xtype: 'datefield', xtype: 'datefield',
fieldLabel: App.localeRes('Date From'), fieldLabel: App.localeRes('Date From'),
allowBlank: false,
name: 'dateFrom', name: 'dateFrom',
value: firstDay
}, },
{ {
xtype: 'datefield', xtype: 'datefield',
fieldLabel: App.localeRes('Date To'), fieldLabel: App.localeRes('Date To'),
allowBlank: false,
name: 'dateTo', name: 'dateTo',
value: lastDay
}
},
{
xtype: 'textfield',
fieldLabel: App.localeRes('Customer Name'),
name: 'customerName',
},
{
xtype: 'textfield',
fieldLabel: App.localeRes('Phone'),
name: 'phone',
},
{
xtype: 'textfield',
fieldLabel: App.localeRes('Email'),
name: 'email',
},
{
xtype: 'textfield',
fieldLabel: App.localeRes('Address'),
name: 'address',
},
{
xtype: 'textfield',
fieldLabel: App.localeRes('Remarks'),
name: 'remarks',
},
{
xtype: 'numberfield',
fieldLabel: App.localeRes('Amount From'),
name: 'amountFrom',
},
{
xtype: 'numberfield',
fieldLabel: App.localeRes('Amount To'),
name: 'amountTo',
},
] ]
} }
], ],
@@ -132,6 +164,9 @@ Ext.define('App.view.Report_CustomerGrid', {
scrollable: { scrollable: {
alwaysShow: true alwaysShow: true
}, },
viewConfig : {
enableTextSelection: true,
},


reloadStore: function() { reloadStore: function() {
var me = this; var me = this;
@@ -142,10 +177,6 @@ Ext.define('App.view.Report_CustomerGrid', {
initComponent: function() { initComponent: function() {
var me = this; var me = this;
Ext.apply(me, { Ext.apply(me, {
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true
},
store: Ext.create('App.store.Report_CustomerStore', {}), store: Ext.create('App.store.Report_CustomerStore', {}),
columns: [ columns: [
{ {
@@ -153,15 +184,16 @@ Ext.define('App.view.Report_CustomerGrid', {
width: 80 width: 80
}, },
{ {
xtype: 'datecolumn',
xtype: 'gridcolumn',
dataIndex: 'created', dataIndex: 'created',
text: App.localeRes('Creation Date'), text: App.localeRes('Creation Date'),
flex: 1
format: 'Y-m-d'
}, },
{ {
xtype: 'gridcolumn', xtype: 'gridcolumn',
dataIndex: 'customerName', dataIndex: 'customerName',
text: App.localeRes('Customer (Eng)'), text: App.localeRes('Customer (Eng)'),
width: 150,
}, },
{ {
xtype: 'gridcolumn', xtype: 'gridcolumn',
@@ -182,11 +214,13 @@ Ext.define('App.view.Report_CustomerGrid', {
xtype: 'gridcolumn', xtype: 'gridcolumn',
dataIndex: 'email', dataIndex: 'email',
text: App.localeRes('Email'), text: App.localeRes('Email'),
width: 150,
}, },
{ {
xtype: 'gridcolumn', xtype: 'gridcolumn',
dataIndex: 'address', dataIndex: 'address',
text: App.localeRes('Address'), text: App.localeRes('Address'),
width: 150,
}, },
{ {
xtype: 'gridcolumn', xtype: 'gridcolumn',


Loading…
Cancel
Save