计件工资优化、能源模块增加数据源
parent
4b0ba99444
commit
45a5f33fe8
@ -0,0 +1,21 @@
|
||||
package com.op.system.api;
|
||||
|
||||
import com.op.common.core.constant.ServiceNameConstants;
|
||||
import com.op.common.core.domain.R;
|
||||
import com.op.system.api.domain.DataSourcePropertyDTO;
|
||||
import com.op.system.api.factory.RemoteEnergyFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/** auth YangWl
|
||||
* 能源服务
|
||||
*/
|
||||
@FeignClient(contextId = "remoteEnergyService", value = ServiceNameConstants.ENERGY_SERVICE, fallbackFactory = RemoteEnergyFallbackFactory.class)
|
||||
public interface RemoteEnergyService {
|
||||
@PostMapping("/energy/addDatasource")
|
||||
public R addDatasource(@RequestBody DataSourcePropertyDTO dataSourceProperty);
|
||||
|
||||
@PostMapping("/energy/removeDatasource")
|
||||
public R removeDatasource(@RequestBody DataSourcePropertyDTO dataSourceProperty);
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.op.system.api.factory;
|
||||
|
||||
import com.op.common.core.domain.R;
|
||||
import com.op.system.api.RemoteEnergyService;
|
||||
import com.op.system.api.RemoteWmsService;
|
||||
import com.op.system.api.domain.DataSourcePropertyDTO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class RemoteEnergyFallbackFactory implements FallbackFactory<RemoteEnergyService> {
|
||||
private static final Logger log = LoggerFactory.getLogger(RemoteEnergyFallbackFactory.class);
|
||||
|
||||
@Override
|
||||
public RemoteEnergyService create(Throwable throwable) {
|
||||
log.error("能源服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteEnergyService() {
|
||||
@Override
|
||||
public R addDatasource(DataSourcePropertyDTO dataSourceProperty) {
|
||||
return R.fail("mes数据源创建失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R removeDatasource(DataSourcePropertyDTO dataSourceProperty) {
|
||||
return R.fail("mes数据源删除失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue