| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | |
| | | import com.whyc.pojo.WorkflowMain; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.DateUtil; |
| | | import com.whyc.util.ThreadLocalUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | statistics.put(2,0); |
| | | statistics.put(3,0); |
| | | QueryWrapper<WorkflowMain> query = Wrappers.query(); |
| | | query.eq("create_user_id",userId); |
| | | query.eq("create_user_id",userId).eq("type",type); |
| | | List<WorkflowMain> mains = mapper.selectList(query); |
| | | Map<Integer, List<WorkflowMain>> statusListMap = mains.stream().collect(Collectors.groupingBy(WorkflowMain::getStatus)); |
| | | Set<Integer> statusSet = statusListMap.keySet(); |
| | | for (Integer status : statusSet) { |
| | | statistics.put(status,statusListMap.get(status).size()); |
| | | } |
| | | return new Response<Map<Integer,Integer>>().set(1,statistics); |
| | | } |
| | | |
| | | /** |
| | | * 二次核容和故障隐患的统计 |
| | | * |
| | | * 增加了全部 key=0 |
| | | * @param type ={0,2,3} 0代表二次核容和故障隐患一起 |
| | | * @see com.whyc.constant.WorkflowEnum |
| | | * |
| | | * @return |
| | | */ |
| | | public Response<Map<Integer,Integer>> getOwnStatistics2(int userId, int type) { |
| | | Map<Integer,Integer> statistics = new HashMap<>(); |
| | | statistics.put(0,0); |
| | | statistics.put(1,0); |
| | | statistics.put(2,0); |
| | | statistics.put(3,0); |
| | | QueryWrapper<WorkflowMain> query = Wrappers.query(); |
| | | query.eq("create_user_id", userId); |
| | | if(type == 0){ |
| | | query.in("type",2,3); |
| | | }else { |
| | | query.eq("type", type); |
| | | } |
| | | List<WorkflowMain> mains = mapper.selectList(query); |
| | | Map<Integer, List<WorkflowMain>> statusListMap = mains.stream().collect(Collectors.groupingBy(WorkflowMain::getStatus)); |
| | | Set<Integer> statusSet = statusListMap.keySet(); |
| | | int sum = 0; |
| | | for (Integer status : statusSet) { |
| | | int size = statusListMap.get(status).size(); |
| | | statistics.put(status, size); |
| | | sum+=size; |
| | | } |
| | | statistics.put(0,sum); |
| | | return new Response<Map<Integer,Integer>>().set(1,statistics); |
| | | } |
| | | |
| | |
| | | private List<WorkflowMain> getOwnListByUserAndType(int userId, int type, int status) { |
| | | QueryWrapper<WorkflowMain> query = Wrappers.query(); |
| | | if(status == 0){ |
| | | query.eq("create_user_id",userId).eq("type",type); |
| | | query.eq("create_user_id",userId).eq("type",type).orderByDesc("id"); |
| | | }else { |
| | | query.eq("create_user_id", userId).eq("type", type).eq("status", status); |
| | | query.eq("create_user_id", userId).eq("type", type).eq("status", status).orderByDesc("id"); |
| | | } |
| | | return mapper.selectList(query); |
| | | } |
| | |
| | | * @param now 当前时间 |
| | | * @return |
| | | */ |
| | | public int submit(String taskDesc,Integer mainType,String mainTypeCN,String mainTypeEn,Integer userId,Integer dealRoleId,Date now){ |
| | | public int submit(String taskDesc,Integer mainType,String mainTypeCN,String mainTypeEn,Integer userId,Integer dealRoleId,Date now,String processLevel){ |
| | | //1.提交到单据审批流程 |
| | | WorkflowMain main = new WorkflowMain(); |
| | | String orderId = getNextOrderId(mainTypeEn); |
| | | String title = mainTypeCN+"审批单-"+ DateUtil.YYYY_MM_DD_HH_MM_SS.format(now); |
| | | //String title = mainTypeCN+"审批单-"+ DateUtil.YYYY_MM_DD_HH_MM_SS.format(now); |
| | | String title = mainTypeCN+"审批单-"+ ThreadLocalUtil.format(now,1); |
| | | Integer mainStatus = WorkflowEnum.MAIN_STATUS_DEALING.getValue(); |
| | | main.setOrderId(orderId); |
| | | main.setTitle(title); |
| | |
| | | main.setBeginTime(now); |
| | | main.setStatus(mainStatus); |
| | | main.setType(mainType); |
| | | main.setProcessLevel(processLevel); |
| | | add(main); |
| | | //内存中去除已插入数据库的单号 |
| | | ServletContext application = ActionUtil.getApplication(); |
| | |
| | | link.setDealRoleId(dealRoleId); |
| | | link.setDealType(WorkflowEnum.TYPE_DELIVER.getValue()); |
| | | link.setDealDesc(taskDesc); |
| | | link.setStatus(WorkflowEnum.STATUS_DEALING.getValue()); |
| | | link.setStatus(WorkflowEnum.STATUS_TAKING.getValue()); |
| | | |
| | | linkService.add(link); |
| | | return main.getId(); |
| | | } |
| | | |
| | | public void updateProcessLevel(String processLevel, Integer mainId) { |
| | | UpdateWrapper<WorkflowMain> update = Wrappers.update(); |
| | | update.set("process_level",processLevel).eq("id",mainId); |
| | | mapper.update((WorkflowMain) ActionUtil.objeNull,update); |
| | | } |
| | | } |