|
@@ -1,5 +1,6 @@
|
|
|
package org.springblade.business.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
@@ -14,15 +15,19 @@ import org.springblade.business.entity.UserOpinionFile;
|
|
|
import org.springblade.business.entity.UserOpinionFlow;
|
|
|
import org.springblade.business.service.IUserOpinionFileService;
|
|
|
import org.springblade.business.service.IUserOpinionFlowService;
|
|
|
-import org.springblade.common.utils.IDUtils;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
|
+import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
|
|
|
+import org.springblade.manager.feign.ProjectAssignmentUserClient;
|
|
|
import org.springblade.system.entity.DictBiz;
|
|
|
import org.springblade.system.feign.IDictBizClient;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
+import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springblade.system.vo.DictBizVO;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -33,10 +38,7 @@ import org.springblade.business.vo.UserOpinionVO;
|
|
|
import org.springblade.business.service.IUserOpinionService;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 用户意见表 控制器
|
|
@@ -58,6 +60,29 @@ public class UserOpinionController extends BladeController {
|
|
|
|
|
|
private final IDictBizClient dictBizClient;
|
|
|
|
|
|
+ private final ProjectAssignmentUserClient projectAssignmentUserClient;
|
|
|
+
|
|
|
+ private final IUserClient userClient;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消点赞
|
|
|
+ * @param userOpinionId 工单ID
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping("/cancelGood")
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
+ @ApiOperation(value = "取消点赞")
|
|
|
+ @ApiImplicitParam(name = "userOpinionId", value = "工单ID")
|
|
|
+ public R<Boolean> cancelGood(@RequestParam String userOpinionId){
|
|
|
+ if(StringUtils.isNotEmpty(userOpinionId)){
|
|
|
+ UserOpinion opinion = this.userOpinionService.getById(userOpinionId);
|
|
|
+ //获取原本的点赞数
|
|
|
+ Integer oldGood = opinion.getGoodNumber();
|
|
|
+ return R.data(this.userOpinionService.update(Wrappers.<UserOpinion>lambdaUpdate().set(UserOpinion::getGoodNumber, (oldGood - 1)).eq(UserOpinion::getId, userOpinionId)));
|
|
|
+ }
|
|
|
+ return R.data(-1, false, "数据操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取工单服务相关数据字典
|
|
|
* @return 结果
|
|
@@ -68,30 +93,47 @@ public class UserOpinionController extends BladeController {
|
|
|
public R<List<DictBizVO>> queryDictBizList(){
|
|
|
//获取字典
|
|
|
List<DictBiz> dictList = this.dictBizClient.getList("opinion_type", "").getData();
|
|
|
- //首先找到父节点为0的
|
|
|
- List<DictBizVO> result = new ArrayList<>();
|
|
|
+ //找到根节点
|
|
|
+ DictBiz root = null;
|
|
|
Iterator<DictBiz> iterator = dictList.iterator();
|
|
|
while (iterator.hasNext()){
|
|
|
DictBiz biz = iterator.next();
|
|
|
if(new Long("0").equals(biz.getParentId())){
|
|
|
+ root = biz;
|
|
|
+ iterator.remove();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //首先找到父节点为0的
|
|
|
+ List<DictBizVO> result = new ArrayList<>();
|
|
|
+ Iterator<DictBiz> iterator1 = dictList.iterator();
|
|
|
+ while (iterator1.hasNext()){
|
|
|
+ DictBiz biz = iterator1.next();
|
|
|
+ if(root != null && root.getId().equals(biz.getParentId())){
|
|
|
DictBizVO vo = new DictBizVO();
|
|
|
BeanUtils.copyProperties(biz, vo);
|
|
|
result.add(vo);
|
|
|
- iterator.remove();
|
|
|
+ iterator1.remove();
|
|
|
+ } else if(new Long("0").equals(biz.getParentId())){
|
|
|
+ DictBizVO vo = new DictBizVO();
|
|
|
+ BeanUtils.copyProperties(biz, vo);
|
|
|
+ result.add(vo);
|
|
|
+ iterator1.remove();
|
|
|
}
|
|
|
}
|
|
|
//组成相关结构树
|
|
|
result.forEach(vo -> {
|
|
|
List<DictBizVO> clientList = new ArrayList<>();
|
|
|
- Iterator<DictBiz> iterators = dictList.iterator();
|
|
|
- while (iterators.hasNext()){
|
|
|
- DictBiz biz = iterators.next();
|
|
|
+ Iterator<DictBiz> iterator2 = dictList.iterator();
|
|
|
+ while (iterator2.hasNext()){
|
|
|
+ DictBiz biz = iterator2.next();
|
|
|
if(biz.getParentId().equals(vo.getId())){
|
|
|
//找到子节点
|
|
|
DictBizVO voClient = new DictBizVO();
|
|
|
BeanUtils.copyProperties(biz, voClient);
|
|
|
clientList.add(voClient);
|
|
|
- iterators.remove();
|
|
|
+ iterator2.remove();
|
|
|
}
|
|
|
}
|
|
|
vo.setChildren(clientList);
|
|
@@ -156,7 +198,7 @@ public class UserOpinionController extends BladeController {
|
|
|
//设置用户信息
|
|
|
this.setUserData(userOpinionVo);
|
|
|
//生成主表ID
|
|
|
- long idKey = IDUtils.generateId19();
|
|
|
+ long idKey = SnowFlakeUtil.getId();
|
|
|
userOpinionVo.setId(idKey);
|
|
|
|
|
|
//获取附件信息
|
|
@@ -183,18 +225,39 @@ public class UserOpinionController extends BladeController {
|
|
|
//新增附件信息
|
|
|
this.userOpinionFileService.saveBatch(saveFileList);
|
|
|
}
|
|
|
+ //获取当前项目合同段下分配的维护人员
|
|
|
+ String manageUserName = "admin", manegeUserPhone = "";
|
|
|
+ Long manageUser = 1123598821738675201L;
|
|
|
+ try{
|
|
|
+ List<SaveUserInfoByProjectDTO> assignmentUserList = this.projectAssignmentUserClient.queryCurrentProjectContractAssignmentUserList(userOpinionVo.getProjectId(), userOpinionVo.getContractId());
|
|
|
+ if(assignmentUserList != null && assignmentUserList.size() > 0){
|
|
|
+ //有分配人员,随机获取某一个人员
|
|
|
+ Random random = new Random();
|
|
|
+ //随机结果集长度下的数量
|
|
|
+ int ran = random.nextInt(assignmentUserList.size());
|
|
|
+ SaveUserInfoByProjectDTO userDto = assignmentUserList.get(ran);
|
|
|
+ User user = this.userClient.userInfoById(Long.parseLong(userDto.getUserId())).getData();
|
|
|
+ if(user != null){
|
|
|
+ manageUser = user.getId();
|
|
|
+ manageUserName = user.getRealName();
|
|
|
+ manegeUserPhone = user.getPhone();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
|
|
|
//生成第一次流程
|
|
|
List<UserOpinionFlow> saveFlowList = new ArrayList<>();
|
|
|
+ String manageTime = DateUtil.format(DateUtils.addDays(new Date(), 5), "yyyy-MM-dd");
|
|
|
//提交成功环节
|
|
|
- saveFlowList.add(setUserData(new UserOpinionFlow(idKey, 2, 1, 1, "已提交", "已成功提交您的工单信息", null, 123654L, "马自达", "123456789")));
|
|
|
+ saveFlowList.add(setUserData(new UserOpinionFlow(idKey, 2, 1, 1, "已提交", "已成功提交您的工单信息", manageTime, manageUser, manageUserName, manegeUserPhone)));
|
|
|
//分配维护人员环节
|
|
|
- saveFlowList.add(setUserData(new UserOpinionFlow(idKey, 1, 1, 2, "已分配专属客服", "客服:马自达<br>电话:123456789", null, 123654L, "马自达", "123456789")));
|
|
|
+ saveFlowList.add(setUserData(new UserOpinionFlow(idKey, 1, 1, 2, "已分配专属客服", "客服:" + manageUser + "<br>电话:" + manegeUserPhone, manageTime, manageUser, manageUserName, manegeUserPhone)));
|
|
|
//进入人工预处理环节
|
|
|
- String manageTime = DateUtil.format(DateUtils.addDays(new Date(), 5), "yyyy-MM-dd");
|
|
|
- saveFlowList.add(setUserData(new UserOpinionFlow(idKey, 0, 1, 3, "进入人工预处理环节", "预计" + manageTime + "之前完成", manageTime, 123654L, "马自达", "123456789")));
|
|
|
+ saveFlowList.add(setUserData(new UserOpinionFlow(idKey, 0, 1, 3, "进入人工预处理环节", "预计" + manageTime + "之前完成", manageTime, manageUser, manageUserName, manegeUserPhone)));
|
|
|
//问题已解决
|
|
|
- saveFlowList.add(setUserData(new UserOpinionFlow(idKey, 0, 1, 4, "问题已解决", null, null, 123654L, "马自达", "123456789")));
|
|
|
+ saveFlowList.add(setUserData(new UserOpinionFlow(idKey, 0, 1, 4, "问题已解决", null, manageTime, manageUser, manageUserName, manegeUserPhone)));
|
|
|
//新增处理环节
|
|
|
this.userOpinionFlowService.saveBatch(saveFlowList);
|
|
|
//最后新增主表数据
|
|
@@ -219,7 +282,7 @@ public class UserOpinionController extends BladeController {
|
|
|
//获取当前登录人
|
|
|
BladeUser user = AuthUtil.getUser();
|
|
|
userOpinion.setCreateUser(user.getUserId());
|
|
|
- userOpinion.setCreateUserName(user.getUserName());
|
|
|
+ userOpinion.setCreateUserName(user.getRoleName());
|
|
|
userOpinion.setCreateDept(user.getDeptId().contains(",") ? Long.parseLong(user.getDeptId().split(",")[0]) : Long.parseLong(user.getDeptId()));
|
|
|
}
|
|
|
}
|