no message

This commit is contained in:
2025-09-05 17:31:29 +08:00
parent 67bdcd22f0
commit 315f9f8d97
7 changed files with 105 additions and 14 deletions

View File

@ -9,6 +9,7 @@ import com.sczx.sync.mapper.CompanyStoreMapper;
import com.sczx.sync.service.SendDataService; import com.sczx.sync.service.SendDataService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -68,6 +69,7 @@ public class SendDataController {
return sendDataService.sendSubOrderToBattery(Long.parseLong(id)); return sendDataService.sendSubOrderToBattery(Long.parseLong(id));
} }
// //
// @ApiOperation(value = "接收需同步数据接口") // @ApiOperation(value = "接收需同步数据接口")
// @GetMapping("/companyinfo") // @GetMapping("/companyinfo")

View File

@ -27,6 +27,8 @@ public interface CompanyInfoMapper extends BaseMapper<CompanyInfo> {
*/ */
CompanyInfo selectByOpId(@Param("bOpId") Long bOpId); CompanyInfo selectByOpId(@Param("bOpId") Long bOpId);
CompanyInfo selectByCompanyName(CompanyInfo companyInfo);
/** /**
* 根据电话号码更新公司信息 * 根据电话号码更新公司信息
* @param companyInfo 公司信息 * @param companyInfo 公司信息
@ -34,6 +36,8 @@ public interface CompanyInfoMapper extends BaseMapper<CompanyInfo> {
*/ */
int updateByPhone(CompanyInfo companyInfo); int updateByPhone(CompanyInfo companyInfo);
int updateByCompanyName(CompanyInfo companyInfo);
int updateByOpId(CompanyInfo companyInfo); int updateByOpId(CompanyInfo companyInfo);
/** /**

View File

@ -37,6 +37,10 @@ public class CompanyInfo implements Serializable {
*/ */
private String citys; private String citys;
private Long company_id;
private Long operator_id;
/** /**
* 是否删除标记 (0-未删除, 1-已删除) * 是否删除标记 (0-未删除, 1-已删除)
*/ */
@ -140,4 +144,20 @@ public class CompanyInfo implements Serializable {
public void setSyncTime(LocalDateTime syncTime) { public void setSyncTime(LocalDateTime syncTime) {
this.syncTime = syncTime; this.syncTime = syncTime;
} }
public Long getCompany_id() {
return company_id;
}
public void setCompany_id(Long company_id) {
this.company_id = company_id;
}
public Long getOperator_id() {
return operator_id;
}
public void setOperator_id(Long operator_id) {
this.operator_id = operator_id;
}
} }

View File

@ -73,6 +73,7 @@ public class StoreInfo implements Serializable {
*/ */
private Integer isDelete; private Integer isDelete;
private Long store_id;
private Long bpStoreId; private Long bpStoreId;
@ -190,4 +191,20 @@ public class StoreInfo implements Serializable {
public void setIs_delete(String is_delete) { public void setIs_delete(String is_delete) {
this.is_delete = is_delete; this.is_delete = is_delete;
} }
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getStore_id() {
return store_id;
}
public void setStore_id(Long store_id) {
this.store_id = store_id;
}
} }

View File

@ -281,8 +281,8 @@ public class ReceiveServiceImpl implements ReceiveService {
map.put("code", "500"); map.put("code", "500");
return map; return map;
} }
if (companyInfo.getbOpId() == null) { if (companyInfo.getOperator_id() == null) {
map.put("msg", "租电平台运营商id不能为空,请补传'bOpId'"); map.put("msg", "租电平台运营商id不能为空,请补传'operator_id'");
map.put("code", "500"); map.put("code", "500");
return map; return map;
} }
@ -292,10 +292,10 @@ public class ReceiveServiceImpl implements ReceiveService {
// //
// } // }
if (companyInfoMapper.selectByOpId(companyInfo.getbOpId()) != null) { if (companyInfoMapper.selectByOpId(companyInfo.getOperator_id()) != null) {
companyInfoMapper.updateByOpId(companyInfo); companyInfoMapper.updateByOpId(companyInfo);
} else if (companyInfoMapper.selectByPhone(companyInfo.getPhone()) != null) { } else if (companyInfoMapper.selectByCompanyName(companyInfo.getCompany_name()) != null) {
companyInfoMapper.updateByPhone(companyInfo); companyInfoMapper.updateByCompanyName(companyInfo);
} else { } else {
companyInfoMapper.insertCompanyInfo(companyInfo); companyInfoMapper.insertCompanyInfo(companyInfo);
} }
@ -368,13 +368,13 @@ public class ReceiveServiceImpl implements ReceiveService {
map.put("code", "500"); map.put("code", "500");
return map; return map;
} }
if (storeInfo.getBpStoreId() == null) { if (storeInfo.getStore_id() == null) {
map.put("msg", "租电平台门店id不能为空,请补传'bpStoreId'"); map.put("msg", "租电平台门店id不能为空,请补传'store_id'");
map.put("code", "500"); map.put("code", "500");
return map; return map;
} }
if (companyStoreMapper.selectByBid(storeInfo.getBpStoreId()) != null) { if (companyStoreMapper.selectByBid(storeInfo.getStore_id()) != null) {
companyStoreMapper.updateByBid(storeInfo); companyStoreMapper.updateByBid(storeInfo);
} else if (companyStoreMapper.selectByPhone(storeInfo.getPhone()) != null) { } else if (companyStoreMapper.selectByPhone(storeInfo.getPhone()) != null) {
companyStoreMapper.updateByName(storeInfo); companyStoreMapper.updateByName(storeInfo);

View File

@ -138,12 +138,14 @@ public class SendDataServiceImpl implements SendDataService {
} }
CompanyInfo companyInfo = new CompanyInfo(); CompanyInfo companyInfo = new CompanyInfo();
companyInfo.setOperator_id(id);
companyInfo.setCompany_name(company.getCompany_name()); companyInfo.setCompany_name(company.getCompany_name());
companyInfo.setContact_name(company.getContact_name()); companyInfo.setContact_name(company.getContact_name());
companyInfo.setPhone(company.getPhone()); companyInfo.setPhone(company.getPhone());
companyInfo.setAddress(company.getAddress()); companyInfo.setAddress(company.getAddress());
companyInfo.setIs_delete(company.getIsDelete().toString()); companyInfo.setIs_delete(company.getIsDelete().toString());
// 使用 Set 去除重复城市 // 使用 Set 去除重复城市
Set<String> uniqueCities = new HashSet<>(); Set<String> uniqueCities = new HashSet<>();
if (storeInfoList != null && !storeInfoList.isEmpty()) { if (storeInfoList != null && !storeInfoList.isEmpty()) {
@ -154,9 +156,13 @@ public class SendDataServiceImpl implements SendDataService {
} }
} }
// 拼接去重后的城市字符串
String citysStr = String.join(",", uniqueCities); String citysStr = String.join(",", uniqueCities);
companyInfo.setCitys(citysStr); if (citysStr.isEmpty() || citysStr.length() == 0){
companyInfo.setCitys(company.getCitys());
}else{
companyInfo.setCitys(citysStr);
}
SyncRequest syncRequest = new SyncRequest(); SyncRequest syncRequest = new SyncRequest();
syncRequest.setData(companyInfo); syncRequest.setData(companyInfo);
@ -220,6 +226,8 @@ public class SendDataServiceImpl implements SendDataService {
map.put("code","500"); map.put("code","500");
} }
storeInfo.setStore_id(id);
SyncRequest syncRequest = new SyncRequest(); SyncRequest syncRequest = new SyncRequest();
syncRequest.setData(storeInfo); syncRequest.setData(storeInfo);
if(saveRecord(syncRequest,URL+"/storeinfo",id,"storeinfo")){ if(saveRecord(syncRequest,URL+"/storeinfo",id,"storeinfo")){

View File

@ -28,6 +28,14 @@
AND is_delete = 0 AND is_delete = 0
</select> </select>
<select id="selectByCompanyName" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM zc_company
WHERE company_name = #{company_name}
AND is_delete = 0
</select>
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap"> <select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
SELECT SELECT
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
@ -40,7 +48,7 @@
SELECT SELECT
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
FROM zc_company FROM zc_company
WHERE b_op_id = #{bOpId} WHERE b_op_id = #{operator_id}
AND is_delete = 0 AND is_delete = 0
</select> </select>
@ -79,13 +87,45 @@
is_delete = #{isDelete}, is_delete = #{isDelete},
</if> </if>
<if test="bOpId != null"> <if test="bOpId != null">
b_op_id = #{bOpId}, b_op_id = #{operator_id},
</if> </if>
phone = #{phone} phone = #{phone}
</set> </set>
WHERE phone = #{phone} WHERE phone = #{phone}
</update> </update>
<update id="updateByCompanyName" parameterType="com.sczx.sync.po.CompanyInfo" >
<selectKey keyProperty='id' resultType='java.lang.Long' order='AFTER'>
SELECT
id
from zc_company
where company_name = #{company_name}
</selectKey>
UPDATE zc_company
<set>
<if test="company_name != null and company_name != ''">
company_name = #{company_name},
</if>
<if test="contact_name != null and contact_name != ''">
contact_name = #{contact_name},
</if>
<if test="address != null and address != ''">
address = #{address},
</if>
<if test="citys != null and citys != ''">
citys = #{citys},
</if>
<if test="isDelete != null">
is_delete = #{isDelete},
</if>
<if test="bOpId != null">
b_op_id = #{operator_id},
</if>
phone = #{phone}
</set>
WHERE company_name = #{company_name}
</update>
<!-- 根据电话号码更新公司信息 --> <!-- 根据电话号码更新公司信息 -->
<update id="updateByOpId" parameterType="com.sczx.sync.po.CompanyInfo"> <update id="updateByOpId" parameterType="com.sczx.sync.po.CompanyInfo">
@ -117,7 +157,7 @@
</if> </if>
phone = #{phone} phone = #{phone}
</set> </set>
WHERE b_op_id = #{bOpId} WHERE b_op_id = #{operator_id}
</update> </update>
<!-- 插入公司信息 --> <!-- 插入公司信息 -->
@ -137,7 +177,7 @@
ali_receiving_account, ali_receiving_account,
ali_key ali_key
) VALUES ( ) VALUES (
#{bOpId}, #{operator_id},
#{company_name}, #{company_name},
#{contact_name}, #{contact_name},
#{phone}, #{phone},