Commit c0f0041c authored by 赵啸非's avatar 赵啸非

添加样表设备部门过滤

parent d7b35791
package com.mortals.xhx.feign.base.pdu;
import lombok.Data;
import java.util.List;
@Data
public class DeptPdu {
private List<Long> idList;
private Long siteId;
private Integer page;
/**分页每页显示数 -1为不分页*/
private Integer size;
}
package com.mortals.xhx.feign.dept;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.dept.DeptPdu;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 部门 Feign接口
* @author zxfei
* @date 2022-12-09
*/
@FeignClient(name = "base-manager", path = "/base", fallbackFactory = DeptFeignFallbackFactory.class)
public interface IDeptFeign extends IFeign {
/**
* 查看部门列表
*
* @param deptPdu
* @return
*/
@PostMapping(value = "/dept/list")
Rest<RespData<List<DeptPdu>>> list(@RequestBody DeptPdu deptPdu);
/**
* 查看部门
*
* @param id
* @return
*/
@GetMapping(value = "/dept/info")
Rest<DeptPdu> info(@RequestParam(value = "id") Long id);
/**
* 删除部门
*
* @param ids
* @return
*/
@GetMapping(value = "/dept/delete")
Rest<Void> delete(Long[] ids,@RequestHeader("Authorization") String authorization);
/**
* 部门保存更新
*
* @param deptPdu
* @return
*/
@PostMapping(value = "/dept/save")
Rest<RespData<DeptPdu>> save(@RequestBody DeptPdu deptPdu,@RequestHeader("Authorization") String authorization);
}
@Slf4j
@Component
class DeptFeignFallbackFactory implements FallbackFactory<IDeptFeign> {
@Override
public IDeptFeign create(Throwable t) {
return new IDeptFeign() {
@Override
public Rest<RespData<List<DeptPdu>>> list(DeptPdu deptPdu) {
return Rest.fail("暂时无法获取部门列表,请稍后再试!");
}
@Override
public Rest<DeptPdu> info(Long id) {
return Rest.fail("暂时无法获取部门详细,请稍后再试!");
}
@Override
public Rest<Void> delete(Long[] ids, String authorization) {
return Rest.fail("暂时无法删除部门,请稍后再试!");
}
@Override
public Rest<RespData<DeptPdu>> save(DeptPdu deptPdu, String authorization) {
return Rest.fail("暂时无法保存部门,请稍后再试!");
}
};
}
}
package com.mortals.xhx.module.device.service.impl;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.dept.DeptPdu;
import com.mortals.xhx.feign.dept.IDeptFeign;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceMatterDatumQuery;
import com.mortals.xhx.module.device.service.DeviceService;
......@@ -38,6 +43,8 @@ public class DeviceMatterDatumServiceImpl extends AbstractCRUDServiceImpl<Device
@Autowired
private MatterDatumService matterDatumService;
@Autowired
private IDeptFeign deptFeign;
@Override
......@@ -71,6 +78,18 @@ public class DeviceMatterDatumServiceImpl extends AbstractCRUDServiceImpl<Device
entity.setSource(matterEntity.getSource());
entity.setSort(matterEntity.getSort());
entity.setDeptId(matterEntity.getDeptId());
DeptPdu deptPdu = new DeptPdu();
deptPdu.setDeptNumber(matterEntity.getDeptCode());
deptPdu.setSiteId(entity.getSiteId());
Rest<RespData<List<DeptPdu>>> rest = deptFeign.list(deptPdu);
if(YesNoEnum.YES.getValue()==rest.getCode()){
List<DeptPdu> data = rest.getData().getData();
if(!ObjectUtils.isEmpty(data)){
entity.setDeptId(data.get(0).getId());
}
}
entity.setDeptCode(matterEntity.getDeptCode());
entity.setDeptName(matterEntity.getDeptName());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment