123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695 |
- package com.iamberry.rst.controllers.approval;
- import com.auth0.jwt.internal.org.apache.commons.io.FileUtils;
- import com.fasterxml.jackson.core.JsonProcessingException;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.iamberry.rst.core.approval.*;
- import com.iamberry.rst.core.page.PageRequest;
- import com.iamberry.rst.core.page.PagedResult;
- import com.iamberry.rst.core.sys.Admin;
- import com.iamberry.rst.faces.approval.ApplyPickService;
- import com.iamberry.rst.faces.approval.ApprovalOrderService;
- import com.iamberry.rst.faces.approval.ApprovalProductionService;
- import com.iamberry.rst.faces.approval.ApprovalTaskService;
- import com.iamberry.rst.faces.sys.SysService;
- import com.iamberry.wechat.core.entity.WechatUtils;
- import com.iamberry.wechat.file.FileType;
- import com.iamberry.wechat.tools.ResponseJson;
- import com.iamberry.wechat.tools.ResultInfo;
- import net.sf.json.JSONArray;
- import net.sf.json.JSONObject;
- import org.activiti.bpmn.model.*;
- import org.activiti.bpmn.model.Process;
- import org.activiti.engine.RepositoryService;
- import org.activiti.engine.repository.Deployment;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.context.ContextLoader;
- import org.springframework.web.context.WebApplicationContext;
- import org.springframework.web.multipart.commons.CommonsMultipartFile;
- import sun.misc.BASE64Decoder;
- import javax.servlet.ServletContext;
- import javax.servlet.http.HttpServletRequest;
- import java.io.*;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * Created by Administrator on 2018/10/9.
- */
- @Controller
- /*@RequestMapping("/approval")*/
- @RequestMapping("/wechat/approval")
- public class ApprovalController {
- @Autowired
- private ApprovalOrderService approvalOrderService;
- @Autowired
- private ApprovalTaskService approvalTaskService;
- @Autowired
- private SysService sysService;
- @Autowired
- private ApplyPickService applyPickService;
- @Autowired
- private ApprovalProductionService approvalProductionService;
- @Autowired
- private RepositoryService repositoryService;
- @SuppressWarnings("restriction")
- private BASE64Decoder decoder = new BASE64Decoder();
- /**
- * 新增审批信息
- * @param request
- * @param approvalProduction
- * @param productionItems
- * @return
- */
- @ResponseBody
- @RequestMapping(value = "/addApproval")
- public ResponseJson addApproval(HttpServletRequest request, ApprovalProduction approvalProduction, String productionItems,String productionContracts) throws ParseException {
- ResponseJson rj =new ResponseJson(200, "添加成功", 200);
- if (approvalProduction == null || productionItems == null) {
- return ResponseJson.getFAILURE();
- }
- //获取openid,根据openid查询当前登录人信息
- String openId = WechatUtils.getUserBySession(request).getUserOpenid();
- /*String openId = "oEy-_s5C7LwmLGTpEGfJoecfsYZc";*/
- //获取审批任务id
- Map<String, Object> taskinfo = approvalTaskService.salesmanSubmitApply(1);
- String deliveryDate = request.getParameter("deliveryDate");
- String inspectionTime = request.getParameter("inspectionDate");
- if(deliveryDate == null ){
- return ResponseJson.getFAILURE();
- }
- if(inspectionTime == null ){
- return ResponseJson.getFAILURE();
- }
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- approvalProduction.setProductionDeliveryDate(format.parse(deliveryDate));
- approvalProduction.setInspectionTime(format.parse(inspectionTime));
- //封装生产审批产品项
- List<ApprovalProductionItem> listApprovalProductionItem = new ArrayList<ApprovalProductionItem>();
- JSONArray jsonProductionItems = JSONArray.fromObject(productionItems);
- for (int i = 0; i < jsonProductionItems.size(); i++) {
- JSONObject orderItem = jsonProductionItems.getJSONObject(i);
- //添加产品项内容
- ApprovalProductionItem approvalProductionItem = new ApprovalProductionItem();
- approvalProductionItem.setItemBrandName(orderItem.getString("itemBrandName"));
- approvalProductionItem.setItemProductName(orderItem.getString("itemProductName"));
- approvalProductionItem.setItemColorName(orderItem.getString("itemColorName"));
- approvalProductionItem.setItemProductNum(orderItem.getInt("itemProductNum"));
- approvalProductionItem.setItemProductModel(orderItem.getString("itemProductModel"));
- approvalProductionItem.setItemProductUnit(orderItem.getString("itemProductUnit"));
- approvalProductionItem.setItemProductBoxNumber(orderItem.getInt("itemProductBoxNumber"));
- approvalProductionItem.setItemShouldStorage(orderItem.getInt("itemProductNum"));
- approvalProductionItem.setItemActualStorage(0);
- approvalProductionItem.setItemLackNumber(orderItem.getInt("itemProductNum"));
- approvalProductionItem.setItemCanpickNumber(0);
- if (orderItem.containsKey("itemExternalModel")) {
- approvalProductionItem.setItemExternalModel(orderItem.getString("itemExternalModel"));
- }
- listApprovalProductionItem.add(approvalProductionItem);
- }
- //封装生产审批合同
- List<ApprovalProductionContract> listProductionContract = new ArrayList<ApprovalProductionContract>();
- if(productionContracts != null){
- JSONArray jsonproductionContracts = JSONArray.fromObject(productionContracts);
- for (int i = 0; i < jsonproductionContracts.size(); i++) {
- JSONObject contract = jsonproductionContracts.getJSONObject(i);
- ApprovalProductionContract contractInfo = new ApprovalProductionContract();
- contractInfo.setContractUrl(contract.getString("contractUrl"));
- contractInfo.setContractType(contract.getString("contractType"));
- listProductionContract.add(contractInfo);
- }
- }
- boolean returnValue = approvalOrderService.insertApprovalProduction(approvalProduction,listApprovalProductionItem,listProductionContract,taskinfo,openId);
- if(!returnValue){
- return ResponseJson.getFAILURE();
- }
- return rj;
- }
- /**
- * 上传合同图片
- * 通过流的方式上传文件
- * @RequestParam("file") 将name=file控件得到的文件封装成CommonsMultipartFile 对象
- */
- @ResponseBody
- @RequestMapping("/fileUpload")
- public ResponseJson fileUpload(HttpServletRequest request,@RequestParam("file") CommonsMultipartFile file) throws IOException {
- ResponseJson responseJson = new ResponseJson();
- System.out.println("fileName:"+file.getOriginalFilename());
- //获取项目根目录
- WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();
- ServletContext servletContext = webApplicationContext.getServletContext();
- String realPath = servletContext.getRealPath(ResultInfo.CONTRACT_IMAGE);
- String imgUrl = new Date().getTime()+file.getOriginalFilename();
- try {
- //获取输出流
- OutputStream os=new FileOutputStream(realPath+imgUrl);
- //获取输入流 CommonsMultipartFile 中可以直接得到文件的流
- InputStream is=file.getInputStream();
- byte[] bts = new byte[1024];
- //一个一个字节的读取并写入
- while(is.read(bts)!=-1)
- {
- os.write(bts);
- }
- os.flush();
- os.close();
- is.close();
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- responseJson.setReturnCode(200);
- responseJson.addResponseKeyValue("imgUrl",ResultInfo.CONTRACT_IMAGE+imgUrl);
- return responseJson;
- }
- /**
- * base图片上传
- * @throws IOException
- */
- @SuppressWarnings({ "deprecation", "restriction" })
- @ResponseBody
- @RequestMapping("/baseFileUpload")
- public ResponseJson baseFileUpload(HttpServletRequest req) throws IOException{
- ResponseJson responseJson = new ResponseJson();
- //取到前台传过来的 base64图片 并创建要存放在项目中的路径
- WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();
- ServletContext servletContext = webApplicationContext.getServletContext();
- String imgFilePath = servletContext.getRealPath(ResultInfo.CONTRACT_IMAGE);
- try {
- isExitsPath(imgFilePath);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- //创建分享对象 并存入数据库
- //String postParams = StrUtils.getPostParamsStr(req); //data:image/png;base64,iVBORw0
- String postParams = req.getParameter("file");
- String[] shareImgUrlArr = org.apache.commons.lang3.StringUtils.split(postParams, ",");
- String imgUrl = "";
- HashMap<String, String> map = new HashMap<String, String>();
- if(shareImgUrlArr != null && shareImgUrlArr.length > 0){
- // 防止内存溢出
- String suffixName = new String (shareImgUrlArr[0].split(";")[0].split("/")[1]);
- String shareImgUrl = new String (shareImgUrlArr[1]);
- // 通过文件头判断后缀
- byte [] b = new byte[28];
- shareImgUrl.getBytes(0, 27, b, 0);
- String temp = new String(b);
- b = decoder.decodeBuffer(temp);
- // 二进制转换文件头
- String type = null;
- String fileHead = byte2hex(b);
- fileHead = fileHead.toUpperCase();
- // 获取系统支持的文件类型,如果不支持,返回默认的图片
- FileType[] fileTypes = FileType.values();
- for (FileType fileType : fileTypes) {
- if (fileHead.startsWith(fileType.getValue())) {
- type = fileType.getSuffix();
- break;
- }
- }
- if (type == null) {
- System.err.println("上传图片异常..." + fileHead);
- } else {
- String fileName = getFileName(suffixName, type);
- boolean flag = generateImage(shareImgUrl, imgFilePath + "/" + fileName);
- if(flag){
- responseJson.setReturnCode(200);
- responseJson.addResponseKeyValue("imgUrl","//rst.iamberry.com/"+ResultInfo.CONTRACT_IMAGE+fileName);
- }else{
- responseJson.setReturnCode(500);
- }
- }
- }else{
- responseJson.setReturnCode(500);
- }
- //返回值拼凑
- /*String requurl = req.getContextPath();//获取web项目的路径*/
- return responseJson;
- }
- /**
- * 判断路径是否存在 不存在则创建
- * create date 2016年6月1日
- * @author 穆再兴
- * @param path
- * @return
- * @throws InterruptedException
- */
- public boolean isExitsPath(String path)throws InterruptedException{
- String [] paths=path.split("/");
- StringBuilder fullPath=new StringBuilder();
- for (int i = 0; i < paths.length; i++) {
- fullPath.append(paths[i]).append("/");
- File file=new File(fullPath.toString());
- if(!file.exists()){
- file.mkdir();
- }
- }
- File file=new File(fullPath.toString());//目录全路径
- if (!file.exists()) {
- return true;
- }else{
- return false;
- }
- }
- public static String byte2hex(byte[] b) { //一个字节的数,
- // 转成16进制字符串
- String hs = "";
- String tmp = "";
- for (int n = 0; n < b.length; n++) {
- //整数转成十六进制表示
- tmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
- if (tmp.length() == 1) {
- hs = hs + "0" + tmp;
- } else {
- hs = hs + tmp;
- }
- }
- tmp = null;
- return hs;
- }
- /**
- * 获取 file 的文件名
- * create date 2016年6月1日
- * @author 穆再兴
- * @param
- * @param
- * @return
- */
- private String getFileName(String suffixName, String type){
- long time = new Date().getTime();
- Long timeStr = new Long(time);
- return timeStr + "." + type;
- }
- /**
- * 对字节数组字符串进行Base64解码生成图片 并存入对应的路径
- * create date 2016年6月1日
- * @author 穆再兴
- * @param imgStr Base64字符串
- * @param imgFilePath 存入的路径
- * @return
- */
- private boolean generateImage(String imgStr, String imgFilePath) {
- if (imgStr == null) {return false;}// 图像数据为空
- try {
- // Base64解码
- @SuppressWarnings("restriction")
- byte[] bytes = decoder.decodeBuffer(imgStr);
- for (int i = 0; i < bytes.length; ++i) {
- if (bytes[i] < 0) {// 调整异常数据
- bytes[i] += 256;
- }
- }
- // 生成图片
- File file = new File(imgFilePath);
- FileUtils.writeByteArrayToFile(file, bytes);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- /**
- * 查询我发起的/我审核的列表
- * @param approvalInfo
- * @param pageSize
- * @param pageNO
- * @param totalNum
- * @param selectType 1.我发起的 2.我审核的 3.仓库确认
- * @param
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping(value = "/approvalInfoList")
- public ResponseJson listApprovalInfo(HttpServletRequest request,
- ApprovalInfo approvalInfo,Integer selectType,
- @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
- @RequestParam(value = "pageNo", defaultValue = "1", required = false) Integer pageNO,
- @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) throws Exception {
- ResponseJson rj =new ResponseJson(200, "查询成功", 200);
- //获取openid,根据openid查询当前登录人信息
- String openId = WechatUtils.getUserBySession(request).getUserOpenid();
- /*String openId = "oEy-_s5C7LwmLGTpEGfJoecfsYZc";*/
- Admin admin = sysService.getByOpenid(openId);
- if(admin == null){
- return new ResponseJson(200, "未查询到登录人信息", 500);
- }
- if(selectType != null){
- if(selectType == 1){//我发起的
- approvalInfo.setAdminId(admin.getAdminId());
- }else if(selectType == 2){//我审核的
- approvalInfo.setApprovalAdminId(admin.getAdminId());
- }
- if(selectType == 3){
- //判断是否是仓库人员
- AdminApprovalAuthority adminApprovalAuthority = approvalOrderService.getApprovalAuthority(admin.getAdminId());
- if(adminApprovalAuthority.getIsWarehouse() == 2){
- List<ApprovalInfo> list = new ArrayList<>();
- return new ResponseJson(200, "非仓库人员不得查询", 501).addResponseKeyValue("approvalList",list);
- }
- }
- }
- String stareDate = request.getParameter("stareDate");
- if(stareDate != null ){
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- approvalInfo.setApprovalCreateTime(format.parse(stareDate));
- }
- PagedResult<ApprovalInfo> pagedResult = approvalOrderService.listApprovalInfo(pageNO, pageSize,approvalInfo,totalNum == null);
- if (totalNum != 0) {
- pagedResult.setTotal(totalNum);
- }
- rj.addResponseKeyValue("total", pagedResult.getTotal());
- rj.addResponseKeyValue("approvalList",pagedResult.getDataList());
- rj.addResponseKeyValue("admin",admin);
- return rj;
- }
- /**
- * 修改审批状态 (1 通过 2驳回 3撤销 4评论)
- * @param
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping(value = "/updateApprovalInfo")
- public ResponseJson updateApprovalInfo(HttpServletRequest request,
- ApprovalInfo approvalInfo,Integer status) throws Exception {
- ResponseJson rj =new ResponseJson(200, "操作成功", 200);
- if(status == null){
- return ResponseJson.getFAILURE();
- }
- if(approvalInfo == null){
- return ResponseJson.getFAILURE();
- }
- //获取openid,根据openid查询当前登录人信息
- String openId = WechatUtils.getUserBySession(request).getUserOpenid();
- /*String openId = "oEy-_s_o_1oIv6h_KAs7QkeTQiJY";*/
- Admin admin = sysService.getByOpenid(openId);
- if(admin == null){
- return new ResponseJson(200, "未查询到登录人信息", 500);
- }
- rj = approvalOrderService.auditApprovalinfo(approvalInfo,admin,status);
- return rj;
- }
- /**
- * 查询审批订单详情
- * @param approvalInfo
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping(value = "/getApprovalInfo")
- public ResponseJson getApprovalInfo(HttpServletRequest request,
- ApprovalInfo approvalInfo) throws Exception {
- ResponseJson rj =new ResponseJson(200, "查询成功", 200);
- if(approvalInfo == null){
- return ResponseJson.getFAILURE();
- }
- //获取openid,根据openid查询当前登录人信息
- String openId = WechatUtils.getUserBySession(request).getUserOpenid();
- /*String openId = "oEy-_s5C7LwmLGTpEGfJoecfsYZc";*/
- Admin admin = sysService.getByOpenid(openId);
- if(admin == null){
- return new ResponseJson(200, "未查询到登录人信息", 500);
- }
- //判断是否是仓库人员
- int isDelivery = 2;
- /*if(admin.getAdminDept() == 8){//8为仓储部门
- isDelivery = 1;
- }*/
- //判断是否是仓库人员
- AdminApprovalAuthority adminApprovalAuthority = approvalOrderService.getApprovalAuthority(admin.getAdminId());
- if(adminApprovalAuthority.getIsWarehouse() == 1){
- isDelivery = 1;
- }
- HistoricalRecord historicalRecord = new HistoricalRecord();
- historicalRecord.setApprovalId(approvalInfo.getApprovalId());
- historicalRecord.setAdminId(admin.getAdminId());
- historicalRecord.setRecordState(1);
- historicalRecord = approvalOrderService.getHistoricalRecord(historicalRecord);
- List<ApprovalInfo> info = approvalOrderService.getApprovalInfo(approvalInfo);
- if(info.size() < 1){
- return ResponseJson.getFAILURE();
- }
- rj.addResponseKeyValue("approvalInfo",info.get(0));
- rj.addResponseKeyValue("historicalRecord",historicalRecord);
- rj.addResponseKeyValue("adminid",admin.getAdminId());
- rj.addResponseKeyValue("isDelivery",isDelivery);
- return rj;
- }
- /**
- * 添加入库信息
- * @param request
- * @param inventoryRecordss
- * @return
- */
- @ResponseBody
- @RequestMapping(value = "/addInventoryRecords")
- public ResponseJson addInventoryRecords(HttpServletRequest request, String inventoryRecordss){
- if (inventoryRecordss == null || inventoryRecordss.equals("")) {
- return ResponseJson.getFAILURE();
- }
- //获取openid,根据openid查询当前登录人信息
- String openId = WechatUtils.getUserBySession(request).getUserOpenid();
- /*String openId = "oEy-_s5C7LwmLGTpEGfJoecfsYZc";*/
- Admin admin = sysService.getByOpenid(openId);
- if(admin == null){
- return new ResponseJson(200, "未查询到登录人信息", 500);
- }
- return approvalOrderService.insertInventoryRecords(inventoryRecordss,admin);
- }
- /**
- * 获取某个审批的整个审批流程及仓库审批人信息 1:生成订单审批;2:提货申请
- * @param
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping(value = "/getFindApplyRu")
- public ResponseJson getFindApplyRu(HttpServletRequest request,
- Integer type) throws Exception {
- ResponseJson rj =new ResponseJson(200, "查询成功", 200);
- if(type == null){
- return ResponseJson.getFAILURE();
- }
- //获取openid,根据openid查询当前登录人信息
- String openId = WechatUtils.getUserBySession(request).getUserOpenid();
- Admin currentAdmin = sysService.getByOpenid(openId);
- if(currentAdmin == null){
- return new ResponseJson(200, "未查询到登录人信息", 500);
- }
- List<Object> info = approvalTaskService.findApplyRu(type);
- if(info.size() < 1){
- return ResponseJson.getFAILURE();
- }
- List<String[]> listString = new ArrayList<>();
- for (Object obj : info){
- String[] strings = (String[])obj;
- String[] str = new String[strings.length];
- for(int i = 0;i< strings.length;i++){
- Admin admin = sysService.getByName(strings[i]);
- if(admin == null){
- return new ResponseJson(200, "未找到管理员信息("+strings[i]+")", 500);
- }
- str[i] = admin.getAdminName();
- }
- listString.add(str);
- }
- AdminApprovalAuthority authority = new AdminApprovalAuthority();
- authority.setIsWarehouse(1);
- List<AdminApprovalAuthority> listAuthority = approvalOrderService.listApprovalAuthority(authority);
- Admin adminTwo = new Admin();
- adminTwo.setAdminId(listAuthority.get(0).getAdminId());
- List<Admin> listAdmin = sysService.listAdminInfo(adminTwo);
- rj.addResponseKeyValue("list",listString);
- rj.addResponseKeyValue("warehouseAdmin",listAdmin);
- rj.addResponseKeyValue("currentAdmin",currentAdmin);
- return rj;
- }
- /**
- * 查询审批产品项
- * @param approvalId
- * @return productionItem
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping(value = "/getProductionItem")
- public ResponseJson getProductionItem(HttpServletRequest request,Integer approvalId) throws Exception {
- ResponseJson rj =new ResponseJson(200, "查询成功", 200);
- if(approvalId == null){
- return ResponseJson.getFAILURE();
- }
- ApprovalProduction approvalProduction = new ApprovalProduction();
- approvalProduction.setApprovalId(approvalId);
- List<ApprovalProduction> approvalProductionList = approvalProductionService.getApprovalProductionList(approvalProduction);
- approvalProduction = approvalProductionList.get(0);
- ApprovalProductionItem approvalProductionItem = new ApprovalProductionItem();
- approvalProductionItem.setProductionId(approvalProduction.getProductionId());
- List<ApprovalProductionItem> approvalProductionItemList = approvalProductionService.getApprovalProductionItemList(approvalProductionItem);
- rj.addResponseKeyValue("apItemList",approvalProductionItemList);
- return rj;
- }
- /**
- * 查询入库记录
- * @param approvalId
- * @return productionItem
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping(value = "/listInventoryRecords")
- public ResponseJson listInventoryRecords(HttpServletRequest request,Integer approvalId) throws Exception {
- ResponseJson rj =new ResponseJson(200, "查询成功", 200);
- if(approvalId == null){
- return ResponseJson.getFAILURE();
- }
- List<ApprovalInventoryRecords> listRecords = approvalOrderService.listInventoryRecords(approvalId);
- rj.addResponseKeyValue("listRecords",listRecords);
- return rj;
- }
- /**
- * 获取优尼雅管理员权限
- * @param request
- * @return
- */
- @ResponseBody
- @RequestMapping(value = "/getApprovalAuthority")
- public ResponseJson getApprovalAuthority(HttpServletRequest request){
- ResponseJson rj =new ResponseJson(200, "查询成功", 200);
- //获取openid,根据openid查询当前登录人信息
- String openId = WechatUtils.getUserBySession(request).getUserOpenid();
- Admin currentAdmin = sysService.getByOpenid(openId);
- if(currentAdmin == null){
- return new ResponseJson(200, "未查询到登录人信息", 500);
- }
- if(currentAdmin.getAdminDept() !=9){//9:优尼雅
- return new ResponseJson(200, "不允许非优尼雅部门员工查询", 500);
- }
- AdminApprovalAuthority adminApprovalAuthority = approvalOrderService.getApprovalAuthority(currentAdmin.getAdminId());
- rj.addResponseKeyValue("adminApprovalAuthority",adminApprovalAuthority);
- return rj;
- }
- /**
- * 查询待办数量
- * @param request
- * @return
- */
- @ResponseBody
- @RequestMapping(value = "/getTo_do")
- public ResponseJson getTo_do(HttpServletRequest request){
- //获取openid,根据openid查询当前登录人信息
- String openId = WechatUtils.getUserBySession(request).getUserOpenid();
- /*String openId = "oEy-_s_o_1oIv6h_KAs7QkeTQiJY";*/
- Admin admin = sysService.getByOpenid(openId);
- ResponseJson rj =new ResponseJson(200, "查询成功", 200);
- if(admin == null){
- return new ResponseJson(200, "未查询到登录人信息", 500);
- }
- if(admin.getAdminDept() !=9){//9:优尼雅
- return new ResponseJson(200, "不允许非优尼雅部门员工查询", 500);
- }
- AdminApprovalAuthority adminApprovalAuthority = approvalOrderService.getApprovalAuthority(admin.getAdminId());
- if(adminApprovalAuthority == null){
- return new ResponseJson(200, "未找到权限信息", 500);
- }
- if(adminApprovalAuthority.getIsSales() == 1){//查询销售 提货数量
- ApprovalInfo approvalInfo = new ApprovalInfo();
- approvalInfo.setAdminId(admin.getAdminId());
- approvalInfo.setSelectState(5);//查询待审批条数
- List<ApprovalInfo> listInfo = approvalOrderService.getApprovalInfo(approvalInfo);
- rj.addResponseKeyValue("salesPickNum",listInfo.size());
- }else{
- rj.addResponseKeyValue("salesPickNum",0);
- }
- if(adminApprovalAuthority.getIsPmc() == 1 || adminApprovalAuthority.getIsManagement() == 1){
- ApprovalInfo approvalInfo = new ApprovalInfo();
- approvalInfo.setApprovalAdminId(admin.getAdminId());
- approvalInfo.setSelectState(1);//查询待审批条数
- List<ApprovalInfo> listInfo = approvalOrderService.getApprovalInfo(approvalInfo);
- rj.addResponseKeyValue("approvalNum",listInfo.size());
- }else{
- rj.addResponseKeyValue("approvalNum",0);
- }
- if(adminApprovalAuthority.getIsWarehouse() == 1){
- ApprovalInfo approvalInfo = new ApprovalInfo();
- approvalInfo.setSelectState(3);
- List<ApprovalInfo> listInfo = approvalOrderService.getApprovalInfo(approvalInfo);
- rj.addResponseKeyValue("warehouseNum",listInfo.size());
- }else{
- rj.addResponseKeyValue("warehouseNum",0);
- }
- return rj;
- }
- /*@ResponseBody
- @RequestMapping(value = "/deploymentPrecessDefinition")
- public void deploymentPrecessDefinition(){
- getBpmnModel();
- repositoryService.deleteDeployment("310008",true);
- repositoryService.deleteDeployment("427508",true);
- repositoryService.deleteDeployment("427501",true);
- repositoryService.deleteDeployment("422501",true);
- *//*Deployment deployment = repositoryService.createDeployment()
- .key("GenerationApproval")
- .name("提交审批流程")
- .addClasspathResource("RST.bpmn")
- .deploy();
- Deployment deployment = repositoryService.createDeployment()
- .key("ApplicationForDelivery")
- .name("提交提货订单审批流程")
- .addClasspathResource("pickRst.bpmn")
- .deploy();*//*
- //获取审批任务id
- Map<String, Object> taskinfo = approvalTaskService.salesmanSubmitApply(1);
- String[] split = (String[])taskinfo.get("users");
- for (String name : split){
- System.out.println(name);
- }
- Map<String, Object> taskinfo2 = approvalTaskService.salesmanSubmitApply(2);
- String[] split2 = (String[])taskinfo2.get("users");
- for (String name : split2){
- System.out.println(name);
- }
- }*/
- }
|