Commit 5e215e69 authored by lining's avatar lining

feat: 最终上门维修工/估价员逻辑,上门时间检验

parent 6bb90954
...@@ -2,6 +2,12 @@ package com.onsiteservice.dao.mapper.service; ...@@ -2,6 +2,12 @@ package com.onsiteservice.dao.mapper.service;
import com.onsiteservice.dao.common.Mapper; import com.onsiteservice.dao.common.Mapper;
import com.onsiteservice.entity.service.ServiceValuatorAssign; import com.onsiteservice.entity.service.ServiceValuatorAssign;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ServiceValuatorAssignMapper extends Mapper<ServiceValuatorAssign> { public interface ServiceValuatorAssignMapper extends Mapper<ServiceValuatorAssign> {
List<ServiceValuatorAssign> selectByDeletedAndIdListAndAssignTime(@Param("list") List<Long> valuatorIds);
} }
\ No newline at end of file
...@@ -2,6 +2,12 @@ package com.onsiteservice.dao.mapper.service; ...@@ -2,6 +2,12 @@ package com.onsiteservice.dao.mapper.service;
import com.onsiteservice.dao.common.Mapper; import com.onsiteservice.dao.common.Mapper;
import com.onsiteservice.entity.service.ServiceWorkerAssign; import com.onsiteservice.entity.service.ServiceWorkerAssign;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ServiceWorkerAssignMapper extends Mapper<ServiceWorkerAssign> { public interface ServiceWorkerAssignMapper extends Mapper<ServiceWorkerAssign> {
List<ServiceWorkerAssign> selectByDeletedAndIdListAndAssignTime(@Param("list") List<Long> workerIds);
} }
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.onsiteservice.dao.mapper.service.ServiceValuatorAssignMapper"> <mapper namespace="com.onsiteservice.dao.mapper.service.ServiceValuatorAssignMapper">
<resultMap id="BaseResultMap" type="com.onsiteservice.entity.service.ServiceValuatorAssign"> <resultMap id="BaseResultMap" type="com.onsiteservice.entity.service.ServiceValuatorAssign">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id"/>
<result column="valuator_id" jdbcType="BIGINT" property="valuatorId" /> <result column="valuator_id" jdbcType="BIGINT" property="valuatorId"/>
<result column="order_id" jdbcType="BIGINT" property="orderId" /> <result column="order_id" jdbcType="BIGINT" property="orderId"/>
<result column="assign_time" jdbcType="TIMESTAMP" property="assignTime" /> <result column="assign_time" jdbcType="TIMESTAMP" property="assignTime"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" /> <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
</resultMap> </resultMap>
<select id="selectByDeletedAndIdListAndAssignTime"
resultType="com.onsiteservice.entity.service.ServiceValuatorAssign">
select * from service_valuator_assign
where deleted=0
and valuator_id in
<foreach collection="list" item="valuatorId" index="index" open="(" close=")" separator=",">
${valuatorId}
</foreach>
and assign_time >=sysdate()
</select>
</mapper> </mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.onsiteservice.dao.mapper.service.ServiceWorkerAssignMapper"> <mapper namespace="com.onsiteservice.dao.mapper.service.ServiceWorkerAssignMapper">
<resultMap id="BaseResultMap" type="com.onsiteservice.entity.service.ServiceWorkerAssign"> <resultMap id="BaseResultMap" type="com.onsiteservice.entity.service.ServiceWorkerAssign">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id"/>
<result column="worker_id" jdbcType="BIGINT" property="workerId" /> <result column="worker_id" jdbcType="BIGINT" property="workerId"/>
<result column="order_id" jdbcType="BIGINT" property="orderId" /> <result column="order_id" jdbcType="BIGINT" property="orderId"/>
<result column="assign_time" jdbcType="TIMESTAMP" property="assignTime" /> <result column="assign_time" jdbcType="TIMESTAMP" property="assignTime"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" /> <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
</resultMap> </resultMap>
<select id="selectByDeletedAndIdListAndAssignTime"
resultType="com.onsiteservice.entity.service.ServiceWorkerAssign">
select * from service_worker_assign
where deleted=0
and worker_id in
<foreach collection="list" item="workerId" index="index" open="(" close=")" separator=",">
${workerId}
</foreach>
and assign_time >=sysdate()
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -69,13 +69,6 @@ public class ServiceOrder implements Serializable { ...@@ -69,13 +69,6 @@ public class ServiceOrder implements Serializable {
@ApiModelProperty("服务数量") @ApiModelProperty("服务数量")
private Integer num; private Integer num;
/**
* 服务需求图片
*/
@Column(name = "demand_img")
@ApiModelProperty("服务需求图片")
private String demandImg;
/** /**
* 服务需求说明 * 服务需求说明
*/ */
......
...@@ -64,8 +64,14 @@ public class ServiceValuatorAssign implements Serializable { ...@@ -64,8 +64,14 @@ public class ServiceValuatorAssign implements Serializable {
@ApiModelProperty("修改人") @ApiModelProperty("修改人")
private Long modifyBy; private Long modifyBy;
@Column(name = "deleted")
@ApiModelProperty("删除标记") @ApiModelProperty("删除标记")
private Boolean deleted; private Boolean deleted;
@Column(name = "final_executed")
@ApiModelProperty("最终上门的估价员")
private Boolean finalExecuted;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
\ No newline at end of file
...@@ -64,8 +64,14 @@ public class ServiceWorkerAssign implements Serializable { ...@@ -64,8 +64,14 @@ public class ServiceWorkerAssign implements Serializable {
@ApiModelProperty("修改人") @ApiModelProperty("修改人")
private Long modifyBy; private Long modifyBy;
@Column(name = "deleted")
@ApiModelProperty("删除标记") @ApiModelProperty("删除标记")
private Boolean deleted; private Boolean deleted;
@Column(name = "final_executed")
@ApiModelProperty("最终上门的维修工")
private Boolean finalExecuted;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel; ...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Future;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -33,6 +34,7 @@ public class DispatchServiceOrderDTO { ...@@ -33,6 +34,7 @@ public class DispatchServiceOrderDTO {
@ApiModelProperty(value = "期望维修工上门时间", required = true) @ApiModelProperty(value = "期望维修工上门时间", required = true)
@NotNull(message = "请选择上门时间") @NotNull(message = "请选择上门时间")
@Future(message = "上门时间必须为将来的某个时间点")
private Date expectArrivalTime; private Date expectArrivalTime;
} }
...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel; ...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Future;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.Date; import java.util.Date;
...@@ -29,6 +30,7 @@ public class ReserveServiceOrderDTO { ...@@ -29,6 +30,7 @@ public class ReserveServiceOrderDTO {
*/ */
@ApiModelProperty(value = "期望上门时间", required = true) @ApiModelProperty(value = "期望上门时间", required = true)
@NotNull(message = "请选择上门时间") @NotNull(message = "请选择上门时间")
@Future(message = "上门时间必须为将来的某个时间点")
private Date expectArrivalTime; private Date expectArrivalTime;
/** /**
......
...@@ -6,6 +6,7 @@ import lombok.Data; ...@@ -6,6 +6,7 @@ import lombok.Data;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
import javax.validation.constraints.Future;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -35,6 +36,7 @@ public class ValuationServiceOrderDTO { ...@@ -35,6 +36,7 @@ public class ValuationServiceOrderDTO {
@ApiModelProperty(value = "期望估价员上门时间", required = true) @ApiModelProperty(value = "期望估价员上门时间", required = true)
@NotNull(message = "请选择上门时间") @NotNull(message = "请选择上门时间")
@Future(message = "上门时间必须为将来的某个时间点")
private Date expectArrivalTime; private Date expectArrivalTime;
} }
...@@ -201,7 +201,7 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> { ...@@ -201,7 +201,7 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
throw new ServiceException(BizCodeEnum.SERVICE_VALUATOR_NOT_EXIST); throw new ServiceException(BizCodeEnum.SERVICE_VALUATOR_NOT_EXIST);
} }
disableServiceValuatorAssign(serviceOrder, userId); disableServiceValuatorAssign(serviceOrder, userId, false);
int result = serviceValuatorAssignMapper.insertSelective(buildServiceValuatorAssign(dto, userId)); int result = serviceValuatorAssignMapper.insertSelective(buildServiceValuatorAssign(dto, userId));
...@@ -232,7 +232,7 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> { ...@@ -232,7 +232,7 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
throw new ServiceException(BizCodeEnum.SERVICE_ORDER_CANNOT_SEND); throw new ServiceException(BizCodeEnum.SERVICE_ORDER_CANNOT_SEND);
} }
disableServiceValuatorAssign(serviceOrder, userId); disableServiceValuatorAssign(serviceOrder, userId, true);
// 估价价格 // 估价价格
serviceOrder.setPrice(dto.getPrice()); serviceOrder.setPrice(dto.getPrice());
...@@ -336,7 +336,7 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> { ...@@ -336,7 +336,7 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
throw new ServiceException(BizCodeEnum.SERVICE_WORKER_NOT_EXIST); throw new ServiceException(BizCodeEnum.SERVICE_WORKER_NOT_EXIST);
} }
disableServiceWorkerAssign(serviceOrder, userId); disableServiceWorkerAssign(serviceOrder, userId, false);
int result = serviceWorkerAssignMapper.insertSelective(buildServiceWorkerAssign(dto, userId)); int result = serviceWorkerAssignMapper.insertSelective(buildServiceWorkerAssign(dto, userId));
...@@ -372,7 +372,7 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> { ...@@ -372,7 +372,7 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
throw new ServiceException(BizCodeEnum.NO_AUTH_FINISH_ORDER); throw new ServiceException(BizCodeEnum.NO_AUTH_FINISH_ORDER);
} }
disableServiceWorkerAssign(serviceOrder, userId); disableServiceWorkerAssign(serviceOrder, userId, true);
serviceOrder.setOrderStatus(ServiceOrderStatusEnum.FINISH.getStatus()); serviceOrder.setOrderStatus(ServiceOrderStatusEnum.FINISH.getStatus());
serviceOrder.setModifyBy(userId); serviceOrder.setModifyBy(userId);
...@@ -396,7 +396,7 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> { ...@@ -396,7 +396,7 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
throw new ServiceException(BizCodeEnum.SERVICE_ORDER_CANNOT_CANCEL); throw new ServiceException(BizCodeEnum.SERVICE_ORDER_CANNOT_CANCEL);
} }
disableServiceValuatorAssign(serviceOrder, userId); disableServiceValuatorAssign(serviceOrder, userId, true);
serviceOrder.setOrderStatus(ServiceOrderStatusEnum.CANCEL.getStatus()); serviceOrder.setOrderStatus(ServiceOrderStatusEnum.CANCEL.getStatus());
serviceOrder.setModifyBy(userId); serviceOrder.setModifyBy(userId);
...@@ -496,11 +496,13 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> { ...@@ -496,11 +496,13 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
* *
* @param serviceOrder 订单 * @param serviceOrder 订单
* @param userId 用户id * @param userId 用户id
* @param finalExecuted 逻辑上谁最有可能是最终的上门人员
*/ */
public void disableServiceValuatorAssign(ServiceOrder serviceOrder, Long userId) { public void disableServiceValuatorAssign(ServiceOrder serviceOrder, Long userId, boolean finalExecuted) {
ServiceValuatorAssign serviceValuatorAssign = new ServiceValuatorAssign(); ServiceValuatorAssign serviceValuatorAssign = new ServiceValuatorAssign();
serviceValuatorAssign.setModifyBy(userId); serviceValuatorAssign.setModifyBy(userId);
serviceValuatorAssign.setDeleted(true); serviceValuatorAssign.setDeleted(true);
serviceValuatorAssign.setFinalExecuted(finalExecuted);
Condition c = new Condition(ServiceValuatorAssign.class); Condition c = new Condition(ServiceValuatorAssign.class);
c.createCriteria().andEqualTo(BizConstants.OrderConstants.ORDER_ID, serviceOrder.getId()); c.createCriteria().andEqualTo(BizConstants.OrderConstants.ORDER_ID, serviceOrder.getId());
...@@ -530,10 +532,11 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> { ...@@ -530,10 +532,11 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
* @param serviceOrder 订单 * @param serviceOrder 订单
* @param userId 用户id * @param userId 用户id
*/ */
public void disableServiceWorkerAssign(ServiceOrder serviceOrder, Long userId) { public void disableServiceWorkerAssign(ServiceOrder serviceOrder, Long userId, boolean finalExecuted) {
ServiceWorkerAssign serviceWorkerAssign = new ServiceWorkerAssign(); ServiceWorkerAssign serviceWorkerAssign = new ServiceWorkerAssign();
serviceWorkerAssign.setModifyBy(userId); serviceWorkerAssign.setModifyBy(userId);
serviceWorkerAssign.setDeleted(true); serviceWorkerAssign.setDeleted(true);
serviceWorkerAssign.setFinalExecuted(finalExecuted);
Condition c = new Condition(ServiceWorkerAssign.class); Condition c = new Condition(ServiceWorkerAssign.class);
c.createCriteria().andEqualTo(BizConstants.OrderConstants.ORDER_ID, serviceOrder.getId()); c.createCriteria().andEqualTo(BizConstants.OrderConstants.ORDER_ID, serviceOrder.getId());
......
...@@ -61,18 +61,17 @@ public class ServiceValuatorService extends AbstractMapper<ServiceValuator> { ...@@ -61,18 +61,17 @@ public class ServiceValuatorService extends AbstractMapper<ServiceValuator> {
// 估价员id列表 // 估价员id列表
List<Long> valuatorIds = serviceValuatorList.parallelStream().map(ServiceValuator::getId).collect(Collectors.toList()); List<Long> valuatorIds = serviceValuatorList.parallelStream().map(ServiceValuator::getId).collect(Collectors.toList());
// 已被指派的时间 // 已被指派的时间
List<ServiceValuatorAssign> serviceValuatorAssignList = serviceValuatorAssignMapper.selectByIdList(valuatorIds); List<ServiceValuatorAssign> serviceValuatorAssignList = serviceValuatorAssignMapper.selectByDeletedAndIdListAndAssignTime(valuatorIds);
Map<Long, List<ServiceValuatorAssign>> serviceValuatorAssignMap = Map<Long, List<ServiceValuatorAssign>> serviceValuatorAssignMap =
serviceValuatorAssignList.parallelStream() serviceValuatorAssignList.parallelStream()
// 未过期的指派时间
.filter(e -> e.getAssignTime().getTime() >= System.currentTimeMillis())
.filter(e -> !e.getDeleted())
.collect(Collectors.groupingBy(ServiceValuatorAssign::getValuatorId)); .collect(Collectors.groupingBy(ServiceValuatorAssign::getValuatorId));
return serviceValuatorList.parallelStream().map(e1 -> { return serviceValuatorList.parallelStream().map(e1 -> {
ServiceValuatorVO serviceValuatorVO = AttrCopyUtils.copy(e1, new ServiceValuatorVO()); ServiceValuatorVO serviceValuatorVO = AttrCopyUtils.copy(e1, new ServiceValuatorVO());
// 估价员已经被指派的时间
List<ServiceValuatorAssign> assigns = serviceValuatorAssignMap.getOrDefault(e1.getId(), Lists.newArrayList()); List<ServiceValuatorAssign> assigns = serviceValuatorAssignMap.getOrDefault(e1.getId(), Lists.newArrayList());
List<Date> assignTimes = assigns.parallelStream().map(ServiceValuatorAssign::getAssignTime).collect(Collectors.toList()); List<Date> assignTimes = assigns.parallelStream().map(ServiceValuatorAssign::getAssignTime).collect(Collectors.toList());
serviceValuatorVO.setAssignTime(assignTimes); serviceValuatorVO.setAssignTime(assignTimes);
return new ServiceValuatorVO(); return new ServiceValuatorVO();
......
...@@ -57,17 +57,17 @@ public class ServiceWorkerService extends AbstractMapper<ServiceWorker> { ...@@ -57,17 +57,17 @@ public class ServiceWorkerService extends AbstractMapper<ServiceWorker> {
// 估价员id列表 // 估价员id列表
List<Long> workerIds = serviceWorkerList.parallelStream().map(ServiceWorker::getId).collect(Collectors.toList()); List<Long> workerIds = serviceWorkerList.parallelStream().map(ServiceWorker::getId).collect(Collectors.toList());
// 已被指派的时间 // 已被指派的时间
List<ServiceWorkerAssign> serviceWorkerAssignList = serviceWorkerAssignMapper.selectByIdList(workerIds); List<ServiceWorkerAssign> serviceWorkerAssignList = serviceWorkerAssignMapper.selectByDeletedAndIdListAndAssignTime(workerIds);
Map<Long, List<ServiceWorkerAssign>> serviceWorkerAssignMap = Map<Long, List<ServiceWorkerAssign>> serviceWorkerAssignMap =
serviceWorkerAssignList.parallelStream() serviceWorkerAssignList.parallelStream()
.filter(e -> e.getAssignTime().getTime() >= System.currentTimeMillis())
.filter(e -> !e.getDeleted())
.collect(Collectors.groupingBy(ServiceWorkerAssign::getWorkerId)); .collect(Collectors.groupingBy(ServiceWorkerAssign::getWorkerId));
return serviceWorkerList.parallelStream().map(e1 -> { return serviceWorkerList.parallelStream().map(e1 -> {
ServiceWorkerVO serviceWorkerVO = AttrCopyUtils.copy(e1, new ServiceWorkerVO()); ServiceWorkerVO serviceWorkerVO = AttrCopyUtils.copy(e1, new ServiceWorkerVO());
// 维修工已经被指派的时间
List<ServiceWorkerAssign> assigns = serviceWorkerAssignMap.getOrDefault(e1.getId(), Lists.newArrayList()); List<ServiceWorkerAssign> assigns = serviceWorkerAssignMap.getOrDefault(e1.getId(), Lists.newArrayList());
List<Date> assignTimes = assigns.parallelStream().map(ServiceWorkerAssign::getAssignTime).collect(Collectors.toList()); List<Date> assignTimes = assigns.parallelStream().map(ServiceWorkerAssign::getAssignTime).collect(Collectors.toList());
serviceWorkerVO.setAssignTime(assignTimes); serviceWorkerVO.setAssignTime(assignTimes);
return new ServiceWorkerVO(); return new ServiceWorkerVO();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment