| | |
| | | @Autowired |
| | | private SmsCodeService smsCodeService; |
| | | |
| | | String PZH=" ———————————————————————————————————————————————————————————————————————————————— "; |
| | | String PZH = " ———————————————————————————————————————————————————————————————————————————————— "; |
| | | |
| | | @RequestMapping(value = "/priQuote/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | |
| | | @RequestMapping(value = "/priQuote/list/auth") |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam(required = false)String condition, |
| | | @RequestParam Map<String, Object> param){ |
| | | public R list(@RequestParam(defaultValue = "1") Integer curr, |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String orderByField, |
| | | @RequestParam(required = false) String orderByType, |
| | | @RequestParam(required = false) String condition, |
| | | @RequestParam Map<String, Object> param) { |
| | | EntityWrapper<PriQuote> wrapper = new EntityWrapper<>(); |
| | | wrapper.setSqlSelect("id,title,create_time as createTime,plan_id as planId,filepath,item_id as itemId,order_num as orderNum,template_name as templateName,sheet_data as sheetData,user_id as userId,dept_id as deptId,settle,settle_msg as settleMsg,form,update_user_id as updateUserId,update_time as updateTime,in_order_num as inOrderNum,member_id as memberId,template"); |
| | | // wrapper.in("member_id", getUserRoleBelongsToUserId()); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | allLike(PriQuote.class, param.keySet(), wrapper, condition); |
| | | wrapper.or().eq("member_id",getUserId()); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | wrapper.or().eq("member_id", getUserId()); |
| | | wrapper.orderBy("update_time", false); |
| | | wrapper.orderBy("create_time", false); |
| | | if (!Cools.isEmpty(orderByField)) { |
| | | wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); |
| | | } |
| | | return R.ok(priQuoteService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) { |
| | | boolean signUserId = false; |
| | | boolean signDeptId = false; |
| | | boolean signHostId = false; |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().equals("dept_id")){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | if (entry.getKey().equals("dept_id")) { |
| | | signDeptId = true; |
| | | if (String.valueOf(entry.getValue()).equals("19")){ |
| | | if (String.valueOf(entry.getValue()).equals("19")) { |
| | | signHostId = true; |
| | | } |
| | | } |
| | | } |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | String val = String.valueOf(entry.getValue()); |
| | | if (val.contains(RANGE_TIME_LINK)){ |
| | | if (val.contains(RANGE_TIME_LINK)) { |
| | | String[] dates = val.split(RANGE_TIME_LINK); |
| | | wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); |
| | | wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); |
| | | } else if (entry.getKey().equals("dept_id")){ |
| | | if (!val.equals("19")){ |
| | | } else if (entry.getKey().equals("dept_id")) { |
| | | if (!val.equals("19")) { |
| | | wrapper.eq(entry.getKey(), val); |
| | | } |
| | | } else if (entry.getKey().equals("user_id") && !signDeptId){ |
| | | } else if (entry.getKey().equals("user_id") && !signDeptId) { |
| | | signUserId = true; |
| | | wrapper.eq(entry.getKey(), val); |
| | | } else { |
| | | wrapper.like(entry.getKey(), val); |
| | | } |
| | | } |
| | | if (!signUserId && !signDeptId){ |
| | | if (getRole().getId()==1){ |
| | | wrapper.or().eq("host_id",1); |
| | | }else if (getRole().getId()==2){ |
| | | wrapper.eq("dept_id",getDeptId()); |
| | | }else { |
| | | if (!signUserId && !signDeptId) { |
| | | if (getRole().getId() == 1) { |
| | | wrapper.or().eq("host_id", getHostId()); |
| | | } else if (getRole().getId() == 2) { |
| | | wrapper.eq("dept_id", getDeptId()); |
| | | } else { |
| | | wrapper.eq("user_id", getUserId()); |
| | | } |
| | | } |
| | | if (signHostId){ |
| | | wrapper.or().eq("host_id",1); |
| | | if (signHostId) { |
| | | wrapper.or().eq("host_id", getHostId()); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/priQuote/add/auth") |
| | | @ManagerAuth(memo = "添加报价单") |
| | | public R add(@RequestBody Map<String,Object> map) { |
| | | public R add(@RequestBody Map<String, Object> map) { |
| | | // PriQuoteBudget priQuoteBudget = priQuoteBudgetService.selectById(Long.parseLong(map.get("priQuoteBudgetId").toString())); |
| | | PriOnline2 priOnline2 = priOnline2Service.selectById(Long.parseLong(map.get("priQuoteBudgetId").toString())); |
| | | |
| | |
| | | priQuote.setPlanId(priOnline2.getPlanId()); |
| | | |
| | | |
| | | |
| | | //设置项目流程 |
| | | plan.setStep(5); |
| | | |
| | | priQuote.setForm(JSON.toJSONString(map)); // 自定义表单内容 |
| | | priQuote.setSettle(1); // 1.开始 |
| | | User manager = new User(); |
| | | try{ |
| | | try { |
| | | manager = userService.getDeptManager(getHostId(), userUp.getDeptId()); // 获取部门领导 |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | manager = userUp; |
| | | } |
| | | priQuote.setMemberId(manager.getId()); |
| | | ProcessPermissions processPermissions = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 2).eq("process", "3-1"));//2:报价流程 |
| | | User president = userService.selectById(processPermissions.getUserId()); // 获取报价流程节点3-1确认人 |
| | | priQuote.setSettleMsg(JSON.toJSONString(SettleDto.initPriQuote(plan, manager,president,getUser()))); |
| | | priQuote.setSettleMsg(JSON.toJSONString(SettleDto.initPriQuote(plan, manager, president, getUser()))); |
| | | |
| | | planService.updateById(plan); |
| | | |
| | |
| | | |
| | | @RequestMapping(value = "/priQuote/addOther/auth") |
| | | @ManagerAuth(memo = "另存报价单") |
| | | public R addOther(@RequestBody Map<String,Object> map) { |
| | | public R addOther(@RequestBody Map<String, Object> map) { |
| | | PriQuote quote = priQuoteService.selectById(Long.parseLong(map.get("id").toString())); |
| | | |
| | | PriQuote priQuote = new PriQuote(); |
| | |
| | | |
| | | @RequestMapping(value = "/priQuote/update/auth") |
| | | @ManagerAuth(memo = "更新报价单") |
| | | public R update(@RequestBody Map<String,Object> map){ |
| | | public R update(@RequestBody Map<String, Object> map) { |
| | | PriQuote priQuote = priQuoteService.selectById(Long.parseLong(map.get("id").toString())); |
| | | priQuote.setTitle(map.get("title").toString()); |
| | | priQuote.setSheetData(map.get("sheetData").toString()); |
| | |
| | | |
| | | @RequestMapping(value = "/priQuote/updateForm/auth") |
| | | @ManagerAuth(memo = "更新报价单") |
| | | public R updateForm(Long id,String templateName,String title){ |
| | | public R updateForm(Long id, String templateName, String title) { |
| | | PriQuote priQuote = priQuoteService.selectById(id); |
| | | priQuote.setTemplateName(templateName); |
| | | priQuote.setTitle(title); |
| | |
| | | |
| | | @RequestMapping(value = "/priQuote/delete/auth") |
| | | @ManagerAuth(memo = "删除报价单") |
| | | public R delete(Long[] ids){ |
| | | if (Cools.isEmpty(ids)){ |
| | | public R delete(Long[] ids) { |
| | | if (Cools.isEmpty(ids)) { |
| | | return R.error(); |
| | | } |
| | | priQuoteService.deleteBatchIds(Arrays.asList(ids)); |
| | |
| | | |
| | | @RequestMapping(value = "/priQuote/export/auth") |
| | | @ManagerAuth |
| | | public R export(@RequestBody JSONObject param){ |
| | | public R export(@RequestBody JSONObject param) { |
| | | EntityWrapper<PriQuote> wrapper = new EntityWrapper<>(); |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("priOnline")); |
| | |
| | | wrapper.in("user_id", getUserRoleBelongsToUserId()); |
| | | Page<PriQuote> page = priQuoteService.selectPage(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (PriQuote priQuote : page.getRecords()){ |
| | | for (PriQuote priQuote : page.getRecords()) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", priQuote.getId()); |
| | | map.put("value", priQuote.getId()); |
| | |
| | | @ManagerAuth |
| | | public R query(@RequestBody JSONObject param) { |
| | | Wrapper<PriQuote> wrapper = new EntityWrapper<PriQuote>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); |
| | | if (null != priQuoteService.selectOne(wrapper)){ |
| | | if (null != priQuoteService.selectOne(wrapper)) { |
| | | return R.parse(BaseRes.REPEAT).add(getComment(PriQuote.class, String.valueOf(param.get("key")))); |
| | | } |
| | | return R.ok(); |
| | |
| | | |
| | | @PostMapping("/priQuote/excel/downfile") |
| | | @ManagerAuth |
| | | public R downExcelFile(@RequestBody Map<String,Object> map) { |
| | | public R downExcelFile(@RequestBody Map<String, Object> map) { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss"); |
| | | String path = ClassUtils.getDefaultClassLoader().getResource("excel").getPath(); |
| | | String path = ClassUtils.getDefaultClassLoader().getResource("excel").getPath(); |
| | | String filename = format.format(new Date()) + ".xlsx"; |
| | | String filepath = path + "/" + filename; |
| | | exportLuckySheetXlsx(path, "/" + filename, map.get("exceldata").toString(), map.get("template").toString()); |
| | |
| | | } |
| | | |
| | | @GetMapping("/priQuote/excel/{path}") |
| | | public void download(@PathVariable String path,HttpServletResponse response) { |
| | | public void download(@PathVariable String path, HttpServletResponse response) { |
| | | try { |
| | | ClassPathResource pathResource = new ClassPathResource("excel/" + path); |
| | | File file = pathResource.getFile(); |
| | |
| | | JSONObject jsonObject = (JSONObject) jsonArray.get(0); |
| | | JSONArray jsonObjectList = jsonObject.getJSONArray("celldata"); |
| | | //excel模板路径 |
| | | String filePath = ClassUtils.getDefaultClassLoader().getResource("excel").getPath() + "/priQuoteTemplate/data" + template +".xlsx"; |
| | | String filePath = ClassUtils.getDefaultClassLoader().getResource("excel").getPath() + "/priQuoteTemplate/data" + template + ".xlsx"; |
| | | // String filePath = "/Users/ouyang/Downloads/uploadTestProductFile/生产日报表.xlsx"; |
| | | File file = new File(filePath); |
| | | FileInputStream in = null; |
| | |
| | | @PostMapping(value = "/priQuote/approval/auth") |
| | | @ManagerAuth |
| | | public R approvalPriQuote(@RequestParam Long planId, |
| | | @RequestParam(required = false) Long plannerId){ |
| | | @RequestParam(required = false) Long plannerId) { |
| | | PriQuote priQuote = priQuoteService.selectById(planId); |
| | | assert priQuote != null; |
| | | |
| | |
| | | // 本部门经理审核 |
| | | User user = userService.selectById(priQuote.getUserId()); |
| | | User manager = new User(); |
| | | try{ |
| | | try { |
| | | manager = userService.getDeptManager(getHostId(), user.getDeptId()); // 获取部门领导 |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | manager = user; |
| | | } |
| | | if (manager.getId().equals(getUserId())) { |
| | |
| | | break; |
| | | case 2: |
| | | dto.setCurr(Boolean.TRUE); |
| | | if (Cools.isEmpty(dto.getMsg())){ |
| | | if (Cools.isEmpty(dto.getMsg())) { |
| | | dto.setMsg("部门经理" + manager.getNickname() + "审批通过"); |
| | | }else { |
| | | dto.setMsg(dto.getMsg()+PZH+DateUtils.convert(new Date())+" "+"部门经理" + manager.getNickname() + "审批通过"); |
| | | } else { |
| | | dto.setMsg(dto.getMsg() + PZH + DateUtils.convert(new Date()) + " " + "部门经理" + manager.getNickname() + "审批通过"); |
| | | } |
| | | dto.setTime(DateUtils.convert(new Date())); |
| | | break; |
| | |
| | | if (!priQuoteService.updateById(priQuote)) { |
| | | throw new CoolException("审核失败,请联系管理员"); |
| | | } |
| | | if (!smsCodeService.sendSmsCodeText(planLeader.getMobile(), PhoneCodeTypeParam.ALIYUN_M1ABAC630E,getUserId())) { |
| | | if (!smsCodeService.sendSmsCodeText(planLeader.getMobile(), PhoneCodeTypeParam.ALIYUN_M1ABAC630E, getUserId())) { |
| | | return R.ok("审批成功但短信发送失败!"); |
| | | } |
| | | |
| | |
| | | break; |
| | | case 3: |
| | | dto.setCurr(Boolean.TRUE); |
| | | if (Cools.isEmpty(dto.getMsg())){ |
| | | if (Cools.isEmpty(dto.getMsg())) { |
| | | dto.setMsg("总裁办" + planLeader.getNickname() + "审批通过"); |
| | | }else { |
| | | dto.setMsg(dto.getMsg()+PZH+DateUtils.convert(new Date())+" "+"总经办" + planLeader.getNickname() + "审批通过"); |
| | | } else { |
| | | dto.setMsg(dto.getMsg() + PZH + DateUtils.convert(new Date()) + " " + "总经办" + planLeader.getNickname() + "审批通过"); |
| | | } |
| | | dto.setTime(DateUtils.convert(new Date())); |
| | | break; |
| | |
| | | throw new CoolException("审核失败,请联系管理员"); |
| | | } |
| | | User phoneUser = userService.selectById(priQuote.getUserId()); |
| | | if (!smsCodeService.sendSmsCodeText(phoneUser.getMobile(), PhoneCodeTypeParam.ALIYUN_M1ABAC630E,getUserId())) { |
| | | if (!smsCodeService.sendSmsCodeText(phoneUser.getMobile(), PhoneCodeTypeParam.ALIYUN_M1ABAC630E, getUserId())) { |
| | | return R.ok("审批成功但短信发送失败!"); |
| | | } |
| | | break; |
| | |
| | | break; |
| | | case 4: |
| | | dto.setCurr(Boolean.TRUE); |
| | | if (Cools.isEmpty(dto.getMsg())){ |
| | | if (Cools.isEmpty(dto.getMsg())) { |
| | | dto.setMsg("业务员" + salesman0.getNickname() + "审批通过"); |
| | | }else { |
| | | dto.setMsg(dto.getMsg()+PZH+DateUtils.convert(new Date())+" "+"业务员" + salesman0.getNickname() + "审批通过"); |
| | | } else { |
| | | dto.setMsg(dto.getMsg() + PZH + DateUtils.convert(new Date()) + " " + "业务员" + salesman0.getNickname() + "审批通过"); |
| | | } |
| | | dto.setTime(DateUtils.convert(new Date())); |
| | | break; |
| | |
| | | @PostMapping(value = "/priQuote/refuse/auth") |
| | | @ManagerAuth |
| | | public R refusePriQuote(@RequestParam Long planId, |
| | | @RequestParam(required = false) Long plannerId){ |
| | | @RequestParam(required = false) Long plannerId) { |
| | | |
| | | PriQuote priQuote = priQuoteService.selectById(planId); |
| | | |
| | | Date now = new Date(); |
| | | Long memberId = priQuote.getMemberId(); |
| | | User member = userService.selectById(memberId); |
| | | if (!member.getId().equals(getUserId())){ |
| | | if (!member.getId().equals(getUserId())) { |
| | | return R.error("抱歉,您没有审核的权限"); |
| | | } |
| | | List<SettleDto> planDtos = JSON.parseArray(priQuote.getSettleMsg(), SettleDto.class); |
| | | List<SettleDto> planDtoList = new ArrayList<>(); |
| | | boolean sign = true; |
| | | for (SettleDto dto : planDtos) { |
| | | if (dto.getStep().equals(2)){ |
| | | if (dto.getStep().equals(2)) { |
| | | priQuote.setMemberId(dto.getUserId()); |
| | | } |
| | | if (sign && dto.getUserId().equals(memberId) && priQuote.getSettle()+1==dto.getStep()){ |
| | | if (Cools.isEmpty(dto.getMsg())){ |
| | | dto.setMsg(DateUtils.convert(now)+" "+member.getNickname()+"回退审批"); |
| | | }else { |
| | | dto.setMsg(dto.getMsg()+PZH+DateUtils.convert(now)+" "+member.getNickname()+"回退审批"); |
| | | if (sign && dto.getUserId().equals(memberId) && priQuote.getSettle() + 1 == dto.getStep()) { |
| | | if (Cools.isEmpty(dto.getMsg())) { |
| | | dto.setMsg(DateUtils.convert(now) + " " + member.getNickname() + "回退审批"); |
| | | } else { |
| | | dto.setMsg(dto.getMsg() + PZH + DateUtils.convert(now) + " " + member.getNickname() + "回退审批"); |
| | | } |
| | | sign = false; |
| | | } |
| | | if (sign){ |
| | | dto.setMsg(dto.getMsg()+PZH+DateUtils.convert(now)+" "+member.getNickname()+"回退审批"); |
| | | if (sign) { |
| | | dto.setMsg(dto.getMsg() + PZH + DateUtils.convert(now) + " " + member.getNickname() + "回退审批"); |
| | | } |
| | | |
| | | planDtoList.add(dto); |