| | |
| | | import com.core.common.R; |
| | | import com.core.domain.KeyValueVo; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.crm.common.entity.PhoneCodeTypeParam; |
| | | import com.zy.crm.common.model.SettleDto; |
| | | import com.zy.crm.common.web.BaseController; |
| | | import com.zy.crm.manager.entity.*; |
| | | import com.zy.crm.manager.service.*; |
| | | import com.zy.crm.manager.utils.CompanySearchUtils; |
| | | import com.zy.crm.system.entity.User; |
| | | import com.zy.crm.system.service.UserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private PriOnline2FollService priOnline2FollService; |
| | | |
| | | @Autowired |
| | | private SmsCodeService smsCodeService; |
| | | |
| | | String PZH = " ———————————————————————————————————————————————————————————————————————————————— "; |
| | | |
| | | @RequestMapping(value = "/priOnline2/{id}/auth") |
| | |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String orderByField, |
| | | @RequestParam(required = false) String orderByType, |
| | | @RequestParam(required = false) String allSwitch, |
| | | @RequestParam(required = false) String condition, |
| | | @RequestParam Map<String, Object> param) { |
| | | @RequestParam Map<String, Object> paramSou) { |
| | | EntityWrapper<PriOnline2> wrapper = new EntityWrapper<>(); |
| | | wrapper.setSqlSelect("id,title,create_time as createTime,filepath,settle,settle_size as settleSize,item_id as itemId,order_num as orderNum,template_name as templateName,user_id as userId,dept_id as deptId,status,update_time as updateTime,check_data as checkData,update_user_id as updateUserId,member_id as memberId"); |
| | | wrapper.setSqlSelect("id,title,create_time as createTime,assistant_plan_id as assistantPlanId,host_plan_id as hostPlanId,assistant_host_sign as assistantHostSign,filepath,settle,settle_size as settleSize,item_id as itemId,order_num as orderNum,template_name as templateName,user_id as userId,dept_id as deptId,status,update_time as updateTime,check_data as checkData,update_user_id as updateUserId,member_id as memberId"); |
| | | // wrapper.in("member_id", getUserRoleBelongsToUserId("allopen")); |
| | | excludeTrash(param); |
| | | excludeTrash(paramSou); |
| | | Map<String, Object> param = convertallSwitch(paramSou); |
| | | |
| | | if (!Cools.isEmpty(allSwitch)){ |
| | | List<PriOnline2> priOnline2List = priOnline2Service.listByAll(getUserId()); |
| | | Page<PriOnline2> page1 = new Page<PriOnline2>(curr, limit).setRecords(priOnline2List); |
| | | page1.setTotal(priOnline2Service.listByAllTotal(getUserId())); |
| | | return R.ok(page1); |
| | | } |
| | | |
| | | convert(param, wrapper); |
| | | allLike(PriOnline2.class, param.keySet(), wrapper, condition); |
| | | wrapper.or().eq("member_id", getUserId()); |
| | | if (!Cools.isEmpty(orderByField)) { |
| | | wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); |
| | | } |
| | | // if (!Cools.isEmpty(orderByField)) { |
| | | // wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); |
| | | // } |
| | | wrapper.orderBy("update_time",false); |
| | | wrapper.orderBy("create_time",false); |
| | | return R.ok(priOnline2Service.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private Map<String, Object> convertallSwitch(Map<String, Object> map) { |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | if (entry.getKey().equals("allSwitch")) { |
| | | map.remove("allSwitch"); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) { |
| | | boolean signUserId = false; |
| | | boolean signDeptId = false; |
| | |
| | | } |
| | | if (!signUserId && !signDeptId) { |
| | | if (getRole().getId() == 1) { |
| | | wrapper.or().eq("host_id", 1); |
| | | wrapper.or().eq("host_id", getHostId()); |
| | | } else if (getRole().getId() == 2) { |
| | | wrapper.eq("dept_id", getDeptId()); |
| | | } else { |
| | |
| | | } |
| | | } |
| | | if (signHostId) { |
| | | wrapper.or().eq("host_id", 1); |
| | | wrapper.or().eq("host_id", getHostId()); |
| | | } |
| | | } |
| | | |
| | |
| | | // Item item = itemService.selectById(priOnline.getItemId()); |
| | | Plan plan = planService.selectById(priOnline2.getItemId()); |
| | | User userUp = userService.selectById(plan.getUserId()); |
| | | priOnline2.setAssistantHostSign(plan.getAssistantHostSign()); |
| | | priOnline2.setAssistantPlanId(plan.getAssistantPlanId()); |
| | | priOnline2.setHostPlanId(plan.getId()); |
| | | if (plan.getAssistantHostSign()==1){ |
| | | priOnline2.setHostPlanId(plan.getHostPlanId()); |
| | | } |
| | | |
| | | |
| | | //业务员 |
| | | priOnline2.setUserId(userUp.getId()); |
| | |
| | | if (plan.getStatus() != 1) { |
| | | return R.error("此规划单状态改变,请刷新页面重新选择!"); |
| | | } |
| | | priOnline2.setMemberId(getUserId()); |
| | | |
| | | Cstmr cstmr = cstmrService.selectById(plan.getCstmrId()); |
| | | priOnline2.setTemplateName(cstmr.getName()); //甲方单位名称 |
| | | priOnline2.setTemplateName(cstmr.getName()); //客户信息名称 |
| | | |
| | | priOnline2.setSettle(0); |
| | | |
| | |
| | | // } |
| | | |
| | | // String node="2-"; |
| | | PlanType planType = planTypeService.selectById(plan.getPlanType()); |
| | | // PlanType planType = planTypeService.selectById(plan.getPlanType()); |
| | | // node = node+planType.getType(); |
| | | // ProcessPermissions processPermissions = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 5).eq("process", "2-1"));//2:核价流程 |
| | | // User manager = userService.selectById(processPermissions.getUserId()); // 获取核价流程节点2确认人 |
| | |
| | | List<String> initNames = new ArrayList<>(); |
| | | initNames.add("接取核价任务"); |
| | | initNames.add("完成核价"); |
| | | if (planType.getType().equals(2)) { |
| | | initNames.add("完成核价"); |
| | | } |
| | | // initNames.add("经理审核"); |
| | | initNames.add("业务员确认"); |
| | | List<User> users = new ArrayList<>(); |
| | | users.add(getUser()); |
| | | users.add(getUser()); |
| | | if (planType.getType().equals(2)) { |
| | | users.add(userService.selectById(73)); |
| | | } |
| | | // users.add(new User()); |
| | | users.add(userUp); |
| | | priOnline2.setSettleMsg(JSON.toJSONString(SettleDto.InItFlowPath(users, initNames, users.size()))); |
| | | priOnline2.setSettleSize(users.size()); |
| | | |
| | | priOnline2.setPlanId(plan.getId()); |
| | | if (users.size()>1){ |
| | | priOnline2.setMemberId(users.get(1).getId()); |
| | | } else { |
| | | priOnline2.setMemberId(getUserId()); |
| | | } |
| | | //设置项目流程 |
| | | plan.setStep(2); |
| | | plan.setStatus(2); |
| | | planService.updateById(plan); |
| | | |
| | | priOnline2Service.insert(priOnline2); |
| | | |
| | | // 自动添加跟进人 |
| | | for (User user:users){ |
| | | List<PriOnline2Foll> priOnline2Folls = priOnline2FollService.selectList(new EntityWrapper<PriOnline2Foll>().eq("pri_online2_id", priOnline2.getId()).eq("user_id", user.getId())); |
| | | if (Cools.isEmpty(priOnline2Folls) || priOnline2Folls.size()==0){ |
| | | PriOnline2Foll priOnline2Foll = new PriOnline2Foll(); |
| | | priOnline2Foll.setPriOnline2Id(priOnline2.getId()); |
| | | priOnline2Foll.setUserId(user.getId()); |
| | | if (!priOnline2FollService.insert(priOnline2Foll)) { |
| | | throw new CoolException("保存失败,请重试"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | if (plan.getAssistantHostSign()==1){ |
| | | Plan plan1 = planService.selectById(plan.getHostPlanId()); |
| | | plan1.setStatus2(2); |
| | | planService.updateById(plan1); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/priOnline2/addOther/auth") |
| | | @ManagerAuth(memo = "另存核价管理") |
| | | public R addOther(@RequestBody Map<String, Object> map) { |
| | | if (true){ |
| | | return R.error("禁止!"); |
| | | } |
| | | PriOnline2 online = priOnline2Service.selectById(Long.parseLong(map.get("id").toString())); |
| | | |
| | | PriOnline2 priOnline2 = new PriOnline2(); |
| | |
| | | Plan plan = planService.selectById(priOnline2.getItemId()); |
| | | plan.setStatus(1); |
| | | planService.updateById(plan); |
| | | if (plan.getAssistantHostSign()==1){ |
| | | Plan planHost = planService.selectById(priOnline2.getHostPlanId()); |
| | | planHost.setStatus2(1); |
| | | planService.updateById(planHost); |
| | | } |
| | | } |
| | | |
| | | priOnline2Service.deleteBatchIds(Arrays.asList(ids)); |
| | |
| | | assert priOnline2 != null; |
| | | Date now = new Date(); |
| | | Long nextUserId = getUserId(); |
| | | User user = new User(); |
| | | List<SettleDto> list = new ArrayList<>(); |
| | | |
| | | user = userService.selectById(priOnline2.getMemberId()); |
| | | User user = userService.selectById(priOnline2.getMemberId()); |
| | | |
| | | if (Cools.isEmpty(getUser()) || Cools.isEmpty(user)){ |
| | | return R.error("抱歉,您无需确认!!!"); |
| | |
| | | return R.error("抱歉,您无需确认!!!"); |
| | | } |
| | | // 修改 settle 步骤数据 |
| | | list = JSON.parseArray(priOnline2.getSettleMsg(), SettleDto.class); |
| | | List<SettleDto> list = JSON.parseArray(priOnline2.getSettleMsg(), SettleDto.class); |
| | | for (SettleDto dto : list) { |
| | | if (dto.getStep().equals(priOnline2.getSettle())) { |
| | | dto.setCurr(Boolean.TRUE); |
| | |
| | | } |
| | | dto.setTime(DateUtils.convert(new Date())); |
| | | } else if (dto.getStep().equals(priOnline2.getSettle() + 2)) { |
| | | nextUserId=dto.getUserId(); |
| | | if (Cools.isEmpty(dto.getUserId())){ |
| | | nextUserId= 0L; |
| | | }else { |
| | | nextUserId=dto.getUserId(); |
| | | } |
| | | } |
| | | } |
| | | priOnline2.setSettleMsg(JSON.toJSONString(list)); |
| | |
| | | if (!priOnline2Service.updateById(priOnline2)) { |
| | | throw new CoolException("确认失败,请联系管理员"); |
| | | } |
| | | |
| | | Plan plan = planService.selectById(priOnline2.getItemId()); |
| | | plan.setStatus(3); |
| | | planService.selectById(plan); |
| | | |
| | | if (user.getId().equals(priOnline2.getUserId())) { |
| | | try { |
| | | priQuoteAdd(priOnline2.getId(), plannerId); |
| | | } catch (Exception e) { |
| | | return R.error("自动生成报价单失败"); |
| | | if (priOnline2.getAssistantHostSign()==0){ |
| | | User manager = new User(); |
| | | try { |
| | | manager = userService.getDeptManager(getHostId(), getUser().getDeptId()); // 获取部门领导 |
| | | } catch (Exception e) { |
| | | manager = getUser(); |
| | | } |
| | | try { |
| | | priQuoteAdd(priOnline2.getId(), plannerId); |
| | | } catch (Exception e) { |
| | | return R.error("自动生成报价单失败"); |
| | | } |
| | | if (!smsCodeService.sendSmsCodeText(manager.getMobile(), PhoneCodeTypeParam.ALIYUN_M1ABAC630E,getUserId())) { |
| | | return R.ok("审批成功但短信发送失败!"); |
| | | } |
| | | }else { |
| | | try { |
| | | Plan planHost = planService.selectById(priOnline2.getHostPlanId()); |
| | | planHost.setStatus2(3); |
| | | planService.selectById(planHost); |
| | | } catch (Exception e) { |
| | | return R.error("更新主表失败"); |
| | | } |
| | | } |
| | | }else { |
| | | User phoneUser = userService.selectById(nextUserId); |
| | | if (!smsCodeService.sendSmsCodeText(phoneUser.getMobile(), PhoneCodeTypeParam.ALIYUN_M1ABAC630E,getUserId())) { |
| | | return R.ok("审批成功但短信发送失败!"); |
| | | } |
| | | } |
| | | |
| | |
| | | @ManagerAuth |
| | | public R priOnline2priQuoteAdd(@RequestParam Long planId) { |
| | | List<KeyValueVo> vos = new ArrayList<>(); |
| | | vos.add(new KeyValueVo("报价模板1", 1L)); |
| | | vos.add(new KeyValueVo("报价模板2", 2L)); |
| | | vos.add(new KeyValueVo("货架模板", 1L)); |
| | | vos.add(new KeyValueVo("集成模板", 2L)); |
| | | return R.ok().add(vos); |
| | | } |
| | | |