陈裕财 2 years ago
parent
commit
f4e7e695ce
  1. 2
      xm-core/src/main/java/com/xm/core/ctrl/XmTaskExecuserController.java
  2. 25
      xm-core/src/main/java/com/xm/core/service/XmTaskExecuserService.java
  3. 47
      xm-core/src/main/java/com/xm/core/service/XmTaskService.java
  4. 8
      xm-core/src/main/java/com/xm/core/service/client/SysClient.java

2
xm-core/src/main/java/com/xm/core/ctrl/XmTaskExecuserController.java

@ -168,7 +168,7 @@ public class XmTaskExecuserController {
if(ObjectTools.isEmpty(xmTaskExecuser.getTaskId())){ if(ObjectTools.isEmpty(xmTaskExecuser.getTaskId())){
return Result.error("taskId-required","任务编号不能为空"); return Result.error("taskId-required","任务编号不能为空");
} }
XmTask xmTaskDb=xmTaskService.selectOneObject(new XmTask(xmTaskExecuser.getTaskId()));
XmTask xmTaskDb=xmTaskService.getById(xmTaskExecuser.getTaskId());
if(xmTaskDb==null){ if(xmTaskDb==null){
return Result.error("任务已不存在"); return Result.error("任务已不存在");

25
xm-core/src/main/java/com/xm/core/service/XmTaskExecuserService.java

@ -5,14 +5,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mdp.core.err.BizException; import com.mdp.core.err.BizException;
import com.mdp.core.service.BaseService; import com.mdp.core.service.BaseService;
import com.mdp.core.utils.ObjectTools;
import com.mdp.msg.client.PushNotifyMsgService; import com.mdp.msg.client.PushNotifyMsgService;
import com.mdp.safe.client.entity.Dept; import com.mdp.safe.client.entity.Dept;
import com.mdp.safe.client.entity.User; import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils; import com.mdp.safe.client.utils.LoginUtils;
import com.xm.core.entity.XmProject;
import com.xm.core.entity.XmTask; import com.xm.core.entity.XmTask;
import com.xm.core.entity.XmTaskExecuser; import com.xm.core.entity.XmTaskExecuser;
import com.xm.core.mapper.XmTaskExecuserMapper; import com.xm.core.mapper.XmTaskExecuserMapper;
import com.xm.core.service.client.MkClient; import com.xm.core.service.client.MkClient;
import com.xm.core.service.client.SysClient;
import com.xm.core.service.push.XmPushMsgService; import com.xm.core.service.push.XmPushMsgService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -37,6 +40,9 @@ public class XmTaskExecuserService extends BaseService<XmTaskExecuserMapper,XmTa
@Autowired @Autowired
XmTaskService xmTaskService; XmTaskService xmTaskService;
@Autowired
XmProjectService xmProjectService;
@Autowired @Autowired
XmGroupService groupService; XmGroupService groupService;
@ -48,6 +54,9 @@ public class XmTaskExecuserService extends BaseService<XmTaskExecuserMapper,XmTa
@Autowired @Autowired
PushNotifyMsgService notifyMsgService; PushNotifyMsgService notifyMsgService;
@Autowired
SysClient sysClient;
@Autowired @Autowired
MkClient mkClient; MkClient mkClient;
@ -189,7 +198,21 @@ public class XmTaskExecuserService extends BaseService<XmTaskExecuserMapper,XmTa
throw new BizException(xmTaskExecuserDb.getBidUsername()+"没有填写报价金额,不允许变更为执行人。"); throw new BizException(xmTaskExecuserDb.getBidUsername()+"没有填写报价金额,不允许变更为执行人。");
} }
} }
XmTaskExecuser xmTaskExecuser2=new XmTaskExecuser();
XmTaskExecuser xmTaskExecuser2=new XmTaskExecuser();
if(ObjectTools.isEmpty(xmTaskExecuserDb.getPrjUserid())){
XmProject projectDb=this.xmProjectService.getProjectFromCache(projectId);
User userParams=new User();
userParams.setCpaUserid(xmTaskExecuserDb.getBidUserid());
userParams.setCpaOrg(xmTaskExecuserDb.getBidBranchId());
userParams.setUsername(xmTaskExecuserDb.getBidUsername());
User userdb=sysClient.createUserIfNotExists(userParams,projectDb.getDeptid(),projectDb.getBranchId());
xmTaskExecuser2.setPrjUserid(userdb.getUserid());
xmTaskExecuser2.setPrjUsername(userdb.getUsername());
xmTaskExecuser2.setBranchId(userdb.getBranchId());
}
xmTaskExecuser2.setTaskId(xmTaskExecuser.getTaskId()); xmTaskExecuser2.setTaskId(xmTaskExecuser.getTaskId());
xmTaskExecuser2.setBidUserid(xmTaskExecuser.getBidUserid()); xmTaskExecuser2.setBidUserid(xmTaskExecuser.getBidUserid());
xmTaskExecuser2.setStatus("1"); xmTaskExecuser2.setStatus("1");

47
xm-core/src/main/java/com/xm/core/service/XmTaskService.java

@ -11,13 +11,9 @@ import com.mdp.core.utils.BaseUtils;
import com.mdp.core.utils.DateUtils; import com.mdp.core.utils.DateUtils;
import com.mdp.core.utils.NumberUtil; import com.mdp.core.utils.NumberUtil;
import com.mdp.msg.client.PushNotifyMsgService; import com.mdp.msg.client.PushNotifyMsgService;
import com.mdp.safe.client.entity.Dept;
import com.mdp.safe.client.entity.User; import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils; import com.mdp.safe.client.utils.LoginUtils;
import com.xm.core.entity.XmMenu;
import com.xm.core.entity.XmTask;
import com.xm.core.entity.XmTaskExecuser;
import com.xm.core.entity.XmTaskSkill;
import com.xm.core.entity.*;
import com.xm.core.mapper.XmTaskMapper; import com.xm.core.mapper.XmTaskMapper;
import com.xm.core.queue.XmTaskSumParentsPushService; import com.xm.core.queue.XmTaskSumParentsPushService;
import com.xm.core.service.client.SysClient; import com.xm.core.service.client.SysClient;
@ -62,6 +58,8 @@ public class XmTaskService extends BaseService<XmTaskMapper,XmTask> {
@Autowired @Autowired
PushNotifyMsgService notifyMsgService; PushNotifyMsgService notifyMsgService;
@Autowired
XmProjectService xmProjectService;
@Autowired @Autowired
SysClient sysClient; SysClient sysClient;
@ -224,41 +222,39 @@ public class XmTaskService extends BaseService<XmTaskMapper,XmTask> {
xmTaskVo.setTaskSkillNames(xmTaskVo.getSkills().stream().map(k->k.getSkillName()).collect(Collectors.joining(","))); xmTaskVo.setTaskSkillNames(xmTaskVo.getSkills().stream().map(k->k.getSkillName()).collect(Collectors.joining(",")));
xmTaskVo.setTaskSkillIds(xmTaskVo.getSkills().stream().map(k->k.getSkillId()).collect(Collectors.joining(","))); xmTaskVo.setTaskSkillIds(xmTaskVo.getSkills().stream().map(k->k.getSkillId()).collect(Collectors.joining(",")));
} }
XmProject projectDb=xmProjectService.getProjectFromCache(xmTaskVo.getProjectId());
//如果是由服务商提供服务构建的任务 //如果是由服务商提供服务构建的任务
if(StringUtils.hasText(xmTaskVo.getServiceId())){ if(StringUtils.hasText(xmTaskVo.getServiceId())){
Map<String,Object> userServiceData=sysClient.getUserSvrByServiceId(xmTaskVo.getServiceId()); Map<String,Object> userServiceData=sysClient.getUserSvrByServiceId(xmTaskVo.getServiceId());
if(userServiceData!=null && !userServiceData.isEmpty()){ if(userServiceData!=null && !userServiceData.isEmpty()){
User exeUser=BaseUtils.fromMap(userServiceData,User.class);
User bidUser=BaseUtils.fromMap(userServiceData,User.class);
UserSvrVo svrVo=BaseUtils.fromMap(userServiceData,UserSvrVo.class); UserSvrVo svrVo=BaseUtils.fromMap(userServiceData,UserSvrVo.class);
XmTaskExecuser xmTaskExecuser=new XmTaskExecuser(); XmTaskExecuser xmTaskExecuser=new XmTaskExecuser();
xmTaskExecuser.setTaskId(xmTaskVo.getId()); xmTaskExecuser.setTaskId(xmTaskVo.getId());
xmTaskExecuser.setTaskName(xmTaskVo.getName()); xmTaskExecuser.setTaskName(xmTaskVo.getName());
xmTaskExecuser.setProjectId(xmTaskVo.getProjectId()); xmTaskExecuser.setProjectId(xmTaskVo.getProjectId());
xmTaskExecuser.setBidUserid(exeUser.getUserid());
xmTaskExecuser.setBidUsername(exeUser.getUsername());
xmTaskExecuser.setBidBranchId(exeUser.getBranchId());
xmTaskExecuser.setBidUserid(bidUser.getUserid());
xmTaskExecuser.setBidUsername(bidUser.getUsername());
xmTaskExecuser.setBidBranchId(bidUser.getBranchId());
xmTaskExecuser.setBranchId(xmTaskVo.getCbranchId()); xmTaskExecuser.setBranchId(xmTaskVo.getCbranchId());
xmTaskExecuser.setStatus("1"); xmTaskExecuser.setStatus("1");
xmTaskExecuser.setQuoteAmount(svrVo.getPrice()); xmTaskExecuser.setQuoteAmount(svrVo.getPrice());
xmTaskExecuser.setQuoteWorkload(xmTaskVo.getBudgetWorkload()); xmTaskExecuser.setQuoteWorkload(xmTaskVo.getBudgetWorkload());
xmTaskExecuser.setSkillRemark((String)userServiceData.get("skills")); xmTaskExecuser.setSkillRemark((String)userServiceData.get("skills"));
Dept Dept=new Dept();
Dept.setDeptid(this.xmTaskSkillService.createKey("id"));
Dept xmGroupUser=new Dept();
Dept.setBranchId(xmTaskVo.getCbranchId());
List<Dept> gs=new ArrayList<>();
gs.add(Dept);
groupService.addGroups(xmTaskVo.getProjectId(),gs);
User exeUserParams=new User();
exeUserParams.setCpaOrg(bidUser.getBranchId());
exeUserParams.setCpaUserid(bidUser.getUserid());
exeUserParams.setUsername(bidUser.getUsername());
exeUserParams.setDeptid(projectDb.getDeptid());
exeUserParams.setBranchId(projectDb.getBranchId());
User exeUserDb=sysClient.createUserIfNotExists(exeUserParams,projectDb.getDeptid(),projectDb.getBranchId());
xmTaskExecuser.setPrjUserid(exeUserDb.getUserid());
xmTaskExecuser.setPrjUsername(exeUserDb.getUsername());
xmTaskExecuserService.addExecuser(xmTaskExecuser,!"0".equals(xmTaskVo.getStatus())); xmTaskExecuserService.addExecuser(xmTaskExecuser,!"0".equals(xmTaskVo.getStatus()));
xmTaskVo.setExeUserids(exeUser.getUserid());
xmTaskVo.setExeUsernames(exeUser.getUsername());
xmTaskVo.setExecutorUserid(exeUser.getUserid());
xmTaskVo.setExecutorUsername(exeUser.getUsername());
xmTaskVo.setExeUserids(exeUserDb.getUserid());
xmTaskVo.setExeUsernames(exeUserDb.getUsername());
xmTaskVo.setExecutorUserid(exeUserDb.getUserid());
xmTaskVo.setExecutorUsername(exeUserDb.getUsername());
xmTaskVo.setExecUsers(1); xmTaskVo.setExecUsers(1);
xmTaskVo.setStatus("1"); xmTaskVo.setStatus("1");
xmTaskVo.setBidStep("4"); xmTaskVo.setBidStep("4");
@ -267,7 +263,6 @@ public class XmTaskService extends BaseService<XmTaskMapper,XmTask> {
xmTaskVo.setEstate("1"); xmTaskVo.setEstate("1");
xmTaskVo.setQuoteFinalAt(svrVo.getPrice()); xmTaskVo.setQuoteFinalAt(svrVo.getPrice());
xmTaskVo.setBidEtime(new Date()); xmTaskVo.setBidEtime(new Date());
} }
} }

8
xm-core/src/main/java/com/xm/core/service/client/SysClient.java

@ -134,4 +134,12 @@ public class SysClient {
public List<Dept> listSubDept(String pdeptid) { public List<Dept> listSubDept(String pdeptid) {
return null; return null;
} }
public User createUserIfNotExists(User exeUser,String deptid,String branchId) {
String url="/sys/user/createIfNotExists";
exeUser.setBranchId(branchId);
Map<String,Object> re=callBizService.postForMap(url,map("user",exeUser ,"userDept",map("deptid",deptid)));
User user=BaseUtils.fromMap((Map<String, Object>) re.get("data"),User.class);
return user;
}
} }
Loading…
Cancel
Save