| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645 |
- package cn.com.goldenwater.dcproj.service.impl.tac;
- import cn.com.goldenwater.core.service.AbstractCrudService;
- import cn.com.goldenwater.dcproj.constValue.SmsCodeEnum;
- import cn.com.goldenwater.dcproj.dao.AttAdXBaseDao;
- import cn.com.goldenwater.dcproj.dao.BisInspAllRlationPersDao;
- import cn.com.goldenwater.dcproj.dao.TacInspYearBatchAreaDao;
- import cn.com.goldenwater.dcproj.dao.TacInspYearBatchDao;
- import cn.com.goldenwater.dcproj.dao.TacInspYearBatchGroupDao;
- import cn.com.goldenwater.dcproj.dao.TacInspYearBatchGroupPersDao;
- import cn.com.goldenwater.dcproj.dao.TacInspYearBatchObjDao;
- import cn.com.goldenwater.dcproj.dao.TacPawpRgstrDao;
- import cn.com.goldenwater.dcproj.dao.TacWorkerBDao;
- import cn.com.goldenwater.dcproj.dto.TacInspYearBatchGroupDto;
- import cn.com.goldenwater.dcproj.dto.TacInspYearBatchObjDto;
- import cn.com.goldenwater.dcproj.model.AttAdXBase;
- import cn.com.goldenwater.dcproj.model.TacInspYearBatch;
- import cn.com.goldenwater.dcproj.model.TacInspYearBatchArea;
- import cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup;
- import cn.com.goldenwater.dcproj.model.TacInspYearBatchGroupPers;
- import cn.com.goldenwater.dcproj.model.TacInspYearBatchObj;
- import cn.com.goldenwater.dcproj.model.TacWorkerB;
- import cn.com.goldenwater.dcproj.param.AttAdXBaseParam;
- import cn.com.goldenwater.dcproj.param.TacInspYearBatchAreaParam;
- import cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupParam;
- import cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupPersParam;
- import cn.com.goldenwater.dcproj.param.TacInspYearBatchObjParam;
- import cn.com.goldenwater.dcproj.param.TacPawpRgstrParam;
- import cn.com.goldenwater.dcproj.param.TacWorkerBParam;
- import cn.com.goldenwater.dcproj.service.TacInspYearBatchGroupService;
- import cn.com.goldenwater.dcproj.utils.DateUtils;
- import cn.com.goldenwater.dcproj.utils.HttpClientUtils;
- import cn.com.goldenwater.id.util.UuidUtil;
- import cn.com.goldenwater.target.CheckException;
- import net.sf.json.JSONObject;
- import org.apache.commons.lang3.StringUtils;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.stream.Collectors;
- /**
- * @author lune
- * @date 2019-9-6
- */
- @Service
- @Transactional
- public class TacInspYearBatchGroupServiceImpl<main> extends AbstractCrudService<TacInspYearBatchGroup, TacInspYearBatchGroupParam> implements TacInspYearBatchGroupService {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private TacInspYearBatchGroupDao tacInspYearBatchGroupDao;
- @Autowired
- private TacInspYearBatchDao yearBatchDao;
- @Autowired
- private TacWorkerBDao workerBDao;
- @Autowired
- private TacPawpRgstrDao tacPawpRgstrDao;
- @Autowired
- private AttAdXBaseDao attAdXBaseDao;
- @Autowired
- private TacInspYearBatchAreaDao areaDao;
- @Autowired
- private TacInspYearBatchGroupPersDao groupPersDao;
- @Autowired
- private TacInspYearBatchObjDao tacInspYearBatchObjDao;
- @Autowired
- private BisInspAllRlationPersDao rlationPersDao;
- @Value("${api.url}")
- private String apiUrl;
- //稽察专家回复超时时间
- // @Value("${replyTimeout}")
- // private long replyTimeout;
- private static String apiKey = "1036432406699048960";
- private static String apiSecrect = "bbSsX1wvmaKdca5x2+yBDgeFtl9hj4zJmnegunWuLuHLwLo+QjxOr3//P4BJNrVADa7tN4w0DX1KS/VSec5G0x+ucDeAcSt9tWgFGyoBVtblybh+vzLbwH4sJa92hQfu\n";
- public TacInspYearBatchGroupServiceImpl(TacInspYearBatchGroupDao tacInspYearBatchGroupDao) {
- super(tacInspYearBatchGroupDao);
- this.tacInspYearBatchGroupDao = tacInspYearBatchGroupDao;
- }
- @Override
- public List<TacInspYearBatchGroup> getGroupListByLoginId(TacInspYearBatchGroupParam tacInspYearBatchGroupParam) {
- List<TacInspYearBatchGroup> groupList = tacInspYearBatchGroupDao.getGroupListApp(tacInspYearBatchGroupParam);
- if (groupList.size() > 0) {
- groupList.forEach(group -> {
- TacInspYearBatchAreaParam areaParam = new TacInspYearBatchAreaParam();
- areaParam.setGroupId(group.getId());
- List<TacInspYearBatchArea> areaList = this.areaDao.findList(areaParam);
- if (areaList.size() > 0) {
- String str = "";
- for (TacInspYearBatchArea area : areaList) {
- str = str + area.getAdName() + ",";
- }
- if (str.length() > 0) {
- str = str.substring(0, str.length() - 1);
- }
- group.setAreas(str);
- }
- });
- }
- return groupList;
- }
- @Override
- public int insertGroupList(TacInspYearBatchGroupDto groupDto) {
- if (groupDto == null) {
- return 0;
- }
- List<String> adCodes = groupDto.getAdCodes();
- if (adCodes.size() > 0) {
- for (String adCode : adCodes) {
- TacInspYearBatchGroup group = new TacInspYearBatchGroup();
- group.setId(UuidUtil.uuid());
- group.setYearBatchId(groupDto.getBatchId());
- group.setTenet(groupDto.getTenet());
- group.setInTm(new Date());
- TacInspYearBatchGroupParam groupParam = new TacInspYearBatchGroupParam();
- groupParam.setYearBatchId(groupDto.getBatchId());
- String groupNum = this.tacInspYearBatchGroupDao.getMaxGourpNum(groupParam);
- if (StringUtils.isBlank(groupNum)) {
- groupNum = "1";
- }
- group.setProvince(groupDto.getProvince());
- group.setGroupNm(Long.valueOf(groupNum));
- group.setConfirmer("0");
- tacInspYearBatchGroupDao.insert(group);
- if (adCode.contains(",")) {
- String[] ads = adCode.split(",");
- for (String ad : ads) {
- TacInspYearBatchArea area = new TacInspYearBatchArea();
- area.setId(UuidUtil.uuid());
- area.setGroupId(group.getId());
- area.setYearBatchId(group.getYearBatchId());
- area.setAdCode(ad);
- area.setInTm(new Date());
- area.setUpTm(new Date());
- area.setProvince(groupDto.getProvince());
- areaDao.insert(area);
- }
- } else {
- TacInspYearBatchArea area = new TacInspYearBatchArea();
- area.setId(UuidUtil.uuid());
- area.setGroupId(group.getId());
- area.setYearBatchId(group.getYearBatchId());
- area.setAdCode(adCode);
- area.setInTm(new Date());
- area.setUpTm(new Date());
- area.setProvince(groupDto.getProvince());
- areaDao.insert(area);
- }
- }
- TacInspYearBatch yearBatch = new TacInspYearBatch();
- yearBatch.setId(groupDto.getBatchId());
- yearBatch.setIsAreaGroup("1");
- yearBatchDao.update(yearBatch);
- }
- return 0;
- }
- @Override
- public List<TacInspYearBatchGroup> getGroupList(TacInspYearBatchGroupParam groupParam) {
- List<TacInspYearBatchGroup> groupList = this.tacInspYearBatchGroupDao.findList(groupParam);
- List<TacInspYearBatchGroup> result = new ArrayList<>();
- if (groupList.size() > 0) {
- for (TacInspYearBatchGroup tacInspYearBatchGroup : groupList) {
- TacWorkerBParam workerBParam = new TacWorkerBParam();
- workerBParam.setGroupId(tacInspYearBatchGroup.getId());
- workerBParam.setProvince(groupParam.getProvince());
- if(StringUtils.isNotBlank(groupParam.getName()) && StringUtils.isBlank(groupParam.getPersName())){
- groupParam.setPersName(groupParam.getName());
- }
- if (StringUtils.isNotBlank(groupParam.getPersName())) {
- workerBParam.setName(groupParam.getPersName());
- List<TacWorkerB> bs = workerBDao.getWorkListByGroupId(workerBParam);
- if (bs.size() == 0) {
- continue;
- }
- workerBParam.setName("");
- tacInspYearBatchGroup.setWorkersList(workerBDao.getWorkListByGroupId(workerBParam));
- } else {
- List<TacWorkerB> bs = workerBDao.getWorkListByGroupId(workerBParam);
- tacInspYearBatchGroup.setWorkersList(bs);
- }
- //获取督查区域
- TacInspYearBatchAreaParam areaParam = new TacInspYearBatchAreaParam();
- areaParam.setGroupId(tacInspYearBatchGroup.getId());
- areaParam.setProvince(groupParam.getProvince());
- if (StringUtils.isNotBlank(groupParam.getAdCode())) {
- areaParam.setAdCode(groupParam.getAdCode());
- List<TacInspYearBatchArea> areaList = this.areaDao.findList(areaParam);
- if (areaList.size() == 0) {
- continue;
- }
- areaParam.setAdCode("");
- }
- List<TacInspYearBatchArea> areaList = this.areaDao.findList(areaParam);
- if (areaList.size() > 0) {
- String str = "";
- for (TacInspYearBatchArea area : areaList) {
- str = str + area.getAdName() + ",";
- }
- if (str.length() > 0) {
- str = str.substring(0, str.length() - 1);
- }
- tacInspYearBatchGroup.setAreas(str);
- }
- tacInspYearBatchGroup.setAreaList(areaList);
- TacInspYearBatchObjParam objParam = new TacInspYearBatchObjParam();
- objParam.setGroupId(tacInspYearBatchGroup.getId());
- objParam.setProvince(groupParam.getProvince());
- if (StringUtils.isNotBlank(groupParam.getType())) {
- objParam.setType(groupParam.getType());
- List<TacInspYearBatchObjDto> list = tacInspYearBatchObjDao.getObjList(objParam);
- if (list.size() == 0) {
- continue;
- }
- objParam.setType("");
- }
- List<TacInspYearBatchObj> objs = tacInspYearBatchObjDao.getObjAndType(objParam);
- tacInspYearBatchGroup.setObjList(objs);
- result.add(tacInspYearBatchGroup);
- }
- }
- return result;
- }
- @Override
- public int deleteGroupById(String id, String province) {
- this.tacInspYearBatchGroupDao.delete(id);
- TacInspYearBatchAreaParam areaParam = new TacInspYearBatchAreaParam();
- areaParam.setGroupId(id);
- areaParam.setProvince(province);
- areaDao.deleteBy(areaParam);
- TacInspYearBatchObjParam tacInspYearBatchObjParam = new TacInspYearBatchObjParam();
- tacInspYearBatchObjParam.setGroupId(id);
- tacInspYearBatchObjDao.deleteBy(tacInspYearBatchObjParam);
- TacPawpRgstrParam tacPawpRgstrParam = new TacPawpRgstrParam();
- tacPawpRgstrParam.setGroupId(id);
- tacPawpRgstrDao.deleteBy(tacPawpRgstrParam);
- TacInspYearBatchGroupPersParam groupPersParam = new TacInspYearBatchGroupPersParam();
- groupPersParam.setGroupId(id);
- int a = groupPersDao.deleteGroupPersByGroupId(groupPersParam);
- return 1;
- }
- @Override
- public int deleteGroupList(TacInspYearBatchGroupDto dto) {
- if (dto == null || dto.getGroupList() == null) {
- return 0;
- }
- List<String> groupIdList = dto.getGroupList().stream().map(m -> m.getId()).collect(Collectors.toList());
- List<String> batchObjList = this.tacInspYearBatchObjDao.getObjListByGroupIdList(groupIdList);
- if(null != batchObjList && batchObjList.size()>0){
- // 这个组下面有项目,不能删除组
- throw new CheckException("删除的组里有项目,请先去掉组里的项目!!!");
- }
- dto.getGroupList().forEach(group -> {
- this.tacInspYearBatchGroupDao.delete(group.getId());
- TacInspYearBatchObjParam tacInspYearBatchObjParam = new TacInspYearBatchObjParam();
- tacInspYearBatchObjParam.setGroupId(group.getId());
- tacInspYearBatchObjParam.setProvince(dto.getProvince());
- tacInspYearBatchObjDao.deleteBy(tacInspYearBatchObjParam);
- TacPawpRgstrParam tacPawpRgstrParam = new TacPawpRgstrParam();
- tacPawpRgstrParam.setGroupId(group.getId());
- tacPawpRgstrParam.setProvince(dto.getProvince());
- tacPawpRgstrDao.deleteBy(tacPawpRgstrParam);
- TacInspYearBatchAreaParam areaParam = new TacInspYearBatchAreaParam();
- areaParam.setGroupId(group.getId());
- areaParam.setProvince(dto.getProvince());
- areaDao.deleteBy(areaParam);
- TacInspYearBatchGroupPersParam groupPersParam = new TacInspYearBatchGroupPersParam();
- groupPersParam.setGroupId(group.getId());
- int a = groupPersDao.deleteGroupPersByGroupId(groupPersParam);
- });
- return 0;
- }
- @Override
- public TacInspYearBatchGroup getGroupById(String id, String province) {
- TacInspYearBatchGroup group = tacInspYearBatchGroupDao.get(id);
- TacInspYearBatchAreaParam areaParam = new TacInspYearBatchAreaParam();
- areaParam.setGroupId(group.getId());
- areaParam.setProvince(province);
- List<TacInspYearBatchArea> list = areaDao.findList(areaParam);
- group.setAreaList(list);
- return group;
- }
- @Override
- public int updateGroupArea(TacInspYearBatchGroup group) {
- Map<String, List<TacInspYearBatchArea>> map = new HashMap<>();
- if (group.getAreaList() != null) {
- group.getAreaList().forEach(tacInspYearBatchArea -> {
- if (map.keySet().contains(tacInspYearBatchArea.getAdName())) {
- map.get(tacInspYearBatchArea.getAdName()).add(tacInspYearBatchArea);
- } else {
- List<TacInspYearBatchArea> list = new ArrayList<>();
- list.add(tacInspYearBatchArea);
- map.put(tacInspYearBatchArea.getAdName(), list);
- }
- });
- }
- if (group.getAdNames() != null) {
- for (Map<String, String> stringMap : group.getAdNames()) {
- String adName = stringMap.get("adName");
- if (map.containsKey(adName)) {
- map.remove(adName);
- continue;
- }
- AttAdXBaseParam adXBaseParam = new AttAdXBaseParam();
- adXBaseParam.setAdName(adName);
- AttAdXBase attAdXBase = attAdXBaseDao.getByName(adXBaseParam);
- if (attAdXBase == null) {
- continue;
- }
- TacInspYearBatchArea batchArea = new TacInspYearBatchArea();
- batchArea.setId(UuidUtil.uuid());
- batchArea.setGroupId(group.getId());
- batchArea.setYearBatchId(group.getYearBatchId());
- batchArea.setGroupNm(group.getGroupNm());
- batchArea.setAdCode(attAdXBase.getAdCode());
- batchArea.setAdName(adName);
- batchArea.setBatch(group.getBatch());
- batchArea.setYear(group.getYear());
- batchArea.setInTm(new Date());
- batchArea.setUpTm(new Date());
- batchArea.setProvince(group.getProvince());
- areaDao.insert(batchArea);
- }
- List<TacInspYearBatchArea> areaList = new ArrayList();
- for (List<TacInspYearBatchArea> list : map.values()) {
- areaList.addAll(list);
- }
- if (areaList.size() > 0) {
- TacInspYearBatchGroupPersParam groupPersParam = new TacInspYearBatchGroupPersParam();
- for (TacInspYearBatchArea area : areaList) {
- groupPersParam.setGroupId(area.getGroupId());
- groupPersDao.deleteBy(groupPersParam);
- if (area.getId().contains(",")) {
- for (String id : area.getId().split(",")) {
- areaDao.delete(id);
- }
- } else {
- areaDao.delete(area.getId());
- }
- }
- }
- }
- return 0;
- }
- @Override
- public List<TacInspYearBatchGroup> getGroupListAndObj(TacInspYearBatchGroupParam groupParam) {
- List<TacInspYearBatchGroup> groupList = this.tacInspYearBatchGroupDao.findList(groupParam);
- if (groupList.size() > 0) {
- for (TacInspYearBatchGroup tacInspYearBatchGroup : groupList) {
- TacWorkerBParam workerBParam = new TacWorkerBParam();
- workerBParam.setGroupId(tacInspYearBatchGroup.getId());
- workerBParam.setProvince(groupParam.getProvince());
- tacInspYearBatchGroup.setWorkersList(workerBDao.getWorkListByGroupId(workerBParam));
- //获取督查区域
- TacInspYearBatchAreaParam areaParam = new TacInspYearBatchAreaParam();
- areaParam.setGroupId(tacInspYearBatchGroup.getId());
- areaParam.setProvince(groupParam.getProvince());
- List<TacInspYearBatchArea> areaList = this.areaDao.findList(areaParam);
- if (areaList.size() > 0) {
- String str = "";
- for (TacInspYearBatchArea area : areaList) {
- str = str + area.getAdName() + ",";
- }
- if (str.length() > 0) {
- str = str.substring(0, str.length() - 1);
- }
- tacInspYearBatchGroup.setAreas(str);
- }
- TacInspYearBatchObjParam objParam = new TacInspYearBatchObjParam();
- objParam.setGroupId(tacInspYearBatchGroup.getId());
- objParam.setProvince(groupParam.getProvince());
- List<TacInspYearBatchObj> objs = tacInspYearBatchObjDao.findList(objParam);
- tacInspYearBatchGroup.setObjList(objs);
- }
- }
- return groupList;
- }
- @Override
- public List<TacInspYearBatchGroup> getGroupListByPersId(TacInspYearBatchGroupParam groupParam) {
- List<TacInspYearBatchGroup> list = tacInspYearBatchGroupDao.getGroupListByPersId(groupParam);
- if (list.size() > 0) {
- for (TacInspYearBatchGroup tacInspYearBatchGroup : list) {
- TacInspYearBatchAreaParam areaParam = new TacInspYearBatchAreaParam();
- areaParam.setGroupId(tacInspYearBatchGroup.getId());
- areaParam.setProvince(groupParam.getProvince());
- List<TacInspYearBatchArea> areaList = this.areaDao.findList(areaParam);
- tacInspYearBatchGroup.setAreaList(areaList);
- }
- }
- return list;
- }
- @Override
- public List<TacInspYearBatchGroup> getGroupListApp(TacInspYearBatchGroupParam tacInspYearBatchGroupParam) {
- if (StringUtils.isNotBlank(tacInspYearBatchGroupParam.getPersId())) {
- if ("1".equals(rlationPersDao.get(tacInspYearBatchGroupParam.getPersId()).getPersType())) {
- tacInspYearBatchGroupParam.setPersId("");
- }
- }
- List<TacInspYearBatchGroup> list = tacInspYearBatchGroupDao.getGroupListApp(tacInspYearBatchGroupParam);
- if (list.size() > 0) {
- for (TacInspYearBatchGroup tacInspYearBatchGroup : list) {
- TacInspYearBatchAreaParam areaParam = new TacInspYearBatchAreaParam();
- areaParam.setGroupId(tacInspYearBatchGroup.getId());
- areaParam.setProvince(tacInspYearBatchGroupParam.getProvince());
- List<TacInspYearBatchArea> areaList = this.areaDao.findList(areaParam);
- tacInspYearBatchGroup.setAreaList(areaList);
- }
- }
- return list;
- }
- @Override
- public int updateGroupList(TacInspYearBatchGroupDto dto) {
- if (dto == null) {
- return 0;
- }
- if (dto.getGroupList() == null && StringUtils.isBlank(dto.getBatchId())) {
- return 0;
- }
- if (dto.getGroupList() != null) {
- dto.getGroupList().forEach(group -> {
- group.setUpTm(new Date());
- tacInspYearBatchGroupDao.update(group);
- });
- }
- if (StringUtils.isNotBlank(dto.getBatchId())) {
- TacInspYearBatchGroup group = new TacInspYearBatchGroup();
- SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
- group.setYearBatchId(dto.getBatchId());
- try {
- if (StringUtils.isNotBlank(dto.getSttm()) && StringUtils.isNotBlank(dto.getEntm())) {
- group.setStTm(fmt.parse(dto.getSttm()));
- group.setEnTm(fmt.parse(dto.getEntm()));
- int a = tacInspYearBatchGroupDao.updateByBatchId(group);
- }
- } catch (ParseException e) {
- }
- }
- return 0;
- }
- @Override
- public String sendGroupMessage(TacInspYearBatchGroupParam tacInspYearBatchGroupParam) throws Exception {
- List<TacInspYearBatchGroupPers> smsWorkListByGroupId = groupPersDao.getSmsWorkListByGroupId(tacInspYearBatchGroupParam);
- //分组数据
- TacInspYearBatchGroup by = tacInspYearBatchGroupDao.get(tacInspYearBatchGroupParam.getId());
- String sttm= DateUtils.Date2Str(by.getStTm(),"yyyy-MM-dd");
- String entm= DateUtils.Date2Str(by.getEnTm(),"yyyy-MM-dd");
- //获取督查区域
- TacInspYearBatchAreaParam areaParam = new TacInspYearBatchAreaParam();
- areaParam.setGroupId(tacInspYearBatchGroupParam.getId());
- areaParam.setProvince(tacInspYearBatchGroupParam.getProvince());
- List<TacInspYearBatchArea> areaList = this.areaDao.findList(areaParam);
- String areas = "";
- if (areaList.size() > 0) {
- for (TacInspYearBatchArea area : areaList) {
- areas = areas + area.getAdName() + ",";
- }
- if (areas.length() > 0) {
- areas = areas.substring(0, areas.length() - 1);
- }
- }
- TacInspYearBatchObjParam objParam = new TacInspYearBatchObjParam();
- objParam.setGroupId(tacInspYearBatchGroupParam.getId());
- objParam.setProvince(tacInspYearBatchGroupParam.getProvince());
- List<TacInspYearBatchObj> objList = tacInspYearBatchObjDao.getObjAndType(objParam);
- String objs = "";
- if (objList.size() > 0) {
- for (TacInspYearBatchObj obj : objList) {
- objs = objs + obj.getOjbNm() + ",";
- }
- if (areas.length() > 0) {
- objs = objs.substring(0, objs.length() - 1);
- }
- }
- //发送短信
- String resultCode = sendMessageByGroup(smsWorkListByGroupId,sttm,entm, areas, objs);
- //定时任务24小时以后查看短信是否回复状态
- // ReplyTimeout(tacInspYearBatchGroupParam);
- return resultCode;
- }
- /**
- * 排除特定专业后剩余专家是否选中
- *
- * @param smsWorkListByGroupId
- * @return
- *//*
- boolean professionalCoverage(List<TacInspYearBatchGroupPers> smsWorkListByGroupId) {
- List<String> getRoleTypes = new ArrayList<>();
- for (TacInspYearBatchGroupPers tacInspYearBatchGroupPers : smsWorkListByGroupId) {
- if (StringUtils.isNotBlank(tacInspYearBatchGroupPers.getRoleType())) {
- getRoleTypes.add(tacInspYearBatchGroupPers.getRoleType());
- }
- }
- if (getRoleTypes.size() > 0) {
- //排除非必选专业专家,与所分配专家对比。
- //全部专业专家类型特派员:20; 助理:19; 前期专家:11 建管专家:12;计划专家:13;财务专家:14;质量专家:15;安全专家:16
- List<String> professions = Stream.of("11", "12", "13", "14", "15", "16", "19", "20").collect(Collectors.toList());
- List<String> filtrationMajors = Stream.of(filtrationMajor.split(",")).collect(Collectors.toList());
- //去除非必选专业专家
- List<String> collect = professions.stream().filter(s -> filtrationMajors.stream().noneMatch(x -> x.contains(s))).collect(Collectors.toList());
- for (String s : collect) {
- for (String major : getRoleTypes) {
- if (!major.contains(s)) {
- return false;
- }
- }
- }
- return true;
- } else {
- return false;
- }
- }
- */
- String sendMessageByGroup(List<TacInspYearBatchGroupPers> smsWorkListByGroupId,String sttm,String entm, String areas, String objs) throws Exception {
- Map<String, String> params = new HashMap<String, String>();
- params.put("apiKey", apiKey);
- params.put("apiSecrect", apiSecrect);
- params.put("signName", "金水云平台");
- params.put("templeteCode", "SMS_210060995");
- for (TacInspYearBatchGroupPers groupPers : smsWorkListByGroupId) {
- if ("1".equals(groupPers.getIsSms())) {
- continue;
- }
- if (StringUtils.isBlank(groupPers.getPhone())) {
- continue;
- }
- params.put("templateParam", "{\"year\":\"" + groupPers.getYear() + "\",\"batch\":\"" + groupPers.getBatch() + "\",\"groupNm\":\"" + groupPers.getGroupNm() + "\",\"sttm\":\"" + sttm + "\",\"entm\":\"" + entm + "\",\"area\":\"" + areas+ "\",\"objList\":\"" + objs + "\"}");
- params.put("mobile", groupPers.getPhone());
- logger.info("稽察通知短信发送前:" + groupPers.getPhone());
- Map<String, String> headerMap=new HashMap<String, String>();
- // String content = HttpClientUtils.doHttpsPost2(apiUrl + "/api/sms/send", params,headerMap);
- // String content ="{\"success\":true,\"code\":null,\"message\":null,\"path\":null,\"throwable\":null,\"data\":[{\"id\":\"a2397b8cc0464d03b5ac26c3ff1a2289\",\"phoneNumber\":\"17521189449\",\"content\":\"1\",\"sendTime\":1615200000000,\"destCode\":\"2478260\",\"sequenceId\":\"8.39577428E8\"}]}";
- String content = HttpClientUtils.simplePostInvoke(apiUrl + "/gateway/api/sms/send", params);
- // String content="{\"success\":true,\"code\":null,\"message\":null,\"path\":null,\"throwable\":null,\"data\":{\"requestId\":\"42FC6AA4-D083-4393-BE55-30995E545BDF\",\"bizId\":\"831619709317356433^0\",\"code\":\"OK\",\"message\":\"OK\"},\"accessToken\":null}";
- logger.info("稽察通知短信发送后:" + content);
- if(StringUtils.isNotBlank(content)){
- JSONObject jsonContent = JSONObject.fromObject(content);
- if (jsonContent.get("success") != null && (Boolean) jsonContent.get("success")) {
- //修改专家是否已发短信,已通知。
- groupPers.setIsSms("1");
- groupPers.setIsNotice("1");
- groupPers.setNoticeInfo("发送至:" + params.get("mobile") + "," + params.get("templateParam"));
- groupPers.setSendsmsTm(new Date());
- groupPersDao.update(groupPers);
- } else {
- continue;
- }
- }else{
- continue;
- }
- }
- return SmsCodeEnum.SUCCESS.getKey();//短信发送成功
- }
- /*void ReplyTimeout(TacInspYearBatchGroupParam tacInspYearBatchGroupParam) {
- if (replyTimeout > 0) {
- //创建定时任务
- Timer timer = new Timer("发送短信通知定时任务");
- TimerTask task = new TimerTask() {
- @Override
- public void run() {
- System.out.println("短信定时任务开启");
- if (StringUtils.isNotBlank(tacInspYearBatchGroupParam.getYearBatchId()) && StringUtils.isNotBlank(tacInspYearBatchGroupParam.getId())) {
- TacInspYearBatchGroupPersParam tacInspYearBatchGroupPersParam = new TacInspYearBatchGroupPersParam();
- tacInspYearBatchGroupPersParam.setGroupId(tacInspYearBatchGroupParam.getId());
- tacInspYearBatchGroupPersParam.setYearBatchId(tacInspYearBatchGroupParam.getYearBatchId());
- List<TacInspYearBatchGroupPers> list = groupPersDao.findList(tacInspYearBatchGroupPersParam);
- if (list.size() > 0) {
- list.forEach(groupPers -> {
- if ("1".equals(groupPers.getIsNotice()) && "1".equals(groupPers.getIsSms())) {
- if ("0".equals(groupPers.getIsJoin()) || StringUtils.isBlank(groupPers.getIsJoin())) {
- TacInspYearBatchReason tacInspYearBatchReason = new TacInspYearBatchReason();
- tacInspYearBatchReason.setId(UuidUtil.uuid());
- tacInspYearBatchReason.setInTm(new Date());
- tacInspYearBatchReason.setUpTm(new Date());
- //回复超时
- tacInspYearBatchReason.setNinReason("回复超时");
- tacInspYearBatchReasonDao.insert(tacInspYearBatchReason);
- TacInspYearBatchGroupPersParam persParam = new TacInspYearBatchGroupPersParam();
- persParam.setYearBatchId(groupPers.getYearBatchId());
- persParam.setGroupId(groupPers.getId());
- persParam.setPersId(groupPers.getPersId());
- groupPersDao.deleteGroupPersInfo(groupPers);
- }
- }
- });
- }
- }
- }
- };
- timer.schedule(task, replyTimeout);
- }
- }*/
- @Override
- public int confirmerGroup(TacInspYearBatchGroupParam tacInspYearBatchGroupParam) {
- int update = 0;
- TacInspYearBatchGroup tacInspYearBatchGroup = tacInspYearBatchGroupDao.get(tacInspYearBatchGroupParam.getId());
- if (tacInspYearBatchGroup != null) {
- tacInspYearBatchGroup.setConfirmer("1");
- update = tacInspYearBatchGroupDao.update(tacInspYearBatchGroup);
- return update;
- }
- return update;
- }
- }
|