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.
204 lines
9.9 KiB
Java
204 lines
9.9 KiB
Java
package com.glxp.api.controller.basic;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
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.auth.AuthAdmin;
|
|
import com.glxp.api.entity.basic.BasicCorpEntity;
|
|
import com.glxp.api.entity.basic.UdiRlSupEntity;
|
|
import com.glxp.api.exception.JsonException;
|
|
import com.glxp.api.req.basic.CompanyProductRelevanceRequest;
|
|
import com.glxp.api.req.basic.FilterCompanyProductRelevanceRequest;
|
|
import com.glxp.api.req.basic.FilterUdiRelRequest;
|
|
import com.glxp.api.req.basic.UdiInfoExportRequest;
|
|
import com.glxp.api.req.system.CompanyRequest;
|
|
import com.glxp.api.req.system.DeleteCompanyFileRequest;
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
import com.glxp.api.res.basic.UdiRlSupResponse;
|
|
import com.glxp.api.res.basic.UdiRelevanceResponse;
|
|
import com.glxp.api.service.auth.AuthAdminService;
|
|
import com.glxp.api.service.basic.BasicCorpService;
|
|
import com.glxp.api.service.basic.UdiRlSupService;
|
|
import com.glxp.api.service.basic.CompanyProductsRelService;
|
|
import com.glxp.api.service.basic.UdiRelevanceService;
|
|
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 org.springframework.web.context.request.RequestContextHolder;
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 供应商关联耗材字典信息
|
|
*/
|
|
@RestController
|
|
public class UdiRlSupController {
|
|
@Resource
|
|
private AuthAdminService authAdminService;
|
|
@Resource
|
|
private UdiRlSupService udiRlSupService;
|
|
@Resource
|
|
private CompanyProductsRelService companyProductsRelService;
|
|
@Resource
|
|
private BasicCorpService basicUnitMaintainService;
|
|
|
|
@Resource
|
|
private UdiRelevanceService udiRelevanceService;
|
|
|
|
@AuthRuleAnnotation("")
|
|
@GetMapping("/sale/info/company/product/relevance/filter")
|
|
public BaseResponse filterCompanyProductRelevance(CompanyProductRelevanceRequest companyProductRelevanceRequest,
|
|
BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
|
|
if (StrUtil.isNotEmpty(companyProductRelevanceRequest.getUnionCode())) {
|
|
FilterUdiRelRequest filterUdiInfoRequest = new FilterUdiRelRequest();
|
|
filterUdiInfoRequest.setNameCode(companyProductRelevanceRequest.getUnionCode());
|
|
List<UdiRelevanceResponse> temps = udiRelevanceService.filterUdiGp(filterUdiInfoRequest);
|
|
if (temps != null && temps.size() > 0) {
|
|
companyProductRelevanceRequest.setUuid(temps.get(0).getUuid());
|
|
companyProductRelevanceRequest.setNameCode(filterUdiInfoRequest.getNameCode());
|
|
companyProductRelevanceRequest.setUnionCode(null);
|
|
}
|
|
} else {
|
|
companyProductRelevanceRequest.setDiType(1);
|
|
}
|
|
List<UdiRlSupResponse> basicInstrumentMaintainRelevanceResponses = null;
|
|
basicInstrumentMaintainRelevanceResponses = udiRlSupService.filterUdiGp(companyProductRelevanceRequest);
|
|
PageInfo<UdiRlSupResponse> pageInfo;
|
|
pageInfo = new PageInfo<>(basicInstrumentMaintainRelevanceResponses);
|
|
PageSimpleResponse<UdiRlSupResponse> pageSimpleResponse = new PageSimpleResponse<>();
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
pageSimpleResponse.setList(basicInstrumentMaintainRelevanceResponses);
|
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@GetMapping("/sale/info/company/product/corp/filter")
|
|
public BaseResponse filterRlCorp(FilterCompanyProductRelevanceRequest filterCompanyProductRelevanceRequest,
|
|
BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
if (StrUtil.isEmpty(filterCompanyProductRelevanceRequest.getUdiRlIdFk())) {
|
|
return ResultVOUtils.error(500, "请先选择产品!");
|
|
}
|
|
List<UdiRlSupEntity> companyProductRelevanceEntities =
|
|
udiRlSupService.filterCompanyProductRelevance(filterCompanyProductRelevanceRequest);
|
|
|
|
if (!companyProductRelevanceEntities.isEmpty()) {
|
|
List<String> erpIds = new ArrayList<>();
|
|
for (UdiRlSupEntity udiRlSupEntity : companyProductRelevanceEntities) {
|
|
erpIds.add(udiRlSupEntity.getUnitFk());
|
|
}
|
|
List<BasicCorpEntity> basicUnitMaintainEntities = basicUnitMaintainService.batchSelectByErpIdsAndName(erpIds, filterCompanyProductRelevanceRequest.getKey());
|
|
return ResultVOUtils.success(basicUnitMaintainEntities);
|
|
}
|
|
return ResultVOUtils.error(500, "该产品未关联供应商!");
|
|
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@GetMapping("/spms/info/company/product/filterAll")
|
|
public BaseResponse filterAll(FilterCompanyProductRelevanceRequest filterCompanyProductRelevanceRequest,
|
|
BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
List<UdiRlSupEntity> companyProductRelevanceEntities =
|
|
udiRlSupService.filterCompanyProductRelevance(filterCompanyProductRelevanceRequest);
|
|
PageInfo<UdiRlSupEntity> pageInfo;
|
|
pageInfo = new PageInfo<>(companyProductRelevanceEntities);
|
|
PageSimpleResponse<UdiRlSupEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
pageSimpleResponse.setList(companyProductRelevanceEntities);
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
@GetMapping("/sale/info/companyProductRelevance")
|
|
public BaseResponse getCompanyProductRelevanceInfo(CompanyRequest companyRequest) {
|
|
UdiRlSupEntity udiRlSupEntity = udiRlSupService.findCompanyProductRelevance(companyRequest.getCustomerId());
|
|
if (udiRlSupEntity != null) {
|
|
return ResultVOUtils.success(udiRlSupEntity);
|
|
}
|
|
return ResultVOUtils.error(500, "空");
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@GetMapping("/sale/info/getCompanyProductRelevance")
|
|
public BaseResponse getCompanyProductRelevance(FilterCompanyProductRelevanceRequest filterCompanyProductRelevanceRequest) {
|
|
// filterCompanyProductRelevanceRequest.setCustomerId(getCustomerId());
|
|
List<UdiRlSupEntity> companyProductRelevanceEntities = udiRlSupService.getCompanyProductRelevance(filterCompanyProductRelevanceRequest);
|
|
PageInfo<UdiRlSupEntity> pageInfo = new PageInfo<>(companyProductRelevanceEntities);
|
|
PageSimpleResponse<UdiRlSupEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
pageSimpleResponse.setList(companyProductRelevanceEntities);
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/sale/info/insertCompanyProductRelevance")
|
|
public BaseResponse insertCompanyProductRelevance(@RequestBody UdiRlSupEntity udiRlSupEntity) {
|
|
if (udiRlSupService.findCompanyProductRelevanceByProductUuid(udiRlSupEntity) != null) {
|
|
return ResultVOUtils.error(ResultEnum.DATA_REPEAT);
|
|
}
|
|
udiRlSupEntity.setUnitFk(null);
|
|
udiRlSupEntity.setCreateTime(new Date());
|
|
udiRlSupEntity.setUpdateTime(new Date());
|
|
udiRlSupEntity.setAuditStatus("3");
|
|
boolean b = udiRlSupService.insertCompanyProductRelevance(udiRlSupEntity);
|
|
return ResultVOUtils.success("成功");
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/sale/info/insertFilter")
|
|
public BaseResponse insertFilter(@RequestBody UdiInfoExportRequest udiInfoExportRequest) {
|
|
if (StrUtil.isEmpty(udiInfoExportRequest.getUnitFk())) {
|
|
return ResultVOUtils.error(500, "未选择供应商!");
|
|
}
|
|
companyProductsRelService.insertCompanyProducts(udiInfoExportRequest);
|
|
return ResultVOUtils.success("后台正在导入,请稍后刷新查看!");
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/sale/info/updateCompanyProductRelevance")
|
|
public BaseResponse updateCompanyProductRelevance(@RequestBody UdiRlSupEntity udiRlSupEntity) {
|
|
udiRlSupEntity.setUpdateTime(new Date());
|
|
int b = udiRlSupService.updateCompanyProductRelevance(udiRlSupEntity);
|
|
return ResultVOUtils.success("修改成功");
|
|
}
|
|
|
|
@PostMapping("/sale/info/deleteCompanyProductRelevance")
|
|
public BaseResponse deleteCompanyProductRelevance(@RequestBody DeleteCompanyFileRequest deleteCompanyFileRequest, BindingResult bindingResult) {
|
|
boolean b = udiRlSupService.deleteById(deleteCompanyFileRequest.getId());
|
|
return ResultVOUtils.success("成功");
|
|
}
|
|
|
|
public String getCustomerId() {
|
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
if (attributes == null) {
|
|
throw new JsonException(ResultEnum.NOT_NETWORK);
|
|
}
|
|
HttpServletRequest request = attributes.getRequest();
|
|
String userId = request.getHeader("ADMIN_ID");
|
|
AuthAdmin authAdmin = authAdminService.findById(Long.parseLong(userId));
|
|
return authAdmin.getCustomerId() + "";
|
|
}
|
|
}
|