You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
147 lines
6.3 KiB
Java
147 lines
6.3 KiB
Java
package com.glxp.api.controller.thrsys;
|
|
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
import com.glxp.api.entity.thrsys.ThrManufacturerEntity;
|
|
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
|
|
import com.glxp.api.httpClient.serviceClient.ErpBasicClient;
|
|
import com.glxp.api.req.system.DeleteRequest;
|
|
import com.glxp.api.req.thrsys.FilterBasicProducstRequest;
|
|
import com.glxp.api.req.thrsys.FilterThrCorpRequest;
|
|
import com.glxp.api.req.thrsys.ThrManuFilterRequest;
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
import com.glxp.api.service.thrsys.ThrManufacturerService;
|
|
import com.glxp.api.service.thrsys.ThrSystemDetailService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.validation.BindingResult;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.List;
|
|
|
|
@Slf4j
|
|
@RestController
|
|
public class ThrManusController {
|
|
|
|
|
|
@Resource
|
|
ThrManufacturerService thrManufacturerService;
|
|
@Resource
|
|
private ThrSystemDetailService thrSystemDetailService;
|
|
@Resource
|
|
private ErpBasicClient erpBasicClient;
|
|
|
|
|
|
@GetMapping("/udiwms/thrsys/getManus")
|
|
public BaseResponse getManus(FilterThrCorpRequest filterThrCorpRequest,
|
|
BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
List<ThrManufacturerEntity> thrManufacturerEntities
|
|
= thrManufacturerService.filterThrManu(filterThrCorpRequest);
|
|
PageInfo<ThrManufacturerEntity> pageInfo;
|
|
pageInfo = new PageInfo<>(thrManufacturerEntities);
|
|
PageSimpleResponse<ThrManufacturerEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
pageSimpleResponse.setList(thrManufacturerEntities);
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/thrsys/delManus")
|
|
public BaseResponse delCorps(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
String id = deleteRequest.getId();
|
|
thrManufacturerService.removeById(id);
|
|
return ResultVOUtils.success("删除成功");
|
|
}
|
|
|
|
|
|
//选中或者下载全部
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/thrsys/manu/corpsDlAll")
|
|
public BaseResponse corpsDlAll(@RequestBody ThrManuFilterRequest thrManuFilterRequest) {
|
|
if (null == thrManuFilterRequest) {
|
|
return ResultVOUtils.error(500, "参数不能为空");
|
|
}
|
|
ThreadUtil.execAsync(() -> {
|
|
try {
|
|
thrManufacturerService.downloadByRequest(thrManuFilterRequest);
|
|
} catch (Exception e) {
|
|
log.error("下载异常", e);
|
|
e.printStackTrace();
|
|
}
|
|
|
|
});
|
|
return ResultVOUtils.success("后台正在下载,请稍后刷新查看!");
|
|
}
|
|
|
|
|
|
//查询ERP往来单位
|
|
@AuthRuleAnnotation("")
|
|
@GetMapping("/udiwms/manu/filterErp")
|
|
public BaseResponse filterErp(ThrManuFilterRequest thrManuFilterRequest,
|
|
BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("manuUrl", thrManuFilterRequest.getThirdSys());
|
|
if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null)
|
|
return ResultVOUtils.error(500, "生产企业接口地址未定义");
|
|
if (thrSystemDetailEntity.getEnabled()) {
|
|
BaseResponse<PageSimpleResponse<ThrManufacturerEntity>> udiDlDeviceResponse = erpBasicClient.getThrManu(thrManuFilterRequest);
|
|
if (udiDlDeviceResponse.getCode() == 20000) {
|
|
for (ThrManufacturerEntity item : udiDlDeviceResponse.getData().getList()) {
|
|
ThrManufacturerEntity thrManufacturerEntity = thrManufacturerService.getOne(new QueryWrapper<ThrManufacturerEntity>().eq("unitId", item.getUnitId()).eq("thirdSysFk", thrManuFilterRequest.getThirdSys()).last("limit 1"));
|
|
if (thrManufacturerEntity != null) {
|
|
item.setChecked(true);
|
|
} else {
|
|
item.setChecked(false);
|
|
}
|
|
}
|
|
return udiDlDeviceResponse;
|
|
} else {
|
|
return udiDlDeviceResponse;
|
|
}
|
|
|
|
} else {
|
|
return ResultVOUtils.error(500, "第三方系统往来单位服务接口未启用");
|
|
}
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@GetMapping("/udiwms/thrsys/getBasicProducts")
|
|
public BaseResponse getProductTypes(FilterBasicProducstRequest basicProducstRequest,
|
|
BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
List<ThrManufacturerEntity> thrManufacturerEntities
|
|
= thrManufacturerService.getProductTypes(basicProducstRequest);
|
|
PageInfo<ThrManufacturerEntity> pageInfo;
|
|
pageInfo = new PageInfo<ThrManufacturerEntity>(thrManufacturerEntities);
|
|
PageSimpleResponse<ThrManufacturerEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
pageSimpleResponse.setList(thrManufacturerEntities);
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
}
|
|
|
|
|
|
}
|