资质审核代码

cert
schry 2 years ago
parent 8d0fece4a1
commit cb93cf45f2

@ -1,24 +1,68 @@
package com.glxp.api.controller.purchase;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.annotation.Log;
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.constant.BusinessType;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.entity.auth.AuthAdmin;
import com.glxp.api.entity.purchase.SupCertEntity;
import com.glxp.api.entity.purchase.SupCertSetEntity;
import com.glxp.api.entity.purchase.SupCompanyEntity;
import com.glxp.api.entity.purchase.SupManufacturerEntity;
import com.glxp.api.exception.JsonException;
import com.glxp.api.req.purchase.FilterCertSetsRequest;
import com.glxp.api.req.purchase.FilterSupCertRequest;
import com.glxp.api.req.purchase.FilterSupManufacturerRequest;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.service.auth.AuthAdminService;
import com.glxp.api.service.purchase.SupCertService;
import com.glxp.api.service.purchase.SupCertSetService;
import com.glxp.api.service.purchase.SupCompanyService;
import com.glxp.api.service.purchase.SupManufacturerService;
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.Date;
import java.util.List;
import java.util.ListIterator;
@RestController
public class SupManufacturerController {
@Resource
private AuthAdminService authAdminService;
@Resource
private SupManufacturerService supManufacturerService;
@Resource
private SupCertService supCertService;
@Resource
private SupCompanyService supCompanyService;
@Resource
SupCertSetService supCertSetService;
@AuthRuleAnnotation("")
@GetMapping("/sup/manufacturer/getCompanyInfo")
public BaseResponse getCompanyInfo(FilterSupManufacturerRequest filterSupManufacturerRequest) {
SupManufacturerEntity supManufacturerEntity = supManufacturerService.findCompany(filterSupManufacturerRequest.getId());
if (supManufacturerEntity != null) {
return ResultVOUtils.success(supManufacturerEntity);
}
return ResultVOUtils.error(500, "企业信息为空");
}
@AuthRuleAnnotation("")
@GetMapping("/sup/manufacturer/getCompanyList")
@ -30,4 +74,336 @@ public class SupManufacturerController {
pageSimpleResponse.setList(companyEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@AuthRuleAnnotation("")
@GetMapping("/sup/manufacturer/getCompanyBySup")
public BaseResponse getCompanyBySup(FilterSupManufacturerRequest filterSupManufacturerRequest) {
// filterSupManufacturerRequest.setCustomerId(getCustomerId());
List<SupManufacturerEntity> companyEntities = supManufacturerService.getCompany(filterSupManufacturerRequest);
PageInfo<SupManufacturerEntity> pageInfo = new PageInfo<>(companyEntities);
PageSimpleResponse<SupManufacturerEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(companyEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@AuthRuleAnnotation("")
@PostMapping("/sup/manufacturer/addCompany")
@Log(title = "资质证书", businessType = BusinessType.INSERT)
public BaseResponse addCompany(@RequestBody SupManufacturerEntity supManufacturerEntity) {
String customerId = getCustomerId();
supManufacturerEntity.setCustomerId(customerId);
//判断用户名和社会信用代码不能重复
FilterSupManufacturerRequest filterSupManufacturerRequest = new FilterSupManufacturerRequest();
filterSupManufacturerRequest.setCompanyName(supManufacturerEntity.getCompanyName());
filterSupManufacturerRequest.setCustomerId(getCustomerId());
List<SupManufacturerEntity> companyEntities = supManufacturerService.getCompanyByNameAndCode(filterSupManufacturerRequest);
if (companyEntities.size() > 0) {
return ResultVOUtils.error(999, "企业名称不能重复!");
}
filterSupManufacturerRequest = new FilterSupManufacturerRequest();
filterSupManufacturerRequest.setCustomerId(getCustomerId());
filterSupManufacturerRequest.setCreditCode(supManufacturerEntity.getCreditCode());
companyEntities = supManufacturerService.getCompanyByNameAndCode(filterSupManufacturerRequest);
if (companyEntities.size() > 0) {
return ResultVOUtils.error(999, "统一社会信用代码不能重复!");
}
//提交审核
if (supManufacturerEntity.getAuditStatus() == ConstantStatus.AUDIT_CHANGE || supManufacturerEntity.getAuditStatus() == ConstantStatus.AUDIT_UN) {
//判断是否上级供应商是否审核通过
SupCompanyEntity supCompanyEntity = supCompanyService.findCompany(supManufacturerEntity.getCustomerId());
if (supCompanyEntity.getAuditStatus() == null || supCompanyEntity.getAuditStatus() != ConstantStatus.AUDIT_PASS
) {
return ResultVOUtils.error(500, "所属配送企业资质未通过审核,暂时无法提交!");
}
//验证证书是否齐全
FilterCertSetsRequest filterCertSetsRequest = new FilterCertSetsRequest();
filterCertSetsRequest.setType(ConstantStatus.CERT_MANUFACTURER);
filterCertSetsRequest.setNeed(0);
List<SupCertSetEntity> supCertSetEntities = supCertSetService.filterCertSets(filterCertSetsRequest);
List<SupCertEntity> supCertEntityList = supCertService.findAll(supManufacturerEntity.getCustomerId(), supManufacturerEntity.getManufacturerId());
//判断存在有草稿的未提交的就不能通过
for (SupCertEntity obj : supCertEntityList) {
if (obj.getAuditStatus() == 0.) {
return ResultVOUtils.error(999, "资质证书存在草稿不能提交!");
}
}
ListIterator<SupCertSetEntity> iterable = supCertSetEntities.listIterator();
while (iterable.hasNext()) {
SupCertSetEntity supCertSetEntity = iterable.next();
if ((supCertSetEntity.getForeign() != null && supCertSetEntity.getForeign() == 2
&& StrUtil.trimToEmpty(supManufacturerEntity.getCompanyType()).equals("2"))
||
(
supCertSetEntity.getForeign() != null && supCertSetEntity.getForeign() == 1
&& StrUtil.trimToEmpty(supManufacturerEntity.getCompanyType()).equals("2"))
||
(supCertSetEntity.getForeign() != null
&& supCertSetEntity.getForeign() == 1
&& supManufacturerEntity.getCompanyType().equals("1"))
||
(supCertSetEntity.getForeign() != null
&& supCertSetEntity.getForeign() == 3
&& supManufacturerEntity.getCompanyType().equals("1"))) {
for (SupCertEntity supCertEntity : supCertEntityList) {
if (supCertEntity.getName().equals(supCertSetEntity.getName())) {
if (StrUtil.isNotEmpty(supCertEntity.getFilePath())) {
iterable.remove();
break;
}
}
}
} else {
iterable.remove();
}
}
String errMsg = "";
if (supCertSetEntities.size() > 0) {
for (SupCertSetEntity supCertSetEntity : supCertSetEntities) {
errMsg = errMsg + "," + supCertSetEntity.getName();
}
return ResultVOUtils.error(500, errMsg.substring(1) + "等证书未上传,无法提交审核!");
}
}
supManufacturerEntity.setCreateTime(new Date());
supManufacturerEntity.setUpdateTime(new Date());
supManufacturerEntity.setId(IdUtil.getSnowflakeNextId());
boolean b = supManufacturerService.insertCompany(supManufacturerEntity);
if (b) {
return ResultVOUtils.success("添加成功");
} else {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
}
@AuthRuleAnnotation("")
@PostMapping("/sup/manufacturer/modifyCompany")
@Log(title = "资质证书", businessType = BusinessType.UPDATE)
public BaseResponse modifyCompany(@RequestBody SupManufacturerEntity supManufacturerEntity) {
if (StrUtil.isEmpty(supManufacturerEntity.getManufacturerId()) || StrUtil.isEmpty(supManufacturerEntity.getCustomerId())) {
return ResultVOUtils.error(500, "参数错误!");
}
if (supManufacturerEntity.getId() == 0) {//新增
//判断用户名和社会信用代码不能重复
FilterSupManufacturerRequest filterSupManufacturerRequest = new FilterSupManufacturerRequest();
filterSupManufacturerRequest.setCompanyName(supManufacturerEntity.getCompanyName());
filterSupManufacturerRequest.setCustomerId(getCustomerId());
List<SupManufacturerEntity> companyEntities = supManufacturerService.getCompanyByNameAndCode(filterSupManufacturerRequest);
if (companyEntities.size() > 0) {
return ResultVOUtils.error(999, "企业名称不能重复!");
}
filterSupManufacturerRequest = new FilterSupManufacturerRequest();
filterSupManufacturerRequest.setCustomerId(getCustomerId());
filterSupManufacturerRequest.setCreditCode(supManufacturerEntity.getCreditCode());
companyEntities = supManufacturerService.getCompanyByNameAndCode(filterSupManufacturerRequest);
if (companyEntities.size() > 0) {
return ResultVOUtils.error(999, "统一社会信用代码不能重复!");
}
}
//提交审核
if (supManufacturerEntity.getAuditStatus() == ConstantStatus.AUDIT_CHANGE || supManufacturerEntity.getAuditStatus() == ConstantStatus.AUDIT_UN) {
//判断是否上级供应商是否审核通过
SupCompanyEntity supCompanyEntity = supCompanyService.findCompany(supManufacturerEntity.getCustomerId());
if (supCompanyEntity.getAuditStatus() == ConstantStatus.AUDIT_UN || supCompanyEntity.getAuditStatus() == ConstantStatus.AUDIT_CHANGE_REJECT
|| supCompanyEntity.getAuditStatus() == ConstantStatus.AUDIT_DRAFT || supCompanyEntity.getAuditStatus() == ConstantStatus.AUDIT_REJECT) {
return ResultVOUtils.error(500, "所属配送企业资质未通过审核,暂时无法提交!");
}
//验证证书是否齐全
FilterCertSetsRequest filterCertSetsRequest = new FilterCertSetsRequest();
filterCertSetsRequest.setType(ConstantStatus.CERT_MANUFACTURER);
filterCertSetsRequest.setNeed(0);
List<SupCertSetEntity> supCertSetEntities = supCertSetService.filterCertSets(filterCertSetsRequest);
List<SupCertEntity> supCertEntityList = supCertService.findAll(supManufacturerEntity.getCustomerId(), supManufacturerEntity.getManufacturerId());
//判断存在有草稿的未提交的就不能通过
for (SupCertEntity obj : supCertEntityList) {
if (obj.getAuditStatus() == 0.) {
return ResultVOUtils.error(999, "资质证书存在草稿不能提交!");
}
}
ListIterator<SupCertSetEntity> iterable = supCertSetEntities.listIterator();
while (iterable.hasNext()) {
SupCertSetEntity supCertSetEntity = iterable.next();
if ((supCertSetEntity.getForeign() != null && supCertSetEntity.getForeign() == 2
&& StrUtil.trimToEmpty(supManufacturerEntity.getCompanyType()).equals("2"))
||
(
supCertSetEntity.getForeign() != null && supCertSetEntity.getForeign() == 1
&& StrUtil.trimToEmpty(supManufacturerEntity.getCompanyType()).equals("2"))
||
(supCertSetEntity.getForeign() != null
&& supCertSetEntity.getForeign() == 1
&& supManufacturerEntity.getCompanyType().equals("1"))
||
(supCertSetEntity.getForeign() != null
&& supCertSetEntity.getForeign() == 3
&& supManufacturerEntity.getCompanyType().equals("1"))) {
for (SupCertEntity supCertEntity : supCertEntityList) {
if (supCertEntity.getName().equals(supCertSetEntity.getName())) {
if (StrUtil.isNotEmpty(supCertEntity.getFilePath())) {
iterable.remove();
break;
}
}
}
} else {
iterable.remove();
}
}
String errMsg = "";
if (supCertSetEntities.size() > 0) {
for (SupCertSetEntity supCertSetEntity : supCertSetEntities) {
errMsg = errMsg + "," + supCertSetEntity.getName();
}
return ResultVOUtils.error(500, errMsg.substring(1) + "等证书未上传,无法提交审核!");
}
}
supManufacturerEntity.setUpdateTime(new Date());
SupManufacturerEntity originEntity = supManufacturerService.findManufacturer(supManufacturerEntity.getManufacturerId());
boolean b = supManufacturerService.modifyCompany(supManufacturerEntity);
//修改证书对应的供应商ID生产企业ID
supCertService.updateManufacturerId(originEntity.getCustomerId(), supManufacturerEntity.getCustomerId(), originEntity.getManufacturerId(), supManufacturerEntity.getManufacturerId());
if (b) {
return ResultVOUtils.success("修改成功");
} else {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/sup/manufacturer/audit")
@Log(title = "资质证书", businessType = BusinessType.UPDATE)
public BaseResponse auditMmanufacturer(@RequestBody SupManufacturerEntity supManufacturerEntity) {
if (StrUtil.isEmpty(supManufacturerEntity.getManufacturerId()) || StrUtil.isEmpty(supManufacturerEntity.getCustomerId())) {
return ResultVOUtils.error(500, "参数错误!");
}
if (supManufacturerEntity.getAuditStatus() == 1 || supManufacturerEntity.getAuditStatus() == 4) {
//查询上传的资质证书
FilterSupCertRequest filterSupCertRequest = new FilterSupCertRequest();
filterSupCertRequest.setCustomerId(supManufacturerEntity.getCustomerId());
filterSupCertRequest.setManufacturerIdFk(supManufacturerEntity.getManufacturerId());
filterSupCertRequest.setType(ConstantStatus.CERT_MANUFACTURER);
List<SupCertEntity> supCertEntityList = supCertService.filterCompanyCert(filterSupCertRequest);
//查询必须上传的资质证书
FilterCertSetsRequest filterCertSetsRequest = new FilterCertSetsRequest();
filterCertSetsRequest.setType(ConstantStatus.CERT_MANUFACTURER);
List<SupCertSetEntity> supCertSetEntities = supCertSetService.filterCertSets(filterCertSetsRequest);
//判断有没有存在必须上传而没有上传的证书
ListIterator<SupCertSetEntity> iterable = supCertSetEntities.listIterator();
while (iterable.hasNext()) {
SupCertSetEntity supCertSetEntity = iterable.next();
if ((supCertSetEntity.getForeign() != null && supCertSetEntity.getForeign() == 2
&& StrUtil.trimToEmpty(supManufacturerEntity.getCompanyType()).equals("2"))
||
(
supCertSetEntity.getForeign() != null && supCertSetEntity.getForeign() == 1
&& StrUtil.trimToEmpty(supManufacturerEntity.getCompanyType()).equals("2"))
||
(supCertSetEntity.getForeign() != null
&& supCertSetEntity.getForeign() == 1
&& supManufacturerEntity.getCompanyType().equals("1"))
||
(supCertSetEntity.getForeign() != null
&& supCertSetEntity.getForeign() == 3
&& supManufacturerEntity.getCompanyType().equals("1"))) {
for (SupCertEntity supCertEntity : supCertEntityList) {
if (supCertEntity.getName().equals(supCertSetEntity.getName())) {
if (StrUtil.isNotEmpty(supCertEntity.getFilePath())) {
iterable.remove();
break;
}
}
}
} else {
iterable.remove();
}
}
String errMsg = "";
if (supCertSetEntities.size() > 0) {
return ResultVOUtils.error(500, "必传证书不齐全!");
}
}
String msg = "";
// 查询是否包含审核未通过的证书
if (supManufacturerEntity.getAuditStatus() == ConstantStatus.AUDIT_PASS ||
supManufacturerEntity.getAuditStatus() == ConstantStatus.AUDIT_CHANGE_PASS) {
FilterSupCertRequest filterSupCertRequest = new FilterSupCertRequest();
filterSupCertRequest.setAuditStatus(24);
filterSupCertRequest.setCustomerId(supManufacturerEntity.getCustomerId());
filterSupCertRequest.setManufacturerIdFk(supManufacturerEntity.getManufacturerId());
filterSupCertRequest.setType(ConstantStatus.CERT_MANUFACTURER);
List<SupCertEntity> supCertEntityList = supCertService.filterCompanyCert(filterSupCertRequest);
if (CollUtil.isNotEmpty(supCertEntityList)) {
for (SupCertEntity supCertEntity : supCertEntityList) {
msg += supCertEntity.getName() + ",";
}
return ResultVOUtils.error(500, "审核失败,还有必须提交证书未确认(" + msg.substring(0, msg.length() - 1) + ")");
}
}
supManufacturerEntity.setUpdateTime(new Date());
SupManufacturerEntity originEntity = supManufacturerService.findCompany(supManufacturerEntity.getId());
boolean b = supManufacturerService.modifyCompany(supManufacturerEntity);
//修改证书对应的供应商ID生产企业ID
supCertService.updateManufacturerId(originEntity.getCustomerId(), supManufacturerEntity.getCustomerId(), originEntity.getManufacturerId(), supManufacturerEntity.getManufacturerId());
if (b) {
return ResultVOUtils.success("修改成功");
} else {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
}
@AuthRuleAnnotation("")
@GetMapping("/sup/manufacturer/basic/delete")
@Log(title = "资质证书", businessType = BusinessType.DELETE)
public BaseResponse deleteContact(DeleteRequest deleteRequest) {
boolean b = supManufacturerService.deleteById(deleteRequest.getId());
if (b)
return ResultVOUtils.success("删除成功");
else {
return ResultVOUtils.error(500, "删除失败");
}
}
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() + "";
}
}

Loading…
Cancel
Save