Search in sources :

Example 1 with Role

use of com.eservice.api.model.role.Role in project sinsim by WilsonHu.

the class RoleController method add.

@PostMapping("/add")
public Result add(String role) {
    Role role1 = JSONObject.parseObject(role, Role.class);
    roleService.save(role1);
    return ResultGenerator.genSuccessResult();
}
Also used : Role(com.eservice.api.model.role.Role) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with Role

use of com.eservice.api.model.role.Role in project sinsim by WilsonHu.

the class CommonService method getCurrentSignStep.

// public String gatewayIpFromDockerFile ="aaa"; //main是静态域,所以不方便从main参数里获取值,已改为从文件里读取。
/**
 * 用于返回对应合同的所有签核记录,每一次提交审核以后,都需要通过该API获取所有审核内容,再设置审核状态
 *
 * @param contractId
 * @return result, 如果签核流程不存在返回null, 未结束则返回正在签核中的名称,结束则返回“FINISHED”
 */
public String getCurrentSignStep(Integer contractId) {
    String result = null;
    // 通过合同号找到有效的订单签核记录
    List<OrderSign> orderSignList = orderSignService.getValidOrderSigns(contractId);
    // 找到有效的合同签核记录,其实就是最新的合同簽和記錄
    ContractSign contractSign1 = contractSignService.detailByContractId(String.valueOf(contractId));
    HashMap<Integer, List<SignContentItem>> signContentSortByNumberMap = new HashMap<>();
    for (OrderSign os : orderSignList) {
        String contentStr = os.getSignContent();
        List<SignContentItem> orderSignContentList = JSON.parseArray(contentStr, SignContentItem.class);
        for (SignContentItem item : orderSignContentList) {
            if (signContentSortByNumberMap.get(item.getNumber()) != null) {
                signContentSortByNumberMap.get(item.getNumber()).add(item);
            } else {
                List<SignContentItem> list = new ArrayList<>();
                list.add(item);
                signContentSortByNumberMap.put(item.getNumber(), list);
            }
        }
    }
    List<SignContentItem> contractSignContentList = JSONObject.parseArray(contractSign1.getSignContent(), SignContentItem.class);
    for (SignContentItem item : contractSignContentList) {
        if (signContentSortByNumberMap.get(item.getNumber()) != null) {
            signContentSortByNumberMap.get(item.getNumber()).add(item);
        } else {
            List<SignContentItem> list = new ArrayList<>();
            list.add(item);
            signContentSortByNumberMap.put(item.getNumber(), list);
        }
    }
    // 签核流程不存在
    if (signContentSortByNumberMap.size() == 0) {
        return result;
    }
    // 将map.entrySet()转换成list
    List<Map.Entry<Integer, List<SignContentItem>>> list = new ArrayList<>(signContentSortByNumberMap.entrySet());
    // 通过比较器来实现排序
    Collections.sort(list, new Comparator<Map.Entry<Integer, List<SignContentItem>>>() {

        @Override
        public int compare(Map.Entry<Integer, List<SignContentItem>> o1, Map.Entry<Integer, List<SignContentItem>> o2) {
            // 升序排序
            return o1.getKey().compareTo(o2.getKey());
        }
    });
    Iterator<Map.Entry<Integer, List<SignContentItem>>> entries = signContentSortByNumberMap.entrySet().iterator();
    boolean currentStepFound = false;
    while (entries.hasNext() && !currentStepFound) {
        Map.Entry<Integer, List<SignContentItem>> entry = entries.next();
        Integer key = entry.getKey();
        List<SignContentItem> value = entry.getValue();
        for (SignContentItem item : value) {
            // 根據簽和順序,找到最先的被拒絕或者未簽合的流程
            if (item.getResult().equals(Constant.SIGN_REJECT) || item.getResult().equals(Constant.SIGN_INITIAL)) {
                List<Role> roleList = roleService.findAll();
                for (Role role : roleList) {
                    if (role.getId().equals(item.getRoleId())) {
                        result = role.getRoleName();
                    }
                }
                currentStepFound = true;
            }
        }
    }
    // 如果没有找到,表示该签核流程已经完成,此时返回一个特殊的String给调用者
    if (!currentStepFound) {
        result = Constant.SIGN_FINISHED;
    }
    return result;
}
Also used : Role(com.eservice.api.model.role.Role) OrderSign(com.eservice.api.model.order_sign.OrderSign) SignContentItem(com.eservice.api.model.contract_sign.SignContentItem) ContractSign(com.eservice.api.model.contract_sign.ContractSign)

Example 3 with Role

use of com.eservice.api.model.role.Role in project sinsim by WilsonHu.

the class CommonService method pushLxdMsgToAftersale.

/**
 * 推送公众号消息给轮到联系单签核的人(通过售后系统)
 * @param cs
 * @param cf
 * @param haveReject 是否驳回 ( 虽然这个信息可以从cs中提取,但是调用该函数的地方前面已经提前过了,方便用)
 */
public void pushLxdMsgToAftersale(ContactSign cs, ContactForm cf, boolean haveReject, String msgInfo) {
    // 指定格式,因为售后解析要用到
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    // 指定北京时间
    formatter.setTimeZone(TimeZone.getTimeZone("GMT+8"));
    String createDateStr = formatter.format(cf.getCreateDate());
    if (cs.getCurrentStep().equals(Constant.SIGN_FINISHED)) {
        // 审核完成时,通知发起人
        logger.info(cf.getContactTitle() + ", 审核完成时,通知发起人");
        List<UserDetail> userList = userService.selectUsers(cf.getApplicantPerson(), null, null, null, null, 1);
        if (userList.isEmpty() || userList == null) {
            logger.error("根据 " + cf.getApplicantPerson() + "找不到User");
        } else {
            // 找到发起人
            UserDetail toUser = userList.get(0);
            commonService.sendSignInfoViWxMsg(toUser.getAccount(), "", cf.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
        }
    } else {
        /**
         * 审核没有结束,
         *      驳回  :推送给参与签核的人,以及发起人
         *      无驳回:推送给下一个轮到签核的角色
         */
        Role role = roleService.findBy("roleName", cs.getCurrentStep());
        if (role == null) {
            logger.error("根据该 role_name " + cs.getCurrentStep() + "找不到Role");
            return;
        }
        List<UserDetail> userList = userService.selectUsers(null, null, role.getId(), null, null, 1);
        if (haveReject) {
            List<User> userNameList = commonService.getUsersInLxdSign(cs);
            for (User toUser : userNameList) {
                logger.info("联系单被拒绝,发给参与签核的人 " + toUser.getAccount());
                commonService.sendSignInfoViWxMsg(toUser.getAccount(), "", cf.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
            }
            logger.info("联系单被拒绝,发给发起签核的人 " + cf.getApplicantPerson());
            commonService.sendSignInfoViWxMsg(cf.getApplicantPerson(), "", cf.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
        } else {
            // 如果是销售部经理还要细分发给哪个经理,
            if (role.getRoleName().equals(Constant.SING_STEP_SALES_MANAGER)) {
                String userSalesManagerAccount = cf.getDesignatedSaleManager();
                logger.info(" 发给被指定的销售部经理 " + userSalesManagerAccount);
                commonService.sendSignInfoViWxMsg(userSalesManagerAccount, "", cf.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
            } else {
                if (userList.isEmpty() || userList == null) {
                    logger.error("根据该roleId " + role.getId() + "找不到User");
                } else {
                    // 可能有多个负责人,比如研发部现在就两个经理,都通知。
                    for (UserDetail toUser : userList) {
                        ContactForm contactForm = contactFormService.findById(cs.getContactFormId());
                        logger.info(" 发给参与签核的角色(可能多个) " + toUser.getAccount());
                        commonService.sendSignInfoViWxMsg(toUser.getAccount(), "", contactForm.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
                    }
                }
            }
        }
    }
}
Also used : UserDetail(com.eservice.api.model.user.UserDetail) Role(com.eservice.api.model.role.Role) User(com.eservice.api.model.user.User) ContactForm(com.eservice.api.model.contact_form.ContactForm) SimpleDateFormat(java.text.SimpleDateFormat)

Example 4 with Role

use of com.eservice.api.model.role.Role in project sinsim by WilsonHu.

the class RoleController method update.

@PostMapping("/update")
public Result update(String role) {
    // TODO:检查签核流程中(sign_process)是否有该角色,否则无法修改
    Role role1 = JSONObject.parseObject(role, Role.class);
    roleService.update(role1);
    return ResultGenerator.genSuccessResult();
}
Also used : Role(com.eservice.api.model.role.Role) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 5 with Role

use of com.eservice.api.model.role.Role in project sinsim by WilsonHu.

the class RoleController method list.

@PostMapping("/list")
public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
    PageHelper.startPage(page, size);
    List<Role> list = roleService.findAll();
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : Role(com.eservice.api.model.role.Role) PageInfo(com.github.pagehelper.PageInfo) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

Role (com.eservice.api.model.role.Role)7 PostMapping (org.springframework.web.bind.annotation.PostMapping)4 User (com.eservice.api.model.user.User)3 UserDetail (com.eservice.api.model.user.UserDetail)2 PageInfo (com.github.pagehelper.PageInfo)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ContactForm (com.eservice.api.model.contact_form.ContactForm)1 ContractSign (com.eservice.api.model.contract_sign.ContractSign)1 SignContentItem (com.eservice.api.model.contract_sign.SignContentItem)1 OrderSign (com.eservice.api.model.order_sign.OrderSign)1 Condition (tk.mybatis.mapper.entity.Condition)1