Commit ae04e21e by duanhq

技工统计 by duanht 2019/2/23

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@17688 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent fccba0ef
......@@ -32,6 +32,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.groups.Default;
import com.glsx.ordercenter.dto.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
......@@ -49,13 +50,6 @@ import com.glsx.common.utils.UserUtils;
import com.glsx.ordercenter.constants.BizConstants;
import com.glsx.ordercenter.constants.OrderTypeEnum;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.BizAmountResp;
import com.glsx.ordercenter.dto.MechanicStatistics;
import com.glsx.ordercenter.dto.OrderActivateReq;
import com.glsx.ordercenter.dto.OrderRepairReq;
import com.glsx.ordercenter.dto.OrderStastic;
import com.glsx.ordercenter.dto.QueryOrderReq;
import com.glsx.ordercenter.dto.ServiceItemScale;
import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.ordercenter.pojo.SysOrderExample;
import com.glsx.ordercenter.pojo.SysOrderStatus;
......@@ -296,20 +290,37 @@ public class OrderController extends BaseController {
* @return String
* @author duanht
* @Title: getMechanicStatistics
*/
@RequestMapping(value = "/getMechanicStatistics", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject getMechanicStatistics(HttpServletRequest request, String selectType, String dateStart,
String dateEnd, @RequestParam(defaultValue = "1") int pageIndex,
@RequestParam(defaultValue = "10") int pageSize) {
Map<String, Object> result = new HashMap<String, Object>();
Page page = new Page(pageIndex, pageSize);
int userId = UserUtils.getUserId(request);
MechanicStatistics mechanicStatistics = orderService.getMechanicStatistics(page, selectType, dateStart, dateEnd,
userId);
result.put("page", page);
result.put("items", mechanicStatistics);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
*/
@SuppressWarnings("resource")
@RequestMapping(value = "/getMechanicStatistics", method = {RequestMethod.GET, RequestMethod.POST})
public ResultObject getMechanicStatistics(HttpServletRequest request, String selectType, String dateStart, String dateEnd,
@RequestParam(defaultValue = "1")
int pageIndex,
@RequestParam(defaultValue = "10")
int pageSize)
{
Map<String, Object> result = new HashMap<String, Object>();
MechanicStatistics mechanicStatistics = new MechanicStatistics();
Page page = new Page(pageIndex, pageSize);
int userId = UserUtils.getUserId(request);
List<MechanicBusiness> mechanicBusinessList = orderService.getMechanicBusiness(page, selectType, dateStart, dateEnd, userId);
//技工总数
mechanicStatistics.setMechanicCount(mechanicBusinessList.size());
//平均单量
int count = 0;
for (MechanicBusiness mechanicBusiness : mechanicBusinessList) {
count += mechanicBusiness.getCount();
}
mechanicStatistics.setAvgBusiness(count / mechanicBusinessList.size());
mechanicStatistics.setMechanicBusinessList(mechanicBusinessList);
com.github.pagehelper.Page<MechanicBusiness> pages = (com.github.pagehelper.Page<MechanicBusiness>) mechanicBusinessList;
page.setTotalCount((int) pages.getTotal());
result.put("page", page);
result.put("items", mechanicStatistics);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
/**
* 服务类别占比
......@@ -327,11 +338,11 @@ public class OrderController extends BaseController {
result.put("items", serviceItemScale);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
/**
*
* @author zhanghj
* @Title: getServiceItemScale
*
* @author zhanghj
* @Title: getServiceItemScale
* @Description: TODO 获取某个订单的售后检修列表
* @param request
* @param orderId
......@@ -349,6 +360,6 @@ public class OrderController extends BaseController {
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
}
......@@ -10,12 +10,34 @@ package com.glsx.ordercenter.dto;
*/
public class MechanicBusiness {
/**
*技工id
*/
private Integer mechanicId;
/**
*技工名
*/
private String name;
/**
*技工单量
*/
private Integer count;
/**
*涨幅
*/
private String rise;
public Integer getMechanicId() {
return mechanicId;
}
public void setMechanicId(Integer mechanicId) {
this.mechanicId = mechanicId;
}
public String getName() {
return name;
}
......
......@@ -8,13 +8,19 @@ import java.util.List;
* @version 1.0.0
* @Title MechanicStatistics
* @Package com.glsx.ordercenter.dto
* @Description ${todo}
* @Description 监控台-技工统计
* @date 2019/2/21 20:22
*/
public class MechanicStatistics {
/**
*技工总数
*/
private Integer mechanicCount;
/**
*平均单量
*/
private Integer avgBusiness;
private List<MechanicBusiness> mechanicBusinessList = new ArrayList<>();
......
......@@ -3,12 +3,12 @@ package com.glsx.ordercenter.mapper;
import java.util.List;
import java.util.Map;
import com.glsx.ordercenter.dto.MechanicBusiness;
import com.glsx.ordercenter.dto.QueryOrderReq;
import com.glsx.ordercenter.dto.ServiceItemInfo;
import com.glsx.ordercenter.dto.ShopBizAmount;
import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.ordercenter.pojo.SysOrderExample;
import org.apache.ibatis.annotations.Param;
public interface SysOrderMapper {
......@@ -41,10 +41,14 @@ public interface SysOrderMapper {
List<ServiceItemInfo> getServiceItemScale(@Param("userId")int userId, @Param("dateStart")String dateStart, @Param("dateEnd")String dateEnd);
List<MechanicBusiness> getMechanicBusiness(@Param("userId")int userId, @Param("dateStart")String dateStart, @Param("dateEnd")String dateEnd,@Param("mechanicId")Integer mechanicId);
/**
*
* @author zhanghj
* @Title: getAfterSaleRepairList
*
* @author zhanghj
* @Title: getAfterSaleRepairList
* @Description: TODO 获取某个订单的售后检修列表
* @param orderId
* @return
......
......@@ -100,7 +100,7 @@ public interface IOrderService {
ServiceItemScale getServiceItemScale(int userId, String selectType, String dateStart, String dateEnd);
MechanicStatistics getMechanicStatistics(Page page, String selectType, String dateStart, String dateEnd, int userId);
List<MechanicBusiness> getMechanicBusiness(Page page, String selectType, String dateStart, String dateEnd, int userId);
/**
*
......
......@@ -34,6 +34,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.glsx.ordercenter.dto.*;
import com.glsx.ordercenter.mapper.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -1162,7 +1163,7 @@ public class OrderServiceImpl implements IOrderService {
}
Integer orderId = originalOrder.getId();
/**
* 此单经历过拆除,不能发起售后
*/
......@@ -1233,10 +1234,67 @@ public class OrderServiceImpl implements IOrderService {
@Override
public MechanicStatistics getMechanicStatistics(Page page, String dateType, String dateStart, String dateEnd, int userId) {
public List<MechanicBusiness> getMechanicBusiness(Page page, String selectType, String dateStart, String dateEnd, int userId) {
List<MechanicBusiness> mechanicBusinesses = new ArrayList<>();
Date now = DateUtil.getCurrentDate();
Date nowDate = DateUtil.getCurrentDate();
Integer mechanicId = null;
// “d”,今日;“w”,本周;“m",本月;"y".本年
if (!StringUtils.isEmpty(selectType)) {
dateStart = setStartDate(selectType);
dateEnd = DateUtil.formatDate(now);
}
List<MechanicBusiness> mechanicBusinessList = orderDao.getMechanicBusiness(userId, dateStart, dateEnd,mechanicId);
//1.通过技工id获取姓名 2.计算涨幅
for(MechanicBusiness mechanicBusiness : mechanicBusinessList){
SysUser sysUser = sysUserDao.selectByPrimaryKey(mechanicBusiness.getMechanicId());
mechanicBusiness.setName(sysUser.getName());
mechanicId = sysUser.getId();
if (!StringUtils.isEmpty(selectType)) {
if ("d".equals(selectType)) {
//日涨幅(前天跟昨天比)
//前天
dateStart = DateUtil.formatDateYmd(DateUtil.getOffsetDayDate(nowDate,2));
dateEnd = DateUtil.formatDateYmd(DateUtil.getOffsetDayDate(nowDate,1));
List<MechanicBusiness> beforeSample = orderDao.getMechanicBusiness(userId, dateStart, dateEnd,mechanicId );
//昨天
dateStart = dateEnd;
dateEnd = DateUtil.formatDateYmd(nowDate);
List<MechanicBusiness> sample = orderDao.getMechanicBusiness(userId, dateStart, dateEnd,mechanicId );
mechanicBusiness.setRise(countRise(sample.get(0).getCount(),beforeSample.get(0).getCount()));
} else if ("w".equals(selectType)) {
//周涨幅(上上周跟上周比)
//上周
dateStart = DateUtil.formatDateYmd(DateUtil.getLastWeekMonday(nowDate));
dateEnd = DateUtil.formatDateYmd(DateUtil.getLastWeekSunday(nowDate));
List<MechanicBusiness> beforeSample = orderDao.getMechanicBusiness(userId, dateStart, dateEnd,mechanicId );
//上上周
dateStart =DateUtil.formatDateYmd( DateUtil.getOffsetDayDate(DateUtil.getLastWeekMonday(nowDate),7));
dateEnd = DateUtil.formatDateYmd( DateUtil.getOffsetDayDate(DateUtil.getLastWeekMonday(nowDate),1));
List<MechanicBusiness> sample = orderDao.getMechanicBusiness(userId, dateStart, dateEnd,mechanicId );
mechanicBusiness.setRise(countRise(sample.get(0).getCount(),beforeSample.get(0).getCount()));
} else if ("m".equals(selectType)) {
//月涨幅(上上月跟上月比)
dateStart = DateUtil.formatDateYmd(DateUtil.getLastWeekMonday(now));
dateEnd = DateUtil.formatDateYmd(DateUtil.getLastWeekSunday(now));
List<MechanicBusiness> sample = orderDao.getMechanicBusiness(userId, dateStart, dateEnd,mechanicId );
mechanicBusiness.setRise(countRise(mechanicBusiness.getCount(),sample.get(0).getCount()));
} else if ("y".equals(selectType)) {
//年涨幅(前年跟去年)
dateStart = DateUtil.formatDateYmd(DateUtil.getLastWeekMonday(now));
dateEnd = DateUtil.formatDateYmd(DateUtil.getLastWeekSunday(now));
List<MechanicBusiness> sample = orderDao.getMechanicBusiness(userId, dateStart, dateEnd,mechanicId );
mechanicBusiness.setRise(countRise(mechanicBusiness.getCount(),sample.get(0).getCount()));
}
}else{
//自选时间则默认周涨幅
dateStart = DateUtil.formatDateYmd(DateUtil.getLastWeekMonday(now));
dateEnd = DateUtil.formatDateYmd(DateUtil.getLastWeekSunday(now));
List<MechanicBusiness> sample = orderDao.getMechanicBusiness(userId, dateStart, dateEnd,mechanicId );
}
}
return null;
return mechanicBusinesses;
}
@Override
......@@ -1245,40 +1303,53 @@ public class OrderServiceImpl implements IOrderService {
Date now = DateUtil.getCurrentDate();
// “d”,今日;“w”,本周;“m",本月;"y".本年
if (!StringUtils.isEmpty(selectType)) {
if ("d".equals(selectType)) {
dateStart = DateUtil.formatDateYmd(DateUtil.getStartDateOfCurrentDay(now));
} else if ("w".equals(selectType)) {
dateStart = DateUtil.getMondayOfThisWeek();
} else if ("m".equals(selectType)) {
dateStart = DateUtil.getMonthFirstDay();
} else if ("y".equals(selectType)) {
dateStart = DateUtil.getFirstDayOfYearString(now);
}
dateStart = setStartDate(selectType);
dateEnd = DateUtil.formatDate(now);
}
List<ServiceItemInfo> serviceItemInfoList = orderDao.getServiceItemScale(userId, dateStart, dateEnd);
Integer amount = 0;
//计算总数
for (ServiceItemInfo serviceItemInfo : serviceItemInfoList)
{
for (ServiceItemInfo serviceItemInfo : serviceItemInfoList) {
amount += serviceItemInfo.getCount();
}
//计算占比
for (
ServiceItemInfo serviceItemInfo : serviceItemInfoList)
{
for (ServiceItemInfo serviceItemInfo : serviceItemInfoList) {
float num = (float) (serviceItemInfo.getCount()) / (amount) * 100;
DecimalFormat df = new DecimalFormat("0.0");
serviceItemInfo.setScale(df.format(num));
//根据服务项key获取值
serviceItemInfo.setInstallDeviceType( dictionaryDataMapper.getDictValueByKey(serviceItemInfo.getInstallDeviceType() ) );
serviceItemInfo.setInstallDeviceType(dictionaryDataMapper.getDictValueByKey(serviceItemInfo.getInstallDeviceType()));
}
serviceItemScale.setAmount(amount);
serviceItemScale.setServiceItemInfoList(serviceItemInfoList);
return serviceItemScale;
}
//计算涨幅
private String countRise(Integer nowCount,Integer preCount){
float num = (float) (nowCount- preCount) / (preCount) * 100;
DecimalFormat df = new DecimalFormat("0.0");
return df.format(num);
}
//设置开始时间
private String setStartDate(String selectType) {
Date now = DateUtil.getCurrentDate();
String dateStart = null;
if ("d".equals(selectType)) {
dateStart = DateUtil.formatDateYmd(DateUtil.getStartDateOfCurrentDay(now));
} else if ("w".equals(selectType)) {
dateStart = DateUtil.getMondayOfThisWeek();
} else if ("m".equals(selectType)) {
dateStart = DateUtil.getMonthFirstDay();
} else if ("y".equals(selectType)) {
dateStart = DateUtil.getFirstDayOfYearString(now);
}
return dateStart;
}
@Override
public List<SysOrder> getAfterSaleRepairList(Integer orderId) {
// TODO Auto-generated method stub
......
......@@ -40,10 +40,8 @@
<result column="vin_no_picture" jdbcType="VARCHAR" property="vinNoPicture" />
<result column="install_location_picture" jdbcType="VARCHAR" property="installLocationPicture" />
<result column="complete_time" jdbcType="TIMESTAMP" property="completeTime" />
<result column="reserve_install_time" jdbcType="TIMESTAMP" property="reserveInstallTime" />
<result column="install_remark" jdbcType="VARCHAR" property="installRemark" />
<result column="install_device_type" jdbcType="VARCHAR" property="installDeviceType" />
<result column="after_sale_type" jdbcType="INTEGER" property="afterSaleType" />
<result column="install_device_type" jdbcType="VARCHAR" property="installDeviceType" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
......@@ -83,7 +81,7 @@
expect_install_time, service_type, car_owner, car_owner_phone, cancel_time, active_status_array, merchant_id,
mechanic_id, repair_reason, remark, create_time, update_time, create_by, update_by, device_no,
install_location, overdue_reason, repair_type, car_picture, vin_no_picture, install_location_picture,
complete_time,reserve_install_time,install_remark,install_device_type
complete_time,install_remark,install_device_type
</sql>
<select id="selectByExample" parameterType="com.glsx.ordercenter.pojo.SysOrderExample" resultMap="BaseResultMap">
select
......@@ -250,10 +248,6 @@
<if test="completeTime != null">
complete_time,
</if>
<if test="reserveInstallTime != null">
reserve_install_time,
</if>
<if test="installRemark != null">
install_remark,
</if>
......@@ -497,9 +491,6 @@
<if test="completeTime != null">
complete_time = #{completeTime,jdbcType=TIMESTAMP},
</if>
<if test="reserveInstallTime != null">
reserve_install_time = #{reserveInstallTime,jdbcType=TIMESTAMP},
</if>
<if test="installRemark != null">
install_remark = #{installRemark,jdbcType=VARCHAR},
</if>
......@@ -636,22 +627,43 @@
</if>
GROUP BY install_device_type
</select>
<select id="getMechanicBusiness" resultType="com.glsx.ordercenter.dto.MechanicBusiness">
SELECT
mechanic_id mechanicId,
COUNT(mechanic_id) count
FROM
sys_order
WHERE
order_type = 1
AND active_status = 8
AND merchant_id = #{userId}
<if test="dateStart != null and dateEnd!=null and dateStart !='' and dateEnd !=''">
and sys_order.create_time between #{dateStart,jdbcType=TIMESTAMP} and #{dateEnd,jdbcType=TIMESTAMP}
</if>
<if test="mechanicId != null">
and mechanic_id = #{mechanicId}
</if>
GROUP BY
mechanic_id
ORDER BY count desc
</select>
<select id="getAfterSaleRepairList" resultMap="BaseResultMap">
select
so.id, so.order_sn, so.active_status, so.canceled, so.order_type,
so.shop_id, so.district, so.address , so.contact, so.phone_number,
so.car_brand, so.car_series, so.car_type, so.vin_no, so.car_color,
select
so.id, so.order_sn, so.active_status, so.canceled, so.order_type,
so.shop_id, so.district, so.address , so.contact, so.phone_number,
so.car_brand, so.car_series, so.car_type, so.vin_no, so.car_color,
so.expect_install_time, so.service_type, so.car_owner, so.car_owner_phone,
so.cancel_time, so.active_status_array, so.merchant_id, so.mechanic_id, so.repair_reason,
so.remark, so.create_time, so.update_time, so.create_by, so.update_by,
so.remark, so.create_time, so.update_time, so.create_by, so.update_by,
so.device_no, so.install_location, so.overdue_reason, so.repair_type, so.car_picture,
so.vin_no_picture, so.install_location_picture, so.complete_time, so.install_remark, so.install_device_type,
sor.after_sale_type
from
from
sys_order_repair sor
LEFT JOIN sys_order so on sor.sub_order_id = so.id
where
where
sor.order_id = #{orderId}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!