package com.agent.action.audit; import com.agent.action.common.AbstractController; import com.agent.constans.CommonConstants; import com.agent.constans.ConfigConstants; import com.agent.constans.TemplateConstants; import com.agent.model.audit.bean.DisplaceAuditBean; import com.agent.model.audit.service.DisplaceAuditService; import com.agent.model.bms.bean.UserBean; import com.agent.model.common.bean.PageResultBean; import com.agent.model.common.bean.ResultBean; import com.agent.model.digger.bean.DiggerBean; import com.agent.model.digger.service.DiggerBeanService; import com.agent.model.offer.service.OfferBeanService; import com.agent.model.pushrecord.bean.PushRecordBean; import com.agent.model.pushrecord.service.PushRecordBeanService; import com.agent.model.sale.bean.SalesBean; import com.agent.model.sale.service.SaleBeanService; import com.agent.model.shop.bean.AgentBean; import com.agent.model.shop.service.AgentBeanService; import com.agent.model.usercolumn.bean.UserColumnRoleBean; import com.agent.model.usermanage.service.UserManageService; import com.agent.model.wxInterface.bean.TemplateData; import com.agent.util.*; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; 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.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.File; import java.io.IOException; import java.util.*; /** * 置换审核controller * */ @Controller @RequestMapping("/audit") public class AuditController extends AbstractController{ private static Logger log = LoggerFactory.getLogger(AuditController.class); /** * 置换审核service */ @Autowired private DisplaceAuditService displaceAuditService; /** * 报价service */ @Autowired private OfferBeanService offerBeanService; @Value("${wjj.api.domain}") private String wjjDomain; /** * 置换审核列表页(后台) */ private final String PLAT_AUDIT_LIST = "audit/platAuditList"; /** * 置换审核列表页(超级管理员) */ private final String SUPER_ADMIN_AUDIT_LIST = "audit/superAdminAuditList"; /** * 置换审核列表页(代理商-代运营) */ private final String AGENT_AUDIT_LIST = "audit/agentAuditList"; /** * 置换审核列表页(代理商-自运营) */ private final String SINCE_AGENT_AUDIT_LIST = "audit/sinceAgentAuditList"; /** * 置换审核列表页(管理员) */ private final String ADMIN_AUDIT_LIST = "audit/adminAuditList"; /** * 置换审核列表页(精品机) */ private final String GOOD_AUDIT_LIST = "audit/goodAdminAuditList"; /** * 登录页 */ private final String LOGIN_INDEX = "login/index"; /** * 车商service */ @Autowired private DiggerBeanService diggerBeanService; /** * 信息记录service */ @Autowired private PushRecordBeanService pushRecordBeanService; /** * 销售员service */ @Autowired private SaleBeanService saleBeanService; /** * 代理商service */ @Autowired private AgentBeanService agentBeanService; //精品机配置 @Value("${jpjgh}") private String jpjgh; /** * 载入置换审核列表页面 * @param request * @param response * @return * @throws IOException */ @RequestMapping("/toAuditList.do") public ModelAndView showShopList(HttpServletRequest request, HttpServletResponse response) throws Exception{ //页面跳转 ModelAndView mv; //获取登录信息 HttpSession session = request.getSession(); UserBean user = (UserBean)session.getAttribute(CommonConstants.USER_INFO); //如果是管理员,跳转到平台列表页,否则跳转到商家列表页 if(user == null){ //如果未登录,跳转到登录页 return super.createJspView(LOGIN_INDEX); } log.info("进入置换审核页面,当前登录人信息 userAccount:" + user.getUserAccount() + ", userRank:" + user.getUserRank() + ", isAdmin:" + user.getIsAdmin() + ", agentType:" + user.getAgentType()); if (UserBean.USER_RANK_SUPER_ADMIN.equals(user.getUserRank())) { mv = super.createJspView(SUPER_ADMIN_AUDIT_LIST); } else if (UserBean.USER_RANK_ADMIN.equals(user.getUserRank())) { mv = super.createJspView(ADMIN_AUDIT_LIST); }else if (UserBean.USER_RANK_GOOD.equals(user.getUserRank())) { mv = super.createJspView(GOOD_AUDIT_LIST); } else { // 判断是 自运营 还是 代运营 if (UserBean.AGENT_TYPE_SINCE == user.getAgentType()) { mv = super.createJspView(SINCE_AGENT_AUDIT_LIST); } else { mv = super.createJspView(AGENT_AUDIT_LIST); } } //查询设备品牌 //List ppList = offerBeanService.queryFlList(ConfigConstants.SBPP,""); //查询设备类型 //List lxList = offerBeanService.queryFlList(ConfigConstants.SBLX,""); //页面跳转 //mv.addObject("deviceBrands", ppList); //mv.addObject("deviceTypes", lxList); return mv; } @RequestMapping("/pushDisplaceAuditMessage.do") public void pushDisplaceAuditMessage(@RequestParam String agentId, @RequestParam String saleId, @RequestParam String displaceId, HttpServletRequest request, HttpServletResponse response) { log.info("调用推送置换审核微信信息(/audit/pushDisplaceAuditMessage.do)接口, agentId:" + agentId + ", saleId:" + saleId + ", displaceId:" + displaceId); ResultBean resultBean = new ResultBean(ResultBean.SUCCESS_CODE, "成功"); try { HttpSession session = request.getSession(); UserBean user = (UserBean)session.getAttribute(CommonConstants.USER_INFO); if(user == null) { resultBean = new ResultBean(PageResultBean.FAIL_CODE, "请先登录!"); return; } final String apiUrl = wjjDomain + "wechat/pushDisplaceAuditMessage"; // final String apiUrl = "http://localhost:8082/" + "wechat/pushDisplaceAuditMessage"; Map requestParams = new HashMap<>(); requestParams.put("agentId", agentId); requestParams.put("saleId", saleId); requestParams.put("displaceId", displaceId); final HttpResult httpResult = HttpUtils.post(apiUrl, requestParams); if (httpResult.getStatusCode() != 200) { log.info("调用wjj-api推送置换审核微信消息失败, statusCode:{}", httpResult.getStatusCode()); resultBean= new ResultBean(PageResultBean.FAIL_CODE,"系统繁忙,请稍后再来!"); } else { final String content = httpResult.getContent(); log.info("调用wjj-api推送置换审核微信消息, 响应内容:{}", content); if (org.apache.commons.lang3.StringUtils.isBlank(content)) { log.info("调用wjj-api推送置换审核微信消息, 响应内容为空"); } else { final JSONObject jsonObject = JSON.parseObject(content); final Integer code = jsonObject.getInteger("code"); String message = jsonObject.getString("message"); message = StringUtils.isBlank(message) ? "系统繁忙,请稍后再来!" : message; if (code == 0) { resultBean = new ResultBean(ResultBean.FAIL_CODE, message); } } } } catch (Exception e) { resultBean= new ResultBean(PageResultBean.FAIL_CODE,"系统繁忙,请稍后再来!"); log.error("调用推送置换审核微信信息异常", e); }finally{ super.printResult(request, response, resultBean.toString()); } } @RequestMapping("/showDaili.do") public void showDaili(@RequestParam String agentId, HttpServletRequest request, HttpServletResponse response){ ResultBean resultBean = new ResultBean(ResultBean.SUCCESS_CODE, "成功"); AgentBean bean=agentBeanService.getAgentBeanByAgentId(agentId); if(bean.getIsAttent().equals("1")){ super.printResult(request,response,resultBean.toString()); }else{ resultBean.setResult("该设备没有同步到微工程,不能同步推送"); super.printResult(request,response,resultBean.toString()); } } @RequestMapping("/showDailiAll.do") public void showDailiAll(HttpServletRequest request, HttpServletResponse response,@RequestParam String agentIds){ ResultBean resultBean = new ResultBean(ResultBean.SUCCESS_CODE, "成功"); String [] allstr=agentIds.split("="); String agentId=allstr[0]; String zhihuanId=allstr[1]; int pageszie=Integer.parseInt( request.getParameter("pagesize")); int page =Integer.parseInt(request.getParameter("page")); String mutiStatus=request.getParameter("mutiStatus"); String focusBrandNames=request.getParameter("focusBrandNames"); if(StringUtils.isNotBlank(agentId)){ AgentBean bean=agentBeanService.getAgentBeanByAgentId(agentId); if(bean.getIsAttent().equals("1")) { List all= agentBeanService.findAgent(); List alldig=new ArrayList<>(); List list = diggerBeanService.getDiggerss(agentId,page,pageszie,mutiStatus,focusBrandNames); // List list = diggerBeanService.getDiggerss("WGC000",page,pageszie,mutiStatus,focusBrandNames); Map map=new HashMap<>(); map.put("list",list); map.put("zhihuanId",zhihuanId); map.put("totalNum",diggerBeanService.getDiggersss(agentId,page,pageszie,mutiStatus,focusBrandNames).size()); resultBean.setResult(map); super.printResult(request,response,resultBean.toString()); }else { resultBean.setResult("该设备没有同步到微工程,不能同步推送"); super.printResult(request,response,resultBean.toString()); } } } @RequestMapping("/selectDailiAll.do") public void selectDailiAll(HttpServletRequest request, HttpServletResponse response,@RequestParam String agentIds){ ResultBean resultBean = new ResultBean(ResultBean.SUCCESS_CODE, "成功"); // String displaceid=request.getParameter("displaceId"); String mutiStatus=request.getParameter("mutiStatus"); String focusBrandNames=request.getParameter("focusBrandNames"); String [] allstr=agentIds.split("="); String agentId=allstr[0]; String zhihuanId=allstr[1]; if(StringUtils.isNotBlank(agentId)) { AgentBean bean=agentBeanService.getAgentBeanByAgentId(agentId); if(bean.getIsAttent().equals("1")) { List list=diggerBeanService.getDiggersss(agentId, 0, 0, mutiStatus, focusBrandNames); resultBean.setResult(list); resultBean.setMessage(zhihuanId); super.printResult(request,response,resultBean.toString()); }else { resultBean.setResult("该设备没有同步到微工程,不能同步推送"); super.printResult(request,response,resultBean.toString()); } } } /** * 搜索置换审核记录分页列表-自运营 * @param request * @param response */ @RequestMapping("/sinceAuditList.do") public void sinceAuditList(HttpServletRequest request, HttpServletResponse response){ //返回页面数据 PageResultBean resultBean = null; try { //获取登录信息 HttpSession session = request.getSession(); UserBean user = (UserBean)session.getAttribute(CommonConstants.USER_INFO); if(user == null) { resultBean = new PageResultBean(PageResultBean.FAIL_CODE, "请先登录!"); return; } //如果不是平台用户的话,则只能搜索到他本身的商家报价信息 String agentId = ""; if(!"1".equals(user.getIsAdmin())){ agentId = user.getAgentId(); }else { agentId = super.getParameter(request, "agentId"); } // 当前页码 String currentPage = super.getParameter(request, "currentPage"); // 分页记录数 String pageSize = super.getParameter(request, "pageSize"); int currentPageInt = 1; int pageSizeInt = 10; if(StringUtils.isNotEmpty(currentPage)){ try { currentPageInt = Integer.parseInt(currentPage); } catch (Exception e) { resultBean = new PageResultBean(PageResultBean.FAIL_CODE,"请输入正确的页数!"); return; } } if(StringUtils.isNotEmpty(pageSize)){ try { pageSizeInt = Integer.parseInt(pageSize); } catch (Exception e) { resultBean = new PageResultBean(PageResultBean.FAIL_CODE,"请输入正确的分页数!"); return; } } // 条件查询参数 String brandCode = "sbpp"; String brandContent = super.getParameter(request, "brandContent"); String typeCode = "sblx"; String typeContent = super.getParameter(request, "typeContent"); String auditStatus = super.getParameter(request, "auditStatus"); String startTimeStr = super.getParameter(request, "startTime"); String endTimeStr = super.getParameter(request, "endTime"); String displaceId = super.getParameter(request, "displaceId"); String journalistName = super.getParameter(request, "journalistName"); String agentName = super.getParameter(request, "agentName"); // 时间转换 Date startTime = null; Date endTime = null; try { if(StringUtils.isNotBlank(startTimeStr)) { startTime = DateUtil.parse(startTimeStr, DateUtil.DEFAULT); } if(StringUtils.isNotBlank(endTimeStr)) { endTime = DateUtil.parse(endTimeStr, DateUtil.DEFAULT); } } catch (Exception e) { resultBean = new PageResultBean(PageResultBean.FAIL_CODE,"请输入正确查询时间!"); return; } // 查询结果 resultBean = displaceAuditService.queryAuditPage(agentId, agentName, brandCode, brandContent, typeCode, typeContent, auditStatus, startTime, endTime, displaceId, journalistName, currentPageInt, pageSizeInt); //获取用户session信息中的字段权限,并组装成map带回页面 List roleList = user.getUserColumnRoleBeans(); Map columnMap = new HashMap(); if(roleList!=null && !roleList.isEmpty()){ for(UserColumnRoleBean role:roleList){ if(role!=null){ if(ConfigConstants.DISPLACE_LIST.equals(role.getListCode())){ columnMap.put(role.getColumnCode(), role.getColumnName()); } } } } resultBean.setColumnMap(columnMap); } catch (Exception e) { resultBean= new PageResultBean(PageResultBean.FAIL_CODE,"系统繁忙,请稍后再来!"); log.error("auditList error!",e); }finally{ super.printResult(request, response, resultBean.toString()); } } /** * 搜索置换审核记录分页列表 * @param request * @param response */ @RequestMapping("/auditList.do") public void auditList(HttpServletRequest request, HttpServletResponse response){ //返回页面数据 PageResultBean resultBean = null; try { //获取登录信息 HttpSession session = request.getSession(); UserBean user = (UserBean)session.getAttribute(CommonConstants.USER_INFO); if(user == null) { resultBean = new PageResultBean(PageResultBean.FAIL_CODE, "请先登录!"); return; } log.info("调用置换审核列表接口,当前登录人信息 userAccount:" + user.getUserAccount() + ", userRank:" + user.getUserRank() + ", isAdmin:" + user.getIsAdmin()); // 1、超级管理员可以看到所有审核列表 2、管理员可以看到隶属自己的商家的审核列表 3、代理商可以看到自己商家的审核列表 String agentId = ""; if (UserBean.USER_RANK_SUPER_ADMIN.equals(user.getUserRank()) || UserBean.USER_RANK_ADMIN.equals(user.getUserRank())) { agentId = super.getParameter(request, "agentId"); } else { agentId = user.getAgentId(); } // 当前页码 String currentPage = super.getParameter(request, "currentPage"); // 分页记录数 String pageSize = super.getParameter(request, "pageSize"); int currentPageInt = 1; int pageSizeInt = 10; if(StringUtils.isNotEmpty(currentPage)){ try { currentPageInt = Integer.parseInt(currentPage); } catch (Exception e) { resultBean = new PageResultBean(PageResultBean.FAIL_CODE,"请输入正确的页数!"); return; } } if(StringUtils.isNotEmpty(pageSize)){ try { pageSizeInt = Integer.parseInt(pageSize); } catch (Exception e) { resultBean = new PageResultBean(PageResultBean.FAIL_CODE,"请输入正确的分页数!"); return; } } // 条件查询参数 String brandCode = "sbpp"; String brandContent = super.getParameter(request, "brandContent"); String typeCode = "sblx"; String typeContent = super.getParameter(request, "typeContent"); //上架状态 审核状态(1-已审核已上架,0-待审核待上架,2-已驳回,3-重新上架成功的,4-已审核待上架) String auditStatus = super.getParameter(request, "auditStatus"); //已删除 记录是否显示(1-显示,0-不显示,,2-取消发布) String status = super.getParameter(request, "status"); String startTimeStr = super.getParameter(request, "startTime"); String endTimeStr = super.getParameter(request, "endTime"); String displaceId = super.getParameter(request, "displaceId"); String journalistName = super.getParameter(request, "journalistName"); String agentName = super.getParameter(request, "agentName"); // 时间转换 Date startTime = null; Date endTime = null; try { if(StringUtils.isNotBlank(startTimeStr)) { startTime = DateUtil.parse(startTimeStr, DateUtil.DEFAULT); } if(StringUtils.isNotBlank(endTimeStr)) { endTime = DateUtil.parse(endTimeStr, DateUtil.DEFAULT); } } catch (Exception e) { resultBean = new PageResultBean(PageResultBean.FAIL_CODE,"请输入正确查询时间!"); return; } // 查询结果 //精品机查询 String isGood="1"; if(jpjgh.equals(agentId)){ isGood="2"; } log.info("jpjgh="+jpjgh); log.info("jpjgh="+isGood); resultBean = displaceAuditService.queryAuditPageByType(agentId, agentName, brandCode, brandContent, typeCode, typeContent, auditStatus,status,startTime, endTime, displaceId, journalistName, currentPageInt, pageSizeInt, user.getUserRank(), user.getId(),isGood); // resultBean = displaceAuditService.queryAuditPage2(agentId, agentName, brandCode, brandContent, typeCode, typeContent, auditStatus,status,startTime, endTime, displaceId, journalistName, currentPageInt, pageSizeInt, user.getUserRank(), user.getId()); //获取用户session信息中的字段权限,并组装成map带回页面 List roleList = user.getUserColumnRoleBeans(); Map columnMap = new HashMap(); if(roleList!=null && !roleList.isEmpty()){ for(UserColumnRoleBean role:roleList){ if(role!=null){ if(ConfigConstants.DISPLACE_LIST.equals(role.getListCode())){ columnMap.put(role.getColumnCode(), role.getColumnName()); } } } } resultBean.setColumnMap(columnMap); } catch (Exception e) { resultBean= new PageResultBean(PageResultBean.FAIL_CODE,"系统繁忙,请稍后再来!"); log.error("auditList error!",e); }finally{ super.printResult(request, response, resultBean.toString()); } } /** * 导出置换审核记录--自运营 * @param request * @param response */ @RequestMapping("/expSinceAuditList.do") public void expSinceAuditList(HttpServletRequest request, HttpServletResponse response){ //返回页面数据 ResultBean resultBean = new ResultBean(ResultBean.SUCCESS_CODE,"成功!"); try { //获取登录信息 HttpSession session = request.getSession(); UserBean user = (UserBean)session.getAttribute(CommonConstants.USER_INFO); if(user == null) { resultBean = new ResultBean(PageResultBean.FAIL_CODE, "请先登录!"); return; } //如果不是平台用户的话,则只能搜索到他本身的商家报价信息 String agentId = ""; if(!"1".equals(user.getIsAdmin())){ agentId = user.getAgentId(); }else { agentId = super.getParameter(request, "agentId"); } // 条件查询参数 String brandCode = "sbpp"; String brandContent = super.getParameter(request, "brandContent"); String typeCode = "sblx"; String typeContent = super.getParameter(request, "typeContent"); String auditStatus = super.getParameter(request, "auditStatus"); String startTimeStr = super.getParameter(request, "startTime"); String endTimeStr = super.getParameter(request, "endTime"); String displaceId = super.getParameter(request, "displaceId"); String journalistName = super.getParameter(request, "journalistName"); String agentName = super.getParameter(request, "agentName"); String ids = super.getParameter(request, "ids"); // 时间转换 Date startTime = null; Date endTime = null; try { if(StringUtils.isNotBlank(startTimeStr)) { startTime = DateUtil.parse(startTimeStr, DateUtil.DEFAULT); } if(StringUtils.isNotBlank(endTimeStr)) { endTime = DateUtil.parse(endTimeStr, DateUtil.DEFAULT); } } catch (Exception e) { resultBean = new ResultBean(PageResultBean.FAIL_CODE,"请输入正确导出时间!"); return; } // 查询结果 String path = request.getSession().getServletContext().getRealPath("/")+ "/auditexcel/";; resultBean = displaceAuditService.createSinceAuditXlsx(agentId, agentName, brandCode, brandContent, typeCode, typeContent, auditStatus, startTime, endTime, displaceId, journalistName, path, user, ids); if(!ResultBean.SUCCESS_CODE.equals(resultBean.getCode())){ resultBean = new ResultBean(ResultBean.FAIL_CODE,"系统繁忙,请稍后再来!"); return; } String filename = resultBean.getMessage(); String[] tempArr= filename.split("\\."); //设置文件下载格式XLS ExcelFileUtil.setXLSXHeader(request, response, tempArr[0]); //获取文件 File upfile = new File(path+filename); ExcelFileUtil.downloadFile(response.getOutputStream(),upfile); } catch (Exception e) { resultBean = new ResultBean(ResultBean.FAIL_CODE, "系统繁忙,请稍后再来!"); log.error("exportOffer error!",e); } } /** * 导出置换审核记录 * @param request * @param response */ @RequestMapping("/expAuditList.do") public void expAuditList(HttpServletRequest request, HttpServletResponse response){ //返回页面数据 ResultBean resultBean = new ResultBean(ResultBean.SUCCESS_CODE,"成功!"); try { //获取登录信息 HttpSession session = request.getSession(); UserBean user = (UserBean)session.getAttribute(CommonConstants.USER_INFO); if(user == null) { resultBean = new ResultBean(PageResultBean.FAIL_CODE, "请先登录!"); return; } log.info("调用导出置换审核列表xlsx接口,当前登录人信息 userAccount:" + user.getUserAccount() + ", userRank:" + user.getUserRank() + ", isAdmin:" + user.getIsAdmin()); // 1、超级管理员可以看到所有审核列表 2、管理员可以看到隶属自己的商家的审核列表 3、代理商可以看到自己商家的审核列表 String agentId = ""; if (UserBean.USER_RANK_SUPER_ADMIN.equals(user.getUserRank()) || UserBean.USER_RANK_ADMIN.equals(user.getUserRank())) { agentId = super.getParameter(request, "agentId"); } else { agentId = user.getAgentId(); } // 条件查询参数 String brandCode = "sbpp"; String brandContent = super.getParameter(request, "brandContent"); String typeCode = "sblx"; String typeContent = super.getParameter(request, "typeContent"); String auditStatus = super.getParameter(request, "auditStatus"); String startTimeStr = super.getParameter(request, "startTime"); String endTimeStr = super.getParameter(request, "endTime"); String displaceId = super.getParameter(request, "displaceId"); String journalistName = super.getParameter(request, "journalistName"); String agentName = super.getParameter(request, "agentName"); String ids = super.getParameter(request, "ids"); // 时间转换 Date startTime = null; Date endTime = null; try { if(StringUtils.isNotBlank(startTimeStr)) { startTime = DateUtil.parse(startTimeStr, DateUtil.DEFAULT); } if(StringUtils.isNotBlank(endTimeStr)) { endTime = DateUtil.parse(endTimeStr, DateUtil.DEFAULT); } } catch (Exception e) { resultBean = new ResultBean(PageResultBean.FAIL_CODE,"请输入正确导出时间!"); return; } // 查询结果 String path = request.getSession().getServletContext().getRealPath("/")+ "/auditexcel/";; resultBean = displaceAuditService.createAuditXlsx(agentId, agentName, brandCode, brandContent, typeCode, typeContent, auditStatus, startTime, endTime, displaceId, journalistName, path, user, ids); if(!ResultBean.SUCCESS_CODE.equals(resultBean.getCode())){ resultBean = new ResultBean(ResultBean.FAIL_CODE,"系统繁忙,请稍后再来!"); return; } String filename = resultBean.getMessage(); String[] tempArr= filename.split("\\."); //设置文件下载格式XLS ExcelFileUtil.setXLSXHeader(request, response, tempArr[0]); //获取文件 File upfile = new File(path+filename); ExcelFileUtil.downloadFile(response.getOutputStream(),upfile); } catch (Exception e) { resultBean = new ResultBean(ResultBean.FAIL_CODE, "系统繁忙,请稍后再来!"); log.error("exportOffer error!",e); } } /** * 删除置换记录 * @param request * @param response */ @RequestMapping("/deleteAudit.do") public void deleteShop(HttpServletRequest request, HttpServletResponse response){ //返回页面数据 ResultBean resultBean = new ResultBean(ResultBean.SUCCESS_CODE,"成功!"); String ids = super.getParameter(request, "ids"); try { //判断必要参数是否传递到后台 if(StringUtils.isEmpty(ids)){ resultBean = new ResultBean(ResultBean.FAIL_CODE,"请选择要删除的置换记录!"); return; } String[] queryCondition = ids.split(","); if(queryCondition==null || queryCondition.length<=0){ resultBean = new ResultBean(ResultBean.FAIL_CODE,"请选择要删除的置换记录!"); return; } if(resultBean.getCode().equals(ResultBean.SUCCESS_CODE)){ boolean flag = true; // 任务项数量 查询条件 StringBuilder conditionSql = new StringBuilder(); // 任务项 条件值 List conditions = new ArrayList(); for (int i = 0; i < queryCondition.length; i++) { conditions.add(queryCondition[i]); conditionSql.append("?"); if(i conditions = new ArrayList(); for (int i = 0; i < queryCondition.length; i++) { conditions.add(queryCondition[i]); conditionSql.append("?"); if(iDouble.parseDouble(displaceAuditBean.getMaxPrice())||Double.parseDouble(displaceAuditBean.getPersistPrice())1500){ resultBean = new PageResultBean(PageResultBean.FAIL_CODE, "短信内容过长"); return; } displaceAuditBean.setStartTime(startTime); displaceAuditBean.setEndTime(endTime); displaceAuditBean.setAuditTime(new Date()); displaceAuditBean.setAuditUser(user.getUserAccount()); // 补充信息 String oldDis=displaceAuditService.findOldDis(displace.getId()); System.out.println(oldDis+"这是查出来的old"); String oldDisplace=""; int count=0; if(oldDis.equals("0")){ count=displaceAuditService.findCount(displace.getDisplaceId()); oldDisplace=displace.getDisplaceId(); }else{ count=displaceAuditService.findCountByOld(oldDisplace)+1; oldDisplace=oldDis; } boolean flag = displaceAuditService.createNewAudit(displaceAuditBean,oldDisplace,count); System.out.println(displaceAuditBean.getId()+"这是id"+displaceAuditBean.getDisplaceId()+"这是置换id"); if(!flag) { resultBean = new PageResultBean(PageResultBean.FAIL_CODE,"系统繁忙,请稍后再来!"); return; } String agentName = agentBean.getAgentName(); String appId = agentBean.getPubAppId(); String appSecret = agentBean.getPubAppSecret(); //String diggerUrl = TemplateConstants.ZHSH_DIGGER_URL + "?agentId=" + agentId + "&id=" + id; String diggerUrl = "https://www.weigongcheng.net/wjj-api/index.html#/join" + "?agentId=" + agentId + "&displaceId="+displaceId+"&status="+displaceAuditBean+"&id=" + id; String wxsms = TemplateConstants.ZHSH_DIGGER_TEMPLATE_CONTENT; wxsms = wxsms.replaceAll("first", "有一台设备正在寻找买家"); wxsms = wxsms.replaceAll("keyword1", sbmc+""); wxsms = wxsms.replaceAll("keyword2", displaceAuditBean.getMinPrice()+"万元"); wxsms = wxsms.replaceAll("keyword3", displaceAuditBean.getMoneyRange()+"万元"); wxsms = wxsms.replaceAll("keyword4", DateUtil.format(startTime, "yyyy年MM月dd日 HH:mm")); wxsms = wxsms.replaceAll("keyword5", displaceAuditBean.getBail()+"万元"); wxsms = wxsms.replaceAll("remark", "点击【详情】前往查看!"); List list = new ArrayList(); PushRecordBean pushRecord = null; // 发送车商信息 if(StringUtils.isNotBlank(ids)) { String[] diggers = ids.substring(0, ids.lastIndexOf(",")).split(","); for (int i = 0; i < diggers.length; i++) { //获取车商bean,并获取车商微信openid和其他信息 DiggerBean digger = diggerBeanService.queryDiggerByID(diggers[i]); String openId = digger.getWxOpenID(); String wxnc = digger.getDaWxnc(); String wxh = digger.getDaWxh(); String name = digger.getDaName(); String phone = digger.getDaPhone(); // 组装车商微信内容 Map param1 = new HashMap(); param1.put("first",new TemplateData("有一台设备正在寻找买家","#696969")); param1.put("keyword1",new TemplateData(sbmc+"","#696969")); param1.put("keyword2",new TemplateData(displaceAuditBean.getMinPrice()+"万元","#696969")); param1.put("keyword3",new TemplateData(displaceAuditBean.getMoneyRange()+"万元","#696969")); param1.put("keyword4",new TemplateData(DateUtil.format(startTime, "yyyy年MM月dd日 HH:mm"),"#696969")); param1.put("keyword5",new TemplateData(displaceAuditBean.getBail()+"万元","#696969")); param1.put("remark",new TemplateData("点击【详情】前往查看!","#696969")); if(StringUtils.isNotBlank(pushWx)){ pushRecord = displaceAuditService.pushSms(displaceId, id, sbmc, ConfigConstants.CDMC_ZHSH, agentId, agentName, openId, wxnc, wxh, name, phone, ConfigConstants.TSFS_WXXX, ConfigConstants.XXLB_SBSJ, appId, appSecret, sms, wxsms, param1, diggerUrl, "拍品上架通知"); list.add(pushRecord); } if(StringUtils.isNotBlank(pushSms)){ pushRecord = displaceAuditService.pushSms(displaceId, id, sbmc, ConfigConstants.CDMC_ZHSH, agentId, agentName, openId, wxnc, wxh, name, phone, ConfigConstants.TSFS_DXX, ConfigConstants.XXLB_SBSJ, appId, appSecret, sms, wxsms, param1, diggerUrl, "拍品上架通知"); list.add(pushRecord); } } } // 发送微工程信息 if(StringUtils.isNotBlank(wgcids)) { String wgcAgentName = ""; String wgcAppId = ""; String wgcAppSecret = ""; String wgcPriceLink = ""; if("1".equals(agentBean.getIsAttent()) || "y".equals(agentBean.getIsAttent()) || ConfigConstants.WGC_ID.equals(agentId)) { // 微工程信息 AgentBean wgcBean = agentBeanService.getAgentBeanByAgentId(ConfigConstants.WGC_ID); wgcAgentName = wgcBean.getAgentName();; wgcAppId = wgcBean.getPubAppId(); wgcAppSecret = wgcBean.getPubAppSecret(); wgcPriceLink = wgcBean.getPriceLink(); String[] wgcdiggers = wgcids.substring(0, wgcids.lastIndexOf(",")).split(","); for (int i = 0; i < wgcdiggers.length; i++) { //获取车商bean,并获取车商微信openid和其他信息 DiggerBean digger = diggerBeanService.queryDiggerByID(wgcdiggers[i]); String openId = digger.getWxOpenID(); String wxnc = digger.getDaWxnc(); String wxh = digger.getDaWxh(); String name = digger.getDaName(); String phone = digger.getDaPhone(); // 组装车商微信内容 Map param2 = new HashMap(); param2.put("first",new TemplateData("有一台设备正在寻找买家","#696969")); param2.put("keyword1",new TemplateData(sbmc+"","#696969")); param2.put("keyword2",new TemplateData(displaceAuditBean.getMinPrice()+"万元","#696969")); param2.put("keyword3",new TemplateData(displaceAuditBean.getMoneyRange()+"万元","#696969")); param2.put("keyword4",new TemplateData(DateUtil.format(startTime, "yyyy年MM月dd日 HH:mm"),"#696969")); param2.put("keyword5",new TemplateData(displaceAuditBean.getBail()+"万元","#696969")); param2.put("remark",new TemplateData("点击【详情】前往查看!","#696969")); wxsms = wxsms.replaceAll("keyword1", wxnc+""); if(StringUtils.isNotBlank(pushWx)){ pushRecord = displaceAuditService.pushSms(displaceId, id, sbmc, ConfigConstants.CDMC_ZHSH, ConfigConstants.WGC_ID, wgcAgentName, openId, wxnc, wxh, name, phone, ConfigConstants.TSFS_WXXX,ConfigConstants.XXLB_SBSJ, wgcAppId, wgcAppSecret, sms, wxsms, param2, wgcPriceLink, "拍品上架通知"); list.add(pushRecord); } if(StringUtils.isNotBlank(pushSms)){ pushRecord = displaceAuditService.pushSms(displaceId, id, sbmc, ConfigConstants.CDMC_ZHSH, ConfigConstants.WGC_ID, wgcAgentName, openId, wxnc, wxh, name, phone, ConfigConstants.TSFS_DXX,ConfigConstants.XXLB_SBSJ, wgcAppId, wgcAppSecret, sms, wxsms, param2, wgcPriceLink, "拍品上架通知"); list.add(pushRecord); } } } } // 发送销售员信息 if(StringUtils.isNotBlank(saleId)) { SalesBean salesBean = saleBeanService.getSaleBeanBySaleId(saleId); if(salesBean != null){ String openId = salesBean.getWxOpenid(); String wxnc = salesBean.getSaleWxnc(); String wxh = salesBean.getSaleWxh(); String name = salesBean.getSaleName(); String phone = salesBean.getSalePhone(); String saleUrl = TemplateConstants.ZHSH_SALE_URL + "?agentId=" + agentId + "&id=" + id; // 组装销售员微信内容 Map param3 = new HashMap(); param3.put("first",new TemplateData("您上传的设备已上架成功,等待买家出价","#696969")); param3.put("keyword1",new TemplateData(wxnc,"#696969")); param3.put("keyword2",new TemplateData(sbmc,"#696969")); param3.put("keyword3",new TemplateData(pubTimeStr,"#696969")); param3.put("keyword4",new TemplateData("上架成功","#696969")); param3.put("remark",new TemplateData("赶快点击“详情”分享给大家吧!","#696969")); String upsms = TemplateConstants.ZHSH_SALE_UP_SMS; upsms = upsms.replace("sbmc", sbmc+""); String wxsms1 = TemplateConstants.ZHSH_SALE_TEMPLATE_CONTENT; wxsms1 = wxsms1.replaceAll("first", "您上传的设备已上架成功,等待买家出价"); wxsms1 = wxsms1.replaceAll("keyword1", wxnc+""); wxsms1 = wxsms1.replaceAll("keyword2", sbmc+""); wxsms1 = wxsms1.replaceAll("keyword3", pubTimeStr); wxsms1 = wxsms1.replaceAll("keyword4", "上架成功"); wxsms1 = wxsms1.replaceAll("remark", "赶快点击“详情”分享给大家吧!"); if(StringUtils.isNotBlank(pushWx)){ pushRecord = displaceAuditService.pushSms(displaceId, id, sbmc, ConfigConstants.CDMC_ZHSH, agentId, agentName, openId, wxnc, wxh, name, phone, ConfigConstants.TSFS_WXXX,ConfigConstants.XXLB_SBSJ, appId, appSecret, upsms,wxsms1, param3, saleUrl, "审核结果通知"); list.add(pushRecord); } if(StringUtils.isNotBlank(pushSms)){ pushRecord = displaceAuditService.pushSms(displaceId, id, sbmc, ConfigConstants.CDMC_ZHSH, agentId, agentName, openId, wxnc, wxh, name, phone, ConfigConstants.TSFS_DXX,ConfigConstants.XXLB_SBSJ, appId, appSecret, upsms,wxsms1, param3, saleUrl, "审核结果通知"); list.add(pushRecord); } } } // 保存推送消息 pushRecordBeanService.saveRecords(list); } catch (Exception e) { resultBean= new PageResultBean(PageResultBean.FAIL_CODE,"系统繁忙,请稍后再来!"); log.error("addInfo error!",e); }finally{ super.printResult(request, response, resultBean.toString()); } } @RequestMapping("/pushAdmin.do") public void pushAdmin(HttpServletRequest request, HttpServletResponse response,@RequestParam("arrayDaili") String arrayDaili,String shebeiId){ System.out.println(arrayDaili+"======"+shebeiId); ResultBean resultBean = new ResultBean(ResultBean.SUCCESS_CODE,"成功!"); try { if (StringUtils.isNotBlank(arrayDaili) && StringUtils.isNotBlank(shebeiId)) { List list = new ArrayList(); PushRecordBean pushRecord = null; AgentBean wgcBean = agentBeanService.getAgentBeanByAgentId(ConfigConstants.WGC_ID); String wgcAgentName = wgcBean.getAgentName(); String wgcAppId = wgcBean.getPubAppId(); String wgcAppSecret = wgcBean.getPubAppSecret(); //String wgcPriceLink = wgcBean.getPriceLink() String xqurl="https://www.xxinjiyuan.com/wjj-api/index.html#/join?agentId=GZZSNJ&displaceId=GZZSNJ-ZH0044&status=finished&id=5c8adc199c7f44a8ac398d9edbcd4914"; DisplaceAuditBean displace = displaceAuditService.queryAuditPageByDisplaceId(shebeiId); String wgcPriceLink ="https://www.weigongcheng.net/wjj-api/index.html#/join?agentId=WGC000"+"&status="+displace.getAuditStatus()+"&id="+displace.getId(); String sbmc = displace.getAttrContent().get("sbpp") + " " + displace.getAttrContent().get("sbxh") + " " + displace.getAttrContent().get("sblx"); String[] chrstr = arrayDaili.split("#"); System.out.println("============================>2"); for (int i = 0; i < chrstr.length; i++) { DiggerBean digger = diggerBeanService.queryDiggerByID(chrstr[i]); String openId = digger.getWxOpenID(); String wxnc = digger.getDaWxnc(); String wxh = digger.getDaWxh(); String name = digger.getDaName(); String phone = digger.getDaPhone(); String wxsms = TemplateConstants.ZHSH_DIGGER_TEMPLATE_CONTENT; System.out.println(openId + "+++openid"); System.out.println(wxnc + "+++wxnc"); // 组装车商微信内容 System.out.println(displace.getStartTime()+"------------------------"); Map param2 = new HashMap(); param2.put("first", new TemplateData("有一台设备正在寻找买家", "#696969")); param2.put("keyword1", new TemplateData(sbmc + "", "#696969")); param2.put("keyword2", new TemplateData(displace.getMinPrice() + "万元", "#696969")); param2.put("keyword3", new TemplateData(displace.getMoneyRange(), "#696969")); param2.put("keyword4", new TemplateData(DateUtil.format(displace.getStartTime(), "yyyy年MM月dd日 HH:mm"), "#696969")); param2.put("keyword5", new TemplateData(displace.getBail() + "万元", "#696969")); param2.put("remark", new TemplateData("点击【详情】前往查看!", "#696969")); wxsms = wxsms.replaceAll("keyword1", wxnc + ""); pushRecord = displaceAuditService.pushSms(shebeiId, "", sbmc, ConfigConstants.CDMC_ZHSH, ConfigConstants.WGC_ID, wgcAgentName, openId, wxnc, wxh, name, phone, ConfigConstants.TSFS_WXXX, ConfigConstants.XXLB_SBSJ, wgcAppId, wgcAppSecret, "", wxsms, param2, wgcPriceLink, "拍品上架通知"); list.add(pushRecord); } pushRecordBeanService.saveRecords(list); resultBean.setMessage("发送成功"); super.printResult(request, response, resultBean.toString()); } ; }catch (Exception e) { log.error("addInfo error!",e); }finally{ super.printResult(request, response, resultBean.toString()); } } }