| | |
| | | <td width="80px"><strong>操作选项:</strong></td> |
| | | <td> |
| | | <% if(((profile&FormOpUtil.listDoc)>0)){%> |
| | | <a href="javascript:void(0);" id="tpDocList" docType="17" plain="true" >单据列表</a> |
| | | <a href="javascript:void(0);" id="tpDocList" docType="15" plain="true" >单据列表</a> |
| | | |
| | | <%} if(((profile&FormOpUtil.copydoc)>0)){%> |
| | | <a id="tpCopy" href="javascript:void(0);" onclick="clearDoc();"plain="true" >复单</a> |
| | |
| | | if (dto.conNum == 1) isDetail = true; |
| | | break; |
| | | } |
| | | return isDetail ? (id.toLowerCase() + "HtmlPostfix=\"<span style='color:white;'> *</span>\"") : " "; |
| | | return isDetail ? (id.toLowerCase() + "HtmlPostfix=\"<span style='color:white;'> *</span>\" ") : " "; |
| | | } |
| | | |
| | | /** |
| | |
| | | boolean uppercase = GridUtils.prossRowSetDataType_Boolean(map, "uppercase");//大写 |
| | | String ValueExp = GridUtils.prossRowSetDataType_String(map, "showFieldValueExpression");//权限控制是否显示该值 |
| | | String editStatus = GridUtils.prossRowSetDataType_String(map, "editStatus");//权限控制是否显示该值 |
| | | if(org.apache.commons.lang3.StringUtils.isNotBlank(editStatus)){ |
| | | if(editStatus.contains("'")){ |
| | | throw new ApplicationException(id+"-editStatus参数值["+editStatus+"】不能存在单引号"); |
| | | } |
| | | } |
| | | boolean oneRec = GridUtils.prossRowSetDataType_Boolean(map, "return_one_record");//是否返回到单记录 |
| | | boolean onlyOne = GridUtils.prossRowSetDataType_Boolean(map, "onlyOne");//只返回单条记录 |
| | | String sqlScript = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "SqlScript"));// 控件sql |
| | |
| | | //避免触发时当前时间已过了设置的打卡提醒时间,所以需要用between and 且增加10分钟作为宽限时间 |
| | | //上班打卡提醒触发时间期间:在AttentionTimeForCheck 和CheckInDateTime之间 |
| | | //下班打卡提醒触发时间期间:因为AttentionTimeForCheck 和CheckInDateTime是相同时间,所以CheckInDateTime+10分钟,作为触发时间期间 |
| | | log.info("workTime:" + workTime); |
| | | //log.info("workTime:" + workTime); |
| | | if(StringUtils.isNotBlank(workTime)) { |
| | | LocalTime parse = LocalTime.parse(workTime, DateTimeFormatter.ofPattern("HH:mm")); |
| | | parse = parse.minusMinutes(perMinutes);//减去指定分钟,因为上班卡可以提前提醒 |
| | | LocalDate localDate = LocalDate.now(); |
| | | String dataTime = localDate.atTime(parse.getHour(), parse.getMinute()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | log.info("dataTime:" + dataTime); |
| | | //log.info("dataTime:" + dataTime); |
| | | String sql = "set nocount on \n select Seq,RulesDocCode,RulesName,UserCode,UserName,CheckInDateTime,Title,Description,CreateDate,LastSendTime,RemainTimes,TryTimes,ErrorCode,ErrorMsg,AttentionTimeForCheck,AttentionTypeForCheck,telephone from t180252 " + |
| | | " where '" + dataTime + "' between AttentionTimeForCheck and DATEADD(mi,10,CheckInDateTime) \n" + |
| | | " and isnull(RemainTimes,0)>0 "; |
| | | log.info("执行打卡提醒sql-1:" + sql); |
| | | //log.info("执行打卡提醒sql-1:" + sql); |
| | | //System.out.println("执行打卡提醒sql:" + sql); |
| | | return this.jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T180252.class)); |
| | | }else{ |
| | | String sql = "set nocount on \n select Seq,RulesDocCode,RulesName,UserCode,UserName,CheckInDateTime,Title,Description,CreateDate,LastSendTime,RemainTimes,TryTimes,ErrorCode,ErrorMsg,AttentionTimeForCheck,AttentionTypeForCheck,telephone from t180252 " + |
| | | " where getdate() between AttentionTimeForCheck and DATEADD(mi,10,CheckInDateTime) \n" + |
| | | " and isnull(RemainTimes,0)>0 "; |
| | | log.info("执行打卡提醒sql-2:" + sql); |
| | | //log.info("执行打卡提醒sql-2:" + sql); |
| | | return this.jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T180252.class)); |
| | | } |
| | | } |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | @RequestMapping("/crm/base") |
| | | @RestController |
| | |
| | | } |
| | | } |
| | | /** |
| | | * 按月份显示日程列表 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/schedule/listByMonth.do") |
| | | public @ResponseBody Object listByMonth(String date, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | List<T482112Entity> response = crmServiceIfc.listByMonth(date,request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+"","482112"); |
| | | TreeMap<String,List<T482112Entity>> map = new TreeMap<String,List<T482112Entity>>(); |
| | | response.stream().distinct().forEach(x->{ |
| | | List<T482112Entity> temp=new ArrayList<>(); |
| | | response.stream().forEach(y->{ |
| | | if(x.getStartTime().equalsIgnoreCase(y.getStartTime())){ |
| | | temp.add(y); |
| | | } |
| | | }); |
| | | map.put(x.getStartTime(),temp); |
| | | }); |
| | | callBackMessage.setInfo(map); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | /** |
| | | * 日程列表 |
| | | * |
| | | * @param request |
| | |
| | | * @return |
| | | */ |
| | | @RequestMapping("/schedule/del.do") |
| | | public @ResponseBody Object scheduleDel(Integer id, HttpServletRequest request) { |
| | | public @ResponseBody Object scheduleDel(@RequestBody T482112Entity entity, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | crmServiceIfc.scheduleDel(id); |
| | | crmServiceIfc.scheduleDel(entity); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | |
| | | private String userName; |
| | | private Integer id; |
| | | private String refCode; |
| | | private String refName; |
| | | private Integer enableFlag; |
| | | private Integer deleteFlag; |
| | | private Integer inquiryId; |
| | |
| | | private String longitude; |
| | | private String address; |
| | | private String attachList; |
| | | private String imageList; |
| | | private String followUpType; |
| | | private String followUpNextTime; |
| | | private String createTime; |
| | | private String updateTime; |
| | | private String followUser; |
| | | private List<FileEntity> files; |
| | | private List<FileEntity> imagFiles; |
| | | private String formid;//关联的功能号(线索,客户,商机) |
| | | private String dbid; |
| | | private Integer totalRowCount; |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 日程实体 |
| | |
| | | private Integer id; |
| | | private String refType; |
| | | private String refCode; |
| | | private String refName; |
| | | private String title; |
| | | private String color; |
| | | private String participantId;//跟进人 |
| | |
| | | private Integer totalRowCount; |
| | | private Integer pageCount; |
| | | private Integer completeFlag;//是否完成 |
| | | private Integer samedeleteFlag;//是否删除后续日程,0:只删除自身,1:删除后续日程 |
| | | private String samedeleteId;//同一个日程生成的重复日程,方便删除 |
| | | |
| | | @Override |
| | | public boolean equals(Object o) { |
| | | if (this == o) return true; |
| | | if (o == null || getClass() != o.getClass()) return false; |
| | | T482112Entity that = (T482112Entity) o; |
| | | return Objects.equals(startTime, that.startTime); |
| | | } |
| | | |
| | | @Override |
| | | public int hashCode() { |
| | | return Objects.hashCode(startTime); |
| | | } |
| | | } |
| | |
| | | |
| | | Response scheduleList(ScheduleRequestEntity entity); |
| | | |
| | | void scheduleDel(Integer id); |
| | | void scheduleDel(T482112Entity entity); |
| | | |
| | | void scheduleAttention(T482112Entity pinFlag); |
| | | |
| | |
| | | Response commentList(CommentRequestEntity entity); |
| | | |
| | | void commentDel(Integer id); |
| | | |
| | | List<T482112Entity> listByMonth(String date,String dbi,String formid); |
| | | } |
| | |
| | | import com.yc.exception.ApplicationException; |
| | | import com.yc.service.BaseService; |
| | | import com.yc.utils.DateUtil; |
| | | import org.apache.commons.lang3.RandomStringUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.jdbc.core.BeanPropertyRowMapper; |
| | |
| | | " @userName nvarchar(30),\n" + |
| | | " @id bigint, \n" + |
| | | " @refCode varchar(50),\n" + |
| | | " @refName nvarchar(150),\n" + |
| | | " @enable_flag bit, \n" + |
| | | " @delete_flag bit, \n" + |
| | | " @inquiry_id int, \n" + |
| | |
| | | " @longitude varchar(50), \n" + |
| | | " @address nvarchar(200),\n" + |
| | | " @attach_list varchar(150),\n" + |
| | | " @image_list varchar(150),\n" + |
| | | " @followUp_type nvarchar(20),\n" + |
| | | " @followUser varchar(20),\n" + |
| | | " @followUp_next_time datetime, \n" + |
| | |
| | | ",@userName=" + GridUtils.prossSqlParm(entity.getUserName()) + "\n" + |
| | | ",@id=" + entity.getId() + "\n" + |
| | | ",@refCode=" + GridUtils.prossSqlParm(entity.getRefCode()) + "\n" + |
| | | ",@refName=" + GridUtils.prossSqlParm(entity.getRefName()) + "\n" + |
| | | ",@inquiry_id=" + entity.getInquiryId() + "\n" + |
| | | ",@content=" + GridUtils.prossSqlParm(entity.getContent()) + "\n" + |
| | | ",@plain_content=" + GridUtils.prossSqlParm(entity.getPlainContent()) + "\n" + |
| | |
| | | ",@longitude=" + GridUtils.prossSqlParm(entity.getLongitude()) + "\n" + |
| | | ",@address=" + GridUtils.prossSqlParm(entity.getAddress()) + "\n" + |
| | | ",@attach_list=" + GridUtils.prossSqlParm(entity.getAttachList()) + "\n" + |
| | | ",@image_list=" + GridUtils.prossSqlParm(entity.getAttachList()) + "\n" + |
| | | ",@followUp_type=" + GridUtils.prossSqlParm(entity.getFollowUpType()) + "\n" + |
| | | ",@followUser=" + GridUtils.prossSqlParm(entity.getFollowUser()) + "\n" + |
| | | ",@followUp_next_time=" + GridUtils.prossSqlParm(entity.getFollowUpNextTime()) + "\n" + |
| | |
| | | ",userCode \n" + |
| | | ",userName \n" + |
| | | ",refCode \n" + |
| | | ",refName \n" + |
| | | ",inquiry_id \n" + |
| | | ",content \n" + |
| | | ",plain_content \n" + |
| | |
| | | ",longitude \n" + |
| | | ",address \n" + |
| | | ",attach_list \n" + |
| | | ",image_list \n" + |
| | | ",followUp_type \n" + |
| | | ",followUser \n" + |
| | | ",followUp_next_time \n" + |
| | |
| | | ",@userCode \n" + |
| | | ",@userName \n" + |
| | | ",@refCode \n" + |
| | | ",@refName \n" + |
| | | ",@inquiry_id \n" + |
| | | ",@content \n" + |
| | | ",@plain_content \n" + |
| | |
| | | ",@longitude \n" + |
| | | ",@address \n" + |
| | | ",@attach_list \n" + |
| | | ",@image_list \n" + |
| | | ",@followUp_type \n" + |
| | | ",@followUser \n" + |
| | | ",@followUp_next_time \n" + |
| | |
| | | ",longitude=" + GridUtils.prossSqlParm(entity.getLongitude()) + "\n" + |
| | | ",address=" + GridUtils.prossSqlParm(entity.getAddress()) + "\n" + |
| | | ",attach_list=" + GridUtils.prossSqlParm(entity.getAttachList()) + "\n" + |
| | | ",image_list=" + GridUtils.prossSqlParm(entity.getAttachList()) + "\n" + |
| | | ",followUp_type=" + GridUtils.prossSqlParm(entity.getFollowUpType()) + "\n" + |
| | | ",followUser=" + GridUtils.prossSqlParm(entity.getFollowUser()) + "\n" + |
| | | ",followUp_next_time=" + GridUtils.prossSqlParm(entity.getFollowUpNextTime()) + "\n" + |
| | |
| | | ",companyName \n" + |
| | | ",userCode \n" + |
| | | ",userName \n" + |
| | | ",id,refCode \n" + |
| | | ",id,refCode,refName \n" + |
| | | ",inquiry_id \n" + |
| | | ",comment_count \n" + |
| | | ",content \n" + |
| | |
| | | ",attach_list \n" + |
| | | ",followUp_type \n" + |
| | | ",followUser \n" + |
| | | ",followUp_next_time \n" + |
| | | ",followUp_next_time as followUpNextTime\n" + |
| | | ",create_time \n" + |
| | | ",case when convert(varchar(19),dateadd(hh,1,update_time),120)>convert(varchar(19),GETDATE(),120) then 1 else 0 end as deleteFlag" +//1小时内可以删除跟进 |
| | | ",update_time ,@TotalRowCount as totalRowCount ,@pageCount as pageCount "; |
| | |
| | | List<T482105Entity> list = this.jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482105Entity.class)); |
| | | list.stream().forEach(x -> { |
| | | //处理图片,附件,生成调用url及相关信息 |
| | | FileStructEntity fileStructEntity = new FileStructEntity(); |
| | | fileStructEntity.setDbid(request.getDbid()); |
| | | fileStructEntity.setFormid(request.getFormid()); |
| | | fileStructEntity.setFileStr(x.getAttachList()); |
| | | x.setFiles(Utils.getFileEntities(fileStructEntity)); |
| | | if (StringUtils.isNotBlank(x.getAttachList())) { |
| | | FileStructEntity fileStructEntity = new FileStructEntity(); |
| | | fileStructEntity.setDbid(request.getDbid()); |
| | | fileStructEntity.setFormid(request.getFormid()); |
| | | fileStructEntity.setFileStr(x.getAttachList()); |
| | | x.setFiles(Utils.getFileEntities(fileStructEntity)); |
| | | } |
| | | if (StringUtils.isNotBlank(x.getImageList())) { |
| | | FileStructEntity fileStructEntity = new FileStructEntity(); |
| | | fileStructEntity.setDbid(request.getDbid()); |
| | | fileStructEntity.setFormid(request.getFormid()); |
| | | fileStructEntity.setFileStr(x.getImageList()); |
| | | x.setFiles(Utils.getFileEntities(fileStructEntity)); |
| | | } |
| | | }); |
| | | Response response = new Response(); |
| | | response.setTotalCount((list != null && list.size() > 0) ? list.get(0).getTotalRowCount() : 0); |
| | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void scheduleDel(Integer id) { |
| | | this.doBaseExecute("delete from t482113 where refid=" + id + " \n delete from t482112 where id=" + id); |
| | | public void scheduleDel(T482112Entity entity) { |
| | | if(entity.getSamedeleteFlag()==0||entity.getSamedeleteFlag()==null){ |
| | | //只删除本身 |
| | | this.doBaseExecute("delete from t482113 where refid=" + entity.getId() + " \n delete from t482112 where id=" + entity.getId()); |
| | | }else{ |
| | | if(StringUtils.isBlank(entity.getSamedeleteId())){ |
| | | throw new ApplicationException("指定samedeleteFlag=1时samedeleteId参数不能为空"); |
| | | } |
| | | String[] deleteId=entity.getSamedeleteId().split(";"); |
| | | String orStr=" or samedeleteId like '%"+deleteId[deleteId.length-1]+"%'"; |
| | | this.doBaseExecute("delete from t482113 where refid=" + entity.getId() + orStr+" \n delete from t482112 where id=" + entity.getId()+orStr); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | start = LocalDateTime.parse(entity.getStartTime(), DateTimeFormatter.ofPattern(pattern)); |
| | | |
| | | } catch (Exception e) { |
| | | //表示没有时间,需要增加00:00:00,以便不出错 |
| | | //表示没有时间,需要增加00:00:00才不出错 |
| | | start = LocalDateTime.parse(entity.getStartTime() + " 00:00:00", DateTimeFormatter.ofPattern(pattern)); |
| | | } |
| | | try { |
| | |
| | | calEnd.setTime(Date.from(repeatEnd.atZone(ZoneId.systemDefault()).toInstant())); |
| | | if (entity.getType().equalsIgnoreCase("everyday")) { |
| | | //1,----每天 |
| | | repeatByDay(entity, list, start, end, pattern, calStart,1); |
| | | repeatByDay(entity, list, start, end, pattern, calStart, calEnd,1); |
| | | } |
| | | if (entity.getType().equalsIgnoreCase("everyweek")) { |
| | | //2,----每周 |
| | | repeatByWeek(entity, list, calStart, calEnd, start, end, pattern,1); |
| | | repeatByWeek(entity, list, calStart, calEnd, start, end, pattern, 1); |
| | | } |
| | | if (entity.getType().equalsIgnoreCase("everymonth")) { |
| | | //3,----每月 |
| | | repeatByMonth(entity, list, calStart, calEnd, start, end, pattern,1); |
| | | repeatByMonth(entity, list, calStart, calEnd, start, end, pattern, 1); |
| | | } |
| | | if (entity.getType().equalsIgnoreCase("ext")) { |
| | | if(entity.getNum()==null||entity.getNum()==0){ |
| | | throw new ApplicationException("自定义重复周期[num]不能为空"); |
| | | if (entity.getNum() == null || entity.getNum() == 0) { |
| | | throw new ApplicationException("自定义重复周期[num]不能为空"); |
| | | } |
| | | //4,----自定义 |
| | | if (entity.getType().equalsIgnoreCase("day")) { |
| | | if (entity.getUnit().equalsIgnoreCase("day")) { |
| | | //1,----每天 |
| | | repeatByDay(entity, list, start, end, pattern, calStart,entity.getNum()); |
| | | repeatByDay(entity, list, start, end, pattern, calStart,calEnd, entity.getNum()); |
| | | } |
| | | if (entity.getType().equalsIgnoreCase("week")) { |
| | | if (entity.getUnit().equalsIgnoreCase("week")) { |
| | | //2,----每周 |
| | | repeatByWeek(entity, list, calStart, calEnd, start, end, pattern,entity.getNum()); |
| | | repeatByWeek(entity, list, calStart, calEnd, start, end, pattern, entity.getNum()); |
| | | } |
| | | if (entity.getType().equalsIgnoreCase("month")) { |
| | | if (entity.getUnit().equalsIgnoreCase("month")) { |
| | | //3,----每月 |
| | | repeatByMonth(entity, list, calStart, calEnd, start, end, pattern,entity.getNum()); |
| | | repeatByMonth(entity, list, calStart, calEnd, start, end, pattern, entity.getNum()); |
| | | } |
| | | } |
| | | // String s=null; |
| | | // s.toLowerCase(); |
| | | } |
| | | |
| | | private static void repeatByDay(T482112Entity entity, List<T482112Entity> list, LocalDateTime start, LocalDateTime end, String pattern, Calendar calStart,int interval) { |
| | | long dayNumber = (ChronoUnit.DAYS.between(start, end)-1)/interval; |
| | | private static void repeatByDay(T482112Entity entity, List<T482112Entity> list, LocalDateTime start, LocalDateTime end, String pattern, Calendar calStart, Calendar CalEnd, int interval) { |
| | | long dayNumber = (long) Math.floor((ChronoUnit.DAYS.between(start, end)) / interval); |
| | | //增加相同标记,以便能把相关联的日程也一起删除 |
| | | String same= entity.getSamedeleteId(); |
| | | if(StringUtils.isBlank(same)){ |
| | | same= RandomStringUtils.randomAlphanumeric(5); |
| | | } |
| | | entity.setSamedeleteId(same); |
| | | list.add(entity); |
| | | SimpleDateFormat sdf = new SimpleDateFormat(pattern); |
| | | while (dayNumber > 0) { |
| | | String currentSame = entity.getSamedeleteId(); |
| | | while (checkCalendar(calStart,CalEnd)) { |
| | | calStart.add(Calendar.DAY_OF_MONTH, 1); //加一天 |
| | | T482112Entity temp = new T482112Entity(); |
| | | BeanUtils.copyProperties(entity, temp); |
| | | //保存修改,内容一点也不变也会生成新的日程,因为这里id都设置成null |
| | | temp.setId(null); |
| | | String newSame= currentSame+";"+RandomStringUtils.randomAlphanumeric(5); |
| | | temp.setSamedeleteId(newSame); |
| | | currentSame=newSame; |
| | | String dateStr = sdf.format(calStart.getTime()); |
| | | temp.setStartTime(dateStr); |
| | | //新结束日期=新的日期+相差天数 |
| | |
| | | temp.setEndTime(dateStr); |
| | | calStart.add(Calendar.DAY_OF_MONTH, -(int) dayNumber);//还原回来 |
| | | list.add(temp); |
| | | dayNumber--; |
| | | } |
| | | } |
| | | |
| | | private void repeatByWeek(T482112Entity entity, List<T482112Entity> list, Calendar calStart, Calendar calEnd, LocalDateTime start, LocalDateTime end, String pattern,int interval) { |
| | | private void repeatByWeek(T482112Entity entity, List<T482112Entity> list, Calendar calStart, Calendar calEnd, LocalDateTime start, LocalDateTime end, String pattern, int interval) { |
| | | int start_weekInYear = this.getWeekInYear(calStart.getTime()); |
| | | int end_weekInYear = this.getWeekInYear(calEnd.getTime()); |
| | | long weekNumber = (end_weekInYear-start_weekInYear)/interval; |
| | | long weekNumber = (long) Math.floor((end_weekInYear - start_weekInYear) / interval); |
| | | long dayNumber = ChronoUnit.DAYS.between(start, end); |
| | | //增加相同标记,以便能把相关联的日程也一起删除 |
| | | String same= entity.getSamedeleteId(); |
| | | if(StringUtils.isBlank(same)){ |
| | | same= RandomStringUtils.randomAlphanumeric(5); |
| | | } |
| | | entity.setSamedeleteId(same); |
| | | String currentSame = entity.getSamedeleteId(); |
| | | list.add(entity); |
| | | SimpleDateFormat sdf = new SimpleDateFormat(pattern); |
| | | while (weekNumber > 0) { |
| | |
| | | T482112Entity temp = new T482112Entity(); |
| | | BeanUtils.copyProperties(entity, temp); |
| | | temp.setId(null); |
| | | String newSame= currentSame+";"+RandomStringUtils.randomAlphanumeric(5); |
| | | temp.setSamedeleteId(newSame); |
| | | currentSame=newSame; |
| | | String dateStr = sdf.format(calStart.getTime()); |
| | | temp.setStartTime(dateStr); |
| | | //新结束日期=新的日期+相差天数 |
| | |
| | | } |
| | | } |
| | | |
| | | private static void repeatByMonth(T482112Entity entity, List<T482112Entity> list, Calendar calStart, Calendar calEnd, LocalDateTime start, LocalDateTime end, String pattern,int interval) { |
| | | private static void repeatByMonth(T482112Entity entity, List<T482112Entity> list, Calendar calStart, Calendar calEnd, LocalDateTime start, LocalDateTime end, String pattern, int interval) { |
| | | int start_monthInYear = calStart.get(Calendar.MONTH); |
| | | int end_monthInYear = calEnd.get(Calendar.MONTH); |
| | | long monthNumber = (end_monthInYear-start_monthInYear)/interval; |
| | | long monthNumber = (long) Math.floor((end_monthInYear - start_monthInYear) / interval);//向下取整,11.7取11 |
| | | long dayNumber = ChronoUnit.DAYS.between(start, end); |
| | | //增加相同标记,以便能把相关联的日程也一起删除 |
| | | String same= entity.getSamedeleteId(); |
| | | if(StringUtils.isBlank(same)){ |
| | | same= RandomStringUtils.randomAlphanumeric(5); |
| | | } |
| | | entity.setSamedeleteId(same); |
| | | String currentSame = entity.getSamedeleteId(); |
| | | list.add(entity); |
| | | SimpleDateFormat sdf = new SimpleDateFormat(pattern); |
| | | while (monthNumber > 0) { |
| | |
| | | T482112Entity temp = new T482112Entity(); |
| | | BeanUtils.copyProperties(entity, temp); |
| | | temp.setId(null); |
| | | String newSame= currentSame+";"+RandomStringUtils.randomAlphanumeric(5); |
| | | temp.setSamedeleteId(newSame); |
| | | currentSame=newSame; |
| | | String dateStr = sdf.format(calStart.getTime()); |
| | | temp.setStartTime(dateStr); |
| | | //新结束日期=新的日期+相差天数 |
| | |
| | | } |
| | | |
| | | //获取到所传日期在当年第几周 |
| | | public int getWeekInYear(Date date){ |
| | | public int getWeekInYear(Date date) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setFirstDayOfWeek(Calendar.MONDAY); |
| | | calendar.setTime(date); |
| | | return calendar.get(Calendar.WEEK_OF_YEAR); |
| | | } |
| | | |
| | | /** |
| | | * 因为日历比较用的是time属性,这个值是创建时候生成,就算二个日期一样,也会不一样。所以这里判断年月日,时分秒 |
| | | * |
| | |
| | | * @param end |
| | | * @return |
| | | */ |
| | | private boolean checkCalendar(Calendar start, Calendar end) { |
| | | private static boolean checkCalendar(Calendar start, Calendar end) { |
| | | int dayNumber = DateUtil.daysBetween(end.getTime(), start.getTime()); |
| | | if (dayNumber > 0) { |
| | | return true; |
| | |
| | | " @id bigint,\n" + |
| | | " @refType varchar(20),\n" + |
| | | " @refCode varchar(50) ,\n" + |
| | | " @refName nvarchar(150) ,\n" + |
| | | " @title nvarchar(100),\n" + |
| | | " @color varchar(10),\n" + |
| | | " @participant_id varchar(100),\n" + |
| | |
| | | " @remark nvarchar(230),\n" + |
| | | " @attach_list varchar(230),\n" + |
| | | " @image_list varchar(230),\n" + |
| | | " @samedeleteId varchar(2000),\n" + |
| | | " @full_day_flag bit,\n" + |
| | | " @create_time datetime,\n" + |
| | | " @update_time datetime,@last_inserted_id bigint\n" + |
| | |
| | | "@id=" + entity.getId() + " ,\n" + |
| | | "@refType=0 ,\n" + |
| | | "@refCode=" + GridUtils.prossSqlParm(entity.getRefCode()) + " ,\n" + |
| | | "@refName=" + GridUtils.prossSqlParm(entity.getRefName()) + " ,\n" + |
| | | "@title=" + GridUtils.prossSqlParm(entity.getTitle()) + " ,\n" + |
| | | "@color=" + GridUtils.prossSqlParm(entity.getColor()) + " ,\n" + |
| | | "@participant_id =" + GridUtils.prossSqlParm(entity.getParticipantId()) + " ,\n" + |
| | |
| | | "@remark=" + GridUtils.prossSqlParm(entity.getRemark()) + " ,\n" + |
| | | "@attach_list=" + GridUtils.prossSqlParm(entity.getAttachList()) + " ,\n" + |
| | | "@image_list=" + GridUtils.prossSqlParm(entity.getImageList()) + " ,\n" + |
| | | "@samedeleteId=" + GridUtils.prossSqlParm(entity.getSamedeleteId()) + " ,\n" + |
| | | "@full_day_flag=" + entity.getFullDayFlag() + " ,\n" + |
| | | "@rule_unit=" + GridUtils.prossSqlParm(entity.getUnit()) + " ,\n" + |
| | | "@rule_type=" + GridUtils.prossSqlParm(entity.getType()) + " ,\n" + |
| | |
| | | ",userName \n" + |
| | | ",refType \n" + |
| | | ",refCode \n" + |
| | | ",refName \n" + |
| | | ",title \n" + |
| | | ",color \n" + |
| | | ",participant_id\n" + |
| | |
| | | ",remark \n" + |
| | | ",attach_list \n" + |
| | | ",image_list \n" + |
| | | ",samedeleteId \n" + |
| | | ",full_day_flag \n" + |
| | | ",unit \n" + |
| | | ",type \n" + |
| | |
| | | ",@userName \n" + |
| | | ",@refType \n" + |
| | | ",@refCode \n" + |
| | | ",@refName \n" + |
| | | ",@title \n" + |
| | | ",@color \n" + |
| | | ",@participant_id\n" + |
| | |
| | | ",@remark \n" + |
| | | ",@attach_list \n" + |
| | | ",@image_list \n" + |
| | | ",@samedeleteId \n" + |
| | | ",@full_day_flag \n" + |
| | | ",@rule_unit \n" + |
| | | ",@rule_type \n" + |
| | |
| | | ",repeat_Start=@rule_repeatStart \n" + |
| | | ",repeat_End=@rule_repeatEnd \n" + |
| | | ",update_time=@update_time\n" + |
| | | ",full_day_flag=@full_day_flag \n" + |
| | | ",full_day_flag=@full_day_flag where id=@id\n" + |
| | | " SELECT @last_inserted_id=@id\n" + |
| | | "end\n" + |
| | | AddRemindTimesSql(entity.getRemindTimes()); |
| | | AddRemindTimesSql(entity.getRemindTimes())+"\n" + |
| | | " exec p482114Save @last_inserted_id \n"; |
| | | //TODO 日程提醒功能 t482114 |
| | | } |
| | | this.doBaseExecute(sql); |
| | | } |
| | |
| | | " insert into t482113(" + |
| | | " refId, \n" + |
| | | "time, \n" + |
| | | "type \n" + |
| | | "type, \n" + |
| | | "samedeleteId \n" + |
| | | ")values(" + |
| | | "@remind_refid, \n" + |
| | | "@remind_time, \n" + |
| | | "@remind_type \n" + |
| | | "@remind_type, \n" + |
| | | "@samedeleteId \n" + |
| | | ")\n"; |
| | | } |
| | | return sql; |
| | | } |
| | | |
| | | @Override |
| | | public List<T482112Entity> listByMonth(String date,String dbid,String formid) { |
| | | if (StringUtils.isBlank(date)) { |
| | | throw new ApplicationException("时间参数不能都为空"); |
| | | } |
| | | String where = " where DateDiff(month, start_time,'"+date+"-01')=0\n" ;//同一个月 |
| | | String fileds = "refType \n" + |
| | | ",id,refCode,refName \n" + |
| | | ",title \n" + |
| | | ",color \n" + |
| | | ",participant_id\n" + |
| | | ",convert(varchar(10), start_time,120) as start_time \n" + |
| | | ",end_time \n" + |
| | | ",remark \n" + |
| | | ",attach_list \n" + |
| | | ",image_list \n" + |
| | | ",full_day_flag \n" + |
| | | ",unit \n" + |
| | | ",type \n" + |
| | | ",repeat_Start \n" + |
| | | ",repeat_End \n" + |
| | | ",num " + |
| | | ",create_time \n" + |
| | | ",update_time \n"; |
| | | |
| | | String sql = "set nocount on ; \n" + |
| | | "select " + |
| | | fileds + " from t482112 a " + where + |
| | | " order by a.start_time asc \n"; |
| | | List<T482112Entity> list = this.jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482112Entity.class)); |
| | | |
| | | list.stream().forEach(x -> { |
| | | if (StringUtils.isNotBlank(x.getAttachList())) { |
| | | FileStructEntity fileStructEntity = new FileStructEntity(); |
| | | fileStructEntity.setDbid(dbid); |
| | | fileStructEntity.setFormid(formid); |
| | | fileStructEntity.setFileStr(x.getAttachList()); |
| | | x.setFiles(Utils.getFileEntities(fileStructEntity)); |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public Response scheduleList(ScheduleRequestEntity request) { |
| | | String where = ""; |
| | | String where = " where 1=1 "; |
| | | if (request.getSearchTxt() == null) { |
| | | throw new ApplicationException("查询参数不能都为空"); |
| | | } else { |
| | | String refCode = request.getSearchTxt().get("refCode"); |
| | | if (refCode == null) { |
| | | throw new ApplicationException("refCode参数不能都为空"); |
| | | } |
| | | where = " where refCode=" + GridUtils.prossSqlParm(refCode); |
| | | if (refCode != null) { |
| | | where += " and refCode=" + GridUtils.prossSqlParm(refCode); |
| | | } |
| | | String completeFlag = request.getSearchTxt().get("completeFlag"); |
| | | if (completeFlag == null) { |
| | | where += " and isnull(completeFlag,0)=0"; |
| | | where += " and isnull(completeFlag,0)=0 "; |
| | | } else { |
| | | where += " and isnull(completeFlag,0)=" + completeFlag; |
| | | } |
| | | } |
| | | String fileds = "refType \n" + |
| | | ",id,refCode \n" + |
| | | ",id,refCode,refName \n" + |
| | | ",title \n" + |
| | | ",color \n" + |
| | | ",participant_id\n" + |
| | |
| | | } |
| | | } |
| | | /** |
| | | * 获取线索 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/get.do") |
| | | public @ResponseBody Object get(@RequestBody CluesRequestEntity cluesRequest, HttpServletRequest request){ |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | cluesRequest.setDbid(request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+""); |
| | | cluesRequest.setFormId(481101); |
| | | callBackMessage.setInfo(cluesServiceIfc.get(cluesRequest)); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | }catch (Exception e){ |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | }finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | /** |
| | | * 线索列表 |
| | | * @param request |
| | | * @return |
| | |
| | | void changeStatus(T481104Entity entity); |
| | | |
| | | void contactDel(Integer id); |
| | | |
| | | T481101Entity get(CluesRequestEntity cluesRequest); |
| | | } |
| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class CluesServiceImpl extends BaseService implements CluesServiceIfc{ |
| | | public class CluesServiceImpl extends BaseService implements CluesServiceIfc { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void save(T481101Entity t481101Entity) { |
| | | if(StringUtils.isBlank(t481101Entity.getCluesName())){ |
| | | throw new ApplicationException("线索名称不能为空"); |
| | | if (StringUtils.isBlank(t481101Entity.getCluesName())) { |
| | | throw new ApplicationException("线索名称不能为空"); |
| | | } |
| | | String sql=" declare " + |
| | | String sql = " declare " + |
| | | " @DocCode nvarchar(16),\n" + |
| | | " @FormID int,\n" + |
| | | " @DocDate datetime,\n" + |
| | |
| | | " @intention_level varchar(50),\n" + |
| | | " @annual_procurement money,\n" + |
| | | " @timezone varchar(10),\n" + |
| | | " @ad_keyword nvarchar(100),\n" + |
| | | " @ad_keyword nvarchar(300),\n" + |
| | | " @image_list varchar(100),\n" + |
| | | " @scale_id varchar(100),\n" + |
| | | " @seller varchar(50),\n" + |
| | |
| | | " @post_grade nvarchar(50),\n" + |
| | | " @growth_level int,\n" + |
| | | " @create_time datetime,\n" + |
| | | " @update_time datetime,\n"+ |
| | | " @last_inserted_id bigint\n"+//自增主键值 |
| | | " @update_time datetime,\n" + |
| | | " @last_inserted_id bigint\n" +//自增主键值 |
| | | " \ndeclare " + |
| | | " @media_type varchar(50),\n" + |
| | | " @media_refid bigint, \n" + |
| | | " @media_id bigint, \n" + |
| | | " @media_value varchar(150)\n"+ |
| | | " @media_value varchar(150)\n" + |
| | | " \ndeclare " + |
| | | " @areaCode varchar(50),\n" + |
| | | " @telList_refid bigint, \n" + |
| | | " @telList_id bigint, \n" + |
| | | " @telList_tel varchar(150)\n"+ |
| | | //---赋值 |
| | | " @telList_tel varchar(150)\n" + |
| | | //---赋值 |
| | | " select " + |
| | | "@FormID=481101 , \n" + |
| | | "@DocDate=convert(datetime,convert(varchar(10),GETDATE(),120) ) , \n" + |
| | | "@DocCode="+ GridUtils.prossSqlParm(t481101Entity.getDocCode()) +", \n" + |
| | | "@companyid="+ GridUtils.prossSqlParm(t481101Entity.getCompanyid()) +", \n" + |
| | | "@companyname= "+ GridUtils.prossSqlParm(t481101Entity.getCompanyname()) +", \n" + |
| | | "@DocCode=" + GridUtils.prossSqlParm(t481101Entity.getDocCode()) + ", \n" + |
| | | "@companyid=" + GridUtils.prossSqlParm(t481101Entity.getCompanyid()) + ", \n" + |
| | | "@companyname= " + GridUtils.prossSqlParm(t481101Entity.getCompanyname()) + ", \n" + |
| | | "@periodid= dbo.GetPeriodID(@FormID,@CompanyID,getdate()), \n" + |
| | | "@EnterCode="+ GridUtils.prossSqlParm(t481101Entity.getCreateUsercode()) +", \n" + |
| | | "@EnterName="+ GridUtils.prossSqlParm(t481101Entity.getCreateUserName()) +" , \n" + |
| | | "@EnterCode=" + GridUtils.prossSqlParm(t481101Entity.getCreateUsercode()) + ", \n" + |
| | | "@EnterName=" + GridUtils.prossSqlParm(t481101Entity.getCreateUserName()) + " , \n" + |
| | | "@EnterDate=getdate() , \n" + |
| | | "@ModifyName ="+ GridUtils.prossSqlParm(t481101Entity.getCreateUserName()) +", \n" + |
| | | "@ModifyName =" + GridUtils.prossSqlParm(t481101Entity.getCreateUserName()) + ", \n" + |
| | | "@ModifyDate =getdate() , \n" + |
| | | "@PostName ="+ GridUtils.prossSqlParm(t481101Entity.getCreateUserName()) +", \n" + |
| | | "@PostName =" + GridUtils.prossSqlParm(t481101Entity.getCreateUserName()) + ", \n" + |
| | | "@PostDate=getdate() , \n" + |
| | | "@CreateUsercode="+ GridUtils.prossSqlParm(t481101Entity.getCreateUsercode()) +", \n" + |
| | | "@CreateUserName="+ GridUtils.prossSqlParm(t481101Entity.getCreateUserName()) +" , \n" + |
| | | "@isRead ="+t481101Entity.getIsRead()+", \n" +//TODO 自己新建,isRead=1,其他人 |
| | | "@CreateUsercode=" + GridUtils.prossSqlParm(t481101Entity.getCreateUsercode()) + ", \n" + |
| | | "@CreateUserName=" + GridUtils.prossSqlParm(t481101Entity.getCreateUserName()) + " , \n" + |
| | | "@isRead =" + t481101Entity.getIsRead() + ", \n" +//TODO 自己新建,isRead=1,其他人 |
| | | "@Email=null, \n" + |
| | | "@Country ="+ GridUtils.prossSqlParm(t481101Entity.getCountry()) +", \n" + |
| | | "@province ="+ GridUtils.prossSqlParm(t481101Entity.getProvince()) +", \n" + |
| | | "@city ="+ GridUtils.prossSqlParm(t481101Entity.getCity()) +", \n" + |
| | | "@Address ="+ GridUtils.prossSqlParm(t481101Entity.getAddress()) +", \n" + |
| | | "@PostCode ="+ GridUtils.prossSqlParm(t481101Entity.getCreateUsercode()) +", \n" + |
| | | "@HDMemo ="+ GridUtils.prossSqlParm(t481101Entity.getHdMemo()) +", \n" + |
| | | "@clues_name= "+ GridUtils.prossSqlParm(t481101Entity.getCluesName()) +", \n" + |
| | | "@last_edit_user="+ GridUtils.prossSqlParm(t481101Entity.getCreateUsercode()) +", \n" + |
| | | "@Country =" + GridUtils.prossSqlParm(t481101Entity.getCountry()) + ", \n" + |
| | | "@province =" + GridUtils.prossSqlParm(t481101Entity.getProvince()) + ", \n" + |
| | | "@city =" + GridUtils.prossSqlParm(t481101Entity.getCity()) + ", \n" + |
| | | "@Address =" + GridUtils.prossSqlParm(t481101Entity.getAddress()) + ", \n" + |
| | | "@PostCode =" + GridUtils.prossSqlParm(t481101Entity.getCreateUsercode()) + ", \n" + |
| | | "@HDMemo =" + GridUtils.prossSqlParm(t481101Entity.getHdMemo()) + ", \n" + |
| | | "@clues_name= " + GridUtils.prossSqlParm(t481101Entity.getCluesName()) + ", \n" + |
| | | "@last_edit_user=" + GridUtils.prossSqlParm(t481101Entity.getCreateUsercode()) + ", \n" + |
| | | "@edit_time=getdate(), \n" + |
| | | "@public_time =getdate(), \n" + |
| | | "@tagList= "+ GridUtils.prossSqlParm(t481101Entity.getTagList()) +", \n" + |
| | | "@homepage="+ GridUtils.prossSqlParm(t481101Entity.getHomepage()) +", \n" + |
| | | "@origin_list= "+ GridUtils.prossSqlParm(t481101Entity.getOriginList()) +", \n" + |
| | | "@short_name="+ GridUtils.prossSqlParm(t481101Entity.getShortName()) +", \n" + |
| | | "@corporate_name="+ GridUtils.prossSqlParm(t481101Entity.getCorporateName()) +", \n" + |
| | | "@biz_type="+ GridUtils.prossSqlParm(t481101Entity.getBizType()) +", \n" + |
| | | "@tel_area_code="+ GridUtils.prossSqlParm(t481101Entity.getTelAreaCode()) +", \n" + |
| | | "@tel="+ GridUtils.prossSqlParm(t481101Entity.getTel()) +", \n" + |
| | | "@intention_level="+ GridUtils.prossSqlParm(t481101Entity.getIntentionLevel()) +", \n" + |
| | | "@annual_procurement="+ t481101Entity.getAnnualProcurement()+", \n" + |
| | | "@timezone="+ GridUtils.prossSqlParm(t481101Entity.getTimezone()) +", \n" + |
| | | "@ad_keyword ="+ GridUtils.prossSqlParm(t481101Entity.getAdKeyword()) +", \n" + |
| | | "@image_list ="+ GridUtils.prossSqlParm(t481101Entity.getImageList()) +", \n" + |
| | | "@scale_id="+ GridUtils.prossSqlParm(t481101Entity.getScaleId()) +", \n" + |
| | | "@seller ="+ GridUtils.prossSqlParm(t481101Entity.getSeller()) +", \n" + |
| | | "@inquiry_origin="+ GridUtils.prossSqlParm(t481101Entity.getInquiryOrigin()) +", \n" + |
| | | "@category_ids ="+ GridUtils.prossSqlParm(t481101Entity.getCategoryIds()) +", \n" + |
| | | "@inquiry_country="+ GridUtils.prossSqlParm(t481101Entity.getInquiryCountry()) +", \n" + |
| | | "@pin_flag="+t481101Entity.getPinFlag()+" \n" + |
| | | "@tagList= " + GridUtils.prossSqlParm(t481101Entity.getTagList()) + ", \n" + |
| | | "@homepage=" + GridUtils.prossSqlParm(t481101Entity.getHomepage()) + ", \n" + |
| | | "@origin_list= " + GridUtils.prossSqlParm(t481101Entity.getOriginList()) + ", \n" + |
| | | "@short_name=" + GridUtils.prossSqlParm(t481101Entity.getShortName()) + ", \n" + |
| | | "@corporate_name=" + GridUtils.prossSqlParm(t481101Entity.getCorporateName()) + ", \n" + |
| | | "@biz_type=" + GridUtils.prossSqlParm(t481101Entity.getBizType()) + ", \n" + |
| | | "@tel_area_code=" + GridUtils.prossSqlParm(t481101Entity.getTelAreaCode()) + ", \n" + |
| | | "@tel=" + GridUtils.prossSqlParm(t481101Entity.getTel()) + ", \n" + |
| | | "@intention_level=" + GridUtils.prossSqlParm(t481101Entity.getIntentionLevel()) + ", \n" + |
| | | "@annual_procurement=" + t481101Entity.getAnnualProcurement() + ", \n" + |
| | | "@timezone=" + GridUtils.prossSqlParm(t481101Entity.getTimezone()) + ", \n" + |
| | | "@ad_keyword =" + GridUtils.prossSqlParm(t481101Entity.getAdKeyword()) + ", \n" + |
| | | "@image_list =" + GridUtils.prossSqlParm(t481101Entity.getImageList()) + ", \n" + |
| | | "@scale_id=" + GridUtils.prossSqlParm(t481101Entity.getScaleId()) + ", \n" + |
| | | "@seller =" + GridUtils.prossSqlParm(t481101Entity.getSeller()) + ", \n" + |
| | | "@inquiry_origin=" + GridUtils.prossSqlParm(t481101Entity.getInquiryOrigin()) + ", \n" + |
| | | "@category_ids =" + GridUtils.prossSqlParm(t481101Entity.getCategoryIds()) + ", \n" + |
| | | "@inquiry_country=" + GridUtils.prossSqlParm(t481101Entity.getInquiryCountry()) + ", \n" + |
| | | "@pin_flag=" + t481101Entity.getPinFlag() + " \n" + |
| | | " if isnull(@doccode,'')=''\n" +//新增 |
| | | "begin\n"+ |
| | | //新增则生成单号 |
| | | " exec sp_newdoccode @formid,@EnterCode,@doccode output \n" + |
| | | "begin\n" + |
| | | //新增则生成单号 |
| | | " exec sp_newdoccode @formid,@EnterCode,@doccode output \n" + |
| | | "insert into t481101H(" + |
| | | "FormID" + |
| | | ",DocDate" + |
| | |
| | | ",@pin_flag,'起草' " + |
| | | ")\n" + |
| | | //----处理联系人信息 |
| | | contactAddSql(t481101Entity.getContactsList()) + |
| | | contactAddSql(t481101Entity.getContactsList()) + |
| | | "end\n" + |
| | | "else \n" +//-------修改 |
| | | "begin\n" + |
| | |
| | | ",category_ids=@category_ids" + |
| | | ",inquiry_country=@inquiry_country,pin_flag=@pin_flag from t481101H where doccode=@doccode\n" + |
| | | //----处理联系人信息 |
| | | contactUpdateSql(t481101Entity.getContactsList()) + |
| | | contactUpdateSql(t481101Entity.getContactsList()) + |
| | | "end\n" + |
| | | //--处理审计功能 |
| | | auditAddSql(t481101Entity); |
| | |
| | | } |
| | | |
| | | private String auditAddSql(T481101Entity t481101Entity) { |
| | | List<AuditEntity> list=t481101Entity.getAuditRecords(); |
| | | if(list==null||list.size()==0){ return "";} |
| | | String sql=" declare @now datetime=getdate()\n" ;//方便同一时间提交到时输出成一条 |
| | | for(AuditEntity audit:list){ |
| | | sql+=" insert into _sysAudit([formid],[newvalue],[headflag],[auditType],[fieldname],[mainFormid],[usercode],[oldvalue],[fieldid],[username],[doccode],[auditIndex],[auditDateTime],[auditDate])values("+t481101Entity.getFormId()+","+GridUtils.prossSqlParm(audit.getNewValue())+",0,"+GridUtils.prossSqlParm(audit.getAuditType())+","+GridUtils.prossSqlParm(audit.getFieldName())+","+t481101Entity.getFormId()+","+GridUtils.prossSqlParm(t481101Entity.getCreateUsercode())+","+GridUtils.prossSqlParm(audit.getOldValue())+","+GridUtils.prossSqlParm(audit.getFieldId())+","+GridUtils.prossSqlParm(t481101Entity.getCreateUserName())+",@docCode,null,@now,convert(varchar(10),@now,120))\n"; |
| | | List<AuditEntity> list = t481101Entity.getAuditRecords(); |
| | | if (list == null || list.size() == 0) { |
| | | return ""; |
| | | } |
| | | String sql = " declare @now datetime=getdate()\n";//方便同一时间提交到时输出成一条 |
| | | for (AuditEntity audit : list) { |
| | | sql += " insert into _sysAudit([formid],[newvalue],[headflag],[auditType],[fieldname],[mainFormid],[usercode],[oldvalue],[fieldid],[username],[doccode],[auditIndex],[auditDateTime],[auditDate])values(" + t481101Entity.getFormId() + "," + GridUtils.prossSqlParm(audit.getNewValue()) + ",0," + GridUtils.prossSqlParm(audit.getAuditType()) + "," + GridUtils.prossSqlParm(audit.getFieldName()) + "," + t481101Entity.getFormId() + "," + GridUtils.prossSqlParm(t481101Entity.getCreateUsercode()) + "," + GridUtils.prossSqlParm(audit.getOldValue()) + "," + GridUtils.prossSqlParm(audit.getFieldId()) + "," + GridUtils.prossSqlParm(t481101Entity.getCreateUserName()) + ",@docCode,null,@now,convert(varchar(10),@now,120))\n"; |
| | | } |
| | | return sql; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public Response getAllClues(CluesRequestEntity request) { |
| | | String fileds="" + |
| | | String fileds = "" + |
| | | "a.DocCode \n" + |
| | | ",a.FormID \n" + |
| | | ",a.DocStatus \n" + |
| | |
| | | ",b.systemFlag " + |
| | | ",b.cluesStatusFlag " + |
| | | ",@TotalRowCount as totalRowCount ,@pageCount as pageCount \n"; |
| | | String where=" 1=1 "; |
| | | if(request.getSearchTxt()!=null&&request.getSearchTxt().size()>0) { |
| | | String where = " 1=1 "; |
| | | if (request.getSearchTxt() != null && request.getSearchTxt().size() > 0) { |
| | | //拼接查询条件 |
| | | where+= getSearchInfo(request); |
| | | where += getSearchInfo(request); |
| | | } |
| | | String sql="set nocount on ; \n" + |
| | | String sql = "set nocount on ; \n" + |
| | | // " declare @key varchar(300) \n" + |
| | | // " select @key ="+1+" \n" + |
| | | " declare @Limit int , @Page int ,@StartRowNo int ,@EndRowNo int ; \n" + |
| | | " select @Limit = "+request.getPageSize()+" , @Page = "+request.getPageNo()+" ; \n" + |
| | | " select @Limit = " + request.getPageSize() + " , @Page = " + request.getPageNo() + " ; \n" + |
| | | " declare @TotalRowCount int ,@pageCount int; \n" + |
| | | " select @StartRowNo = (isnull(@Page,0) - 1) * isnull(@Limit,0) + 1 ; \n" + |
| | | " select @EndRowNo = isnull(@Page,0) * isnull(@Limit,0) ; \n" + |
| | | " select @TotalRowCount =count(1),@pageCount=CEILING((COUNT(1)+0.0)/" + request.getPageSize() + ") from t481101h a left join t481104h b on a.docCode=b.refCode where "+where+" \n" + |
| | | " select @TotalRowCount =count(1),@pageCount=CEILING((COUNT(1)+0.0)/" + request.getPageSize() + ") from t481101h a left join t481104h b on a.docCode=b.refCode where " + where + " \n" + |
| | | " SELECT * FROM ( \n" + |
| | | " select top 100 percent ROW_NUMBER() OVER (ORDER BY docCode) AS NO,\n" + |
| | | fileds+" from t481101h a left join t481104h b on a.docCode=b.refCode\n" + |
| | | " where " +where+ |
| | | fileds + " from t481101h a left join t481104h b on a.docCode=b.refCode\n" + |
| | | " where " + where + |
| | | " order by a.docCode asc \n" + |
| | | " ) t WHERE t.NO BETWEEN @StartRowNo AND @EndRowNo"; |
| | | List<T481104Entity> list = this.jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T481104Entity.class)); |
| | | //增加联系人输出 |
| | | if(list!=null&&list.size()>0){ |
| | | list.stream().forEach(x->{ |
| | | if (list != null && list.size() > 0) { |
| | | list.stream().forEach(x -> { |
| | | List<T482103Entity> query = this.jdbcTemplate.query("select main_customer_flag\n" + |
| | | ",refCode,id \n" + |
| | | ",name \n" + |
| | |
| | | ",create_time \n" + |
| | | ",update_time \n" + |
| | | ",DocVersion \n from t482103 where refCode=" + GridUtils.prossSqlParm(x.getDocCode()), new BeanPropertyRowMapper<>(T482103Entity.class)); |
| | | if(query!=null&&query.size()>0){ |
| | | query.stream().forEach(y->{ |
| | | if (query != null && query.size() > 0) { |
| | | query.stream().forEach(y -> { |
| | | //--社交平台 |
| | | List<T482111Entity> mediaList = this.jdbcTemplate.query("select \n" + |
| | | "refId,id \n" + |
| | | ",value \n" + |
| | | ",type from t482111 where refId=" +y.getId(), new BeanPropertyRowMapper<>(T482111Entity.class)); |
| | | ",type from t482111 where refId=" + y.getId(), new BeanPropertyRowMapper<>(T482111Entity.class)); |
| | | y.setMediaList(mediaList); |
| | | //电话列表 |
| | | List<T482116Entity> telList = this.jdbcTemplate.query("select " + |
| | |
| | | x.setContactsList(query); |
| | | //附件的输出 |
| | | //处理图片,附件,生成调用url及相关信息 |
| | | if(StringUtils.isNotBlank(x.getImageList())) { |
| | | if (StringUtils.isNotBlank(x.getImageList())) { |
| | | FileStructEntity fileStructEntity = new FileStructEntity(); |
| | | fileStructEntity.setDbid(request.getDbid()); |
| | | fileStructEntity.setFormid(request.getFormId() + ""); |
| | |
| | | } |
| | | }); |
| | | } |
| | | Response response=new Response(); |
| | | response.setTotalCount((list!=null&&list.size()>0)?list.get(0).getTotalRowCount():0); |
| | | response.setPageCount((list!=null&&list.size()>0)?list.get(0).getPageCount():0); |
| | | Response response = new Response(); |
| | | response.setTotalCount((list != null && list.size() > 0) ? list.get(0).getTotalRowCount() : 0); |
| | | response.setPageCount((list != null && list.size() > 0) ? list.get(0).getPageCount() : 0); |
| | | response.setData(list); |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public T481101Entity get(CluesRequestEntity request) { |
| | | String fileds = "" + |
| | | "a.DocCode \n" + |
| | | ",a.FormID \n" + |
| | | ",a.DocStatus \n" + |
| | | ",a.DocStatusName \n" + |
| | | ",a.companyid \n" + |
| | | ",a.companyname \n" + |
| | | ",a.EnterCode \n" + |
| | | ",a.EnterName \n" + |
| | | ",a.EnterDate \n" + |
| | | ",a.ModifyName \n" + |
| | | ",a.ModifyDate \n" + |
| | | ",a.PostName \n" + |
| | | ",a.PostDate \n" + |
| | | ",a.CreateUsercode \n" + |
| | | ",a.CreateUserName \n" + |
| | | ",a.Country \n" + |
| | | ",a.HDMemo \n" + |
| | | ",a.clues_name \n" + |
| | | ",a.archive_time \n" + |
| | | ",a.order_time \n" + |
| | | ",a.lost_day_count \n" + |
| | | ",a.transfer_count \n" + |
| | | ",a.release_count \n" + |
| | | ",a.is_archive \n" + |
| | | ",a.archive_type \n" + |
| | | ",a.status_id \n" + |
| | | ",a.status \n" + |
| | | ",a.follow_up_time \n" + |
| | | ",a.fail_type \n" + |
| | | ",a.fail_status \n" + |
| | | ",a.fail_status_name \n" + |
| | | ",a.fail_reason \n" + |
| | | ",a.read_flag \n" + |
| | | ",a.last_edit_user \n" + |
| | | ",a.edit_time \n" + |
| | | ",a.private_time \n" + |
| | | ",a.public_time \n" + |
| | | ",a.is_public \n" + |
| | | ",a.store_id \n" + |
| | | ",a.star \n" + |
| | | ",a.transform_task_status \n" + |
| | | ",a.next_follow_up_time \n" + |
| | | ",a.duplicate_flag \n" + |
| | | ",a.tagList \n" + |
| | | ",a.homepage \n" + |
| | | ",a.address \n" + |
| | | ",a.origin_list \n" + |
| | | ",a.short_name \n" + |
| | | ",a.corporate_name \n" + |
| | | ",a.biz_type \n" + |
| | | ",a.tel_area_code \n" + |
| | | ",a.tel \n" + |
| | | ",a.intention_level \n" + |
| | | ",a.annual_procurement \n" + |
| | | ",a.timezone \n" + |
| | | ",a.ad_keyword \n" + |
| | | ",a.image_list \n" + |
| | | ",a.scale_id \n" + |
| | | ",a.seller \n" + |
| | | ",a.inquiry_origin \n" + |
| | | ",a.category_ids \n" + |
| | | ",a.inquiry_country \n" + |
| | | ",b.id \n" + |
| | | ",b.refCode \n" + |
| | | ",b.ownerCode \n" + |
| | | ",b.ownerName \n" + |
| | | ",b.enterTime \n" + |
| | | ",b.exitTime \n" + |
| | | ",b.isRead as hasRead \n" + |
| | | ",b.reasonForRollback \n" + |
| | | ",b.costs \n" + |
| | | ",b.pinFlag as hasPinFlag \n" + |
| | | ",b.firstFllowUpTime \n" + |
| | | ",b.lastModifyTime \n" + |
| | | ",b.daysNotContacted " + |
| | | ",b.systemFlag " + |
| | | ",b.cluesStatusFlag "; |
| | | String where = " b.refCode= " + GridUtils.prossSqlParm(request.getDocCode()); |
| | | |
| | | String sql = "set nocount on ; \n" + |
| | | " select \n" + |
| | | fileds + " from t481101h a left join t481104h b on a.docCode=b.refCode\n" + |
| | | " where " + where; |
| | | T481104Entity entity = this.jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(T481104Entity.class)); |
| | | //增加联系人输出 |
| | | if (entity != null) { |
| | | List<T482103Entity> query = this.jdbcTemplate.query("select main_customer_flag\n" + |
| | | ",refCode,id \n" + |
| | | ",name \n" + |
| | | ",email \n" + |
| | | ",gender \n" + |
| | | ",post \n" + |
| | | ",remark \n" + |
| | | ",image_list \n" + |
| | | ",birth \n" + |
| | | ",post_grade \n" + |
| | | ",growth_level \n" + |
| | | ",create_time \n" + |
| | | ",update_time \n" + |
| | | ",DocVersion \n from t482103 where refCode=" + GridUtils.prossSqlParm(entity.getDocCode()), new BeanPropertyRowMapper<>(T482103Entity.class)); |
| | | if (query != null && query.size() > 0) { |
| | | query.stream().forEach(y -> { |
| | | //--社交平台 |
| | | List<T482111Entity> mediaList = this.jdbcTemplate.query("select \n" + |
| | | "refId,id \n" + |
| | | ",value \n" + |
| | | ",type from t482111 where refId=" + y.getId(), new BeanPropertyRowMapper<>(T482111Entity.class)); |
| | | y.setMediaList(mediaList); |
| | | //电话列表 |
| | | List<T482116Entity> telList = this.jdbcTemplate.query("select " + |
| | | "refId,id,areaCode,tel from t482116 where refId=" + y.getId(), new BeanPropertyRowMapper<>(T482116Entity.class)); |
| | | y.setTelList(telList); |
| | | }); |
| | | } |
| | | entity.setContactsList(query); |
| | | //附件的输出 |
| | | //处理图片,附件,生成调用url及相关信息 |
| | | if (StringUtils.isNotBlank(entity.getImageList())) { |
| | | FileStructEntity fileStructEntity = new FileStructEntity(); |
| | | fileStructEntity.setDbid(request.getDbid()); |
| | | fileStructEntity.setFormid(request.getFormId() + ""); |
| | | fileStructEntity.setFileStr(entity.getImageList()); |
| | | entity.setFiles(Utils.getFileEntities(fileStructEntity)); |
| | | } |
| | | } |
| | | return entity; |
| | | } |
| | | |
| | | @Override |
| | | public void attention(CluesRequestEntity cluesRequest) { |
| | | String sql="update a set a.pinFlag="+cluesRequest.getPinFlag()+" from t481104h a where id="+cluesRequest.getId(); |
| | | String sql = "update a set a.pinFlag=" + cluesRequest.getPinFlag() + " from t481104h a where id=" + cluesRequest.getId(); |
| | | this.doBaseExecute(sql); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void assign(AssignCluesEntity assignClues) { |
| | | String sql=" declare @refCode varchar(20),@ownerCode varchar(20),@ownerName varchar(20)\n" + |
| | | "select @refCode=" +GridUtils.prossSqlParm(assignClues.getDocCode())+",@ownerCode=" +GridUtils.prossSqlParm(assignClues.getOwnerCode())+",@ownerName=" +GridUtils.prossSqlParm(assignClues.getOwnerName())+"\n"+ |
| | | String sql = " declare @refCode varchar(20),@ownerCode varchar(20),@ownerName varchar(20)\n" + |
| | | "select @refCode=" + GridUtils.prossSqlParm(assignClues.getDocCode()) + ",@ownerCode=" + GridUtils.prossSqlParm(assignClues.getOwnerCode()) + ",@ownerName=" + GridUtils.prossSqlParm(assignClues.getOwnerName()) + "\n" + |
| | | " insert into t481104h(refCode \n" + |
| | | ",ownerCode \n" + |
| | | ",ownerName \n" + |
| | |
| | | |
| | | @Override |
| | | public void changeStatus(T481104Entity entity) { |
| | | String sql=" update a set a.cluesStatusFlag="+entity.getCluesStatusFlag()+" from t481104h a where id= "+entity.getId(); |
| | | String sql = " update a set a.cluesStatusFlag=" + entity.getCluesStatusFlag() + " from t481104h a where id= " + entity.getId(); |
| | | this.doBaseExecute(sql); |
| | | } |
| | | |
| | | /** |
| | | * 拼接查询条件 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | private String getSearchInfo(CluesRequestEntity request) { |
| | | String where=" and(1=1 "; |
| | | String where = " and(1=1 "; |
| | | Set<Map.Entry<String, String>> entries = request.getSearchTxt().entrySet(); |
| | | for (Map.Entry<String, String> entry : entries) { |
| | | if(entry.getKey().equalsIgnoreCase("cluesName")){ |
| | | where+=" and a.clues_name like '%"+entry.getValue()+"%'"; |
| | | if (entry.getKey().equalsIgnoreCase("cluesName")) { |
| | | where += " and a.clues_name like '%" + entry.getValue() + "%'"; |
| | | } |
| | | if(entry.getKey().equalsIgnoreCase("isRead")){ |
| | | where+=" and isnull(b.isRead,0)="+entry.getValue(); |
| | | if (entry.getKey().equalsIgnoreCase("isRead")) { |
| | | where += " and isnull(b.isRead,0)=" + entry.getValue(); |
| | | } |
| | | if(entry.getKey().equalsIgnoreCase("pinFlag")){ |
| | | where+=" and isnull(b.pinFlag,0)="+entry.getValue(); |
| | | if (entry.getKey().equalsIgnoreCase("pinFlag")) { |
| | | where += " and isnull(b.pinFlag,0)=" + entry.getValue(); |
| | | } |
| | | if(entry.getKey().equalsIgnoreCase("ownerCode")){ |
| | | where+=" and b.ownerCode like '%"+entry.getValue()+"%'"; |
| | | if (entry.getKey().equalsIgnoreCase("ownerCode")) { |
| | | where += " and b.ownerCode like '%" + entry.getValue() + "%'"; |
| | | } |
| | | if(entry.getKey().equalsIgnoreCase("systemFlag")){ |
| | | where+=" and isnull(b.systemFlag,0) = "+entry.getValue()+""; |
| | | if (entry.getKey().equalsIgnoreCase("systemFlag")) { |
| | | where += " and isnull(b.systemFlag,0) = " + entry.getValue() + ""; |
| | | } |
| | | if(entry.getKey().equalsIgnoreCase("cluesStatusFlag")){ |
| | | where+=" and isnull(b.cluesStatusFlag,0) = "+entry.getValue()+""; |
| | | if (entry.getKey().equalsIgnoreCase("cluesStatusFlag")) { |
| | | where += " and isnull(b.cluesStatusFlag,0) = " + entry.getValue() + ""; |
| | | } |
| | | if(entry.getKey().equalsIgnoreCase("tagList")){ |
| | | where+=" and a.tag_List like '%"+entry.getValue()+"%'"; |
| | | if (entry.getKey().equalsIgnoreCase("tagList")) { |
| | | where += " and a.tag_List like '%" + entry.getValue() + "%'"; |
| | | } |
| | | if(entry.getKey().equalsIgnoreCase("failStatus")){ |
| | | where+=" and isnull(a.failStatus,0) = "+entry.getValue()+""; |
| | | if (entry.getKey().equalsIgnoreCase("failStatus")) { |
| | | where += " and isnull(a.failStatus,0) = " + entry.getValue() + ""; |
| | | } |
| | | if(entry.getKey().equalsIgnoreCase("cluesStatusFlag")){ |
| | | where+=" and isnull(b.cluesStatusFlag,0) = "+entry.getValue()+""; |
| | | if (entry.getKey().equalsIgnoreCase("cluesStatusFlag")) { |
| | | where += " and isnull(b.cluesStatusFlag,0) = " + entry.getValue() + ""; |
| | | } |
| | | if(entry.getKey().equalsIgnoreCase("originList")){ |
| | | where+=" and a.originList like '%"+entry.getValue()+"%'"; |
| | | if (entry.getKey().equalsIgnoreCase("originList")) { |
| | | where += " and a.originList like '%" + entry.getValue() + "%'"; |
| | | } |
| | | if(entry.getKey().equalsIgnoreCase("createUsercode")){ |
| | | where+=" and a.createUsercode like '%"+entry.getValue()+"%'"; |
| | | if (entry.getKey().equalsIgnoreCase("createUsercode")) { |
| | | where += " and a.createUsercode like '%" + entry.getValue() + "%'"; |
| | | } |
| | | if(entry.getKey().equalsIgnoreCase("country")){ |
| | | where+=" and a.country = '"+entry.getValue()+"'"; |
| | | if (entry.getKey().equalsIgnoreCase("country")) { |
| | | where += " and a.country = '" + entry.getValue() + "'"; |
| | | } |
| | | if(entry.getKey().equalsIgnoreCase("lastModifyTime")){ |
| | | String[] value=entry.getValue().split(";"); |
| | | if (entry.getKey().equalsIgnoreCase("lastModifyTime")) { |
| | | String[] value = entry.getValue().split(";"); |
| | | |
| | | where+=" and (b.lastModifyTime >= DATEADD(day, -"+value[0]+", CAST(GETDATE() AS date)) )";//TODO 后期增加处理联系,未联系功能 |
| | | where += " and (b.lastModifyTime >= DATEADD(day, -" + value[0] + ", CAST(GETDATE() AS date)) )";//TODO 后期增加处理联系,未联系功能 |
| | | } |
| | | } |
| | | return where+" )"; |
| | | return where + " )"; |
| | | } |
| | | |
| | | private String contactUpdateSql(List<T482103Entity> contactsList) { |
| | | if(contactsList==null||contactsList.size()==0){ return "";} |
| | | String sql=""; |
| | | for(T482103Entity contact:contactsList){ |
| | | if(StringUtils.isNotBlank(contact.getRefCode())&&contact.getId()==null){ |
| | | List<T482103Entity> temp=new ArrayList<T482103Entity>(); |
| | | if (contactsList == null || contactsList.size() == 0) { |
| | | return ""; |
| | | } |
| | | String sql = ""; |
| | | for (T482103Entity contact : contactsList) { |
| | | if (StringUtils.isNotBlank(contact.getRefCode()) && contact.getId() == null) { |
| | | List<T482103Entity> temp = new ArrayList<T482103Entity>(); |
| | | temp.add(contact); |
| | | sql+= contactAddSql(temp); |
| | | sql += contactAddSql(temp); |
| | | continue; |
| | | } |
| | | sql+="\nselect\n" + |
| | | " @main_customer_flag="+contact.getMainCustomerFlag()+"\n" + |
| | | ",@id="+contact.getId()+"\n" + |
| | | ",@name="+GridUtils.prossSqlParm(contact.getName())+"\n" + |
| | | ",@contact_email="+GridUtils.prossSqlParm(contact.getEmail())+"\n" + |
| | | ",@gender="+GridUtils.prossSqlParm(contact.getGender())+"\n" + |
| | | ",@post="+GridUtils.prossSqlParm(contact.getPost())+"\n" + |
| | | ",@remark="+GridUtils.prossSqlParm(contact.getRemark())+"\n" + |
| | | ",@contact_image_list ="+GridUtils.prossSqlParm(contact.getImageList())+"\n" + |
| | | ",@birth="+GridUtils.prossSqlParm(contact.getBirth())+"\n" + |
| | | ",@post_grade="+GridUtils.prossSqlParm(contact.getPostGrade())+"\n" + |
| | | sql += "\nselect\n" + |
| | | " @main_customer_flag=" + contact.getMainCustomerFlag() + "\n" + |
| | | ",@id=" + contact.getId() + "\n" + |
| | | ",@name=" + GridUtils.prossSqlParm(contact.getName()) + "\n" + |
| | | ",@contact_email=" + GridUtils.prossSqlParm(contact.getEmail()) + "\n" + |
| | | ",@gender=" + GridUtils.prossSqlParm(contact.getGender()) + "\n" + |
| | | ",@post=" + GridUtils.prossSqlParm(contact.getPost()) + "\n" + |
| | | ",@remark=" + GridUtils.prossSqlParm(contact.getRemark()) + "\n" + |
| | | ",@contact_image_list =" + GridUtils.prossSqlParm(contact.getImageList()) + "\n" + |
| | | ",@birth=" + GridUtils.prossSqlParm(contact.getBirth()) + "\n" + |
| | | ",@post_grade=" + GridUtils.prossSqlParm(contact.getPostGrade()) + "\n" + |
| | | ",@update_time=getdate()\n " + |
| | | " update t482103 set\n" + |
| | | "main_customer_flag=@main_customer_flag \n" + |
| | |
| | | ",post_grade=@post_grade \n" + |
| | | ",update_time=@update_time from t482103 where id=@id \n " + |
| | | " select @last_inserted_id=@id\n" + |
| | | mediaUpdateSql(contact.getMediaList())+ |
| | | mediaUpdateSql(contact.getMediaList()) + |
| | | telListUpdateSql(contact.getTelList()); |
| | | |
| | | } |
| | | return sql; |
| | | } |
| | | @Transactional(rollbackFor = Exception.class) |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void contactDel(Integer id) { |
| | | String sql="declare @id int="+id+",@mainCustomerFlag int \n" + |
| | | String sql = "declare @id int=" + id + ",@mainCustomerFlag int \n" + |
| | | " select @mainCustomerFlag=isnull(main_Customer_Flag,0) from t482103 where id=@id\n" + |
| | | " if isnull(@mainCustomerFlag,0)=1 \n" + |
| | | " begin \n" + |
| | |
| | | |
| | | /** |
| | | * 生成联系人信息sql |
| | | * |
| | | * @param contactsList |
| | | * @return |
| | | */ |
| | | private String contactAddSql(List<T482103Entity> contactsList) { |
| | | if(contactsList==null||contactsList.size()==0){ return "";} |
| | | String sql="" ; |
| | | for(T482103Entity contact:contactsList){ |
| | | sql+="\nselect\n" + |
| | | " @main_customer_flag="+contact.getMainCustomerFlag()+"\n" + |
| | | ",@refCode=@doccode\n" + |
| | | ",@name="+GridUtils.prossSqlParm(contact.getName())+"\n" + |
| | | ",@contact_email="+GridUtils.prossSqlParm(contact.getEmail())+"\n" + |
| | | ",@gender="+GridUtils.prossSqlParm(contact.getGender())+"\n" + |
| | | ",@post="+GridUtils.prossSqlParm(contact.getPost())+"\n" + |
| | | ",@remark="+GridUtils.prossSqlParm(contact.getRemark())+"\n" + |
| | | ",@contact_image_list ="+GridUtils.prossSqlParm(contact.getImageList())+"\n" + |
| | | ",@birth="+GridUtils.prossSqlParm(contact.getBirth())+"\n" + |
| | | ",@post_grade="+GridUtils.prossSqlParm(contact.getPostGrade())+"\n" + |
| | | ",@create_time =getdate() \n" + |
| | | ",@update_time=getdate()\n " + |
| | | " insert into t482103(" + |
| | | "main_customer_flag \n" + |
| | | ",refCode \n" + |
| | | ",name \n" + |
| | | ",email \n" + |
| | | ",gender \n" + |
| | | ",post \n" + |
| | | ",remark \n" + |
| | | ",image_list \n" + |
| | | ",birth \n" + |
| | | ",post_grade \n" + |
| | | ",create_time \n" + |
| | | ",update_time " + |
| | | ")values(" + |
| | | "@main_customer_flag \n" + |
| | | ",@refCode \n" + |
| | | ",@name \n" + |
| | | ",@contact_email \n" + |
| | | ",@gender \n" + |
| | | ",@post \n" + |
| | | ",@remark \n" + |
| | | ",@contact_image_list \n" + |
| | | ",@birth \n" + |
| | | ",@post_grade \n" + |
| | | ",@create_time \n" + |
| | | ",@update_time " + |
| | | ")\n" + |
| | | " SELECT @last_inserted_id=IDENT_CURRENT('t482103')\n"+ |
| | | mediaAddSql(contact.getMediaList())+ |
| | | telListAddSql(contact.getTelList()); |
| | | if (contactsList == null || contactsList.size() == 0) { |
| | | return ""; |
| | | } |
| | | String sql = ""; |
| | | for (T482103Entity contact : contactsList) { |
| | | sql += "\nselect\n" + |
| | | " @main_customer_flag=" + contact.getMainCustomerFlag() + "\n" + |
| | | ",@refCode=@doccode\n" + |
| | | ",@name=" + GridUtils.prossSqlParm(contact.getName()) + "\n" + |
| | | ",@contact_email=" + GridUtils.prossSqlParm(contact.getEmail()) + "\n" + |
| | | ",@gender=" + GridUtils.prossSqlParm(contact.getGender()) + "\n" + |
| | | ",@post=" + GridUtils.prossSqlParm(contact.getPost()) + "\n" + |
| | | ",@remark=" + GridUtils.prossSqlParm(contact.getRemark()) + "\n" + |
| | | ",@contact_image_list =" + GridUtils.prossSqlParm(contact.getImageList()) + "\n" + |
| | | ",@birth=" + GridUtils.prossSqlParm(contact.getBirth()) + "\n" + |
| | | ",@post_grade=" + GridUtils.prossSqlParm(contact.getPostGrade()) + "\n" + |
| | | ",@create_time =getdate() \n" + |
| | | ",@update_time=getdate()\n " + |
| | | " insert into t482103(" + |
| | | "main_customer_flag \n" + |
| | | ",refCode \n" + |
| | | ",name \n" + |
| | | ",email \n" + |
| | | ",gender \n" + |
| | | ",post \n" + |
| | | ",remark \n" + |
| | | ",image_list \n" + |
| | | ",birth \n" + |
| | | ",post_grade \n" + |
| | | ",create_time \n" + |
| | | ",update_time " + |
| | | ")values(" + |
| | | "@main_customer_flag \n" + |
| | | ",@refCode \n" + |
| | | ",@name \n" + |
| | | ",@contact_email \n" + |
| | | ",@gender \n" + |
| | | ",@post \n" + |
| | | ",@remark \n" + |
| | | ",@contact_image_list \n" + |
| | | ",@birth \n" + |
| | | ",@post_grade \n" + |
| | | ",@create_time \n" + |
| | | ",@update_time " + |
| | | ")\n" + |
| | | " SELECT @last_inserted_id=IDENT_CURRENT('t482103')\n" + |
| | | mediaAddSql(contact.getMediaList()) + |
| | | telListAddSql(contact.getTelList()); |
| | | } |
| | | return sql; |
| | | } |
| | | |
| | | /** |
| | | * 生成社交平台信息sql |
| | | * |
| | | * @param mediaEntityList |
| | | * @return |
| | | */ |
| | | private String mediaAddSql(List<T482111Entity> mediaEntityList) { |
| | | if(mediaEntityList==null||mediaEntityList.size()==0){ return "";} |
| | | String sql=""; |
| | | for(T482111Entity contact:mediaEntityList){ |
| | | sql+="\nselect\n" + |
| | | " @media_type="+GridUtils.prossSqlParm(contact.getType())+"\n" + |
| | | ",@media_value="+GridUtils.prossSqlParm(contact.getValue())+"\n" + |
| | | ",@media_id="+contact.getId()+"\n" + |
| | | if (mediaEntityList == null || mediaEntityList.size() == 0) { |
| | | return ""; |
| | | } |
| | | String sql = ""; |
| | | for (T482111Entity contact : mediaEntityList) { |
| | | sql += "\nselect\n" + |
| | | " @media_type=" + GridUtils.prossSqlParm(contact.getType()) + "\n" + |
| | | ",@media_value=" + GridUtils.prossSqlParm(contact.getValue()) + "\n" + |
| | | ",@media_id=" + contact.getId() + "\n" + |
| | | ",@media_refid=@last_inserted_id\n" + |
| | | " insert into t482111(" + |
| | | "type \n" + |
| | |
| | | } |
| | | return sql; |
| | | } |
| | | |
| | | /** |
| | | * 修改社交平台信息sql |
| | | * |
| | | * @param mediaEntityList |
| | | * @return |
| | | */ |
| | | private String mediaUpdateSql(List<T482111Entity> mediaEntityList) { |
| | | if(mediaEntityList==null||mediaEntityList.size()==0){ return "";} |
| | | String sql=""; |
| | | //增加删除,保证最新 |
| | | String collectIds = mediaEntityList.stream().filter(x->x.getId()!=null&&x.getId()!=0).map(x -> x.getId()+"").collect(Collectors.joining(",")); |
| | | if(collectIds.equalsIgnoreCase("")){ |
| | | //没有修改,都是新增情况 |
| | | sql=" delete from t482111 \n"; |
| | | }else { |
| | | sql=" delete from t482111 where id not in("+collectIds+")\n"; |
| | | if (mediaEntityList == null || mediaEntityList.size() == 0) { |
| | | return ""; |
| | | } |
| | | for(T482111Entity mediaEntity:mediaEntityList){ |
| | | if(mediaEntity.getId()==null){ |
| | | List<T482111Entity> temp=new ArrayList<>(); |
| | | String sql = ""; |
| | | //增加删除,保证最新 |
| | | String collectIds = mediaEntityList.stream().filter(x -> x.getId() != null && x.getId() != 0).map(x -> x.getId() + "").collect(Collectors.joining(",")); |
| | | if (collectIds.equalsIgnoreCase("")) { |
| | | //没有修改,都是新增情况 |
| | | sql = " delete from t482111 \n"; |
| | | } else { |
| | | sql = " delete from t482111 where id not in(" + collectIds + ")\n"; |
| | | } |
| | | for (T482111Entity mediaEntity : mediaEntityList) { |
| | | if (mediaEntity.getId() == null) { |
| | | List<T482111Entity> temp = new ArrayList<>(); |
| | | temp.add(mediaEntity); |
| | | sql+=mediaAddSql(temp); |
| | | sql += mediaAddSql(temp); |
| | | continue; |
| | | } |
| | | sql+="\nselect\n" + |
| | | " @media_type="+GridUtils.prossSqlParm(mediaEntity.getType())+"\n" + |
| | | ",@media_value="+GridUtils.prossSqlParm(mediaEntity.getValue())+"\n" + |
| | | ",@media_id="+mediaEntity.getId()+"\n" + |
| | | sql += "\nselect\n" + |
| | | " @media_type=" + GridUtils.prossSqlParm(mediaEntity.getType()) + "\n" + |
| | | ",@media_value=" + GridUtils.prossSqlParm(mediaEntity.getValue()) + "\n" + |
| | | ",@media_id=" + mediaEntity.getId() + "\n" + |
| | | " update t482111 set " + |
| | | "type=@media_type \n" + |
| | | ",value=@media_value from t482111 where id=@media_id \n" ; |
| | | ",value=@media_value from t482111 where id=@media_id \n"; |
| | | } |
| | | |
| | | |
| | | return sql; |
| | | } |
| | | |
| | | /** |
| | | * 生成电话列表信息sql |
| | | * |
| | | * @param telListEntities |
| | | * @return |
| | | */ |
| | | private String telListAddSql(List<T482116Entity> telListEntities) { |
| | | if(telListEntities==null||telListEntities.size()==0){ return "";} |
| | | String sql=""; |
| | | for(T482116Entity contact:telListEntities){ |
| | | sql+="\nselect\n" + |
| | | " @areaCode="+GridUtils.prossSqlParm(contact.getAreaCode())+"\n" + |
| | | ",@telList_tel="+GridUtils.prossSqlParm(contact.getTel())+"\n" + |
| | | ",@telList_id="+contact.getId()+"\n" + |
| | | if (telListEntities == null || telListEntities.size() == 0) { |
| | | return ""; |
| | | } |
| | | String sql = ""; |
| | | for (T482116Entity contact : telListEntities) { |
| | | sql += "\nselect\n" + |
| | | " @areaCode=" + GridUtils.prossSqlParm(contact.getAreaCode()) + "\n" + |
| | | ",@telList_tel=" + GridUtils.prossSqlParm(contact.getTel()) + "\n" + |
| | | ",@telList_id=" + contact.getId() + "\n" + |
| | | ",@telList_refid=@last_inserted_id\n" + |
| | | " insert into t482116(" + |
| | | "areaCode \n" + |
| | |
| | | } |
| | | return sql; |
| | | } |
| | | |
| | | /** |
| | | * 生成电话列表信息sql |
| | | * |
| | | * @param telListEntities |
| | | * @return |
| | | */ |
| | | private String telListUpdateSql(List<T482116Entity> telListEntities) { |
| | | if(telListEntities==null||telListEntities.size()==0){ return "";} |
| | | String sql=""; |
| | | if (telListEntities == null || telListEntities.size() == 0) { |
| | | return ""; |
| | | } |
| | | String sql = ""; |
| | | //增加删除,保证最新 |
| | | String collectIds = telListEntities.stream().filter(x->x.getId()!=null&&x.getId()!=0).map(x -> x.getId()+"").collect(Collectors.joining(",")); |
| | | if(collectIds.equalsIgnoreCase("")){ |
| | | //没有修改,都是新增情况 |
| | | sql=" delete from t482116 \n"; |
| | | }else { |
| | | sql=" delete from t482116 where id not in("+collectIds+")\n"; |
| | | } |
| | | for(T482116Entity telListEntity:telListEntities){ |
| | | if(telListEntity.getId()==null){ |
| | | List<T482116Entity> temp=new ArrayList<>(); |
| | | String collectIds = telListEntities.stream().filter(x -> x.getId() != null && x.getId() != 0).map(x -> x.getId() + "").collect(Collectors.joining(",")); |
| | | if (collectIds.equalsIgnoreCase("")) { |
| | | //没有修改,都是新增情况 |
| | | sql = " delete from t482116 \n"; |
| | | } else { |
| | | sql = " delete from t482116 where id not in(" + collectIds + ")\n"; |
| | | } |
| | | for (T482116Entity telListEntity : telListEntities) { |
| | | if (telListEntity.getId() == null) { |
| | | List<T482116Entity> temp = new ArrayList<>(); |
| | | temp.add(telListEntity); |
| | | sql+=telListAddSql(temp); |
| | | sql += telListAddSql(temp); |
| | | continue; |
| | | } |
| | | sql+="\nselect\n" + |
| | | " @areaCode="+GridUtils.prossSqlParm(telListEntity.getAreaCode())+"\n" + |
| | | ",@telList_tel="+GridUtils.prossSqlParm(telListEntity.getTel())+"\n" + |
| | | sql += "\nselect\n" + |
| | | " @areaCode=" + GridUtils.prossSqlParm(telListEntity.getAreaCode()) + "\n" + |
| | | ",@telList_tel=" + GridUtils.prossSqlParm(telListEntity.getTel()) + "\n" + |
| | | ",@telList_refid=@last_inserted_id\n" + |
| | | ",@telList_id="+telListEntity.getId()+"\n" + |
| | | ",@telList_id=" + telListEntity.getId() + "\n" + |
| | | " update t482116 set " + |
| | | "areaCode=@areaCode \n" + |
| | | ",tel=@telList_tel \n" + |
| | |
| | | package com.yc.crm.mail.action; |
| | | |
| | | import com.sun.mail.imap.IMAPStore; |
| | | import com.yc.action.mail.EmailConfigUtils; |
| | | import com.yc.crm.mail.entity.T482102Entity; |
| | | import com.yc.crm.mail.service.MailAccountIfc; |
| | | import com.yc.crm.mail.service.MailIfc; |
| | |
| | | AllBackMsg msg = new AllBackMsg(); |
| | | try { |
| | | if (StringUtils.isBlank(account.getEmail())) { |
| | | msg.setFail("请输入邮箱地址"); |
| | | msg.setFail("请输入邮箱账号"); |
| | | return msg; |
| | | } |
| | | if (account.getMailType().equals(0) || account.getMailType().equals(1)) { |
| | | if (StringUtils.isBlank(account.getPassword())) { |
| | | msg.setFail("请输入邮箱密码"); |
| | | return msg; |
| | | } |
| | | account.setReceiveEmail(account.getEmail()); |
| | | account.setReceivePassword(account.getPassword()); |
| | | account.setSmtpEmail(account.getEmail()); |
| | | account.setSmtpPassword(account.getPassword()); |
| | | } |
| | | if (account.getMailType().equals(1) || account.getMailType().equals(2)) { |
| | | if (StringUtils.isBlank(account.getReceiveProtocol())) { |
| | | msg.setFail("请选择协议类型"); |
| | | return msg; |
| | | } |
| | | if (StringUtils.isBlank(account.getReceiveHost())) { |
| | | msg.setFail("请输入收邮件服务器"); |
| | | return msg; |
| | | } |
| | | if (account.getReceivePort().equals(0)) { |
| | | msg.setFail("请输入收邮件服务器端口"); |
| | | return msg; |
| | | } |
| | | if (StringUtils.isBlank(account.getSmtpHost())) { |
| | | msg.setFail("请输入发邮件服务器"); |
| | | return msg; |
| | | } |
| | | if (account.getSmtpPort().equals(0)) { |
| | | msg.setFail("请输入发邮件服务器端口"); |
| | | return msg; |
| | | } |
| | | if (account.getMailType().equals(2)) { |
| | | if (StringUtils.isBlank(account.getReceiveEmail())) { |
| | | msg.setFail("请输入收件账号"); |
| | | return msg; |
| | | } |
| | | if (StringUtils.isBlank(account.getReceivePassword())) { |
| | | msg.setFail("请输入收件密码"); |
| | | return msg; |
| | | } |
| | | if (StringUtils.isBlank(account.getSmtpEmail())) { |
| | | msg.setFail("请输入发件账号"); |
| | | return msg; |
| | | } |
| | | if (StringUtils.isBlank(account.getSmtpPassword())) { |
| | | msg.setFail("请输入发件密码"); |
| | | return msg; |
| | | } |
| | | } |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | String companyId = (String) session.getAttribute(SessionKey.COMPANY_ID); |
| | |
| | | account.setCompanyName(companyName); |
| | | account.setUserCode(userCode); |
| | | account.setUserName(userName); |
| | | if (account.getMailType().equals(0)) { |
| | | //初始配置 |
| | | getMailConfigProperties(account); |
| | | } |
| | | DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源 |
| | | SpObserver.setDBtoInstance("_" + dataSource.getDbId()); |
| | | //邮件检测 |
| | | String error = emailDetection(account); |
| | | if (StringUtils.isNotBlank(error)) { |
| | | account.setMailStatus("异常"); |
| | | } |
| | | mailAccountIfc.addEmailAccount(account);//添加新的邮箱配置 |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("companyId", companyId); |
| | | map.put("companyName", companyName); |
| | | map.put("userCode", userCode); |
| | | map.put("userName", userName); |
| | | map.put("email", account.getEmail()); |
| | | msg.setSuccess("已保存", map); |
| | | if (StringUtils.isBlank(error)) { |
| | | map.put("companyId", companyId); |
| | | map.put("companyName", companyName); |
| | | map.put("userCode", userCode); |
| | | map.put("userName", userName); |
| | | map.put("email", account.getEmail()); |
| | | msg.setSuccess("已保存", map); |
| | | } else { |
| | | map.put("mailStatus", "异常"); |
| | | map.put("error", error); |
| | | msg.setSuccess("执行成功", map); |
| | | } |
| | | } catch (Exception e) { |
| | | msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * 添加别名邮箱 |
| | | * |
| | | * @param account |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @GetMapping("/addAliasEmail.do") |
| | | public AllBackMsg addAliasEmail(String aliasEmail, Integer accountId, HttpServletRequest request, HttpServletResponse response) { |
| | | AllBackMsg msg = new AllBackMsg(); |
| | | try { |
| | | if (StringUtils.isBlank(aliasEmail)) { |
| | | msg.setFail("请输入别名邮箱"); |
| | | return msg; |
| | | } |
| | | if (accountId.equals(0)) { |
| | | msg.setFail("邮箱账号Id不能为空"); |
| | | return msg; |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | String userCode = (String) session.getAttribute(SessionKey.USERCODE); |
| | | if (StringUtils.isBlank(userCode)) { |
| | | msg.setFail("登录用户已过期,请检查"); |
| | | return msg; |
| | | } |
| | | DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源 |
| | | SpObserver.setDBtoInstance("_" + dataSource.getDbId()); |
| | | T482102Entity t482102Entity = mailAccountIfc.getAccountInfo(userCode, accountId); |
| | | if (t482102Entity.getMailType().equals(0) || t482102Entity.getMailType().equals(1)) { |
| | | t482102Entity.setEmail(aliasEmail); |
| | | t482102Entity.setReceiveEmail(aliasEmail); |
| | | t482102Entity.setSmtpEmail(aliasEmail); |
| | | } |
| | | //邮箱检测 |
| | | String error = emailDetection(t482102Entity); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (StringUtils.isBlank(error)) { |
| | | mailAccountIfc.updateAliasEmail(aliasEmail, accountId); |
| | | map.put("userCode", userCode); |
| | | map.put("aliasEmail", aliasEmail); |
| | | map.put("accountId", accountId); |
| | | msg.setSuccess("已保存", map); |
| | | } else { |
| | | map.put("mailStatus", "异常"); |
| | | map.put("error", error); |
| | | msg.setSuccess("执行成功", map); |
| | | } |
| | | } catch (Exception e) { |
| | | msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
| | | } finally { |
| | |
| | | msg.setFail("获取不到邮箱配置ID,请检查"); |
| | | return msg; |
| | | } |
| | | if (StringUtils.isBlank(account.getEmail())) { |
| | | msg.setFail("请输入邮箱账号"); |
| | | return msg; |
| | | } |
| | | if (account.getMailType().equals(0)) { |
| | | account.setMailType(1); |
| | | } |
| | | if (account.getMailType().equals(1)) { |
| | | if (StringUtils.isBlank(account.getPassword())) { |
| | | msg.setFail("请输入邮箱密码"); |
| | | return msg; |
| | | } |
| | | account.setReceiveEmail(account.getEmail()); |
| | | account.setReceivePassword(account.getPassword()); |
| | | account.setSmtpEmail(account.getEmail()); |
| | | account.setSmtpPassword(account.getPassword()); |
| | | } else if (account.getMailType().equals(2)) { |
| | | if (StringUtils.isBlank(account.getReceiveEmail())) { |
| | | msg.setFail("请输入收件账号"); |
| | | return msg; |
| | | } |
| | | if (StringUtils.isBlank(account.getReceivePassword())) { |
| | | msg.setFail("请输入收件密码"); |
| | | return msg; |
| | | } |
| | | if (StringUtils.isBlank(account.getSmtpEmail())) { |
| | | msg.setFail("请输入发件账号"); |
| | | return msg; |
| | | } |
| | | if (StringUtils.isBlank(account.getSmtpPassword())) { |
| | | msg.setFail("请输入发件密码"); |
| | | return msg; |
| | | } |
| | | } |
| | | if (StringUtils.isBlank(account.getReceiveHost())) { |
| | | msg.setFail("请输入收邮件服务器"); |
| | | return msg; |
| | | } |
| | | if (account.getReceivePort().equals(0)) { |
| | | msg.setFail("请输入收邮件服务器端口"); |
| | | return msg; |
| | | } |
| | | if (StringUtils.isBlank(account.getSmtpHost())) { |
| | | msg.setFail("请输入发邮件服务器"); |
| | | return msg; |
| | | } |
| | | if (account.getSmtpPort().equals(0)) { |
| | | msg.setFail("请输入发邮件服务器端口"); |
| | | return msg; |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | String userCode = (String) session.getAttribute(SessionKey.USERCODE); |
| | | String userName = (String) session.getAttribute(SessionKey.USER_NAME); |
| | |
| | | DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源 |
| | | SpObserver.setDBtoInstance("_" + dataSource.getDbId()); |
| | | mailAccountIfc.updateEmailAccount(account); |
| | | String error = emailDetection(account); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("userCode", userCode); |
| | | map.put("userName", userName); |
| | | map.put("email", account.getEmail()); |
| | | msg.setSuccess("已更新", map); |
| | | if (StringUtils.isBlank(error)) { |
| | | map.put("userCode", userCode); |
| | | map.put("userName", userName); |
| | | map.put("email", account.getEmail()); |
| | | msg.setSuccess("已更新", map); |
| | | } else { |
| | | //异常处理 |
| | | mailAccountIfc.updateMailStatus("异常", account.getAccountId()); |
| | | map.put("mailStatus", "异常"); |
| | | map.put("error", error); |
| | | msg.setSuccess("执行成功", map); |
| | | } |
| | | } catch (Exception e) { |
| | | msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
| | | } finally { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询个人邮箱信息 |
| | | * 查询邮箱配置列表 |
| | | * |
| | | * @param search 搜索 |
| | | * @param request |
| | |
| | | String userCode = (String) session.getAttribute(SessionKey.USERCODE); |
| | | DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源 |
| | | SpObserver.setDBtoInstance("_" + dataSource.getDbId()); |
| | | List<T482102Entity> t482102Entities = mailAccountIfc.getAccount(userCode, null); |
| | | List<T482102Entity> t482102Entities = mailAccountIfc.getAccount(userCode); |
| | | if (t482102Entities.size() > 0) { |
| | | msg.setSuccess("执行成功", t482102Entities); |
| | | } else { |
| | |
| | | @GetMapping("/isEmailValid.do") |
| | | public AllBackMsg isEmailValid(String email, HttpServletRequest request, HttpServletResponse response) { |
| | | AllBackMsg msg = new AllBackMsg(); |
| | | |
| | | try { |
| | | HttpSession session = request.getSession(); |
| | | String userCode = (String) session.getAttribute(SessionKey.USERCODE); |
| | |
| | | msg.setFail("找不到邮箱:" + email + "配置信息请完善。"); |
| | | return msg; |
| | | } |
| | | Properties props = new Properties(); |
| | | props.put("mail.smtp.host", emailEntity.getSmtpHost()); // 替换为你的SMTP服务器 |
| | | props.put("mail.smtp.port", emailEntity.getSmtpPort()); // 或者你使用的端口 |
| | | props.put("mail.smtp.auth", "true"); |
| | | props.put("mail.smtp.starttls.enable", "true");//启用tls |
| | | props.put("mail.smtp.ssl.enable", emailEntity.isSmtpSSL() + "");//启用SSL |
| | | |
| | | Session mailSession = Session.getInstance(props, new Authenticator() { |
| | | @Override |
| | | protected PasswordAuthentication getPasswordAuthentication() { |
| | | return new PasswordAuthentication(emailEntity.getEmail(), emailEntity.getPassword()); |
| | | } |
| | | }); |
| | | Transport transport = mailSession.getTransport(); |
| | | transport.connect(); |
| | | transport.close(); |
| | | String error = emailDetection(emailEntity); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("email", emailEntity.getEmail()); |
| | | map.put("protocol", emailEntity.getReceiveProtocol()); |
| | | map.put("receiveHost", emailEntity.getReceiveHost()); |
| | | map.put("receiveSSL", emailEntity.isReceiveSSL()); |
| | | map.put("receivePort", emailEntity.getReceivePort()); |
| | | map.put("smtpHost", emailEntity.getSmtpHost()); |
| | | map.put("smtpSSL", emailEntity.isSmtpSSL()); |
| | | map.put("smtpPort", emailEntity.getSmtpPort()); |
| | | map.put("proxyFlag", emailEntity.isProxyFlag()); |
| | | map.put("biSyncFlag", emailEntity.isBiSyncFlag()); |
| | | msg.setSuccess("有效邮箱", map); |
| | | if (StringUtils.isBlank(error)) { |
| | | // map.put("code", "0"); |
| | | map.put("email", emailEntity.getEmail()); |
| | | map.put("protocol", emailEntity.getReceiveProtocol()); |
| | | map.put("receiveHost", emailEntity.getReceiveHost()); |
| | | map.put("receiveSSL", emailEntity.isReceiveSSL()); |
| | | map.put("receivePort", emailEntity.getReceivePort()); |
| | | map.put("smtpHost", emailEntity.getSmtpHost()); |
| | | map.put("smtpSSL", emailEntity.isSmtpSSL()); |
| | | map.put("smtpPort", emailEntity.getSmtpPort()); |
| | | map.put("proxyFlag", emailEntity.isProxyFlag()); |
| | | map.put("biSyncFlag", emailEntity.isBiSyncFlag()); |
| | | map.put("mailStatus", emailEntity.getMailStatus()); |
| | | msg.setSuccess("执行成功", map); |
| | | } else { |
| | | //异常处理 |
| | | mailAccountIfc.updateMailStatus("异常", emailEntity.getAccountId()); |
| | | // map.put("code", "-1"); |
| | | map.put("mailStatus", "异常"); |
| | | map.put("error", error); |
| | | msg.setSuccess("执行成功", map); |
| | | } |
| | | } catch (MessagingException e) { |
| | | msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * 邮箱检测 |
| | | * |
| | | * @param emailEntity |
| | | * @return |
| | | * @throws MessagingException |
| | | */ |
| | | private String emailDetection(T482102Entity emailEntity) throws MessagingException { |
| | | String errorMsg = ""; |
| | | try { |
| | | Properties props = new Properties(); |
| | | |
| | | props.put("mail.store.protocol", "imaps");//emailEntity.getReceiveProtocol()); // IMAP over SSL |
| | | props.put("mail.imaps.host", emailEntity.getReceiveHost()); |
| | | props.put("mail.imaps.port", emailEntity.getReceivePort()); |
| | | props.put("mail.imaps.starttls.enable", "true");//// IMAP 协议设置 STARTTLS |
| | | props.put("mail.smtp.host", emailEntity.getSmtpHost()); // 替换为你的SMTP服务器 |
| | | props.put("mail.smtp.port", emailEntity.getSmtpPort()); // 或者你使用的端口 |
| | | props.put("mail.smtp.auth", "true"); |
| | | props.put("mail.smtp.starttls.enable", "true");//启用tls |
| | | props.put("mail.smtp.ssl.enable", emailEntity.isSmtpSSL() + "");//启用SSL |
| | | |
| | | HashMap IAM = new HashMap(); |
| | | //带上IMAP ID信息,由key和value组成,例如name,version,vendor,support-email等。 |
| | | IAM.put("name", emailEntity.getReceiveEmail()); |
| | | IAM.put("version", emailEntity.getDocVersion() + ""); |
| | | IAM.put("vendor", emailEntity.getCompanyName()); |
| | | IAM.put("support-email", emailEntity.getEmail()); |
| | | |
| | | //创建会话 |
| | | Session session = Session.getInstance(props, new Authenticator() { |
| | | @Override |
| | | protected PasswordAuthentication getPasswordAuthentication() { |
| | | return new PasswordAuthentication(emailEntity.getReceiveEmail(), emailEntity.getReceivePassword()); |
| | | } |
| | | }); |
| | | |
| | | //存储对象 |
| | | IMAPStore store = (IMAPStore) session.getStore(emailEntity.getReceiveProtocol());//imap协议或pop3协议类型(推荐你使用IMAP协议来存取服务器上的邮件。) |
| | | //连接 |
| | | store.connect(emailEntity.getReceiveHost(), emailEntity.getReceiveEmail(), emailEntity.getReceivePassword()); |
| | | store.id(IAM);//163邮箱需要,不然会报:A3 NO SELECT Unsafe Login. Please contact kefu@188.com for help |
| | | Folder folder = null; |
| | | // 获得收件箱 |
| | | folder = store.getFolder("INBOX"); |
| | | // 以读写模式打开收件箱 |
| | | folder.open(Folder.READ_WRITE); |
| | | folder.close(false); |
| | | store.close(); |
| | | |
| | | |
| | | // Session mailSession = Session.getInstance(props, new Authenticator() { |
| | | // @Override |
| | | // protected PasswordAuthentication getPasswordAuthentication() { |
| | | // return new PasswordAuthentication(emailEntity.getEmail(), emailEntity.getPassword()); |
| | | // } |
| | | // }); |
| | | Transport transport = session.getTransport(); |
| | | transport.connect(); |
| | | transport.close(); |
| | | |
| | | } catch (MessagingException e) { |
| | | errorMsg = e.getCause() != null ? e.getCause().getMessage() : e.getMessage(); |
| | | } catch (Exception e) { |
| | | errorMsg = e.getCause() != null ? e.getCause().getMessage() : e.getMessage(); |
| | | } |
| | | return errorMsg; |
| | | } |
| | | |
| | | private T482102Entity getMailConfigProperties(T482102Entity t482102) { |
| | | try { |
| | | String email = t482102.getEmail(); |
| | | int index = email.lastIndexOf("@"); |
| | | String emailSuffix = email.substring(index + 1).toLowerCase();//邮箱后缀 |
| | | String port = ""; |
| | | t482102.setReceiveHost(EmailConfigUtils.getMailConfig("mail.imap.host." + emailSuffix)); |
| | | t482102.setSmtpHost(EmailConfigUtils.getMailConfig("mail.smtp.host." + emailSuffix)); |
| | | port = EmailConfigUtils.getMailConfig("mail.imap.port." + emailSuffix); |
| | | if (StringUtils.isNotBlank(port)) { |
| | | t482102.setReceivePort(Integer.parseInt(port)); |
| | | } |
| | | port = EmailConfigUtils.getMailConfig("mail.smtp.port." + emailSuffix); |
| | | if (StringUtils.isNotBlank(port)) { |
| | | t482102.setSmtpPort(Integer.parseInt(port)); |
| | | } |
| | | } catch (Exception e) { |
| | | return t482102; |
| | | } |
| | | return t482102; |
| | | } |
| | | } |
| | |
| | | DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息 |
| | | SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源 |
| | | //根据当前用户查询绑定的邮箱信息 |
| | | List<T482102Entity> emailEntities = emailAccountIfc.getAccount(userCode, mail);//返回邮箱的账号信息 |
| | | List<T482102Entity> emailEntities = emailAccountIfc.getAccount(userCode);//返回邮箱的账号信息 |
| | | if (emailEntities.size() > 0) { |
| | | List<t482101HEntity> mails = new ArrayList<>(); |
| | | for (T482102Entity e : emailEntities) {//遍历用户绑定邮箱 |
| | |
| | | */ |
| | | @Data |
| | | public class MailModuleEntity { |
| | | private String key; |
| | | private String mailName; |
| | | private Integer total = 0; |
| | | private Integer mailType; |
| | | private List<MailCode> list; |
| | | private List<MailCode> children; |
| | | |
| | | @Data |
| | | public static class MailCode { |
| | | private String key; |
| | | private String mailName;//名称 |
| | | private Integer total = 0;//当前数量 |
| | | private Integer mailType; |
| | |
| | | List<MailModuleEntity> module = new ArrayList<>(); |
| | | //待处理邮件 |
| | | MailModuleEntity receiving = new MailModuleEntity(); |
| | | receiving.setKey("Inbox"); |
| | | receiving.setMailName("收件箱"); |
| | | receiving.setTotal(0);//待处理邮件数量 |
| | | receiving.setMailType(1); |
| | | module.add(receiving); |
| | | //待处理邮件 |
| | | MailModuleEntity untreated = new MailModuleEntity(); |
| | | untreated.setKey("HandlingEmailsOnBehalfOfOthers"); |
| | | untreated.setMailName("待处理邮件"); |
| | | untreated.setTotal(0);//待处理邮件数量 |
| | | untreated.setMailType(3); |
| | | module.add(untreated); |
| | | //未读邮件 |
| | | MailModuleEntity unread = new MailModuleEntity(); |
| | | unread.setKey("Index"); |
| | | unread.setMailName("未读邮件"); |
| | | unread.setTotal(0);//未读数量 |
| | | unread.setMailType(4); |
| | | module.add(unread); |
| | | //群发箱 |
| | | MailModuleEntity draft = new MailModuleEntity(); |
| | | draft.setKey("Drafts"); |
| | | draft.setMailName("草稿箱"); |
| | | draft.setTotal(0); |
| | | draft.setMailType(0); |
| | | module.add(draft); |
| | | //未读邮件 |
| | | MailModuleEntity send = new MailModuleEntity(); |
| | | send.setKey("ShippingBox"); |
| | | send.setMailName("发件箱"); |
| | | send.setTotal(0);//未读数量 |
| | | send.setMailType(2); |
| | | module.add(send); |
| | | //群发箱 |
| | | MailModuleEntity mailGroup = new MailModuleEntity(); |
| | | mailGroup.setKey("MassMailbox"); |
| | | mailGroup.setMailName("群发箱"); |
| | | mailGroup.setTotal(0); |
| | | mailGroup.setMailType(5); |
| | |
| | | private boolean biSyncFlag; //是否同步文件夹 |
| | | private boolean proxyFlag;//是否启用代理 |
| | | private String mailDomain; |
| | | private String mailType; |
| | | private Integer mailType = 0;//邮箱类型 |
| | | private String mailStatus = "正常";//邮箱状态 |
| | | private String keywordList; |
| | | private String siteUrl; |
| | | private String receiveProtocol;//收件协议类型 |
| | | private String receiveProtocol = "imap";//收件协议类型 |
| | | private String receiveEmail;//收件邮箱 |
| | | private String receivePassword;//收件邮箱密码 |
| | | private boolean receiveSSL; |
| | | private Integer receivePort;//收邮件服务器端口 |
| | | private boolean receiveSSL = true; |
| | | private Integer receivePort = 0;//收邮件服务器端口 |
| | | private String receiveHost;//收邮件服务器 |
| | | private String smtpEmail;//发件邮箱 |
| | | private String smtpPassword;//发件邮箱密码 |
| | | private boolean smtpSSL;//SMTP SSL是一种基于SMTP协议的加密传输方式,通过SSL(Secure Sockets Layer,安全套接层)协议对SMTP通信进行加密保护 |
| | | private Integer smtpPort;//发邮件服务器端口 如:25 |
| | | private boolean smtpSSL = true;//SMTP SSL是一种基于SMTP协议的加密传输方式,通过SSL(Secure Sockets Layer,安全套接层)协议对SMTP通信进行加密保护 |
| | | private Integer smtpPort = 0;//发邮件服务器端口 如:25 |
| | | private String smtpHost;//发邮件服务器(简单邮件传送协议服务器:smtp.163.com) |
| | | private boolean invalid;//是否已绑定 |
| | | private String createTime;//创建时间 |
| | |
| | | |
| | | /** |
| | | * 添加新的邮箱配置 |
| | | * |
| | | * @param account |
| | | */ |
| | | abstract void addEmailAccount(T482102Entity account); |
| | | |
| | | /** |
| | | * 修改邮箱配置 |
| | | * |
| | | * @param account |
| | | * @return |
| | | */ |
| | | abstract Integer updateEmailAccount(T482102Entity account); |
| | | |
| | | /** |
| | | * 修改邮箱状态 |
| | | * |
| | | * @param status |
| | | * @return |
| | | */ |
| | | abstract Integer updateMailStatus(String status, Integer accountId); |
| | | |
| | | /** |
| | | * 修改别名邮箱 |
| | | * |
| | | * @param status |
| | | * @return |
| | | */ |
| | | abstract Integer updateAliasEmail(String aliasEmail, Integer accountId); |
| | | |
| | | /** |
| | | * 删除邮箱配置 |
| | | * |
| | | * @param userCode |
| | | * @param accountId |
| | | * @return |
| | | */ |
| | | abstract Integer deleteEmailAccount(String userCode,Integer accountId); |
| | | abstract Integer deleteEmailAccount(String userCode, Integer accountId); |
| | | |
| | | /** |
| | | * 用户绑定的邮箱信息 |
| | | * |
| | | * @param userCode |
| | | * @return |
| | | */ |
| | | abstract List<T482102Entity> getAccount(String userCode, String email); |
| | | abstract T482102Entity getAccountInfo(String userCode, String email) throws Exception; |
| | | abstract List<T482102Entity> getAccount(String userCode); |
| | | |
| | | abstract T482102Entity getAccountInfo(String userCode, Integer accountId) throws Exception; |
| | | |
| | | abstract T482102Entity getAccountInfo(String userCode, String eMail) throws Exception; |
| | | } |
| | |
| | | public class MailAccountImpl extends BaseService implements MailAccountIfc { |
| | | @Override |
| | | public void addEmailAccount(T482102Entity account) { |
| | | if (StringUtils.isBlank(account.getReceiveEmail())) { |
| | | account.setReceiveEmail(account.getEmail()); |
| | | account.setReceivePassword(account.getPassword()); |
| | | } |
| | | if (StringUtils.isBlank(account.getSmtpEmail())) { |
| | | account.setSmtpEmail(account.getEmail()); |
| | | account.setSmtpPassword(account.getPassword()); |
| | | } |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "insert into t482102(companyId,companyName,email,password,alias_email,userCode,userName,receiveProtocol," + |
| | | "receiveEmail,receivePassword,receiveSSL,receivePort,receiveHost," + |
| | | "smtpEmail,smtpPassword,smtpSSL,smtpPort,smtpHost,invalid,create_time,update_time)\n" + |
| | | "smtpEmail,smtpPassword,smtpSSL,smtpPort,smtpHost,invalid,bisync_flag,proxyFlag,mailType,mailStatus,create_time,update_time)\n" + |
| | | "values(" + GridUtils.prossSqlParm(account.getCompanyId()) + "," + GridUtils.prossSqlParm(account.getCompanyName()) + "," + GridUtils.prossSqlParm(account.getEmail()) + "," + |
| | | GridUtils.prossSqlParm(account.getPassword()) + "," + |
| | | GridUtils.prossSqlParm(account.getAliasEmail()) + "," + GridUtils.prossSqlParm(account.getUserCode()) + "," + GridUtils.prossSqlParm(account.getUserName()) + "," + |
| | | GridUtils.prossSqlParm(account.getReceiveProtocol()) + "," + GridUtils.prossSqlParm(account.getReceiveEmail()) + "," + GridUtils.prossSqlParm(account.getReceivePassword()) + "," + |
| | | "'" + account.isReceiveSSL() + "'," + account.getReceivePort() + "," + GridUtils.prossSqlParm(account.getReceiveHost()) + "," + |
| | | GridUtils.prossSqlParm(account.getSmtpEmail()) + "," + GridUtils.prossSqlParm(account.getSmtpPassword()) + ",'" + account.isSmtpSSL() + "'," + |
| | | account.getSmtpPort() + "," + GridUtils.prossSqlParm(account.getSmtpHost()) + ",'" + account.isInvalid() + "'," + |
| | | "convert(varchar(19),getdate(),120),convert(varchar(19),getdate(),120))"; |
| | | account.getSmtpPort() + "," + GridUtils.prossSqlParm(account.getSmtpHost()) + ",'" + account.isInvalid() + "','" + account.isBiSyncFlag() + "','" + account.isProxyFlag() + "'," + |
| | | account.getMailType() + "," + GridUtils.prossSqlParm(account.getMailStatus()) + ",convert(varchar(19),getdate(),120),convert(varchar(19),getdate(),120))"; |
| | | jdbcTemplate.update(sql); |
| | | } catch (Exception e) { |
| | | throw e; |
| | |
| | | |
| | | @Override |
| | | public Integer updateEmailAccount(T482102Entity account) { |
| | | if (StringUtils.isBlank(account.getReceiveEmail())) { |
| | | account.setReceiveEmail(account.getEmail()); |
| | | account.setReceivePassword(account.getPassword()); |
| | | } |
| | | if (StringUtils.isBlank(account.getSmtpEmail())) { |
| | | account.setSmtpEmail(account.getEmail()); |
| | | account.setSmtpPassword(account.getPassword()); |
| | | } |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "update t482102 set alias_email=" + GridUtils.prossSqlParm(account.getAliasEmail()) + ","; |
| | | if (StringUtils.isNotBlank(account.getPassword())) { |
| | | sql += "password=" + GridUtils.prossSqlParm(account.getPassword()) + ","; |
| | | } |
| | | sql += " receiveProtocol=" + GridUtils.prossSqlParm(account.getReceiveProtocol()) + "," + |
| | | " receiveEmail=" + GridUtils.prossSqlParm(account.getReceiveEmail()) + ","; |
| | | sql += " receiveEmail=" + GridUtils.prossSqlParm(account.getReceiveEmail()) + ","; |
| | | if (StringUtils.isNotBlank(account.getReceivePassword())) { |
| | | sql += "receivePassword=" + GridUtils.prossSqlParm(account.getReceivePassword()) + ","; |
| | | } |
| | |
| | | sql += "smtpPassword=" + GridUtils.prossSqlParm(account.getSmtpPassword()) + ","; |
| | | } |
| | | sql += " smtpSSL='" + account.isSmtpSSL() + "'," + " smtpPort=" + account.getSmtpPort() + ",smtpHost=" + GridUtils.prossSqlParm(account.getSmtpHost()) + "," + |
| | | " invalid='" + account.isInvalid() + "',update_time=convert(varchar(19),getdate(),120) " + |
| | | " invalid='" + account.isInvalid() + "',bisync_flag='" + account.isBiSyncFlag() + "',proxyFlag='" + account.isProxyFlag() + "'," + |
| | | " mailType=" + account.getMailType() + ",mailStatus=" + GridUtils.prossSqlParm(account.getMailStatus()) + "," + |
| | | " update_time=convert(varchar(19),getdate(),120) " + |
| | | " where userCode=" + GridUtils.prossSqlParm(account.getUserCode()) + " and accountId=" + account.getAccountId(); |
| | | sql += "select @@ROWCOUNT"; |
| | | return jdbcTemplate.queryForObject(sql, Integer.class); |
| | | } catch (Exception e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Integer updateMailStatus(String status, Integer accountId) { |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "update t482102 set mailStatus=" + GridUtils.prossSqlParm(status) + ",update_time=convert(varchar(19),getdate(),120) " + |
| | | " where accountId=" + accountId; |
| | | sql += "select @@ROWCOUNT"; |
| | | return jdbcTemplate.queryForObject(sql, Integer.class); |
| | | } catch (Exception e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Integer updateAliasEmail(String aliasEmail, Integer accountId) { |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "update t482102 set alias_email=" + GridUtils.prossSqlParm(aliasEmail) + ",update_time=convert(varchar(19),getdate(),120) " + |
| | | " where accountId=" + accountId; |
| | | sql += "select @@ROWCOUNT"; |
| | | return jdbcTemplate.queryForObject(sql, Integer.class); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<T482102Entity> getAccount(String userCode, String email) { |
| | | public List<T482102Entity> getAccount(String userCode) { |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "select companyId,companyName,email,password,alias_email as aliasEmail,userCode,userName,accountId,receive_server_user_name as receiveServerUserName," + |
| | | "isnull(bisync_flag,0) as biSyncFlag,isnull(proxyFlag,0) as proxyFlag,mailDomain,mailType,keywordList,siteUrl,receiveProtocol," + |
| | | "isnull(bisync_flag,0) as biSyncFlag,isnull(proxyFlag,0) as proxyFlag,mailDomain,isnull(mailType,0) as mailType,mailStatus,keywordList,siteUrl,receiveProtocol," + |
| | | "receiveEmail,receivePassword,receiveSSL,receivePort,receiveHost,smtpEmail,smtpPassword,smtpSSL,smtpPort,smtpHost," + |
| | | "isnull(invalid,0) as invalid,create_time as createTime,update_time as updateTime,DocVersion " + |
| | | "from t482102 " + |
| | | "where userCode=" + GridUtils.prossSqlParm(userCode); |
| | | if (StringUtils.isNotBlank(email)) { |
| | | sql += " and email=" + GridUtils.prossSqlParm(email); |
| | | } |
| | | sql += " order by accountId"; |
| | | return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482102Entity.class)); |
| | | } catch (Exception e) { |
| | | throw e; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public T482102Entity getAccountInfo(String userCode, String email) throws Exception { |
| | | if (StringUtils.isBlank(userCode) || StringUtils.isBlank(email)) { |
| | | throw new Exception("参数UserCode和email不能为空"); |
| | | } |
| | | List<T482102Entity> t482101HEntity = getAccount(userCode, email); |
| | | if (t482101HEntity.size() > 0) { |
| | | return t482101HEntity.get(0); |
| | | } else { |
| | | public T482102Entity getAccountInfo(String userCode, Integer accountId) throws Exception { |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "select companyId,companyName,email,password,alias_email as aliasEmail,userCode,userName,accountId,receive_server_user_name as receiveServerUserName," + |
| | | "isnull(bisync_flag,0) as biSyncFlag,isnull(proxyFlag,0) as proxyFlag,mailDomain,isnull(mailType,0) as mailType,mailStatus,keywordList,siteUrl,receiveProtocol," + |
| | | "receiveEmail,receivePassword,receiveSSL,receivePort,receiveHost,smtpEmail,smtpPassword,smtpSSL,smtpPort,smtpHost," + |
| | | "isnull(invalid,0) as invalid,create_time as createTime,update_time as updateTime,DocVersion " + |
| | | "from t482102 " + |
| | | "where userCode=" + GridUtils.prossSqlParm(userCode) + " and accountId=" + accountId; |
| | | sql += " order by accountId"; |
| | | List<T482102Entity> t482101HEntity = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482102Entity.class)); |
| | | if (t482101HEntity.size() > 0) { |
| | | return t482101HEntity.get(0); |
| | | } |
| | | return null; |
| | | } catch (Exception e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public T482102Entity getAccountInfo(String userCode, String eMail) throws Exception { |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "select companyId,companyName,email,password,alias_email as aliasEmail,userCode,userName,accountId,receive_server_user_name as receiveServerUserName," + |
| | | "isnull(bisync_flag,0) as biSyncFlag,isnull(proxyFlag,0) as proxyFlag,mailDomain,isnull(mailType,0) as mailType,mailStatus,keywordList,siteUrl,receiveProtocol," + |
| | | "receiveEmail,receivePassword,receiveSSL,receivePort,receiveHost,smtpEmail,smtpPassword,smtpSSL,smtpPort,smtpHost," + |
| | | "isnull(invalid,0) as invalid,create_time as createTime,update_time as updateTime,DocVersion " + |
| | | "from t482102 " + |
| | | "where userCode=" + GridUtils.prossSqlParm(userCode) + " and email=" + GridUtils.prossSqlParm(eMail); |
| | | sql += " order by accountId"; |
| | | List<T482102Entity> t482101HEntity = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482102Entity.class)); |
| | | if (t482101HEntity.size() > 0) { |
| | | return t482101HEntity.get(0); |
| | | } |
| | | return null; |
| | | } catch (Exception e) { |
| | | throw e; |
| | | } |
| | | } |
| | | } |
| | |
| | | String pwd = emailEntity.getReceivePassword();//"xxxx"; |
| | | |
| | | Properties properties = new Properties(); |
| | | properties.put("mail.store.protocol", emailEntity.getReceiveProtocol()); // IMAP over SSL |
| | | properties.put("mail.store.protocol", "imaps");//emailEntity.getReceiveProtocol()); // IMAP over SSL |
| | | properties.put("mail.imaps.host", emailEntity.getReceiveHost()); |
| | | properties.put("mail.imaps.port", emailEntity.getReceivePort()); |
| | | properties.put("mail.imaps.starttls.enable", "true");//// IMAP 协议设置 STARTTLS |
| | |
| | | properties.setProperty("mail.smtp.host", emailEntity.getSmtpHost()); |
| | | properties.setProperty("mail.smtp.port", emailEntity.getSmtpPort() + ""); |
| | | properties.setProperty("mail.smtp.auth", "true");// // 设置SMTP是否需要认证 |
| | | properties.put("mail.smtp.ssl.enable", emailEntity.isSmtpSSL()+"");// // 设置启用SSL加密 |
| | | properties.put("mail.smtp.ssl.enable", emailEntity.isSmtpSSL() + "");// // 设置启用SSL加密 |
| | | properties.setProperty("mail.smtp.starttls.enable", "true");//// SMTP 协议设置 STARTTLS 开启tls |
| | | |
| | | // |
| | |
| | | public List<MailModuleEntity> getMailModuleList(String userCode) { |
| | | List<MailModuleEntity> module = MailModuleEntity.setMailInitial(); |
| | | try { |
| | | List<T482102Entity> account = emailAccountIfc.getAccount(userCode, null);//获取这个账号绑定的邮箱 |
| | | List<T482102Entity> account = emailAccountIfc.getAccount(userCode);//获取这个账号绑定的邮箱 |
| | | List<t482101HList> userMail = getUserMailList(userCode); |
| | | for (MailModuleEntity m : module) { |
| | | List<t482101HList> mailTypeList = null; |
| | |
| | | case 1://收件箱 |
| | | case 2://发件箱 |
| | | if (mailType == 0) { |
| | | m.setList(new ArrayList<>()); |
| | | m.setChildren(new ArrayList<>()); |
| | | if (userMail.size() > 0) { |
| | | m.setTotal((int) userMail.stream().filter(s -> s.getMailType().equals(mailType)).count()); |
| | | } |
| | | } else { |
| | | List<MailModuleEntity.MailCode> codeList = new ArrayList<>(); |
| | | MailModuleEntity.MailCode code = new MailModuleEntity.MailCode(); |
| | | code.setKey(mailType == 1 ? "InboxPage1" : "IndexPage1"); |
| | | code.setMailType(mailType); |
| | | code.setMailName(mailType == 1 ? "全部收件" : "全部发件"); |
| | | codeList.add(code); |
| | | if (account.size() == 0) {//没有直接跳过 |
| | | m.setList(codeList); |
| | | m.setChildren(codeList); |
| | | continue; |
| | | } |
| | | int allCount = 0; |
| | | int count = 0; |
| | | for (T482102Entity a : account) { |
| | | for (T482102Entity a:account) { |
| | | MailModuleEntity.MailCode nextCode = new MailModuleEntity.MailCode(); |
| | | String eMail = (mailType == 1 ? a.getReceiveEmail() : a.getSmtpEmail());//获取邮箱账号 |
| | | nextCode.setKey(mailType == 1 ? "page" : "page"); |
| | | nextCode.setMailName(eMail); |
| | | nextCode.setMailType(m.getMailType()); |
| | | if (userMail.size() > 0) { |
| | |
| | | } |
| | | codeList.get(0).setTotal(allCount); |
| | | m.setTotal(allCount); |
| | | m.setList(codeList); |
| | | m.setChildren(codeList); |
| | | } |
| | | break; |
| | | case 3://待处理邮件 |
| | | m.setList(new ArrayList<>()); |
| | | m.setChildren(new ArrayList<>()); |
| | | if (userMail.size() > 0) { |
| | | m.setTotal((int) userMail.stream().filter(s -> s.getReadFlag().equals("1")).count()); |
| | | } |
| | | break; |
| | | case 4://未读邮件 |
| | | m.setList(new ArrayList<>()); |
| | | m.setChildren(new ArrayList<>()); |
| | | if (userMail.size() > 0) { |
| | | m.setTotal((int) userMail.stream().filter(s -> s.getReadFlag().equals("0")).count()); |
| | | } |
| | | break; |
| | | case 5://群邮箱 |
| | | m.setList(new ArrayList<>()); |
| | | m.setChildren(new ArrayList<>()); |
| | | break; |
| | | default: |
| | | break; |
New file |
| | |
| | | package com.yc.crm.schedule; |
| | | |
| | | import com.yc.action.grid.GridUtils; |
| | | import com.yc.entity.DataSourceEntity; |
| | | import com.yc.exception.ApplicationException; |
| | | import com.yc.factory.FactoryBean; |
| | | import com.yc.multiData.SpObserver; |
| | | import com.yc.open.init.shcedule.BaseSchedule; |
| | | import com.yc.open.init.shcedule.MessageTipsEntity; |
| | | import com.yc.sdk.WebSocketMessage.action.WebSocketMessageServer; |
| | | import com.yc.sdk.WebSocketMessage.entity.MessageInfo; |
| | | import com.yc.sdk.WebSocketMessage.entity.MessageType; |
| | | import com.yc.sdk.WebSocketMessage.entity.WsMessageUserEntity; |
| | | import com.yc.service.impl.BaseDoIfc; |
| | | |
| | | import java.util.List; |
| | | import java.util.StringJoiner; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 日程提醒 |
| | | * 系统加载所有未推送日程,符合条件则推送日程 |
| | | * |
| | | */ |
| | | public class MessagePopSchedule extends BaseSchedule implements Runnable { |
| | | |
| | | public MessagePopSchedule(DataSourceEntity dataSourceEntity) { |
| | | super(dataSourceEntity); |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | if (Thread.interrupted()) { |
| | | throw new InterruptedException(); |
| | | } |
| | | //log.info(dataSourceEntity.getSystemID() + "右下角弹窗开始....."); |
| | | SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId()); |
| | | BaseDoIfc doIfc = (BaseDoIfc) FactoryBean.getBean("baseDoImpl"); |
| | | //BaseService baseService=(BaseService)FactoryBean.getBean("BaseService"); |
| | | //获取当前已连接webscoket的用户 |
| | | final List<WsMessageUserEntity> onlineUser = WebSocketMessageServer.getOnlineUser(dataSourceEntity.getDbId(), null); |
| | | StringJoiner joiner = new StringJoiner(","); |
| | | if (onlineUser != null && onlineUser.size() > 0){ |
| | | for(WsMessageUserEntity entity:onlineUser){ |
| | | joiner.add(entity.getUserCode()); |
| | | } |
| | | //因为用户已下线,为了避免发送失败导致用户下次登录收不到通知的情况,取数及更新次数分开处理 |
| | | final List<MessageTipsEntity> list = doIfc.doQuery("set nocount on ; declare @UserCodes varchar(max) =" +GridUtils.prossSqlParm(joiner.toString())+ |
| | | "\n select a.messid,a.messagetxt,a.unvaliddate,a.createuser,a.createtime,\n" + |
| | | " a.rejustsrvflag,a.Readers,a.UsrReaded,a.tipcount,a.formid,\n" + |
| | | " a.formtype,a.origfields,a.linkfields,a.linkmode,a.self_datafields,\n" + |
| | | " a.link_datafields,a.efilter , b.usercode ,a.url ,\n" + |
| | | " a.createusername ,a.topic ,a.messagetype ,a.isPublicUser,"+dataSourceEntity.getDbId()+"as dbid\n" + |
| | | " from _sysMessageCount b \n" + |
| | | " join _sysmessage a on a.messid = b.messid\n" + |
| | | " where b.usercode in (select list from getinstr(@UserCodes)) \n" + |
| | | " and b.tipcount < a.tipcount\n" + |
| | | " and a.unvaliddate >= getdate() \n" + |
| | | " and b.isRead = 0 ", MessageTipsEntity.class); |
| | | if (list != null && list.size() > 0) { |
| | | final StringJoiner updateJoiner=new StringJoiner("\n"); |
| | | list.stream().unordered().distinct().forEach(x -> { |
| | | //取每一个用户的所有消息 |
| | | String userCode = x.getUsercode(); |
| | | //--分二种消息类型,1右下角弹窗,2系统级消息显示 |
| | | final List<MessageTipsEntity> collect = list.stream().filter(y -> y.getUsercode().equalsIgnoreCase(x.getUsercode())).collect(Collectors.toList()); |
| | | if (collect != null && collect.size() > 0) { |
| | | //----发送出去 |
| | | //---通知webscoket |
| | | MessageInfo messageInfo = new MessageInfo(); |
| | | messageInfo.setDbId(dataSourceEntity.getDbId()); |
| | | messageInfo.setMsgType(MessageType.NOTICE_AND_TODO); |
| | | messageInfo.setUserFromType("1");//TODO PC端 |
| | | messageInfo.setUserCode(userCode); |
| | | messageInfo.setMsg(GridUtils.toJson(collect)); |
| | | //直接发送 |
| | | List<WsMessageUserEntity> wsMessageUserEntityList = WebSocketMessageServer.getOnlineUserByTips(dataSourceEntity.getDbId(), userCode); |
| | | if (wsMessageUserEntityList != null && wsMessageUserEntityList.size() != 0) { |
| | | for (WsMessageUserEntity wsMessageUserEntity : wsMessageUserEntityList) { |
| | | boolean flag= wsMessageUserEntity.sendMessageV3(messageInfo); |
| | | if(flag){ |
| | | //成功才更新次数 |
| | | collect.stream().forEach(z->{ |
| | | updateJoiner.add(" if not exists(select 1 from @table where MessId = "+z.getMessid()+" and UserCode = "+GridUtils.prossSqlParm(userCode)+")\n" + |
| | | " begin\n" + |
| | | " insert into @table(MessId,UserCode) values ( "+z.getMessid()+","+GridUtils.prossSqlParm(userCode)+")\n" + |
| | | " end\n"); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | }); |
| | | //---更新次数 |
| | | if(updateJoiner.length()>0) { |
| | | String sql = "set nocount on \n declare @table table(MessId int,UserCode varchar(50), Primary Key(MessId,UserCode))\n" + |
| | | updateJoiner.toString() + |
| | | " \n update a set tipcount = isnull(tipcount,0) + 1,LastPushTime=getDate() \n" + |
| | | " from _sysMessageCount a \n" + |
| | | "where exists ( select 1 from @table b where a.MessId = b.MessId and a.UserCode = b.UserCode and (a.LastPushTime is null or datediff(second,a.LastPushTime,getdate()) > 45 )) "; |
| | | doIfc.doExecute(sql); |
| | | //log.info(dataSourceEntity.getSystemID() + "右下角弹窗完成:"+sql); |
| | | } |
| | | } |
| | | } |
| | | } catch (InterruptedException ex) { |
| | | log.info(dataSourceEntity.getSystemID() + "右下角弹窗任务已被终止"); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | log.error(dataSourceEntity.getSystemDescribe() + ":" + ex.getMessage()); |
| | | }finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | public String replaceBlank(String str) { |
| | | if (str == null || str == "") { return ""; } |
| | | Matcher m = null; |
| | | try { |
| | | Pattern p = Pattern.compile("\t|\r|\n"); |
| | | m = p.matcher(str); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new ApplicationException(str + "-解析出错,存在有特殊字符"); |
| | | } |
| | | return m.replaceAll(" ").replaceAll("\\$", "\\\\\\$"); |
| | | } |
| | | public static String toString(Object obj){ |
| | | if(obj==null)return ""; |
| | | return obj.toString(); |
| | | } |
| | | } |
| | |
| | | * @return SqlRowSet 参数值列表 |
| | | * */ |
| | | public List getDataByAjax(ThreeJSON json, String where)throws DataAccessException; |
| | | public List getDataByAjax(String tabName,String fields,String where)throws DataAccessException; |
| | | public List getDataByAjaxBy42(String tabName, String fields, String where, int limit, int page,String orderBy,int formid)throws DataAccessException; |
| | | public List getDataByAjaxBy42(String tabName, String fields, String where, int limit, int page,String orderBy)throws DataAccessException; |
| | | /** |
| | | * 通过调用用户定义函数返回内容 |
| | | * @return Page --分页类 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List getDataByAjaxBy42(String tabName, String fields, String where, int limit, int page, String orderBy) throws DataAccessException { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | @Override |
| | | public List getDataByAjax(ThreeJSON json, String where) throws DataAccessException { |
| | | String tabName = this.getTableName(json.getFormID(), json.getType() + "|" + 0); |
| | | String fields=json.getParm().replaceAll(" ", " ").replaceAll("&", "").replaceAll("nbsp;", " ") |
| | |
| | | //增加排序功能 |
| | | return this.jdbcTemplate.queryForList(sql.replaceAll("\\^", " and ")); |
| | | } |
| | | private int proccesSymbol(String str){ |
| | | |
| | | @Override |
| | | public List getDataByAjax(String tabName, String fields, String where) throws DataAccessException { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | private int proccesSymbol(String str){ |
| | | if (org.apache.commons.lang3.StringUtils.isBlank(str)) {return -1;} |
| | | boolean isSymo=str.indexOf("!")>-1?true:false;//存在!号才处理 |
| | | if(isSymo) { |
| | |
| | | |
| | | mail.pop3.host=192.168.100.5 |
| | | #mail.pop3.host=192.168.0.2mail.pop3.port=110 |
| | | mail.domain=yingchen.com |
| | | mail.domain=yingchen.com |
| | | |
| | | #QQ邮箱服务器 |
| | | mail.imap.host.qq.com=imap.qq.com |
| | | mail.imap.port.qq.com=993 |
| | | mail.smtp.host.qq.com=smtp.qq.com |
| | | mail.smtp.port.qq.com=465 |
| | | |
| | | #163邮箱服务器 |
| | | mail.imap.host.163.com=imap.163.com |
| | | mail.imap.port.163.com=993 |
| | | mail.smtp.host.163.com=smtp.163.com |
| | | mail.smtp.port.163.com=465 |
| | | |
| | | |