| | |
| | | package cn.huge.module.grid.service; |
| | | |
| | | import cn.huge.base.common.bo.R; |
| | | import cn.huge.base.common.exception.ServiceException; |
| | | import cn.huge.base.common.utils.DateUtils; |
| | | import cn.huge.base.common.utils.HttpClientUtils; |
| | | import cn.huge.base.common.utils.IdUtils; |
| | | import cn.huge.base.common.utils.ObjectUtils; |
| | | import cn.huge.module.client.api.impl.CustClientImpl; |
| | | import cn.huge.module.client.api.impl.UtilsClientImpl; |
| | | import cn.huge.module.cust.dto.CtUserDTO; |
| | | import cn.huge.module.file.domain.po.FileInfo; |
| | | import cn.huge.module.file.service.FileInfoService; |
| | | import cn.huge.module.grid.dao.mapper.GridEventMapper; |
| | | import cn.huge.module.grid.domain.dto.GridFileUploadDTO; |
| | | import cn.huge.module.grid.domain.dto.GridOrgDTO; |
| | | import cn.huge.module.grid.domain.po.GridEvent; |
| | | import cn.huge.module.grid.domain.vo.*; |
| | | import cn.huge.module.sys.dto.FileInfoBaseDTO; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.PageImpl; |
| | | import org.springframework.data.domain.PageRequest; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author wangwh |
| | |
| | | |
| | | @Autowired |
| | | private UtilsClientImpl utilsClient; |
| | | |
| | | @Autowired |
| | | private GridCaseTaskService gridCaseTaskService; |
| | | |
| | | @Autowired |
| | | private GridCaseDataService gridCaseDataService; |
| | | |
| | | @Autowired |
| | | private GridUserService gridUserService; |
| | | |
| | | @Autowired |
| | | private CustClientImpl custClient; |
| | | |
| | | @Autowired |
| | | private FileInfoService fileInfoService; |
| | | |
| | | @Value("${grid.url:http://219.137.166.84:8061}") |
| | | private String gridUrl; |
| | | @Value("${grid.username:mtxt0011}") |
| | | private String userName; |
| | | @Value("${grid.password}") |
| | | private String passWord; |
| | | @Value("${grid.secret:BZb2hLCx05}") |
| | | private String secret; |
| | | @Value("${grid.passid:b08c0ec0-772d-caf8-5c9b-1f7d86295a95}") |
| | | private String passid; |
| | | public HashMap<String,String> initHeadVo() { |
| | | long timestamp = System.currentTimeMillis()/1000; |
| | | HashMap<String,String> headVo = new HashMap<>(); |
| | | headVo.put("x-rio-paasid",passid); |
| | | headVo.put("x-rio-timestamp",timestamp+""); |
| | | headVo.put("x-rio-nonce","mt"); |
| | | headVo.put("x-rio-signature", DigestUtils.sha256Hex(timestamp+secret+"mt"+timestamp)); |
| | | return headVo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新对象 |
| | |
| | | public GridEvent getEventByCaseId(String caseId) { |
| | | return mapper.getEventByCaseId(caseId); |
| | | } |
| | | |
| | | /** |
| | | * 同步矛纠工单的办理反馈信息 |
| | | * |
| | | * @param saveEventFeedBackVo |
| | | * @return |
| | | */ |
| | | public R<Object> saveEventFeedback(SaveEventFeedBackVo saveEventFeedBackVo) { |
| | | HashMap<String,String> headVo= initHeadVo(); |
| | | try{ |
| | | // 传递过来的是子平台的id,需要转换为大平台的id |
| | | String appOrgId = saveEventFeedBackVo.getAppOrgId(); |
| | | |
| | | String appGridUnitId = null; |
| | | if (StringUtils.isNotBlank(appOrgId)) { |
| | | appGridUnitId = gridCaseTaskService.getGridUnitIdByUnitId(saveEventFeedBackVo.getAppOrgId()); |
| | | saveEventFeedBackVo.setAppOrgId(appGridUnitId); |
| | | if (StringUtils.isBlank(appGridUnitId)) { |
| | | throw new Exception("矛纠工单的办理反馈信息的组织不存在"); |
| | | } |
| | | } |
| | | // else { |
| | | // saveEventFeedBackVo.setAppOrgId(gridEvent.getSysOrgId()); |
| | | // saveEventFeedBackVo.setAppOrgName(gridEvent.getSysOrgName()); |
| | | // } |
| | | log.info("当前环节组织:" + saveEventFeedBackVo.getAppOrgId()); |
| | | |
| | | if (StringUtils.isNotBlank(saveEventFeedBackVo.getAppUserId())) { |
| | | CtUserDTO ctUserDTO = custClient.clientGetUserAll(saveEventFeedBackVo.getAppUserId()); |
| | | if (ObjectUtils.isNotEmpty(ctUserDTO)) { |
| | | if (StringUtils.isNotBlank(ctUserDTO.getIdcard())) { |
| | | GridUserIdNumberVo gridUserIdNumberVo = new GridUserIdNumberVo(); |
| | | gridUserIdNumberVo.setIdNumber(ctUserDTO.getIdcard()); |
| | | R<GridUserVo> result = gridUserService.getUserByIdNumber(gridUserIdNumberVo); |
| | | if (R.SUCCESS == result.getCode()) { |
| | | saveEventFeedBackVo.setAppUserId(result.getData().getId()); |
| | | log.info("当前环节审批用户为: " + saveEventFeedBackVo.getAppUserId()); |
| | | } else { |
| | | saveEventFeedBackVo.setAppUserId("a9406a88c8234cda82452799bf6bd6cd"); |
| | | log.info("当前环节审批用户为特殊用户,身份证找不到用户{},{}", ctUserDTO.getIdcard(), ctUserDTO.getTrueName()); |
| | | } |
| | | } else { |
| | | saveEventFeedBackVo.setAppUserId("a9406a88c8234cda82452799bf6bd6cd"); |
| | | log.info("当前环节审批用户为特殊用户,找不到用户{}", saveEventFeedBackVo.getAppUserId()); |
| | | } |
| | | } else { |
| | | saveEventFeedBackVo.setAppUserId("a9406a88c8234cda82452799bf6bd6cd"); |
| | | log.info("当前环节审批用户为特殊用户,找不到用户{}", saveEventFeedBackVo.getAppUserId()); |
| | | } |
| | | } else { |
| | | saveEventFeedBackVo.setAppUserId("a9406a88c8234cda82452799bf6bd6cd"); |
| | | log.info("矛纠工单的办理反馈信息的用户为特殊用户"); |
| | | } |
| | | |
| | | // 判断附件不为空 |
| | | List<FileInfoBaseDTO> fileInfoList = saveEventFeedBackVo.getFileInfoList(); |
| | | if (!CollectionUtils.isEmpty(fileInfoList)){ |
| | | List<GridFileRelatedVo> feedbackAttrInfos = new ArrayList<>(); |
| | | log.info("获取到矛纠工单的办理反馈信息的附件上传:" + fileInfoList.size()); |
| | | for (FileInfoBaseDTO fileInfoBaseDTO : fileInfoList) { |
| | | try { |
| | | GridFileUploadVo gridFileUploadVo = new GridFileUploadVo(); |
| | | // 通过id获取文件信息 |
| | | FileInfo fileInfo = fileInfoService.getById(fileInfoBaseDTO.getId()); |
| | | |
| | | gridFileUploadVo.setFileName(fileInfo.getFileName()); |
| | | gridFileUploadVo.setFilePath(fileInfo.getFullPath()); |
| | | gridFileUploadVo.setFileSize(fileInfo.getSize() != null ? fileInfo.getSize().longValue() : 0L); |
| | | gridFileUploadVo.setType(fileInfo.getSuffix()); |
| | | R<GridFileUploadDTO> result = null; |
| | | //上传附件信息 |
| | | result = gridCaseDataService.uploadFileInfo(gridFileUploadVo); |
| | | if (R.SUCCESS == result.getCode()) { |
| | | //获取上传结果,组成新的附件对象 |
| | | GridFileUploadDTO gridFileUploadDTO = result.getData(); |
| | | GridFileRelatedVo gridFileRelatedVo = new GridFileRelatedVo(); |
| | | gridFileRelatedVo.setFileName(gridFileUploadDTO.getFileName()); |
| | | gridFileRelatedVo.setFilePath(gridFileUploadDTO.getFilePath()); |
| | | gridFileRelatedVo.setOriginalFileName(gridFileUploadDTO.getOriginalFileName()); |
| | | gridFileRelatedVo.setFileSize(gridFileUploadDTO.getFileSize()); |
| | | gridFileRelatedVo.setType("add"); |
| | | gridFileRelatedVo.setFileType(gridFileUploadDTO.getFileType()); |
| | | feedbackAttrInfos.add(gridFileRelatedVo); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.info("附件上传失败:" + fileInfoBaseDTO.getId()); |
| | | } |
| | | } |
| | | |
| | | // 上传完成后设置原附件列表为空 |
| | | saveEventFeedBackVo.setFileInfoList(null); |
| | | } |
| | | |
| | | |
| | | // 发起请求 |
| | | log.info("办理反馈信息-xsd:{}", JSON.toJSONString(saveEventFeedBackVo)); |
| | | log.info("办理反馈信息-xsd:{}", gridUrl + "/standard/eventform/saveFeedback"); |
| | | String s = null; |
| | | try { |
| | | s = HttpClientUtils.httpPostRaw(gridUrl + "/standard/eventform/saveFeedback", JSON.toJSONString(saveEventFeedBackVo), headVo, "utf-8"); |
| | | } catch (Exception e) { |
| | | log.info("xsderror:{}", e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("xsd:{}", s); |
| | | |
| | | // |
| | | JSONObject object = JSONObject.parseObject(s); |
| | | if (object.getInteger("code") != null && object.getInteger("code") == 0) { |
| | | log.info("同步矛纠工单的办理反馈信息成功!"); |
| | | Object data = object.get("data"); |
| | | return R.ok(data); |
| | | } else { |
| | | log.info("同步矛纠工单的办理反馈信息失败,错误原因:" + object.getString("message")); |
| | | return R.fail("同步矛纠工单的办理反馈信息失败"); |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("同步矛纠工单的办理反馈信息报错",e); |
| | | } |
| | | return R.fail("同步矛纠工单的办理反馈信息失败"); |
| | | |
| | | } |
| | | } |