南歧nc65对接修改

This commit is contained in:
hjx
2025-12-06 21:57:17 +08:00
parent 7ff3054dc9
commit 8527d24d48
9 changed files with 121 additions and 22 deletions
@@ -22,9 +22,9 @@ public class ServiceNameConstants
*/ */
public static final String FILE_SERVICE = "mhd-file"; public static final String FILE_SERVICE = "mhd-file";
//public static final String USER_CENTER = "mhd-userCenter-service"; public static final String USER_CENTER = "mhd-userCenter-service";
public static final String USER_CENTER = "http://192.168.0.28:8007"; // public static final String USER_CENTER = "http://192.168.0.28:8007";
public static final String TRANSPORT_CENTER = "mhd-transport-service"; public static final String TRANSPORT_CENTER = "mhd-transport-service";
@@ -226,4 +226,11 @@ public class ReconciliationDTO extends BaseVOEntity{
@ApiModelProperty(value = "运单发票开具状态(0-未索取,1-已索取,2-已开票,3-部分索取)") @ApiModelProperty(value = "运单发票开具状态(0-未索取,1-已索取,2-已开票,3-部分索取)")
private Integer isInvoice; private Integer isInvoice;
@ApiModelProperty("nc同步状态 0-未同步 1-已同步")
private Integer synchronousStatus;
@ApiModelProperty("nc同步状态 0-未同步 1-已同步")
private Integer skSynchronousStatus;
} }
@@ -1025,7 +1025,7 @@ public class UserShipperApplicationService {
} }
public UserShipperPo getShipperSummaryData(Long userId) { public com.mhd.common.core.domain.po.UserShipperPo getShipperSummaryData(Long userId) {
return userShipperDomainService.getShipperSummaryData(userId); return userShipperDomainService.getShipperSummaryData(userId);
} }
} }
@@ -59,5 +59,5 @@ public interface UserShipperRepositoryInterface extends IService<UserShipperEnti
SettlementInfoQueryVo getSettlementInfoByUserId(Long userId); SettlementInfoQueryVo getSettlementInfoByUserId(Long userId);
public UserShipperPo getShipperSummaryData(Long userId); public com.mhd.common.core.domain.po.UserShipperPo getShipperSummaryData(Long userId);
} }
@@ -27,5 +27,5 @@ public interface UserShipperMapper extends BaseMapper<UserShipperEntity> {
List<UserShipperEntity> selectBySealId(@Param("userShipperEntity") UserShipperEntity userShipperEntity); List<UserShipperEntity> selectBySealId(@Param("userShipperEntity") UserShipperEntity userShipperEntity);
public UserShipperPo getShipperSummaryData(Long userId); public com.mhd.common.core.domain.po.UserShipperPo getShipperSummaryData(Long userId);
} }
@@ -163,7 +163,7 @@ public class UserShipperRepositoryImpl extends ServiceImpl<UserShipperMapper, Us
} }
@Override @Override
public UserShipperPo getShipperSummaryData(Long userId) { public com.mhd.common.core.domain.po.UserShipperPo getShipperSummaryData(Long userId) {
return shipperMapper.getShipperSummaryData(userId); return shipperMapper.getShipperSummaryData(userId);
} }
} }
@@ -224,7 +224,7 @@ public class UserShipperDomainService {
return userShipperRepositoryInterface.getSettlementInfoByUserId(userId); return userShipperRepositoryInterface.getSettlementInfoByUserId(userId);
} }
public UserShipperPo getShipperSummaryData(Long userId) { public com.mhd.common.core.domain.po.UserShipperPo getShipperSummaryData(Long userId) {
return userShipperRepositoryInterface.getShipperSummaryData(userId); return userShipperRepositoryInterface.getShipperSummaryData(userId);
} }
} }
@@ -379,7 +379,7 @@
</select> </select>
<select id="getShipperSummaryData" parameterType="java.lang.Long" <select id="getShipperSummaryData" parameterType="java.lang.Long"
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo"> resultType="com.mhd.common.core.domain.po.UserShipperPo">
<include refid="selectShipperVo1"/> <include refid="selectShipperVo1"/>
and b.user_id = #{value} and b.user_id = #{value}
group by b.user_id group by b.user_id
@@ -388,14 +388,39 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
String [] businessDocumentDetaliIdArray=businessDocumentDetaliIds.split(","); String [] businessDocumentDetaliIdArray=businessDocumentDetaliIds.split(",");
LoginUser loginUser= SecurityUtils.getLoginUser(); LoginUser loginUser= SecurityUtils.getLoginUser();
UserPo userPo=loginUser.getUserPo(); UserPo userPo=loginUser.getUserPo();
ObjectMapper mapper = new ObjectMapper();
AjaxResult ajaxResult5=userServiceFeign.getInfo(loginUser.getUserid());
if(ajaxResult5.get("code").toString().equals("200")){
Object userShipperPo= ajaxResult5.get("data");
JSONObject jsonObject = new JSONObject((Map) userShipperPo);
try {
String jsonString = mapper.writeValueAsString(jsonObject);
userPo = mapper.readValue(jsonString, UserPo.class);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}else{
throw new ServiceException("查询当前登录人用户信息失败");
}
if (org.apache.commons.lang.StringUtils.isBlank(userPo.getSalespersonNcCode())) {
throw new ServiceException("请先维护业务员编码");
}
if (org.apache.commons.lang.StringUtils.isBlank(userPo.getDocumentPreparerNcCode())) {
throw new ServiceException("请先维护制单员编码");
}
for (String businessDocumentDetaliId:businessDocumentDetaliIdArray){ for (String businessDocumentDetaliId:businessDocumentDetaliIdArray){
Reconciliation reconciliation=reconciliationMapper.selectById(businessDocumentDetaliId); Reconciliation reconciliation=reconciliationMapper.selectById(businessDocumentDetaliId);
if(reconciliation.getSynchronousStatus()==1){ if(reconciliation.getSynchronousStatus()==1){
throw new ServiceException("该记录已同步,不需要再次同步"); throw new ServiceException("该记录已同步,不需要再次同步");
} }
if(reconciliation.getIsInvoice()!=2){
/* if(reconciliation.getIsInvoice()!=2){
throw new ServiceException("该记录还未开票,不允许同步"); throw new ServiceException("该记录还未开票,不允许同步");
} }*/
try { try {
Date date = reconciliation.getCreateTime(); Date date = reconciliation.getCreateTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -413,20 +438,31 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
R<TmsTransportNote> ajaxResult1=wlhyServiceFeign.selectByOrderNum(tmsOrder.getGoodsNumber()); R<TmsTransportNote> ajaxResult1=wlhyServiceFeign.selectByOrderNum(tmsOrder.getGoodsNumber());
if(ajaxResult1.getCode()==200){ if(ajaxResult1.getCode()==200){
TmsTransportNote tmsTransportNote= ajaxResult1.getData(); TmsTransportNote tmsTransportNote= ajaxResult1.getData();
date=tmsTransportNote.getPaperReceiptTime(); if(ObjectUtil.isNotNull(tmsTransportNote.getIsPaper())){
date=tmsTransportNote.getConfirmReceiptTime();
dateString = sdf.format(date); dateString = sdf.format(date);
}else{
throw new ServiceException("运单还没签收, 先签收");
}
}
if(null==reconciliation.getSettlementPartyId()){
throw new ServiceException("没有结算方,请核对");
} }
AjaxResult ajaxResult=userServiceFeign.getShipperSummaryData(Long.valueOf(reconciliation.getSettlementPartyId())); AjaxResult ajaxResult=userServiceFeign.getShipperSummaryData(Long.valueOf(reconciliation.getSettlementPartyId()));
if(ajaxResult.get("code").equals("200")){ if(ajaxResult.get("code").toString().equals("200")){
UserShipperPo userShipperPo= (UserShipperPo) ajaxResult.get("data"); Object userShipperPo= ajaxResult.get("data");
JSONObject jsonObject = new JSONObject((Map) userShipperPo);
if(org.apache.commons.lang.StringUtils.isBlank(jsonObject.get("customerNcCode").toString())){
throw new ServiceException("请先维护客户编码");
}
Ysitem item=new Ysitem(); Ysitem item=new Ysitem();
item.setSo_deptid("NG040104"); item.setSo_deptid("NG040104");
item.setPk_deptid("NG040104"); item.setPk_deptid("NG040104");
item.setPk_psndoc(userPo.getSalespersonNcCode()); item.setPk_psndoc(userPo.getSalespersonNcCode());
item.setCustomer(userShipperPo.getCustomerNcCode()); item.setCustomer(jsonObject.get("customerNcCode").toString());
item.setObjtype("0"); item.setObjtype("0");
item.setDirection("1"); item.setDirection("1");
item.setScomment(userShipperPo.getShipperEnterpriseName()); item.setScomment(jsonObject.get("shipperEnterpriseName").toString());
item.setPk_currtype("CNY"); item.setPk_currtype("CNY");
item.setPurchaseorder(tmsOrder.getGoodsNumber()); item.setPurchaseorder(tmsOrder.getGoodsNumber());
item.setTaxrate("0"); item.setTaxrate("0");
@@ -458,6 +494,8 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
billhead.setPk_tradetype("D0"); billhead.setPk_tradetype("D0");
billhead.setBillclass("ys"); billhead.setBillclass("ys");
billhead.setIsinit("N"); billhead.setIsinit("N");
date=reconciliation.getCreateTime();
dateString = sdf.format(date);
billhead.setBilldate(dateString); billhead.setBilldate(dateString);
billhead.setSyscode("0"); billhead.setSyscode("0");
billhead.setBillno(""); billhead.setBillno("");
@@ -540,17 +578,45 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
String [] businessDocumentDetaliIdArray=businessDocumentDetaliIds.split(","); String [] businessDocumentDetaliIdArray=businessDocumentDetaliIds.split(",");
LoginUser loginUser= SecurityUtils.getLoginUser(); LoginUser loginUser= SecurityUtils.getLoginUser();
UserPo userPo=loginUser.getUserPo(); UserPo userPo=loginUser.getUserPo();
ObjectMapper mapper = new ObjectMapper();
AjaxResult ajaxResult5=userServiceFeign.getInfo(loginUser.getUserid());
if(ajaxResult5.get("code").toString().equals("200")){
Object userShipperPo= ajaxResult5.get("data");
JSONObject jsonObject = new JSONObject((Map) userShipperPo);
try {
String jsonString = mapper.writeValueAsString(jsonObject);
userPo = mapper.readValue(jsonString, UserPo.class);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}else{
throw new ServiceException("查询当前登录人用户信息失败");
}
if (org.apache.commons.lang.StringUtils.isBlank(userPo.getSalespersonNcCode())) {
throw new ServiceException("请先维护业务员编码");
}
if (org.apache.commons.lang.StringUtils.isBlank(userPo.getDocumentPreparerNcCode())) {
throw new ServiceException("请先维护制单员编码");
}
for (String businessDocumentDetaliId:businessDocumentDetaliIdArray){ for (String businessDocumentDetaliId:businessDocumentDetaliIdArray){
Reconciliation reconciliation=reconciliationMapper.selectById(businessDocumentDetaliId); Reconciliation reconciliation=reconciliationMapper.selectById(businessDocumentDetaliId);
if(reconciliation.getSkSynchronousStatus()==1){ if(reconciliation.getSkSynchronousStatus()==1){
throw new ServiceException("该记录已同步,不需要再次同步"); throw new ServiceException("该记录已同步,不需要再次同步");
} }
if(reconciliation.getIsInvoice()!=2){ /* if(reconciliation.getIsInvoice()!=2){
throw new ServiceException("该记录还未开票,不允许同步"); throw new ServiceException("该记录还未开票,不允许同步");
} }*/
if(reconciliation.getCollectionState()!=2){ if(reconciliation.getCollectionState()!=2){
throw new ServiceException("该记录还未结算完成,不允许同步"); throw new ServiceException("该记录还未结算完成,不允许同步");
} }
/* if(org.apache.commons.lang.StringUtils.isBlank(userPo.getSalespersonNcCode())){
throw new ServiceException("请先维护业务员编码");
}
if(org.apache.commons.lang.StringUtils.isBlank(userPo.getDocumentPreparerNcCode())){
throw new ServiceException("请先维护制单员编码");
}*/
try { try {
Date date = reconciliation.getCreateTime(); Date date = reconciliation.getCreateTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -565,19 +631,26 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
List<TmsOrder> list=result.getData(); List<TmsOrder> list=result.getData();
if(ObjectUtil.isNotNull(list)){ if(ObjectUtil.isNotNull(list)){
for(TmsOrder tmsOrder:list){ for(TmsOrder tmsOrder:list){
if(null==reconciliation.getSettlementPartyId()){
throw new ServiceException("没有结算方,请核对");
}
AjaxResult ajaxResult=userServiceFeign.getShipperSummaryData(Long.valueOf(reconciliation.getSettlementPartyId())); AjaxResult ajaxResult=userServiceFeign.getShipperSummaryData(Long.valueOf(reconciliation.getSettlementPartyId()));
if(ajaxResult.get("code").equals("200")){ if(ajaxResult.get("code").toString().equals("200")){
UserShipperPo userShipperPo= (UserShipperPo) ajaxResult.get("data"); Object userShipperPo= ajaxResult.get("data");
JSONObject jsonObject = new JSONObject((Map) userShipperPo);
if(org.apache.commons.lang.StringUtils.isBlank(jsonObject.get("customerNcCode").toString())){
throw new ServiceException("请先维护客户编码");
}
SKitem item=new SKitem(); SKitem item=new SKitem();
item.setSo_deptid("NG040104"); item.setSo_deptid("NG040104");
item.setPk_deptid("NG040104"); item.setPk_deptid("NG040104");
item.setCheckdirection("ar"); item.setCheckdirection("ar");
item.setPk_psndoc(userPo.getSalespersonNcCode()); item.setPk_psndoc(userPo.getSalespersonNcCode());
item.setCustomer(userShipperPo.getCustomerNcCode()); item.setCustomer(jsonObject.get("customerNcCode").toString());
item.setPurchaseorder(tmsOrder.getGoodsNumber()); item.setPurchaseorder(tmsOrder.getGoodsNumber());
item.setObjtype("0"); item.setObjtype("0");
item.setDirection("1"); item.setDirection("1");
item.setScomment(userShipperPo.getShipperEnterpriseName()); item.setScomment(jsonObject.get("shipperEnterpriseName").toString());
item.setPk_currtype("CNY"); item.setPk_currtype("CNY");
item.setMoney_cr(String.valueOf(tmsOrder.getCollectedFreight())); item.setMoney_cr(String.valueOf(tmsOrder.getCollectedFreight()));
item.setMoney_bal(String.valueOf(tmsOrder.getCollectedFreight())); item.setMoney_bal(String.valueOf(tmsOrder.getCollectedFreight()));
@@ -650,6 +723,25 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
reconciliation.setSkSynchronousTime(new Date()); reconciliation.setSkSynchronousTime(new Date());
reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getReconciliationId())); reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getReconciliationId()));
reconciliationMapper.updateById(reconciliation); reconciliationMapper.updateById(reconciliation);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
StringEntity postingString = new StringEntity(xmlString, "UTF-8");
httpPost.setEntity(postingString);
httpPost.setHeader("Content-type", "application/xml");
try {
CloseableHttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString);
response.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (JAXBException e) { } catch (JAXBException e) {
e.printStackTrace(); e.printStackTrace();
} }