Commit a7c79c1f by zhengxj

finish 指派/改派技工列表 on 20191012 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@24199 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 3520228a
...@@ -77,7 +77,9 @@ public class AMapUtils { ...@@ -77,7 +77,9 @@ public class AMapUtils {
public static void main2(String[] args) { public static void main2(String[] args) {
// 科兴科学园
GlobalCoordinates source = new GlobalCoordinates(22.573316, 113.975012); GlobalCoordinates source = new GlobalCoordinates(22.573316, 113.975012);
// 西丽新屋村工业大厦
GlobalCoordinates target = new GlobalCoordinates(22.554243, 113.950922); GlobalCoordinates target = new GlobalCoordinates(22.554243, 113.950922);
double meter1 = getDistanceMeter(source, target); double meter1 = getDistanceMeter(source, target);
......
...@@ -808,12 +808,12 @@ public class OrderController extends BaseController { ...@@ -808,12 +808,12 @@ public class OrderController extends BaseController {
@RequestMapping(value = "/getMechanicListBySpId", method = { RequestMethod.GET, RequestMethod.POST }) @RequestMapping(value = "/getMechanicListBySpId", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject getMechanicList(HttpServletRequest request, @RequestParam(required = true) Integer id, public ResultObject getMechanicList(HttpServletRequest request, @RequestParam(required = true) Integer id,
@RequestParam(required = true) Integer merchantId, Integer district, @RequestParam(required = true) Integer merchantId, Integer district,
@RequestParam(required = true, defaultValue = "d") String orderBy) { @RequestParam(required = true, defaultValue = "d") String orderBy, String keyWord) {
// orderBy:c按单量排序,d按距离排序,t按时效排序 // orderBy:c按单量排序,d按距离排序,t按时效排序
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
orderService.getMechanicList(merchantId, district, keyWord, orderBy));
return null;
} }
} }
...@@ -27,5 +27,7 @@ public interface SysMechanicMapper { ...@@ -27,5 +27,7 @@ public interface SysMechanicMapper {
SysMechanic selectByUserId(Integer userId); SysMechanic selectByUserId(Integer userId);
List<MechanicBusiness> getMechanicList(@Param("keyWord") String keyWord); List<MechanicBusiness> getMechanicList(Integer serviceId, String keyWord);
MechanicBusiness getMechanicOrderCountAndTimeliness(@Param("mechanicId") Integer mechanicId);
} }
\ No newline at end of file \ No newline at end of file
...@@ -301,4 +301,7 @@ public interface IOrderService { ...@@ -301,4 +301,7 @@ public interface IOrderService {
Integer recever); Integer recever);
Map<String, Integer> countByOrderStatusAndUserType(QueryOrderReq oueryOrderReq); Map<String, Integer> countByOrderStatusAndUserType(QueryOrderReq oueryOrderReq);
List<MechanicBusiness> getMechanicList(Integer serviceId, Integer district, String keyWord, String orderBy);
} }
...@@ -10,15 +10,18 @@ import java.math.RoundingMode; ...@@ -10,15 +10,18 @@ import java.math.RoundingMode;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.gavaghan.geodesy.GlobalCoordinates;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -41,6 +44,7 @@ import com.glsx.common.utils.Page; ...@@ -41,6 +44,7 @@ import com.glsx.common.utils.Page;
import com.glsx.common.utils.PropertiesUtil; import com.glsx.common.utils.PropertiesUtil;
import com.glsx.common.utils.RedisCacheUtil; import com.glsx.common.utils.RedisCacheUtil;
import com.glsx.common.utils.UserUtils; import com.glsx.common.utils.UserUtils;
import com.glsx.common.utils.map.AMapUtils;
import com.glsx.common.utils.wehcat.MiniProgram; import com.glsx.common.utils.wehcat.MiniProgram;
import com.glsx.common.utils.wehcat.TemplateData; import com.glsx.common.utils.wehcat.TemplateData;
import com.glsx.common.utils.wehcat.WechatTemplate; import com.glsx.common.utils.wehcat.WechatTemplate;
...@@ -3564,4 +3568,60 @@ public class OrderServiceImpl implements IOrderService { ...@@ -3564,4 +3568,60 @@ public class OrderServiceImpl implements IOrderService {
return map; return map;
} }
/**
* 指派、改派技工--查询技工列表
*/
@Override
public List<MechanicBusiness> getMechanicList(Integer serviceId, Integer district, String keyWord, String orderBy) {
List<MechanicBusiness> list = sysMechanicDao.getMechanicList(serviceId, keyWord);
List<MechanicBusiness> newList = new ArrayList<>();
if (list.isEmpty()) {
for (MechanicBusiness mechanicBusiness : list) {
MechanicBusiness mb = sysMechanicDao
.getMechanicOrderCountAndTimeliness(mechanicBusiness.getMechanicId());
// 安装时效
mechanicBusiness.setTimeliness(mb.getTimeliness());
// 单量
mechanicBusiness.setCount(mb.getCount());
if (!StringUtils.isEmpty(mechanicBusiness.getAddress()) && null != district) {
// 订单地址
Map<String, String> orderAddress = AMapUtils
.parseAddress(areaService.getFullAreaByDistrictId(district));
// 技工地址
Map<String, String> mechanicAddress = AMapUtils.parseAddress(mechanicBusiness.getAddress());
if (orderAddress.containsKey("latitude") && mechanicAddress.containsKey("latitude")) {
// 技工坐标
GlobalCoordinates source = new GlobalCoordinates(
Double.parseDouble(mechanicAddress.get("latitude")),
Double.parseDouble(mechanicAddress.get("longitude")));
// 订单坐标
GlobalCoordinates target = new GlobalCoordinates(
Double.parseDouble(orderAddress.get("latitude")),
Double.parseDouble(orderAddress.get("longitude")));
// 距离
mechanicBusiness.setDistance(AMapUtils.getDistanceMeter(source, target) + "米");
}
}
// orderBy:c按单量排序降序,d按距离升序排序(默认),t按时效升序排序
switch (orderBy) {
case "c":
newList = list.stream().sorted(Comparator.comparing(MechanicBusiness::getCount).reversed())
.collect(Collectors.toList());
break;
case "t":
newList = list.stream().sorted(Comparator.comparing(MechanicBusiness::getTimeliness))
.collect(Collectors.toList());
break;
default:
newList = list.stream().sorted(Comparator.comparing(MechanicBusiness::getDistance))
.collect(Collectors.toList());
break;
}
}
}
return newList;
}
} }
...@@ -223,19 +223,39 @@ ...@@ -223,19 +223,39 @@
LEFT JOIN sys_area sa2 ON LEFT JOIN sys_area sa2 ON
sa1.parent_id = sa2.id sa1.parent_id = sa2.id
<where> <where>
and sm.service_id = #{userId} and sm.service_id = #{serviceId}
and u.user_status = 'sys_user_status_normal' and u.user_status = 'sys_user_status_normal'
and m.mechanic_status = 'sys_user_status_pass_check' and m.mechanic_status = 'sys_user_status_pass_check'
and sa.id = #{district}
</where> </where>
GROUP BY u.id GROUP BY u.id
ORDER BY m.work_status ASC, u.create_time DESC, u.id DESC ORDER BY m.work_status ASC, u.create_time DESC, u.id DESC
) d ) d
<where> <where>
<if test="queryContent != null and queryContent != ''"> <if test="keyWord != null and keyWord != ''">
and (d.name like #{keyWord} or d.phoneNumber like #{keyWord} or address and (d.name like #{keyWord} or d.phoneNumber like #{keyWord} or address
like #{keyWord}) like #{keyWord})
</if> </if>
</where> </where>
</select> </select>
<select id="getMechanicOrderCountAndTimeliness" resultType="com.glsx.ordercenter.dto.MechanicBusiness">
SELECT
COUNT(os.order_id) as count ,
TIMESTAMPDIFF(MINUTE,MIN(os.update_time),MAX(os.update_time))/COUNT(os.order_id) timeliness
from (
SELECT
sos.order_id,sos.update_time
FROM
sys_order so
left JOIN
sys_order_status sos on sos.order_id=so.id
WHERE
so.order_type = 1
AND so.active_status = 8
AND(sos.active_status in (4,8))
AND so.mechanic_id = #{mechanicId}
GROUP BY order_id
) os
</select>
</mapper> </mapper>
\ No newline at end of file \ 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!