修改商业合作伙伴推送-各组织独立问题
This commit is contained in:
@@ -213,7 +213,8 @@ public interface UserServiceFeign {
|
||||
@RequestParam(value = "pushStatus", required = false) Integer pushStatus,
|
||||
@RequestParam(value = "pushTime", required = false) String pushTime,
|
||||
@RequestParam(value = "pushBy", required = false) Long pushBy,
|
||||
@RequestParam(value = "pushByName", required = false) String pushByName);
|
||||
@RequestParam(value = "pushByName", required = false) String pushByName,
|
||||
@RequestParam(value = "organizationId") Long organizationId);
|
||||
|
||||
@PostMapping("/userShipperApi/getCustomerNcCodeBatch")
|
||||
AjaxResult getCustomerNcCodeBatch(@RequestBody List<Long> shipperIdList);
|
||||
|
||||
+1
-1
@@ -203,7 +203,7 @@ public class RemoteUserFeignFallbackFactory implements FallbackFactory<UserServi
|
||||
|
||||
|
||||
@Override
|
||||
public AjaxResult<?> updatePushStatus(Long shipperId, Integer pushStatus, String pushTime, Long pushBy, String pushByName) {
|
||||
public AjaxResult<?> updatePushStatus(Long shipperId, Integer pushStatus, String pushTime, Long pushBy, String pushByName, Long organizationId) {
|
||||
return AjaxResult.error("更新失败" + throwable.getMessage());
|
||||
}
|
||||
|
||||
|
||||
+44
-15
@@ -26,6 +26,8 @@ import com.mhd.system.api.FinanceServiceFeign;
|
||||
import com.mhd.system.api.WlhyServiceFeign;
|
||||
import com.mhd.system.api.event.object.ShipperNameChangedEvent;
|
||||
import com.mhd.system.api.service.webSocket.AsyncWebSocketApplicationService;
|
||||
import com.mhd.user.domain.businessPartnerPushLog.entity.BusinessPartnerPushLog;
|
||||
import com.mhd.user.domain.businessPartnerPushLog.repository.mapper.BusinessPartnerPushLogMapper;
|
||||
import com.mhd.user.domain.roleAggregate.entity.RoleEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleDo;
|
||||
import com.mhd.user.domain.roleAggregate.service.RoleDomainService;
|
||||
@@ -117,6 +119,9 @@ public class UserShipperApplicationService {
|
||||
@Resource
|
||||
private UserShipperMapper userShipperMapper;
|
||||
|
||||
@Resource
|
||||
private BusinessPartnerPushLogMapper businessPartnerPushLogMapper;
|
||||
|
||||
/**
|
||||
* @Description 查询托运人列表
|
||||
* @Author Alex
|
||||
@@ -1223,23 +1228,47 @@ public class UserShipperApplicationService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送状态更新
|
||||
* @param shipperId
|
||||
* @param pushStatus
|
||||
* @param pushTime
|
||||
* @param pushBy
|
||||
* @return
|
||||
* 推送状态更新(按 shipper_id + organization_id 维度,支持多组织独立推送)
|
||||
*/
|
||||
public int updatePushStatus(Long shipperId, Integer pushStatus, String pushTime, Long pushBy,String pushByName) {
|
||||
UserShipperEntity userShipper = new UserShipperEntity();
|
||||
userShipper.setShipperId(shipperId);
|
||||
userShipper.setPushStatus(pushStatus);
|
||||
if (pushTime != null && !"".equals(pushTime)) {
|
||||
userShipper.setPushTime(DateUtil.parse(pushTime));
|
||||
public int updatePushStatus(Long shipperId, Integer pushStatus, String pushTime, Long pushBy, String pushByName, Long organizationId) {
|
||||
// 查询是否已有该组织对该货主的推送记录
|
||||
BusinessPartnerPushLog pushLog =
|
||||
businessPartnerPushLogMapper.selectOne(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<BusinessPartnerPushLog>()
|
||||
.eq(BusinessPartnerPushLog::getShipperId, shipperId)
|
||||
.eq(BusinessPartnerPushLog::getOrganizationId, organizationId)
|
||||
.eq(BusinessPartnerPushLog::getDelFlag, 1)
|
||||
);
|
||||
|
||||
Date now = new Date();
|
||||
Date pushDate = (pushTime != null && !"".equals(pushTime)) ? DateUtil.parse(pushTime) : now;
|
||||
|
||||
if (pushLog != null) {
|
||||
// 已有记录 → 更新
|
||||
pushLog.setPushStatus(pushStatus);
|
||||
pushLog.setPushTime(pushDate);
|
||||
pushLog.setPushBy(pushBy);
|
||||
pushLog.setPushByName(pushByName);
|
||||
pushLog.setUpdateTime(now);
|
||||
pushLog.setUpdateBy(pushBy);
|
||||
return businessPartnerPushLogMapper.updateById(pushLog) > 0 ? 1 : 0;
|
||||
} else {
|
||||
// 没有记录 → 新增
|
||||
BusinessPartnerPushLog newLog =
|
||||
new BusinessPartnerPushLog();
|
||||
newLog.setShipperId(shipperId);
|
||||
newLog.setOrganizationId(organizationId);
|
||||
newLog.setPushStatus(pushStatus);
|
||||
newLog.setPushTime(pushDate);
|
||||
newLog.setPushBy(pushBy);
|
||||
newLog.setPushByName(pushByName);
|
||||
newLog.setDelFlag(1);
|
||||
newLog.setCreateTime(now);
|
||||
newLog.setCreateBy(pushBy);
|
||||
newLog.setUpdateTime(now);
|
||||
newLog.setUpdateBy(pushBy);
|
||||
return businessPartnerPushLogMapper.insert(newLog) > 0 ? 1 : 0;
|
||||
}
|
||||
userShipper.setPushBy(pushBy);
|
||||
userShipper.setPushByName(pushByName);
|
||||
return userShipperMapper.updatePushStatus(userShipper);
|
||||
}
|
||||
|
||||
public UserShipperPo findByCustomerNcCodeAndOrganizationId(String customerNcCode, Long organizationId) {
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.mhd.user.domain.businessPartnerPushLog.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商业合作伙伴推送日志
|
||||
* 按 (shipper_id + organization_id) 维度记录每个组织的独立推送状态
|
||||
*/
|
||||
@Data
|
||||
@TableName("business_partner_push_log")
|
||||
public class BusinessPartnerPushLog {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 货主ID */
|
||||
private Long shipperId;
|
||||
|
||||
/** 组织ID */
|
||||
private Long organizationId;
|
||||
|
||||
/** 组织名称 */
|
||||
private String organizationName;
|
||||
|
||||
/** 推送人ID */
|
||||
private Long pushBy;
|
||||
|
||||
/** 推送人姓名 */
|
||||
private String pushByName;
|
||||
|
||||
/** 推送状态:1-未推送 2-推送中 3-推送成功 4-推送失败 */
|
||||
private Integer pushStatus;
|
||||
|
||||
/** 推送时间 */
|
||||
private Date pushTime;
|
||||
|
||||
/** 删除标志 */
|
||||
private Integer delFlag;
|
||||
|
||||
private Date createTime;
|
||||
private Long createBy;
|
||||
private Date updateTime;
|
||||
private Long updateBy;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.mhd.user.domain.businessPartnerPushLog.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhd.user.domain.businessPartnerPushLog.entity.BusinessPartnerPushLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BusinessPartnerPushLogMapper extends BaseMapper<BusinessPartnerPushLog> {
|
||||
}
|
||||
@@ -241,16 +241,17 @@ public class UserShipperAPI extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("商业合作伙伴-更新推送状态")
|
||||
@ApiOperation("商业合作伙伴-更新推送状态(支持多组织独立推送)")
|
||||
@PostMapping("/updatePushStatus")
|
||||
public AjaxResult updatePushStatus(@RequestParam("shipperId") Long shipperId,
|
||||
@RequestParam("pushStatus") Integer pushStatus,
|
||||
@RequestParam(value = "pushTime", required = false) String pushTime,
|
||||
@RequestParam(value = "pushBy", required = false) Long pushBy,
|
||||
@RequestParam(value = "pushByName", required = false) String pushByName){
|
||||
@RequestParam(value = "pushByName", required = false) String pushByName,
|
||||
@RequestParam("organizationId") Long organizationId){
|
||||
|
||||
try{
|
||||
int result = userShipperApplicationService.updatePushStatus(shipperId,pushStatus,pushTime,pushBy,pushByName);
|
||||
int result = userShipperApplicationService.updatePushStatus(shipperId, pushStatus, pushTime, pushBy, pushByName, organizationId);
|
||||
return result > 0 ? AjaxResult.success() : AjaxResult.error("更新失败");
|
||||
}catch (Exception e){
|
||||
log.error("更新推送状态异常: shipperId = {} , error = ", e.getMessage());
|
||||
|
||||
+9
-9
@@ -124,7 +124,7 @@ public class BusinessPartnerApplicationService {
|
||||
gwLog.setDelFlag(1);
|
||||
gwLogMapper.insert(gwLog);
|
||||
|
||||
updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()),2,new Date(),pushBy,pushByName);
|
||||
updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()),2, new Date(), pushBy, pushByName, organizationId);
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(pushUrl);
|
||||
@@ -140,7 +140,7 @@ public class BusinessPartnerApplicationService {
|
||||
|
||||
if(response.getStatusLine().getStatusCode() == 200){
|
||||
// gwLog.setStatus(2);
|
||||
// updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()),3, new Date(), pushBy,pushByName);
|
||||
// updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()),3, new Date(), pushBy,pushByName, organizationId);
|
||||
// successCount++;
|
||||
// 解析返回内容
|
||||
JSONObject responseJson = JSONObject.parseObject(responseString);
|
||||
@@ -150,19 +150,19 @@ public class BusinessPartnerApplicationService {
|
||||
|
||||
if (dataCode != null && dataCode == 200) { // 业务也成功
|
||||
gwLog.setStatus(2);
|
||||
updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()), 3, new Date(), pushBy, pushByName);
|
||||
updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()),3, new Date(), pushBy, pushByName, organizationId);
|
||||
successCount++;
|
||||
} else {
|
||||
gwLog.setStatus(3);
|
||||
gwLog.setErrorMsg(responseString);
|
||||
updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()), 4, new Date(), pushBy, pushByName);
|
||||
updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()),4, new Date(), pushBy, pushByName, organizationId);
|
||||
failCount++;
|
||||
failMsg.append("CorpCode:").append(businessPartnerDTO.getCorpCode()).append("失败;");
|
||||
}
|
||||
}else{
|
||||
gwLog.setStatus(3);
|
||||
gwLog.setErrorMsg(responseString);
|
||||
updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()),4, new Date(), pushBy,pushByName);
|
||||
updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()),4, new Date(), pushBy,pushByName, organizationId);
|
||||
failCount++;
|
||||
failMsg.append("CorpCode:").append(businessPartnerDTO.getCorpCode()).append("失败:");
|
||||
}
|
||||
@@ -176,7 +176,7 @@ public class BusinessPartnerApplicationService {
|
||||
gwLog.setErrorMsg(e.getMessage());
|
||||
gwLog.setResponseBody("请求异常:" + e.getMessage());
|
||||
gwLogMapper.updateById(gwLog);
|
||||
updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()),4, new Date(), pushBy,pushByName);
|
||||
updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()),4, new Date(), pushBy,pushByName, organizationId);
|
||||
failCount++;
|
||||
failMsg.append("CorpCode:").append(businessPartnerDTO.getCorpCode()).append("异常:").append(e.getMessage()).append(":");
|
||||
log.error("GW推送异常:shipperId={}, error={}",businessPartnerDTO.getShipperId(),e.getMessage());
|
||||
@@ -202,11 +202,11 @@ public class BusinessPartnerApplicationService {
|
||||
|
||||
|
||||
|
||||
private void updatePushStatus(Long shipperId, Integer pushStatus, Date pushTime, Long pushBy,String pushByName) {
|
||||
private void updatePushStatus(Long shipperId, Integer pushStatus, Date pushTime, Long pushBy, String pushByName, Long organizationId) {
|
||||
try {
|
||||
// 调用user-center的Feign接口,更新货主的推送状态
|
||||
// 调用user-center的Feign接口,写入 business_partner_push_log 表(按 shipper_id + organization_id 维度)
|
||||
String pushTimeStr = pushTime != null ? DateUtil.format(pushTime, "yyyy-MM-dd HH:mm:ss") : null;
|
||||
AjaxResult result = userServiceFeign.updatePushStatus(shipperId, pushStatus, pushTimeStr, pushBy, pushByName);
|
||||
AjaxResult result = userServiceFeign.updatePushStatus(shipperId, pushStatus, pushTimeStr, pushBy, pushByName, organizationId);
|
||||
log.info("更新返回结果:{}",result);
|
||||
} catch (Exception e) {
|
||||
// 如果更新失败,记录错误日志,但不阻断主流程
|
||||
|
||||
Reference in New Issue
Block a user