New file |
| | |
| | | package com.dg.core.api; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.dg.core.ResultData; |
| | | import com.dg.core.annotation.Authorization; |
| | | import com.dg.core.annotation.CurrentUser; |
| | | import com.dg.core.controller.BaseController; |
| | | import com.dg.core.db.gen.entity.GuideEvolveEntity; |
| | | import com.dg.core.db.gen.entity.GuideRepairOrder; |
| | | import com.dg.core.db.gen.entity.SysUser; |
| | | import com.dg.core.db.manual.mapper.util.ConstantPropertiesUtil; |
| | | import com.dg.core.service.IGuideEvolveService; |
| | | import com.dg.core.service.IGuideRepairOrderService; |
| | | import com.dg.core.util.SmsUtil; |
| | | import com.dg.core.util.WxUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Map; |
| | | |
| | | import static com.dg.core.util.WxUtil.httpGet; |
| | | |
| | | |
| | | /** |
| | | * 工单管理 |
| | | */ |
| | | @Api(tags = {"工单管理小程序接口"}) |
| | | @RestController |
| | | @RequestMapping("/applets/guideRepairOrder") |
| | | public class GuideRepairOrderAppletsController extends BaseController { |
| | | |
| | | @Resource |
| | | private IGuideRepairOrderService iGuideRepairOrderService; |
| | | |
| | | @Autowired |
| | | private IGuideEvolveService iGuideEvolveService; |
| | | |
| | | private static String guideRepairOrderCompleteTemplateId = "7ZCHHii87rWPwVkdhZnvNiYbYi_Buq0NXO10cmUhAFk"; |
| | | |
| | | @Resource |
| | | SmsUtil smsUtil; |
| | | |
| | | /** |
| | | * 提交导办订单 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "提交导办订单",response = GuideRepairOrder.class) |
| | | @PostMapping("/addOrder") |
| | | @Authorization |
| | | public ResultData addOrder(@RequestBody GuideRepairOrder guideRepairOrder,@CurrentUser SysUser sysUser) { |
| | | guideRepairOrder.setSubmitUserId(sysUser.getUserId().toString()); |
| | | guideRepairOrder.setSubmitUserPhone(sysUser.getPhonenumber()); |
| | | guideRepairOrder.setSubmitType(1); |
| | | int i = iGuideRepairOrderService.addOrder(guideRepairOrder); |
| | | if (i>0){ |
| | | iGuideEvolveService.updateGuid(); |
| | | return ResultData.success(); |
| | | } |
| | | else |
| | | return ResultData.error("提交失败,请检查你是否有相同的咨询内容在处理中"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取详情 |
| | | * @param Id |
| | | * @param orderNum |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "获取订单详情",response = GuideRepairOrder.class) |
| | | @GetMapping("/orderdata") |
| | | @Authorization |
| | | public ResultData selectConfigData(@RequestParam(value = "Id",required = false) String Id, |
| | | @RequestParam(value = "orderNum",required = false) String orderNum) |
| | | { |
| | | if(StringUtils.isEmpty(Id) && StringUtils.isEmpty(orderNum)) |
| | | { |
| | | return ResultData.error("id或者订单号不能都为空"); |
| | | } |
| | | |
| | | GuideRepairOrder order=iGuideRepairOrderService.selectConfigData(Id,orderNum); |
| | | order.setGuideEvolveEntities(iGuideEvolveService.selectConfigList(Id)); |
| | | |
| | | return ResultData.success(order); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 转派人员 |
| | | * @param order |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "转派人员",response = GuideRepairOrder.class) |
| | | @PostMapping("/redeploy") |
| | | @Authorization |
| | | public ResultData redeploy(@RequestBody GuideRepairOrder order, @CurrentUser SysUser sysUser) |
| | | { |
| | | if(order==null) |
| | | { |
| | | return ResultData.error("参数不能为空"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(order.getGuideDepartmentId())) |
| | | { |
| | | return ResultData.error("导办部门id不能为空"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(order.getGuideUserId())) |
| | | { |
| | | return ResultData.error("导办人员id不能为空"); |
| | | } |
| | | |
| | | |
| | | //已分配 |
| | | order.setState("2"); |
| | | |
| | | //新增转派记录 |
| | | GuideEvolveEntity entity=new GuideEvolveEntity(); |
| | | entity.setCreateTime(LocalDateTime.now()); |
| | | entity.setUpdateTime(LocalDateTime.now()); |
| | | entity.setState("12"); |
| | | entity.setDepartmentalId(order.getGuideDepartmentId()); |
| | | entity.setToUserId(order.getGuideUserId()); |
| | | entity.setFromUserId(sysUser.getUserId()+""); |
| | | entity.setFromDepartmentalId(sysUser.getDepartmentId()); |
| | | |
| | | iGuideEvolveService.insertConfig(entity); |
| | | iGuideRepairOrderService.updateSysUserOrderNum(entity); |
| | | |
| | | return toAjax(iGuideRepairOrderService.updateConfig(order)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 去处理 |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "去处理",response = GuideRepairOrder.class) |
| | | @PostMapping("/dispose") |
| | | @Authorization |
| | | public ResultData dispose(@RequestBody GuideEvolveEntity entity, @CurrentUser SysUser sysUser) |
| | | { |
| | | if(entity==null) |
| | | { |
| | | return ResultData.error("参数不能为空"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(entity.getGuideId())) |
| | | { |
| | | return ResultData.error("工单id不能为空"); |
| | | } |
| | | |
| | | GuideRepairOrder order=iGuideRepairOrderService.selectConfigData(entity.getGuideId(),""); |
| | | if(order==null) |
| | | { |
| | | return ResultData.error("该工单不存在!"); |
| | | } |
| | | |
| | | if(StringUtils.equals(order.getState(),"3")) |
| | | { |
| | | return ResultData.error("该工单已办结!"); |
| | | } |
| | | if(StringUtils.equals(entity.getState(),"2")){//如果用户选择未解决则状态改为待办 |
| | | order.setState("2"); |
| | | entity.setState("8"); |
| | | } |
| | | else if(StringUtils.equals(entity.getState(),"4")){ |
| | | if (order.getSubmitType().equals(1))//小程序提交 |
| | | { |
| | | WxUtil wxUtil=new WxUtil(); |
| | | String accessToken="0"; |
| | | try { |
| | | accessToken= wxUtil.getBatteryCarAccessToken(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | SysUser submitUser = iGuideRepairOrderService.getSubmitUser(order); |
| | | wxUtil.sendGuideRepairOrderComplete(submitUser.getOpenid(),accessToken,guideRepairOrderCompleteTemplateId,order); |
| | | } |
| | | else if (order.getSubmitType().equals(2)){ |
| | | smsUtil.sendSmsComplete(order.getSubmitUserPhone(),order.getMatterName()); |
| | | } |
| | | //待评价 |
| | | order.setState("4"); |
| | | entity.setState("9"); |
| | | } |
| | | //新增已办结记录 |
| | | entity.setCreateTime(LocalDateTime.now()); |
| | | entity.setUpdateTime(LocalDateTime.now()); |
| | | entity.setDepartmentalId(order.getGuideDepartmentId()); |
| | | entity.setToUserId(order.getGuideUserId()); |
| | | entity.setGuideId(order.getId().toString()); |
| | | iGuideEvolveService.insertConfig(entity); |
| | | return toAjax(iGuideRepairOrderService.updateConfig(order)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 取消导办工单 |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "取消导办工单",response = GuideRepairOrder.class) |
| | | @PostMapping("/cancel") |
| | | @Authorization |
| | | public ResultData cancel(@RequestBody GuideEvolveEntity entity, @CurrentUser SysUser sysUser) |
| | | { |
| | | if(entity==null) |
| | | { |
| | | return ResultData.error("参数不能为空"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(entity.getGuideId())) |
| | | { |
| | | return ResultData.error("工单id不能为空"); |
| | | } |
| | | |
| | | GuideRepairOrder order=iGuideRepairOrderService.selectConfigData(entity.getGuideId(),""); |
| | | if(order==null) |
| | | { |
| | | return ResultData.error("该工单不存在!"); |
| | | } |
| | | |
| | | if(!StringUtils.equals(order.getState(),"1")) |
| | | { |
| | | return ResultData.error("该工单不能取消!"); |
| | | } |
| | | //取消状态 |
| | | order.setState("5"); |
| | | |
| | | //新增已取消记录 |
| | | entity.setCreateTime(LocalDateTime.now()); |
| | | entity.setUpdateTime(LocalDateTime.now()); |
| | | entity.setState("5"); |
| | | entity.setDepartmentalId(sysUser.getDepartmentId()); |
| | | entity.setToUserId(sysUser.getUserId()+""); |
| | | iGuideEvolveService.insertConfig(entity); |
| | | return toAjax(iGuideRepairOrderService.updateConfig(order)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 工单评价 |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "工单评价",response = GuideRepairOrder.class) |
| | | @PostMapping("/evaluate") |
| | | @Authorization |
| | | public ResultData evaluate(@RequestBody GuideRepairOrder entity, @CurrentUser SysUser sysUser) |
| | | { |
| | | if(entity==null) |
| | | { |
| | | return ResultData.error("参数不能为空"); |
| | | } |
| | | |
| | | if(entity.getId()<=0) |
| | | { |
| | | return ResultData.error("工单id不能为空"); |
| | | } |
| | | |
| | | if(!StringUtils.equals(entity.getState(),"4")) |
| | | { |
| | | return ResultData.error("该工单不能评价!"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(entity.getEvaluateState())) |
| | | { |
| | | return ResultData.error("满意程度不能为空!"); |
| | | } |
| | | |
| | | //已办结 |
| | | entity.setState("3"); |
| | | //新增已办结记录 |
| | | GuideEvolveEntity guideEvolveEntity=new GuideEvolveEntity(); |
| | | guideEvolveEntity.setCreateTime(LocalDateTime.now()); |
| | | guideEvolveEntity.setUpdateTime(LocalDateTime.now()); |
| | | guideEvolveEntity.setState("3"); |
| | | guideEvolveEntity.setDepartmentalId(sysUser.getDepartmentId()); |
| | | guideEvolveEntity.setToUserId(sysUser.getUserId()+""); |
| | | int i = iGuideRepairOrderService.updateConfig(entity); |
| | | if (i>0) |
| | | return toAjax( iGuideEvolveService.insertConfig(guideEvolveEntity)); |
| | | else |
| | | return ResultData.error(); |
| | | } |
| | | |
| | | /** |
| | | * 获取个人中心工单数据 |
| | | * @param sysUser 当前登录人员信息 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "获取个人中心工单数据",response = GuideRepairOrder.class) |
| | | @GetMapping("/personalCenter") |
| | | @Authorization |
| | | public ResultData selectBySubmitId(@CurrentUser SysUser sysUser){ |
| | | return ResultData.success(iGuideRepairOrderService.selectBySubmitId(sysUser.getUserId().toString())); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |