|
|
|
@ -13,6 +13,7 @@ import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
|
|
|
|
|
import com.glxp.api.http.ErpBasicClient;
|
|
|
|
|
import com.glxp.api.req.thrsys.FilterThrProductsRequest;
|
|
|
|
|
import com.glxp.api.req.thrsys.PostThrProductsRequest;
|
|
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
|
import com.glxp.api.res.thrsys.ThrProductsResponse;
|
|
|
|
|
import com.glxp.api.service.thrsys.ThrProductsService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -160,8 +161,86 @@ public class ThrProductsServiceImpl implements ThrProductsService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse downloadThrPi(ThrSystemDetailEntity thrSystemDetailEntity) {
|
|
|
|
|
int page = 1;
|
|
|
|
|
int limit = 200;
|
|
|
|
|
FilterThrProductsRequest request = new FilterThrProductsRequest();
|
|
|
|
|
request.setThirdSysFk(thrSystemDetailEntity.getThirdSysFk());
|
|
|
|
|
request.setLimit(limit);
|
|
|
|
|
while (true) {
|
|
|
|
|
request.setPage(page);
|
|
|
|
|
|
|
|
|
|
BaseResponse<PageSimpleResponse<ThrProductsResponse>> baseResponse = erpBasicClient.getErpProducts(request);
|
|
|
|
|
if (baseResponse.getCode() == 20000) {
|
|
|
|
|
List<ThrProductsResponse> list = baseResponse.getData().getList();
|
|
|
|
|
list.forEach(item -> {
|
|
|
|
|
ThrProductsEntity thrProductsEntity = thrProductsDao.selectByCodeAndThird(item.getCode(), item.getThirdSys());
|
|
|
|
|
if (null == thrProductsEntity) {
|
|
|
|
|
thrProductsEntity = new ThrProductsEntity();
|
|
|
|
|
BeanUtil.copyProperties(item, thrProductsEntity);
|
|
|
|
|
thrProductsEntity.setCreateTime(new Date());
|
|
|
|
|
thrProductsEntity.setUpdateTime(new Date());
|
|
|
|
|
} else {
|
|
|
|
|
boolean isChange = verifyDataChange(thrProductsEntity, item);
|
|
|
|
|
if (isChange) {
|
|
|
|
|
thrProductsEntity.setUpdateTime(new Date());
|
|
|
|
|
thrProductsDao.updateById(thrProductsEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (list.size() >= limit) {
|
|
|
|
|
page++;
|
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return ResultVOUtils.error(500, "下载第三方系统产品信息异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success("下载成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
/**
|
|
|
|
|
* 校验拉取的第三方数据是否有更新
|
|
|
|
|
*
|
|
|
|
|
* @param thrProductsEntity
|
|
|
|
|
* @param thrProductsResponse
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean verifyDataChange(ThrProductsEntity thrProductsEntity, ThrProductsResponse thrProductsResponse) {
|
|
|
|
|
ThrProductsEntity oldData = new ThrProductsEntity();
|
|
|
|
|
BeanUtil.copyProperties(thrProductsEntity, oldData);
|
|
|
|
|
|
|
|
|
|
//将关键字段的值设置为新数据的值
|
|
|
|
|
thrProductsEntity.setName(thrProductsResponse.getName());
|
|
|
|
|
thrProductsEntity.setMeasname(thrProductsResponse.getMeasname());
|
|
|
|
|
thrProductsEntity.setSpec(thrProductsResponse.getSpec());
|
|
|
|
|
thrProductsEntity.setRegisterNo(thrProductsResponse.getRegisterNo());
|
|
|
|
|
thrProductsEntity.setManufactory(thrProductsResponse.getManufactory());
|
|
|
|
|
thrProductsEntity.setCplb(thrProductsResponse.getCplb());
|
|
|
|
|
thrProductsEntity.setFlbm(thrProductsResponse.getFlbm());
|
|
|
|
|
thrProductsEntity.setQtbm(thrProductsResponse.getQtbm());
|
|
|
|
|
thrProductsEntity.setSptm(thrProductsResponse.getSptm());
|
|
|
|
|
thrProductsEntity.setYbbm(thrProductsResponse.getYbbm());
|
|
|
|
|
thrProductsEntity.setTyshxydm(thrProductsResponse.getTyshxydm());
|
|
|
|
|
thrProductsEntity.setZczbhhzbapzbh(thrProductsResponse.getZczbhhzbapzbh());
|
|
|
|
|
thrProductsEntity.setYlqxzcrbarmc(thrProductsResponse.getYlqxzcrbarmc());
|
|
|
|
|
thrProductsEntity.setYlqxzcrbarywmc(thrProductsResponse.getYlqxzcrbarywmc());
|
|
|
|
|
thrProductsEntity.setCpms(thrProductsResponse.getCpms());
|
|
|
|
|
thrProductsEntity.setSupName(thrProductsResponse.getSupName());
|
|
|
|
|
thrProductsEntity.setModel(thrProductsResponse.getModel());
|
|
|
|
|
thrProductsEntity.setStandard(thrProductsResponse.getStandard());
|
|
|
|
|
thrProductsEntity.setQtbm(thrProductsResponse.getQtbm());
|
|
|
|
|
thrProductsEntity.setZczyxqz(thrProductsResponse.getZczyxqz());
|
|
|
|
|
thrProductsEntity.setRemark(thrProductsResponse.getRemark());
|
|
|
|
|
thrProductsEntity.setRemark1(thrProductsResponse.getRemark1());
|
|
|
|
|
thrProductsEntity.setRemark2(thrProductsResponse.getRemark2());
|
|
|
|
|
thrProductsEntity.setRemark3(thrProductsResponse.getRemark3());
|
|
|
|
|
thrProductsEntity.setPrice(thrProductsResponse.getPrice());
|
|
|
|
|
|
|
|
|
|
//比对更新完的对象和原对象是否发生变化,若有变化则说明书有更新
|
|
|
|
|
return !thrProductsEntity.equals(oldData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|