|
|
@@ -8,6 +8,7 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -55,17 +56,20 @@ public class MessageServiceImpl extends BaseMybatisDao<MessageFromSystemMapper>
|
|
|
String result = "";
|
|
|
if(selectMap.containsKey(ConsumerType.LOCATION_PROVINCE.getTypeCode())){ //省
|
|
|
sql = "select group_concat(a.id) from user a left join user_identity b on a.id = b.uid where a.source=0 and b.province in (" + selectMap.get(ConsumerType.LOCATION_PROVINCE.getTypeCode()) + ")";
|
|
|
- result += ","+messageFromSystemMapper.selectSendTarget(sql);
|
|
|
+ String tmp=messageFromSystemMapper.selectSendTarget(sql);
|
|
|
+ result +="," + tmp==null?"":tmp;
|
|
|
}
|
|
|
if(selectMap.containsKey(ConsumerType.LOCATION_CITY.getTypeCode())){ //市
|
|
|
sql = "select group_concat(a.id) from user a left join user_identity b on a.id = b.uid where a.source=0 and b.city in (" + selectMap.get(ConsumerType.LOCATION_CITY.getTypeCode()) + ") and a.status != 2";
|
|
|
- result += ","+messageFromSystemMapper.selectSendTarget(sql);
|
|
|
+ String tmp=messageFromSystemMapper.selectSendTarget(sql);
|
|
|
+ result +="," + tmp==null?"":tmp;
|
|
|
}
|
|
|
if(selectMap.containsKey(ConsumerType.LOCATION_AREA.getTypeCode())){ //区
|
|
|
sql = "select group_concat(a.id) from user a left join user_identity b on a.id = b.uid where a.source=0 and b.area in (" + selectMap.get(ConsumerType.LOCATION_AREA.getTypeCode()) + ") and a.status != 2";
|
|
|
- result += ","+messageFromSystemMapper.selectSendTarget(sql);
|
|
|
+ String tmp=messageFromSystemMapper.selectSendTarget(sql);
|
|
|
+ result +="," + tmp==null?"":tmp;
|
|
|
}
|
|
|
- if(!result.equals("")){
|
|
|
+ if(!result.equals("")&&result!=null){
|
|
|
String data[] = result.substring(1).split(",");
|
|
|
List<String> list = new ArrayList<String>();
|
|
|
boolean flag;
|
|
|
@@ -84,6 +88,9 @@ public class MessageServiceImpl extends BaseMybatisDao<MessageFromSystemMapper>
|
|
|
}
|
|
|
}else if(selectMap.containsKey(ConsumerType.INDUSTRY.getTypeCode())){ //行业
|
|
|
String sql = "select group_concat(a.id) from user a left join user_identity b on a.id = b.uid where a.source=0 and b.industry in (" + selectMap.get(ConsumerType.INDUSTRY.getTypeCode()) + ") and a.status != 2";
|
|
|
+ if(messageFromSystemMapper.selectSendTarget(sql)==null){
|
|
|
+ return "";
|
|
|
+ }
|
|
|
return messageFromSystemMapper.selectSendTarget(sql);
|
|
|
}
|
|
|
return "";
|
|
|
@@ -93,9 +100,11 @@ public class MessageServiceImpl extends BaseMybatisDao<MessageFromSystemMapper>
|
|
|
public String selectSendAdmin(Map<Integer, String> selectMap,Integer type) {
|
|
|
String sql = "";
|
|
|
if(selectMap.containsKey(ConsumerType.COMPANY.getTypeCode())){
|
|
|
- sql = "select group_concat(id) from admin where department_id in ("+ selectMap.get(ConsumerType.COMPANY.getTypeCode()) + ")";
|
|
|
+ // 123,123
|
|
|
+
|
|
|
+ sql = "select group_concat(id) from admin where department_id in ("+ changeSql(selectMap.get(ConsumerType.COMPANY.getTypeCode())) + ")";
|
|
|
}else if(selectMap.containsKey(ConsumerType.ROLE.getTypeCode())){
|
|
|
- sql = "select group_concat(id) from admin a left join user_role b on a.id = b.uid where b.id in (" + selectMap.get(ConsumerType.ROLE.getTypeCode()) + ")";
|
|
|
+ sql = "select group_concat(id) from admin a left join user_role b on a.id = b.uid where b.rid in (" + changeSql(selectMap.get(ConsumerType.ROLE.getTypeCode())) + ")";
|
|
|
}
|
|
|
if(!sql.equals("")) return messageFromSystemMapper.selectSendTarget(sql);
|
|
|
return "";
|
|
|
@@ -105,7 +114,7 @@ public class MessageServiceImpl extends BaseMybatisDao<MessageFromSystemMapper>
|
|
|
public List<MessageFromSystem> selectRecommend(Map<Integer, String> selectMap,Integer type){
|
|
|
String sql = "";
|
|
|
if(selectMap.containsKey(RecommendType.TECH_SERVICE.getTypeCode())){ //科技服务
|
|
|
- sql = "select project_name as title,project_des as body,id as resourceId from tech_project where id in (" + selectMap.get(RecommendType.TECH_SERVICE.getTypeCode()) + ")";
|
|
|
+ sql = "select project_name as title,project_des as body,id as resourceId from tech_project where id in (" + changeSql(selectMap.get(RecommendType.TECH_SERVICE.getTypeCode())) + ")";
|
|
|
}else if(selectMap.containsKey(RecommendType.PERSON_ACHIEVEMENT.getTypeCode())){ //个人成果
|
|
|
sql = "select name as title,summary as body,id as resourceIdfrom achievement where id in (" + selectMap.get(RecommendType.PERSON_ACHIEVEMENT.getTypeCode()) +")";
|
|
|
}else if(selectMap.containsKey(RecommendType.ORGANIZATION_ACHIEVEMENT.getTypeCode())){ //组织成果
|
|
|
@@ -135,6 +144,7 @@ public class MessageServiceImpl extends BaseMybatisDao<MessageFromSystemMapper>
|
|
|
mfs.setSubject(subject);
|
|
|
mfs.setConsumerType(targetType);
|
|
|
mfs.setIsDraft(isDraft);
|
|
|
+ mfs.setDeleteSign(Boolean.FALSE);
|
|
|
if(SecurityUtils.getSubject().getPrincipal() instanceof Admin){
|
|
|
Admin admin = (Admin)SecurityUtils.getSubject().getPrincipal();
|
|
|
mfs.setCreater(admin.getName());
|
|
|
@@ -144,26 +154,30 @@ public class MessageServiceImpl extends BaseMybatisDao<MessageFromSystemMapper>
|
|
|
List<MessageProducer> target = new ArrayList<MessageProducer>();
|
|
|
String[] cids;
|
|
|
if(subject == SubjectType.KE_HU.getTypeCode()){
|
|
|
- cids = selectSendUser(targetMap,targetType).split(",");
|
|
|
- MessageProducer mp;
|
|
|
- for(String cid : cids){
|
|
|
- mp = new MessageProducer();
|
|
|
- mp.setId(UUID.randomUUID().toString());
|
|
|
- mp.setMessageId(mfs.getId());
|
|
|
- mp.setConsumerId(cid);
|
|
|
- target.add(mp);
|
|
|
+ if(selectSendUser(targetMap,targetType).split(",")!=null){
|
|
|
+ cids = selectSendUser(targetMap,targetType).split(",");
|
|
|
+ MessageProducer mp;
|
|
|
+ for(String cid : cids){
|
|
|
+ mp = new MessageProducer();
|
|
|
+ mp.setId(UUID.randomUUID().toString());
|
|
|
+ mp.setMessageId(mfs.getId());
|
|
|
+ mp.setConsumerId(cid);
|
|
|
+ target.add(mp);
|
|
|
+ }
|
|
|
}
|
|
|
- if(target.size()>0) insertBatchProducer(target);
|
|
|
+ if(target.size()>0) insertBatchProducer(target);
|
|
|
}else if(subject == SubjectType.YUN_YING.getTypeCode()){
|
|
|
- cids = selectSendAdmin(targetMap,targetType).split(",");
|
|
|
- MessageProducer mp;
|
|
|
- for(String cid : cids){
|
|
|
- mp = new MessageProducer();
|
|
|
- mp.setId(UUID.randomUUID().toString());
|
|
|
- mp.setMessageId(mfs.getId());
|
|
|
- mp.setConsumerId(cid);
|
|
|
- target.add(mp);
|
|
|
- }
|
|
|
+ if(selectSendUser(targetMap,targetType).split(",")!=null){
|
|
|
+ cids = selectSendAdmin(targetMap,targetType).split(",");
|
|
|
+ MessageProducer mp;
|
|
|
+ for(String cid : cids){
|
|
|
+ mp = new MessageProducer();
|
|
|
+ mp.setId(UUID.randomUUID().toString());
|
|
|
+ mp.setMessageId(mfs.getId());
|
|
|
+ mp.setConsumerId(cid);
|
|
|
+ target.add(mp);
|
|
|
+ }
|
|
|
+ }
|
|
|
if(target.size()>0) insertBatchProducer(target);
|
|
|
}
|
|
|
return 1;
|
|
|
@@ -327,4 +341,13 @@ public class MessageServiceImpl extends BaseMybatisDao<MessageFromSystemMapper>
|
|
|
public JpushEasemobAccount selectSynAccByUid(String uid) {
|
|
|
return jpushEasemobAccountMapper.selectSynAccByUid(uid);
|
|
|
}
|
|
|
+
|
|
|
+ private String changeSql(String source){
|
|
|
+ String result = "";
|
|
|
+ if(StringUtils.isNotBlank(source)){
|
|
|
+ source = "'" + source + "'";
|
|
|
+ result = source.replace(",", "','");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|