|
@@ -4,11 +4,13 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.TimeUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.service.ICompanyUserService;
|
|
|
+import com.fs.framework.security.LoginUser;
|
|
|
import com.fs.framework.service.TokenService;
|
|
|
import com.fs.hisStore.param.FsStoreStatisticsParam;
|
|
|
import com.fs.hisStore.service.IFsStoreOrderScrmService;
|
|
@@ -36,8 +38,7 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/store/store/statistics")
|
|
|
-public class FsStoreStatisticsScrmController extends BaseController
|
|
|
-{
|
|
|
+public class FsStoreStatisticsScrmController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private ICompanyUserService userService;
|
|
@@ -48,29 +49,28 @@ public class FsStoreStatisticsScrmController extends BaseController
|
|
|
private IFsStorePaymentScrmService storePaymentService;
|
|
|
@Autowired
|
|
|
private TokenService tokenService;
|
|
|
+
|
|
|
@PreAuthorize("@ss.hasPermi('store:statistics:storeOrder')")
|
|
|
@GetMapping("/storeOrder")
|
|
|
@Deprecated
|
|
|
- public R storeOrder(FsStoreStatisticsParam param)
|
|
|
- {
|
|
|
- if(StringUtils.isNotEmpty(param.getUserIds())){
|
|
|
- String[] userIds=param.getUserIds().split(",");
|
|
|
- Long[] ids=new Long[userIds.length];
|
|
|
- for(int i=0;i<ids.length; i++){
|
|
|
- ids[i]=Long.parseLong(userIds[i]);
|
|
|
+ public R storeOrder(FsStoreStatisticsParam param) {
|
|
|
+ if (StringUtils.isNotEmpty(param.getUserIds())) {
|
|
|
+ String[] userIds = param.getUserIds().split(",");
|
|
|
+ Long[] ids = new Long[userIds.length];
|
|
|
+ for (int i = 0; i < ids.length; i++) {
|
|
|
+ ids[i] = Long.parseLong(userIds[i]);
|
|
|
}
|
|
|
param.setUsers(ids);
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
//获取部门下的所有用户
|
|
|
- CompanyUser usermap=new CompanyUser();
|
|
|
+ CompanyUser usermap = new CompanyUser();
|
|
|
usermap.setDeptId(param.getDeptId());
|
|
|
List<CompanyUser> users = userService.getUserListByDeptId(usermap);
|
|
|
List<Long> userIds = users.stream().map(element -> element.getUserId()).collect(Collectors.toList());
|
|
|
param.setUsers(userIds.toArray(new Long[userIds.size()]));
|
|
|
}
|
|
|
- if(param.getUsers()!=null&¶m.getUsers().length>0){
|
|
|
- TimeUtils.TimeEntity timeEntity=TimeUtils.parseTime(param.getType()==null?null:param.getType().toString(),param.getStartTime(),param.getEndTime());
|
|
|
+ if (param.getUsers() != null && param.getUsers().length > 0) {
|
|
|
+ TimeUtils.TimeEntity timeEntity = TimeUtils.parseTime(param.getType() == null ? null : param.getType().toString(), param.getStartTime(), param.getEndTime());
|
|
|
timeEntity.setUserIds(param.getUsers());
|
|
|
Integer cycleNum = timeEntity.getCycleNum();
|
|
|
Integer beginTime = timeEntity.getBeginTime();
|
|
@@ -80,17 +80,16 @@ public class FsStoreStatisticsScrmController extends BaseController
|
|
|
beginTime = TimeUtils.formatTime(beginTime);
|
|
|
}
|
|
|
Map<String, Object> map = timeEntity.toMap();
|
|
|
- map.put("orderType",param.getOrderType());
|
|
|
- map.put("orderMedium",param.getOrderMedium());
|
|
|
+ map.put("orderType", param.getOrderType());
|
|
|
+ map.put("orderMedium", param.getOrderMedium());
|
|
|
List<JSONObject> jsonObjectList = storeOrderService.selectFsStoreOrderCounts(map);
|
|
|
List<String> dates = jsonObjectList.stream().map(jsonObject -> jsonObject.getString("type")).collect(Collectors.toList());
|
|
|
List<Integer> orderCount = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("orderCount")).collect(Collectors.toList());
|
|
|
List<Integer> payPrice = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("payPrice")).collect(Collectors.toList());
|
|
|
//表格数据
|
|
|
- List<FsStoreOrderCountsVO> tableData = storeOrderService.selectFsStoreOrderCountsByDept(map,param.getDeptId());
|
|
|
- return R.ok().put("dates",dates).put("orderCount",orderCount).put("payPrice",payPrice).put("tableData",tableData);
|
|
|
- }
|
|
|
- else {
|
|
|
+ List<FsStoreOrderCountsVO> tableData = storeOrderService.selectFsStoreOrderCountsByDept(map, param.getDeptId());
|
|
|
+ return R.ok().put("dates", dates).put("orderCount", orderCount).put("payPrice", payPrice).put("tableData", tableData);
|
|
|
+ } else {
|
|
|
return R.ok("未查找到数据");
|
|
|
}
|
|
|
}
|
|
@@ -104,20 +103,24 @@ public class FsStoreStatisticsScrmController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('store:statistics:storeOrder')")
|
|
|
@GetMapping("/storeOrderStatistics")
|
|
|
- public R storeOrderStatistics(FsStoreStatisticsParam param)
|
|
|
- {
|
|
|
+ public R storeOrderStatistics(FsStoreStatisticsParam param) {
|
|
|
|
|
|
- TimeUtils.TimeEntity timeEntity=TimeUtils.parseTimeTwo(param.getType()==null?null:param.getType().toString(),param.getStartTime(),param.getEndTime());
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+
|
|
|
+
|
|
|
+ TimeUtils.TimeEntity timeEntity = TimeUtils.parseTimeTwo(param.getType() == null ? null : param.getType().toString(), param.getStartTime(), param.getEndTime());
|
|
|
// 判断 员工是否为空
|
|
|
timeEntity.setCompanyUserId(param.getCompanyUserId());
|
|
|
timeEntity.setCompanyId(param.getCompanyId());
|
|
|
timeEntity.setDeptId(param.getDeptId());
|
|
|
timeEntity.setOrderType(param.getOrderType());
|
|
|
timeEntity.setOrderMedium(param.getOrderMedium());
|
|
|
+ timeEntity.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
+
|
|
|
+ Map<String, Object> map = timeEntity.toMap();
|
|
|
+ map.put("queryType", param.getQueryType());
|
|
|
+ map.put("amountType", param.getAmountType());
|
|
|
|
|
|
- Map<String,Object> map = timeEntity.toMap();
|
|
|
- map.put("queryType",param.getQueryType());
|
|
|
- map.put("amountType",param.getAmountType());
|
|
|
|
|
|
// 公司汇总
|
|
|
List<FsStoreOrderCountsVO> companyTableData = storeOrderService.selectFsStoreOrderGroupByCompanyId(map);
|
|
@@ -128,32 +131,51 @@ public class FsStoreStatisticsScrmController extends BaseController
|
|
|
// 按员工汇总
|
|
|
List<FsStoreOrderCountsVO> userTableData = storeOrderService.selectFsStoreOrderGroupByUserId(map);
|
|
|
|
|
|
- return R.ok().put("companyTableData",companyTableData).put("deptTableData",deptTableData).put("userTableData",userTableData);
|
|
|
+ // 统计图需要
|
|
|
+ TimeUtils.TimeEntity timeEntityView = TimeUtils.parseTime(param.getType() == null ? null : param.getType().toString(), param.getStartTime(), param.getEndTime());
|
|
|
+ timeEntityView.setCompanyUserId(param.getCompanyUserId());
|
|
|
+ timeEntityView.setCompanyId(param.getCompanyId());
|
|
|
+ timeEntityView.setDeptId(param.getDeptId());
|
|
|
+ timeEntityView.setOrderType(param.getOrderType());
|
|
|
+ timeEntityView.setOrderMedium(param.getOrderMedium());
|
|
|
+ timeEntityView.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
+
|
|
|
+ Map<String, Object> mapView = timeEntity.toMap();
|
|
|
+ mapView.put("queryType", param.getQueryType());
|
|
|
+ mapView.put("amountType", param.getAmountType());
|
|
|
+ // 统计图返回值
|
|
|
+ List<JSONObject> jsonObjectList = storeOrderService.selectFsStoreOrderCountsView(mapView);
|
|
|
+
|
|
|
+
|
|
|
+ List<String> dates = jsonObjectList.stream().map(jsonObject -> jsonObject.getString("type")).collect(Collectors.toList());
|
|
|
+ List<Integer> orderCount = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("orderCount")).collect(Collectors.toList());
|
|
|
+ List<Integer> payPrice = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("payPrice")).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ return R.ok().put("dates", dates).put("orderCount", orderCount).put("payPrice", payPrice).put("companyTableData", companyTableData).put("deptTableData", deptTableData).put("userTableData", userTableData);
|
|
|
}
|
|
|
|
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('store:statistics:storeProduct')")
|
|
|
@GetMapping("/storeProduct")
|
|
|
- public R storeProduct(FsStoreStatisticsParam param)
|
|
|
- {
|
|
|
- if(StringUtils.isNotEmpty(param.getUserIds())){
|
|
|
- String[] userIds=param.getUserIds().split(",");
|
|
|
- Long[] ids=new Long[userIds.length];
|
|
|
- for(int i=0;i<ids.length; i++){
|
|
|
- ids[i]=Long.parseLong(userIds[i]);
|
|
|
+ public R storeProduct(FsStoreStatisticsParam param) {
|
|
|
+ if (StringUtils.isNotEmpty(param.getUserIds())) {
|
|
|
+ String[] userIds = param.getUserIds().split(",");
|
|
|
+ Long[] ids = new Long[userIds.length];
|
|
|
+ for (int i = 0; i < ids.length; i++) {
|
|
|
+ ids[i] = Long.parseLong(userIds[i]);
|
|
|
}
|
|
|
param.setUsers(ids);
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
//获取部门下的所有用户
|
|
|
- CompanyUser usermap=new CompanyUser();
|
|
|
+ CompanyUser usermap = new CompanyUser();
|
|
|
usermap.setDeptId(param.getDeptId());
|
|
|
List<CompanyUser> users = userService.getUserListByDeptId(usermap);
|
|
|
List<Long> userIds = users.stream().map(element -> element.getUserId()).collect(Collectors.toList());
|
|
|
param.setUsers(userIds.toArray(new Long[userIds.size()]));
|
|
|
}
|
|
|
- if(param.getUsers()!=null&¶m.getUsers().length>0){
|
|
|
- TimeUtils.TimeEntity timeEntity=TimeUtils.parseTime(param.getType()==null?null:param.getType().toString(),param.getStartTime(),param.getEndTime());
|
|
|
+ if (param.getUsers() != null && param.getUsers().length > 0) {
|
|
|
+ TimeUtils.TimeEntity timeEntity = TimeUtils.parseTime(param.getType() == null ? null : param.getType().toString(), param.getStartTime(), param.getEndTime());
|
|
|
timeEntity.setUserIds(param.getUsers());
|
|
|
Integer cycleNum = timeEntity.getCycleNum();
|
|
|
Integer beginTime = timeEntity.getBeginTime();
|
|
@@ -167,35 +189,33 @@ public class FsStoreStatisticsScrmController extends BaseController
|
|
|
List<Integer> orderCount = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("orderCount")).collect(Collectors.toList());
|
|
|
List<Integer> payPrice = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("payPrice")).collect(Collectors.toList());
|
|
|
//表格数据
|
|
|
- List<FsStoreProductCountsVO> tableData = storeOrderService.selectFsStoreProductCountsByDept(timeEntity.toMap(),param.getDeptId());
|
|
|
- return R.ok().put("dates",dates).put("orderCount",orderCount).put("payPrice",payPrice).put("tableData",tableData);
|
|
|
- }
|
|
|
- else {
|
|
|
+ List<FsStoreProductCountsVO> tableData = storeOrderService.selectFsStoreProductCountsByDept(timeEntity.toMap(), param.getDeptId());
|
|
|
+ return R.ok().put("dates", dates).put("orderCount", orderCount).put("payPrice", payPrice).put("tableData", tableData);
|
|
|
+ } else {
|
|
|
return R.ok("未查找到数据");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@PreAuthorize("@ss.hasPermi('store:statistics:exportStoreOrder')")
|
|
|
@GetMapping("/exportStoreOrder")
|
|
|
- public AjaxResult exportStoreOrder(FsStoreStatisticsParam param)
|
|
|
- {
|
|
|
- if(StringUtils.isNotEmpty(param.getUserIds())){
|
|
|
- String[] userIds=param.getUserIds().split(",");
|
|
|
- Long[] ids=new Long[userIds.length];
|
|
|
- for(int i=0;i<ids.length; i++){
|
|
|
- ids[i]=Long.parseLong(userIds[i]);
|
|
|
+ public AjaxResult exportStoreOrder(FsStoreStatisticsParam param) {
|
|
|
+ if (StringUtils.isNotEmpty(param.getUserIds())) {
|
|
|
+ String[] userIds = param.getUserIds().split(",");
|
|
|
+ Long[] ids = new Long[userIds.length];
|
|
|
+ for (int i = 0; i < ids.length; i++) {
|
|
|
+ ids[i] = Long.parseLong(userIds[i]);
|
|
|
}
|
|
|
param.setUsers(ids);
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
//获取所有员工
|
|
|
- CompanyUser usermap=new CompanyUser();
|
|
|
+ CompanyUser usermap = new CompanyUser();
|
|
|
usermap.setDeptId(param.getDeptId());
|
|
|
List<CompanyUser> users = userService.getUserListByDeptId(usermap);
|
|
|
List<Long> userIds = users.stream().map(element -> element.getUserId()).collect(Collectors.toList());
|
|
|
param.setUsers(userIds.toArray(new Long[userIds.size()]));
|
|
|
}
|
|
|
|
|
|
- List<FsStoreOrderStatisticsVO> list= storeOrderService.selectFsStoreOrderStatisticsList(param);
|
|
|
+ List<FsStoreOrderStatisticsVO> list = storeOrderService.selectFsStoreOrderStatisticsList(param);
|
|
|
|
|
|
ExcelUtil<FsStoreOrderStatisticsVO> util = new ExcelUtil<FsStoreOrderStatisticsVO>(FsStoreOrderStatisticsVO.class);
|
|
|
return util.exportExcel(list, "orderLogs");
|
|
@@ -204,27 +224,25 @@ public class FsStoreStatisticsScrmController extends BaseController
|
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('store:statistics:storePayment')")
|
|
|
@GetMapping("/storePayment")
|
|
|
- public R storePayment(FsStoreStatisticsParam param)
|
|
|
- {
|
|
|
- if(StringUtils.isNotEmpty(param.getUserIds())){
|
|
|
- String[] userIds=param.getUserIds().split(",");
|
|
|
- Long[] ids=new Long[userIds.length];
|
|
|
- for(int i=0;i<ids.length; i++){
|
|
|
- ids[i]=Long.parseLong(userIds[i]);
|
|
|
+ public R storePayment(FsStoreStatisticsParam param) {
|
|
|
+ if (StringUtils.isNotEmpty(param.getUserIds())) {
|
|
|
+ String[] userIds = param.getUserIds().split(",");
|
|
|
+ Long[] ids = new Long[userIds.length];
|
|
|
+ for (int i = 0; i < ids.length; i++) {
|
|
|
+ ids[i] = Long.parseLong(userIds[i]);
|
|
|
}
|
|
|
param.setUsers(ids);
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
//获取部门下的所有用户
|
|
|
- CompanyUser usermap=new CompanyUser();
|
|
|
+ CompanyUser usermap = new CompanyUser();
|
|
|
usermap.setDeptId(param.getDeptId());
|
|
|
List<CompanyUser> users = userService.getUserListByDeptId(usermap);
|
|
|
List<Long> userIds = users.stream().map(element -> element.getUserId()).collect(Collectors.toList());
|
|
|
param.setUsers(userIds.toArray(new Long[userIds.size()]));
|
|
|
}
|
|
|
- if(param.getUsers()!=null&¶m.getUsers().length>0){
|
|
|
- List<FsStorePaymentStatisticsVO> list= storePaymentService.selectFsStorePaymentStatisticsList(param);
|
|
|
- TimeUtils.TimeEntity timeEntity=TimeUtils.parseTime(param.getType().toString(),param.getStartTime(),param.getEndTime());
|
|
|
+ if (param.getUsers() != null && param.getUsers().length > 0) {
|
|
|
+ List<FsStorePaymentStatisticsVO> list = storePaymentService.selectFsStorePaymentStatisticsList(param);
|
|
|
+ TimeUtils.TimeEntity timeEntity = TimeUtils.parseTime(param.getType().toString(), param.getStartTime(), param.getEndTime());
|
|
|
timeEntity.setUserIds(param.getUsers());
|
|
|
Integer cycleNum = timeEntity.getCycleNum();
|
|
|
Integer beginTime = timeEntity.getBeginTime();
|
|
@@ -237,40 +255,36 @@ public class FsStoreStatisticsScrmController extends BaseController
|
|
|
List<String> dates = jsonObjectList.stream().map(jsonObject -> jsonObject.getString("type")).collect(Collectors.toList());
|
|
|
List<Integer> orderCount = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("orderCount")).collect(Collectors.toList());
|
|
|
List<Integer> payMoney = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("payMoney")).collect(Collectors.toList());
|
|
|
- return R.ok().put("list",list).put("dates",dates).put("orderCount",orderCount).put("payMoney",payMoney);
|
|
|
- }
|
|
|
- else {
|
|
|
+ return R.ok().put("list", list).put("dates", dates).put("orderCount", orderCount).put("payMoney", payMoney);
|
|
|
+ } else {
|
|
|
return R.ok("未查找到数据");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@PreAuthorize("@ss.hasPermi('store:statistics:exportStorePayment')")
|
|
|
@GetMapping("/exportStorePayment")
|
|
|
- public AjaxResult exportStorePayment(FsStoreStatisticsParam param)
|
|
|
- {
|
|
|
- if(StringUtils.isNotEmpty(param.getUserIds())){
|
|
|
- String[] userIds=param.getUserIds().split(",");
|
|
|
- Long[] ids=new Long[userIds.length];
|
|
|
- for(int i=0;i<ids.length; i++){
|
|
|
- ids[i]=Long.parseLong(userIds[i]);
|
|
|
+ public AjaxResult exportStorePayment(FsStoreStatisticsParam param) {
|
|
|
+ if (StringUtils.isNotEmpty(param.getUserIds())) {
|
|
|
+ String[] userIds = param.getUserIds().split(",");
|
|
|
+ Long[] ids = new Long[userIds.length];
|
|
|
+ for (int i = 0; i < ids.length; i++) {
|
|
|
+ ids[i] = Long.parseLong(userIds[i]);
|
|
|
}
|
|
|
param.setUsers(ids);
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
//获取所有员工
|
|
|
- CompanyUser usermap=new CompanyUser();
|
|
|
+ CompanyUser usermap = new CompanyUser();
|
|
|
usermap.setDeptId(param.getDeptId());
|
|
|
List<CompanyUser> users = userService.getUserListByDeptId(usermap);
|
|
|
List<Long> userIds = users.stream().map(element -> element.getUserId()).collect(Collectors.toList());
|
|
|
param.setUsers(userIds.toArray(new Long[userIds.size()]));
|
|
|
}
|
|
|
|
|
|
- List<FsStorePaymentStatisticsVO> list= storePaymentService.selectFsStorePaymentStatisticsList(param);
|
|
|
+ List<FsStorePaymentStatisticsVO> list = storePaymentService.selectFsStorePaymentStatisticsList(param);
|
|
|
|
|
|
ExcelUtil<FsStorePaymentStatisticsVO> util = new ExcelUtil<FsStorePaymentStatisticsVO>(FsStorePaymentStatisticsVO.class);
|
|
|
return util.exportExcel(list, "paymentLogs");
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|