diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 01815fd23c..7f54dd2bb8 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -83,6 +83,10 @@ public enum EpmetErrorCode { DOOR_NAME_EXITED(8216,"门牌号已存在"), NEIGHBOOR_NAME_EXITED(8217,"小区名称已存在"), DEMAND_NAME_EXITED(8218, "分类名称已存在"), + DEMAND_CAN_NOT_CANCEL(8219, "需求已完成,不可取消"), + DEMAND_CAN_NOT_ASSIGN(8220, "当前状态,不可指派"), + DEMAND_CAN_NOT_FINISH(8221, "当前状态,不能评价"), + DEMAND_FINISHED(8222,"需求已完成"), REQUIRE_PERMISSION(8301, "您没有足够的操作权限"), THIRD_PLAT_REQUEST_ERROR(8302, "请求第三方平台错误"), diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AssignFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AssignFormDTO.java new file mode 100644 index 0000000000..b24a505a5f --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AssignFormDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.form.demand; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +@Data +public class AssignFormDTO implements Serializable { + private static final long serialVersionUID = -8844710824469349121L; + + public interface AddUserInternalGroup { + } + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + @NotBlank(message = "需求id不能为空", groups = AddUserInternalGroup.class) + private String demandRecId; + @NotBlank(message = "服务方类型不能为空", groups = AddUserShowGroup.class) + private String serviceType; + @NotBlank(message = "服务方不能为空", groups = AddUserShowGroup.class) + private String serverId; + + + + @NotBlank(message = "userId不能为空", groups = AddUserInternalGroup.class) + private String userId; + @NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) + private String customerId; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/DemandAddFromDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/DemandAddFromDTO.java index 125550e413..8e1afc8143 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/DemandAddFromDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/DemandAddFromDTO.java @@ -2,6 +2,7 @@ package com.epmet.dto.form.demand; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import org.hibernate.validator.constraints.Length; import org.springframework.format.annotation.DateTimeFormat; import javax.validation.constraints.NotBlank; @@ -58,7 +59,8 @@ public class DemandAddFromDTO implements Serializable { /** * 需求内容1000字 */ - @NotBlank(message = "需求类型不能为空",groups = AddUserShowGroup.class) + @NotBlank(message = "需求内容不能为空",groups = AddUserShowGroup.class) + @Length(max = 1000,message = "需求内容至多输入1000字",groups = AddUserShowGroup.class) private String content; /** diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/FinishStaffFromDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/FinishStaffFromDTO.java new file mode 100644 index 0000000000..8213529326 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/FinishStaffFromDTO.java @@ -0,0 +1,48 @@ +package com.epmet.dto.form.demand; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Data +public class FinishStaffFromDTO implements Serializable { + private static final long serialVersionUID = 591380873862126679L; + + public interface AddUserInternalGroup { + } + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + @NotBlank(message = "需求id不能为空", groups = AddUserInternalGroup.class) + private String demandRecId; + + @NotBlank(message = "服务方不能为空", groups = AddUserShowGroup.class) + private String serverId; + + @NotNull(message = "实际服务开始不能为空", groups = AddUserShowGroup.class) + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date serviceStartTime; + + @NotNull(message = "实际服务结束不能为空", groups = AddUserShowGroup.class) + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date serviceEndTime; + + @NotBlank(message = "完成结果不能为空", groups = AddUserShowGroup.class) + private String finishResult; + private String finishDesc; + + @NotNull(message = "得分不能为空", groups = AddUserShowGroup.class) + private BigDecimal score; + + + + @NotBlank(message = "userId不能为空", groups = AddUserInternalGroup.class) + private String userId; + @NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) + private String customerId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/StaffCancelFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/StaffCancelFormDTO.java new file mode 100644 index 0000000000..09d920f55c --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/StaffCancelFormDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.form.demand; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class StaffCancelFormDTO { + public interface AddUserInternalGroup {} + @NotBlank(message = "需求id不能为空",groups = AddUserInternalGroup.class) + private String demandRecId; + + @NotBlank(message = "userId不能为空", groups =AddUserInternalGroup.class) + private String userId; + @NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) + private String customerId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UserDemandPageFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UserDemandPageFormDTO.java index 9d6115243e..265a88b5f1 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UserDemandPageFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UserDemandPageFormDTO.java @@ -2,6 +2,7 @@ package com.epmet.dto.form.demand; import com.epmet.commons.tools.dto.form.PageFormDTO; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.util.Date; @@ -41,12 +42,14 @@ public class UserDemandPageFormDTO extends PageFormDTO implements Serializable { /** * 上报时间开始 */ - private Date reportStartTime; + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date reportStartDate; /** * 上报时间截止 */ - private Date reportEndTime; + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date reportEndDate; /** * 待处理:pending;已取消canceled;已派单:assigned;已接单:have_order;已完成:finished @@ -69,10 +72,12 @@ public class UserDemandPageFormDTO extends PageFormDTO implements Serializable { /** * 希望服务时间开始 */ - private Date wantServiceStartTime; + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date wantServiceStartDate; /** * 希望截止 */ - private Date wantServiceEndTime; + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date wantServiceEndDate; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/DemandRecResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/DemandRecResultDTO.java index 7cd8eff5b3..a1cba4b0a5 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/DemandRecResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/DemandRecResultDTO.java @@ -19,26 +19,30 @@ public class DemandRecResultDTO implements Serializable { @JsonIgnore private String categoryCode; - @JsonIgnore - private String parentCode; private String categoryName; + + private String content; + + private String reportType; private String reportUserName; - - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date reportTime; + private String demandUser; private String demandUserName; + private String demandUserMobile; @JsonIgnore private String serviceType; @JsonIgnore private String serverId; - private String serviceName; - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private String wantServiceTime; private String status; + private String statusName; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java index 022ec5580f..4bac4aeefb 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java @@ -23,10 +23,7 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.UserDemandConstant; -import com.epmet.dto.form.demand.DemandAddFromDTO; -import com.epmet.dto.form.demand.DemandRecId; -import com.epmet.dto.form.demand.ServiceQueryFormDTO; -import com.epmet.dto.form.demand.UserDemandPageFormDTO; +import com.epmet.dto.form.demand.*; import com.epmet.dto.result.demand.DemandRecResultDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.service.*; @@ -108,9 +105,61 @@ public class IcUserDemandRecController { * @param formDTO * @return */ + @PostMapping("pagelist") public Result> pageList(@LoginUser TokenDto tokenDto, @RequestBody UserDemandPageFormDTO formDTO){ formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setCurrentStaffId(tokenDto.getUserId()); return new Result>().ok(icUserDemandRecService.pageList(formDTO)); } + + + /** + * 取消,未完成之前都可以取消 + * + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("cancel") + public Result cancel(@LoginUser TokenDto tokenDto,@RequestBody StaffCancelFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,StaffCancelFormDTO.AddUserInternalGroup.class); + icUserDemandRecService.cancel(formDTO); + return new Result(); + } + + + /** + * 指派 + * 待处理:pending;已取消canceled;已派单:assigned;已接单:have_order;已完成:finished + * 待处理+已派单才可以指派 + * + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("assign") + public Result assign(@LoginUser TokenDto tokenDto,@RequestBody AssignFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,AssignFormDTO.AddUserShowGroup.class,AssignFormDTO.AddUserInternalGroup.class); + icUserDemandRecService.assign(formDTO); + return new Result(); + } + + /** + * 完成并评价 + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("finish") + public Result finish(@LoginUser TokenDto tokenDto,@RequestBody FinishStaffFromDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,FinishStaffFromDTO.AddUserShowGroup.class,FinishStaffFromDTO.AddUserInternalGroup.class); + icUserDemandRecService.finish(formDTO); + return new Result(); + } } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java index 1d21b7fe2e..12bc2f68b4 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java @@ -18,9 +18,13 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.demand.UserDemandPageFormDTO; +import com.epmet.dto.result.demand.DemandRecResultDTO; import com.epmet.entity.IcUserDemandRecEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 居民需求记录表 * @@ -29,5 +33,7 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcUserDemandRecDao extends BaseDao { - + + + List pageSelect(UserDemandPageFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandServiceDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandServiceDao.java index 7ed924bdcd..5f9adffb87 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandServiceDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandServiceDao.java @@ -29,5 +29,6 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcUserDemandServiceDao extends BaseDao { - + + IcUserDemandServiceEntity selectByRecId(String demandRecId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java index 2d969e1d46..e963ac94df 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java @@ -20,9 +20,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcUserDemandRecDTO; -import com.epmet.dto.form.demand.DemandAddFromDTO; -import com.epmet.dto.form.demand.DemandRecId; -import com.epmet.dto.form.demand.UserDemandPageFormDTO; +import com.epmet.dto.form.demand.*; import com.epmet.dto.result.demand.DemandRecResultDTO; import com.epmet.entity.IcUserDemandRecEntity; @@ -106,4 +104,27 @@ public interface IcUserDemandRecService extends BaseService pageList(UserDemandPageFormDTO formDTO); + + /** + * 未完成之前都可以取消 + * + * @param formDTO + */ + void cancel(StaffCancelFormDTO formDTO); + + /** + * 指派 + * 待处理:pending;已取消canceled;已派单:assigned;已接单:have_order;已完成:finished + * 待处理+已派单才可以指派 + * + * @param formDTO + * @return + */ + void assign(AssignFormDTO formDTO); + + /** + * 完成并评价 + * @param formDTO + */ + void finish(FinishStaffFromDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java index 352b5e82f2..d76ba00374 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java @@ -23,6 +23,7 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; @@ -31,17 +32,22 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constant.UserDemandConstant; import com.epmet.dao.IcUserDemandOperateLogDao; import com.epmet.dao.IcUserDemandRecDao; +import com.epmet.dao.IcUserDemandSatisfactionDao; +import com.epmet.dao.IcUserDemandServiceDao; import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.IcUserDemandRecDTO; import com.epmet.dto.form.CustomerGridFormDTO; -import com.epmet.dto.form.demand.DemandAddFromDTO; -import com.epmet.dto.form.demand.DemandRecId; -import com.epmet.dto.form.demand.UserDemandPageFormDTO; +import com.epmet.dto.form.demand.*; import com.epmet.dto.result.demand.DemandRecResultDTO; import com.epmet.entity.IcUserDemandOperateLogEntity; import com.epmet.entity.IcUserDemandRecEntity; +import com.epmet.entity.IcUserDemandSatisfactionEntity; +import com.epmet.entity.IcUserDemandServiceEntity; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.IcUserDemandRecService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -63,6 +69,10 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl pageList(UserDemandPageFormDTO formDTO) { - CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getCurrentStaffId()); - String gridPids=staffInfoCacheResult.getAgencyPIds().concat(StrConstant.COLON).concat(staffInfoCacheResult.getAgencyId()); - formDTO.setGridPids(formDTO.getGridPids()); - // todo - return null; + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getCurrentStaffId()); + if (null == staffInfo) { + throw new RenException("工作人员所属组织信息查询异常"); + } + if (StringUtils.isBlank(staffInfo.getAgencyPIds())) { + formDTO.setGridPids(staffInfo.getAgencyId()); + } else { + if (staffInfo.getAgencyPIds().contains(StrConstant.COLON)) { + formDTO.setGridPids(staffInfo.getAgencyPIds().concat(StrConstant.COLON).concat(staffInfo.getAgencyId())); + } + } + PageInfo pageInfo= PageHelper.startPage(formDTO.getPageNo(), + formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.pageSelect(formDTO)); + List list=pageInfo.getList(); + if(CollectionUtils.isNotEmpty(list)){ + /*for(){ + + }*/ + } + return new PageData<>(list, pageInfo.getTotal()); + } + + /** + * 未完成之前都可以取消 + * + * @param formDTO + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void cancel(StaffCancelFormDTO formDTO) { + IcUserDemandRecEntity entity = baseDao.selectById(formDTO.getDemandRecId()); + if (null == entity) { + throw new RenException("需求不存在"); + } + if (UserDemandConstant.FINISH.equals(entity.getStatus())) { + //需求已完成,不可取消 + throw new RenException(EpmetErrorCode.DEMAND_CAN_NOT_CANCEL.getCode(),EpmetErrorCode.DEMAND_CAN_NOT_CANCEL.getMsg()); + } + //1、修改主表 + //置为取消状态、设置取消时间 + entity.setStatus(UserDemandConstant.CANCELED); + entity.setCancelTime(new Date()); + baseDao.updateById(entity); + //2、插入操作日志 + IcUserDemandOperateLogEntity logEntity = new IcUserDemandOperateLogEntity(); + logEntity.setCustomerId(formDTO.getCustomerId()); + logEntity.setDemandRecId(formDTO.getDemandRecId()); + logEntity.setUserType(UserDemandConstant.STAFF); + logEntity.setUserId(formDTO.getUserId()); + logEntity.setActionCode(UserDemandConstant.CANCEL); + logEntity.setOperateTime(entity.getCancelTime()); + operateLogDao.insert(logEntity); + } + + /** + * 指派 + * 待处理:pending;已取消canceled;已派单:assigned;已接单:have_order;已完成:finished + * 待处理+已派单才可以指派 + * + * @param formDTO + * @return + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void assign(AssignFormDTO formDTO) { + IcUserDemandRecEntity entity = baseDao.selectById(formDTO.getDemandRecId()); + if (null == entity) { + throw new RenException("需求不存在"); + } + if (!UserDemandConstant.PENDING.equals(entity.getStatus()) && !UserDemandConstant.ASSIGNED.equals(entity.getStatus())) { + //待处理+已派单才可以指派 + throw new RenException(EpmetErrorCode.DEMAND_CAN_NOT_ASSIGN.getCode(), EpmetErrorCode.DEMAND_CAN_NOT_ASSIGN.getMsg()); + } + //1、修改主表 + //置为已派单 + entity.setStatus(UserDemandConstant.ASSIGNED); + baseDao.updateById(entity); + //2、插入操作日志 + IcUserDemandOperateLogEntity logEntity = new IcUserDemandOperateLogEntity(); + logEntity.setCustomerId(formDTO.getCustomerId()); + logEntity.setDemandRecId(formDTO.getDemandRecId()); + logEntity.setUserType(UserDemandConstant.STAFF); + logEntity.setUserId(formDTO.getUserId()); + logEntity.setActionCode(UserDemandConstant.ASSIGN); + logEntity.setOperateTime(new Date()); + operateLogDao.insert(logEntity); + //3、插入或更新服务记录 + IcUserDemandServiceEntity serviceEntity=ConvertUtils.sourceToTarget(formDTO,IcUserDemandServiceEntity.class); + IcUserDemandServiceEntity origin=demandServiceDao.selectByRecId(formDTO.getDemandRecId()); + if (null == origin) { + demandServiceDao.insert(serviceEntity); + }else{ + serviceEntity.setId(origin.getId()); + serviceEntity.setUpdatedBy(formDTO.getUserId()); + demandServiceDao.updateById(serviceEntity); + } + + } + + /** + * 完成并评价 + * + * @param formDTO + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void finish(FinishStaffFromDTO formDTO) { + IcUserDemandRecEntity entity = baseDao.selectById(formDTO.getDemandRecId()); + if (null == entity) { + throw new RenException("需求不存在"); + } + if (UserDemandConstant.PENDING.equals(entity.getStatus()) ||UserDemandConstant.CANCELED.equals(entity.getStatus())) { + //待处理或者已取消的不能评价 + throw new RenException(EpmetErrorCode.DEMAND_CAN_NOT_FINISH.getCode(), EpmetErrorCode.DEMAND_CAN_NOT_FINISH.getMsg()); + } + if(UserDemandConstant.FINISHED.equals(entity.getStatus()) ){ + //已经完成 + throw new RenException(EpmetErrorCode.DEMAND_FINISHED.getCode(), EpmetErrorCode.DEMAND_FINISHED.getMsg()); + } + //1、修改主表 + entity.setStatus(UserDemandConstant.FINISHED); + entity.setFinishResult(formDTO.getFinishResult()); + entity.setEvaluateFlag(true); + baseDao.updateById(entity); + + //2、插入操作日志 + IcUserDemandOperateLogEntity logEntity = new IcUserDemandOperateLogEntity(); + logEntity.setCustomerId(formDTO.getCustomerId()); + logEntity.setDemandRecId(formDTO.getDemandRecId()); + logEntity.setUserType(UserDemandConstant.STAFF); + logEntity.setUserId(formDTO.getUserId()); + logEntity.setActionCode(UserDemandConstant.FINISH); + logEntity.setOperateTime(new Date()); + operateLogDao.insert(logEntity); + + //3、更新服务记录 + IcUserDemandServiceEntity serviceEntity=demandServiceDao.selectById(formDTO.getServerId()); + serviceEntity.setServiceStartTime(formDTO.getServiceStartTime()); + serviceEntity.setServiceEndTime(formDTO.getServiceEndTime()); + serviceEntity.setFinishDesc(formDTO.getFinishDesc()); + demandServiceDao.updateById(serviceEntity); + + //4、插入评价 + IcUserDemandSatisfactionEntity satisfactionEntity=new IcUserDemandSatisfactionEntity(); + satisfactionEntity.setCustomerId(formDTO.getCustomerId()); + satisfactionEntity.setDemandRecId(formDTO.getDemandRecId()); + satisfactionEntity.setUserType(UserDemandConstant.STAFF); + satisfactionEntity.setUserId(formDTO.getUserId()); + satisfactionEntity.setEvaluateTime(logEntity.getOperateTime()); + satisfactionEntity.setScore(formDTO.getScore()); + demandSatisfactionDao.insert(satisfactionEntity); } } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml index 3f62cd300d..90a203098b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml @@ -34,5 +34,64 @@ - + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandServiceDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandServiceDao.xml index b615ea90be..219f457444 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandServiceDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandServiceDao.xml @@ -20,5 +20,10 @@ - + \ No newline at end of file