Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

ezhizao_zx 2 minggu lalu
induk
melakukan
05d4691899

+ 492 - 0
src/main/java/cn/ezhizao/project/business/controller/BizCompanyMaterialController.java

@@ -0,0 +1,492 @@
+package cn.ezhizao.project.business.controller;
+
+import java.util.*;
+import java.util.stream.Collectors;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+
+import cn.ezhizao.common.utils.ServletUtils;
+import cn.ezhizao.framework.aspectj.lang.annotation.Log;
+import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
+import cn.ezhizao.framework.web.controller.BaseController;
+import cn.ezhizao.framework.web.domain.AjaxResult;
+import cn.ezhizao.framework.web.page.TableDataInfo;
+import cn.ezhizao.project.business.domain.*;
+import cn.ezhizao.project.business.service.IBizCompanyService;
+import cn.ezhizao.project.business.service.IBizProductService;
+import cn.ezhizao.project.business.service.IBizTenantService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import cn.ezhizao.project.business.service.IBizCompanyMaterialService;
+
+
+/**
+ * 客户物料Controller
+ *
+ * @author ezhizao
+ * @date 2025-05-27
+ */
+@RestController
+@RequestMapping("/business/companyMaterial")
+public class BizCompanyMaterialController extends BaseController
+{
+    @Resource
+    private IBizCompanyMaterialService bizCompanyMaterialService;
+    @Resource
+    private IBizTenantService bizTenantService;
+    @Resource
+    private IBizCompanyService bizCompanyService;
+    @Resource
+    private IBizProductService bizProductService;
+    public static final String PAGE_SIZE = "pageSize";
+
+    /**
+     * 查询客户物料列表
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(BizCompanyMaterial bizCompanyMaterial) throws NoSuchFieldException, IllegalAccessException
+    {
+        String pageSizeStr = ServletUtils.getParameter(PAGE_SIZE);
+        if (pageSizeStr !=null) {
+            startPage();
+        }
+        List<BizCompanyMaterial> list = bizCompanyMaterialService.getList(bizCompanyMaterial);
+        return getDataTable(list);
+    }
+    /**
+     * 新增客户物料
+     */
+    @Log(title = "客户物料", businessType = BusinessType.INSERT)
+    @PostMapping
+    @Transactional
+    public AjaxResult add(@RequestBody List<BizCompanyMaterial> bizCompanyMaterialList) throws NoSuchFieldException, IllegalAccessException
+    {
+        //判断传入的个数
+        if(bizCompanyMaterialList.size() == 0){
+            throw new RuntimeException("新增失败,数据不能为空");
+        }
+        if(bizCompanyMaterialList.size() >100) {
+            throw new RuntimeException("新增失败,数据过多,不允许超过100条");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getCode() == null || companyMaterial.getCode() == "")) {
+            throw new RuntimeException("新增失败,单据编号不能为空");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getJdId() == null)) {
+            throw new RuntimeException("新增失败,金蝶id不能为空");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getCompanyMaterialCode() == null || companyMaterial.getCompanyMaterialCode() == "")) {
+            throw new RuntimeException("新增失败,客户物料编码不能为空");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getProductCode() == null || companyMaterial.getProductCode() == "")) {
+            throw new RuntimeException("新增失败,产品编码不能为空");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsStartUsing() == null)){
+            throw new RuntimeException("新增失败,是否启用不能为空");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsStartUsing() != 0) && bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsStartUsing() != 1)){
+            throw new RuntimeException("新增失败,是否启用只能为0或1");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsCarry() != null) && (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsCarry() != 0) && bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsCarry() != 1))){
+            throw new RuntimeException("新增失败,默认携带只能为0或1");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsMutiCompany() != null) && (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsMutiCompany() != 0) && bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsMutiCompany() != 1))){
+            throw new RuntimeException("新增失败,是否多选客户只能为0或1");
+        }
+        //查询厂别是否存在
+        Set<Long> tenantSet = bizCompanyMaterialList.stream()
+                .filter(Objects::nonNull)
+                .map(BizCompanyMaterial::getTenantId)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+
+        List<Long> tenantIdsList = new ArrayList<>(tenantSet);
+        if (tenantIdsList.size() > 0) {
+            List<BizTenant> tenantList = bizTenantService.query().in("id", tenantIdsList).list();
+            if(tenantList.isEmpty() || tenantList.size() != tenantIdsList.size()){
+                throw new RuntimeException("新增失败,厂别不存在");
+            }
+        }
+        //判断客户是否存在
+        Set<String> companySet = bizCompanyMaterialList.stream()
+                .filter(Objects::nonNull)
+                .map(BizCompanyMaterial::getCompanyCode)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+
+        List<String> companyCodesList = new ArrayList<>(companySet);
+        if (companyCodesList.size() > 0) {
+            List<BizCompany> companyList = bizCompanyService.query().in("company_code", companyCodesList).list();
+            if(companyList.isEmpty() || companyList.size() != companyCodesList.size()){
+                throw new RuntimeException("新增失败,客户不存在");
+            }
+            for (BizCompanyMaterial companyMaterial : bizCompanyMaterialList){
+                if(companyMaterial.getCompanyCode() != null && !companyMaterial.getCompanyCode().equals("")){
+                    BizCompany bizCompany = companyList.stream().filter(company -> company.getCompanyCode().equals(companyMaterial.getCompanyCode())).findFirst().orElse(null);
+                    if(bizCompany == null){
+                        throw new RuntimeException("新增失败,客户不存在");
+                        }
+                    companyMaterial.setCompanyId(bizCompany.getId());
+                    companyMaterial.setCompanyName(bizCompany.getCompanyName());
+                }
+            }
+        }
+        //判断多选客户是否存在
+        Set<String> multiCompanySet = bizCompanyMaterialList.stream()
+                .filter(Objects::nonNull) // 确保 BizCompanyMaterial 对象不为 null
+                .map(BizCompanyMaterial::getCompanyCodes) // 获取 List<String>
+                .filter(Objects::nonNull) // 确保返回的 List 不为 null
+                .flatMap(List::stream) // 将 List<String> 展平为 Stream<String>
+                .filter(Objects::nonNull) // 确保每个字符串不为 null
+                .collect(Collectors.toSet()); // 收集到 Set 中
+        List<String> mutiCompanyCodesList = new ArrayList<>(multiCompanySet);
+        if (mutiCompanyCodesList.size() > 0) {
+            List<BizCompany> companyList = bizCompanyService.query().in("company_code", mutiCompanyCodesList).list();
+            if (companyList.isEmpty() || companyList.size() != mutiCompanyCodesList.size()) {
+                throw new RuntimeException("新增失败,多选客户不存在");
+            }
+            for (BizCompanyMaterial companyMaterial : bizCompanyMaterialList) {
+                if (companyMaterial.getCompanyCodes() != null && !companyMaterial.getCompanyCodes().isEmpty()) {
+                    List<BizCompany> companylist = companyList.stream().filter(v -> companyMaterial.getCompanyCodes().contains(v.getCompanyCode())).collect(Collectors.toList());
+                    if (companylist.isEmpty() || companylist.size() != companyMaterial.getCompanyCodes().size()) {
+                        throw new RuntimeException("新增失败,多选客户不存在");
+                    }
+                    List<Long> ids = companylist.stream().map(BizCompany::getId).collect(Collectors.toList());
+                    companyMaterial.setMutiCompanyIds(ids.stream()
+                            .map(Object::toString)
+                            .collect(Collectors.joining(",")));
+                    companyMaterial.setMutiCompanyNames(companylist.stream()
+                            .map(BizCompany::getCompanyName)
+                            .collect(Collectors.joining(",")));
+                    companyMaterial.setMutiCompanyCodes(companylist.stream()
+                            .map(BizCompany::getCompanyCode)
+                            .collect(Collectors.joining(",")));
+                }
+            }
+        }
+        //判断客户物料是否存在
+        Set<String> companyMaterialSet = bizCompanyMaterialList.stream()
+                .filter(Objects::nonNull)
+                .map(BizCompanyMaterial::getCompanyMaterialCode)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+
+        List<String> companyMaterialCodesList = new ArrayList<>(companyMaterialSet);
+        if (companyMaterialCodesList.size() > 0) {
+            List<BizCompany> companyList = bizCompanyService.query().in("company_code", companyMaterialCodesList).list();
+            if(companyList.isEmpty() || companyList.size() != companyMaterialCodesList.size()){
+                throw new RuntimeException("新增失败,客户物料编码不存在");
+            }
+            for (BizCompanyMaterial companyMaterial : bizCompanyMaterialList){
+                    BizCompany bizCompany = companyList.stream().filter(company -> company.getCompanyCode().equals(companyMaterial.getCompanyMaterialCode())).findFirst().orElse(null);
+                    if(bizCompany == null){
+                        throw new RuntimeException("新增失败,客户物料编码不存在");
+                    }
+                    companyMaterial.setCompanyMaterialId(bizCompany.getId());
+                    companyMaterial.setCompanyMaterialName(bizCompany.getCompanyName());
+            }
+        }
+        //判断产品是否存在
+        Set<String>productSet = bizCompanyMaterialList.stream()
+                .filter(Objects::nonNull)
+                .map(BizCompanyMaterial::getProductCode)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+
+        List<String> productCodesList = new ArrayList<>(productSet);
+        if (productCodesList.size() > 0) {
+            List<BizProduct> productList = bizProductService.query().in("product_code", productCodesList).list();
+            if(productList.isEmpty() || productList.size() != productCodesList.size()){
+                throw new RuntimeException("新增失败,产品不存在");
+            }
+            for (BizCompanyMaterial product : bizCompanyMaterialList){
+                BizProduct bizProduct = productList.stream().filter(v -> v.getProductCode().equals(product.getProductCode())).findFirst().orElse(null);
+                if(bizProduct == null){
+                    throw new RuntimeException("新增失败,产品不存在");
+                    }
+                product.setDescription(bizProduct.getDescription());
+                product.setProductId(bizProduct.getId());
+                product.setSpecification(bizProduct.getSpecification());
+            }
+        }
+        //保存
+        bizCompanyMaterialService.saveBatch(bizCompanyMaterialList);
+        return success(bizCompanyMaterialList.stream()
+                .map(v -> {
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("id", v.getId());
+                    map.put("code", v.getCode());
+                    return map;
+                })
+                .collect(Collectors.toList()));
+    }
+
+    /**
+     * 修改客户物料
+     */
+    @Log(title = "客户物料", businessType = BusinessType.UPDATE)
+    @PutMapping
+    @Transactional
+    public AjaxResult edit(@RequestBody List<BizCompanyMaterial> bizCompanyMaterialList) throws NoSuchFieldException, IllegalAccessException
+    {
+        //判断传入的个数
+        if(bizCompanyMaterialList.size() == 0){
+            throw new RuntimeException("修改失败,数据不能为空");
+        }
+        if(bizCompanyMaterialList.size() >100) {
+            throw new RuntimeException("修改失败,数据过多,不允许超过100条");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getId() == null)) {
+            throw new RuntimeException("修改失败,id不能为空");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getJdId() == null)) {
+            throw new RuntimeException("修改失败,金蝶id不能为空");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsStartUsing() != null) && (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsStartUsing() != 0) && bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsStartUsing() != 1))){
+            throw new RuntimeException("修改失败,是否启用只能为0或1");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsCarry() != null) && (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsCarry() != 0) && bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsCarry() != 1))){
+            throw new RuntimeException("修改失败,默认携带只能为0或1");
+        }
+        if (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsMutiCompany() != null) && (bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsMutiCompany() != 0) && bizCompanyMaterialList.stream().anyMatch(companyMaterial -> companyMaterial.getIsMutiCompany() != 1))){
+            throw new RuntimeException("修改失败,是否多选客户只能为0或1");
+        }
+        //查询厂别是否存在
+        Set<Long> tenantSet = bizCompanyMaterialList.stream()
+                .filter(Objects::nonNull)
+                .map(BizCompanyMaterial::getTenantId)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+
+        List<Long> tenantIdsList = new ArrayList<>(tenantSet);
+        if (tenantIdsList.size() > 0) {
+            List<BizTenant> tenantList = bizTenantService.query().in("id", tenantIdsList).list();
+            if(tenantList.isEmpty() || tenantList.size() != tenantIdsList.size()){
+                throw new RuntimeException("修改失败,厂别不存在");
+            }
+        }
+        //判断客户是否存在
+        Set<String> companySet = bizCompanyMaterialList.stream()
+                .filter(Objects::nonNull)
+                .map(BizCompanyMaterial::getCompanyCode)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+
+        List<String> companyCodesList = new ArrayList<>(companySet);
+        if (companyCodesList.size() > 0) {
+            List<BizCompany> companyList = bizCompanyService.query().in("company_code", companyCodesList).list();
+            if(companyList.isEmpty() || companyList.size() != companyCodesList.size()){
+                throw new RuntimeException("修改失败,客户不存在");
+            }
+            for (BizCompanyMaterial companyMaterial : bizCompanyMaterialList){
+                if(companyMaterial.getCompanyCode() != null && !companyMaterial.getCompanyCode().equals("")){
+                    BizCompany bizCompany = companyList.stream().filter(company -> company.getCompanyCode().equals(companyMaterial.getCompanyCode())).findFirst().orElse(null);
+                    if(bizCompany == null){
+                        throw new RuntimeException("修改失败,客户不存在");
+                    }
+                    companyMaterial.setCompanyId(bizCompany.getId());
+                    companyMaterial.setCompanyName(bizCompany.getCompanyName());
+                }
+            }
+        }
+        //判断多选客户是否存在
+        Set<String> multiCompanySet = bizCompanyMaterialList.stream()
+                .filter(Objects::nonNull) // 确保 BizCompanyMaterial 对象不为 null
+                .map(BizCompanyMaterial::getCompanyCodes) // 获取 List<String>
+                .filter(Objects::nonNull) // 确保返回的 List 不为 null
+                .flatMap(List::stream) // 将 List<String> 展平为 Stream<String>
+                .filter(Objects::nonNull) // 确保每个字符串不为 null
+                .collect(Collectors.toSet()); // 收集到 Set 中
+        List<String> mutiCompanyCodesList = new ArrayList<>(multiCompanySet);
+        if (mutiCompanyCodesList.size() > 0) {
+            List<BizCompany> companyList = bizCompanyService.query().in("company_code", mutiCompanyCodesList).list();
+            if (companyList.isEmpty() || companyList.size() != multiCompanySet.size()) {
+                throw new RuntimeException("修改失败,多选客户不存在");
+            }
+            for (BizCompanyMaterial companyMaterial : bizCompanyMaterialList) {
+                if (companyMaterial.getCompanyCodes() != null && !companyMaterial.getCompanyCodes().isEmpty()) {
+                    List<BizCompany> companylist = companyList.stream().filter(v -> companyMaterial.getCompanyCodes().contains(v.getCompanyCode())).collect(Collectors.toList());
+                    if (companylist.isEmpty() || companylist.size() != companyMaterial.getCompanyCodes().size()) {
+                        throw new RuntimeException("修改失败,多选客户不存在");
+                    }
+                    List<Long> ids = companylist.stream().map(BizCompany::getId).collect(Collectors.toList());
+                    companyMaterial.setMutiCompanyIds(ids.stream()
+                            .map(Object::toString)
+                            .collect(Collectors.joining(",")));
+                    companyMaterial.setMutiCompanyNames(companylist.stream()
+                            .map(BizCompany::getCompanyName)
+                            .collect(Collectors.joining(",")));
+                    companyMaterial.setMutiCompanyCodes(companylist.stream()
+                            .map(BizCompany::getCompanyCode)
+                            .collect(Collectors.joining(",")));
+                }
+            }
+        }
+        //判断客户物料是否存在
+        Set<String> companyMaterialSet = bizCompanyMaterialList.stream()
+                .filter(Objects::nonNull)
+                .map(BizCompanyMaterial::getCompanyMaterialCode)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+
+        List<String> companyMaterialCodesList = new ArrayList<>(companyMaterialSet);
+        if (companyMaterialCodesList.size() > 0) {
+            List<BizCompany> companyList = bizCompanyService.query().in("company_code", companyMaterialCodesList).list();
+            if(companyList.isEmpty() || companyList.size() != companyMaterialCodesList.size()){
+                throw new RuntimeException("修改失败,客户物料编码不存在");
+            }
+            for (BizCompanyMaterial companyMaterial : bizCompanyMaterialList){
+                BizCompany bizCompany = companyList.stream().filter(company -> company.getCompanyCode().equals(companyMaterial.getCompanyMaterialCode())).findFirst().orElse(null);
+                if(bizCompany == null){
+                    throw new RuntimeException("修改失败,客户物料编码不存在");
+                }
+                companyMaterial.setCompanyMaterialId(bizCompany.getId());
+                companyMaterial.setCompanyMaterialName(bizCompany.getCompanyName());
+            }
+        }
+        //判断产品是否存在
+        Set<String>productSet = bizCompanyMaterialList.stream()
+                .filter(Objects::nonNull)
+                .map(BizCompanyMaterial::getProductCode)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+
+        List<String> productCodesList = new ArrayList<>(productSet);
+        if (productCodesList.size() > 0) {
+            List<BizProduct> productList = bizProductService.query().in("product_code", productCodesList).list();
+            if(productList.isEmpty() || productList.size() != productCodesList.size()){
+                throw new RuntimeException("修改失败,产品不存在");
+            }
+            for (BizCompanyMaterial product : bizCompanyMaterialList){
+                BizProduct bizProduct = productList.stream().filter(v -> v.getProductCode().equals(product.getProductCode())).findFirst().orElse(null);
+                if(bizProduct == null){
+                    throw new RuntimeException("修改失败,产品不存在");
+                }
+                product.setDescription(bizProduct.getDescription());
+                product.setProductId(bizProduct.getId());
+                product.setSpecification(bizProduct.getSpecification());
+            }
+        }
+        List<BizCompanyMaterial> companyMaterialList = bizCompanyMaterialService.query().in("id", bizCompanyMaterialList.stream()
+                .map(BizCompanyMaterial::getId)
+                .collect(Collectors.toList())).list();
+        for(BizCompanyMaterial companyMaterial : bizCompanyMaterialList){
+            BizCompanyMaterial bizCompanyMaterial = companyMaterialList.stream().filter(v -> v.getId().equals(companyMaterial.getId())).findFirst().orElse(null);
+            if(bizCompanyMaterial == null){
+                throw new RuntimeException("修改失败,客户物料id不存在");
+            }
+            if (companyMaterial.getCode()!= null && !companyMaterial.getCode().equals("")){
+                bizCompanyMaterial.setCode(companyMaterial.getCode());
+            }
+            if (companyMaterial.getJdId() != null){
+                bizCompanyMaterial.setJdId(companyMaterial.getJdId());
+            }
+            if (companyMaterial.getTenantId() != null){
+                bizCompanyMaterial.setTenantId(companyMaterial.getTenantId());
+            }
+            if (companyMaterial.getCompanyId() != null){
+                bizCompanyMaterial.setCompanyId(companyMaterial.getCompanyId());
+            }
+            if (companyMaterial.getCompanyName() != null){
+                bizCompanyMaterial.setCompanyName(companyMaterial.getCompanyName());
+            }
+            if (companyMaterial.getCompanyCode() != null){
+                bizCompanyMaterial.setCompanyCode(companyMaterial.getCompanyCode());
+            }
+            if (companyMaterial.getMutiCompanyIds() != null){
+                bizCompanyMaterial.setMutiCompanyIds(companyMaterial.getMutiCompanyIds());
+            }
+            if(companyMaterial.getMutiCompanyCodes() != null){
+                bizCompanyMaterial.setMutiCompanyCodes(companyMaterial.getMutiCompanyCodes());
+            }
+            if (companyMaterial.getMutiCompanyNames() != null){
+                bizCompanyMaterial.setMutiCompanyNames(companyMaterial.getMutiCompanyNames());
+            }
+            if(companyMaterial.getStatus() != null){
+                bizCompanyMaterial.setStatus(companyMaterial.getStatus());
+            }
+            if (companyMaterial.getCompanyMaterialId() != null){
+                bizCompanyMaterial.setCompanyMaterialId(companyMaterial.getCompanyMaterialId());
+            }
+            if (companyMaterial.getCompanyMaterialName() != null){
+                bizCompanyMaterial.setCompanyMaterialName(companyMaterial.getCompanyMaterialName());
+            }
+            if (companyMaterial.getCompanyMaterialCode() != null){
+                bizCompanyMaterial.setCompanyMaterialCode(companyMaterial.getCompanyMaterialCode());
+            }
+            if (companyMaterial.getProductCode() != null){
+                bizCompanyMaterial.setProductCode(companyMaterial.getProductCode());
+            }
+            if (companyMaterial.getDescription() != null){
+                bizCompanyMaterial.setDescription(companyMaterial.getDescription());
+            }
+            if (companyMaterial.getProductId() != null){
+                bizCompanyMaterial.setProductId(companyMaterial.getProductId());
+            }
+            if (companyMaterial.getSpecification() != null){
+                bizCompanyMaterial.setSpecification(companyMaterial.getSpecification());
+            }
+            if (companyMaterial.getIsStartUsing() != null){
+                bizCompanyMaterial.setIsStartUsing(companyMaterial.getIsStartUsing());
+            }
+            if (companyMaterial.getIsCarry() != null){
+                bizCompanyMaterial.setIsCarry(companyMaterial.getIsCarry());
+            }
+            if (companyMaterial.getIsMutiCompany() != null){
+                bizCompanyMaterial.setIsMutiCompany(companyMaterial.getIsMutiCompany());
+            }
+            if (companyMaterial.getRemark() != null){
+                bizCompanyMaterial.setRemark(companyMaterial.getRemark());
+            }
+        }
+        bizCompanyMaterialService.updateBatchById(companyMaterialList);
+        return success(companyMaterialList.stream()
+                .map(v -> {
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("id", v.getId());
+                    map.put("code", v.getCode());
+                    return map;
+                })
+                .collect(Collectors.toList()));
+    }
+
+    /**
+     * 删除客户物料
+     */
+    @Log(title = "客户物料", businessType = BusinessType.DELETE)
+	@DeleteMapping
+    public AjaxResult remove(@RequestBody List<Long> ids)
+    {
+        if(ids.isEmpty()){
+            return error("删除失败,id不能为空");
+        }
+        List<BizCompanyMaterial> companyMaterialList = bizCompanyMaterialService.query().in("id", ids).list();
+        if(companyMaterialList.isEmpty()){
+            return error("删除失败,数据不存在");
+        }
+        Set<Long> uniqueIds = new HashSet<>(ids);
+        // 获取companyMaterialList中的id集合
+        Set<Long> materialIds = companyMaterialList.stream()
+                .map(BizCompanyMaterial::getId)
+                .collect(Collectors.toSet());
+
+        // 比较去重后的ids列表和companyMaterialList的大小
+        if (uniqueIds.size() != materialIds.size()) {
+            // 获取不存在的id列表
+            Set<Long> nonExistentIds = new HashSet<>(uniqueIds);
+            nonExistentIds.removeAll(materialIds);
+            // 返回不存在的id列表
+            return error("删除失败,以下ID不存在: " + nonExistentIds);
+        }
+
+        return toAjax(bizCompanyMaterialService.removeBatchByIds(companyMaterialList));
+    }
+}

+ 2 - 2
src/main/java/cn/ezhizao/project/business/controller/BizProductAccessoriesMaterialController.java

@@ -152,7 +152,7 @@ public class BizProductAccessoriesMaterialController extends BaseController {
                     .collect(Collectors.toSet());
 
             List<Long> tenantIdsList = new ArrayList<>(tenantSet);
-            if (tenantIdsList.size() > 1) {
+            if (tenantIdsList.size() > 0) {
                 List<BizTenant> tenantList = bizTenantService.query().in("id", tenantIdsList).list();
                 if (tenantList.isEmpty() || tenantList.size() != tenantIdsList.size()) {
                     throw new RuntimeException("新增失败,厂别不存在");
@@ -545,7 +545,7 @@ public class BizProductAccessoriesMaterialController extends BaseController {
                     .collect(Collectors.toSet());
 
             List<Long> tenantIdsList = new ArrayList<>(tenantSet);
-            if (tenantIdsList.size() > 1) {
+            if (tenantIdsList.size() > 0) {
                 List<BizTenant> tenantList = bizTenantService.query().in("id", tenantIdsList).list();
                 if (tenantList.isEmpty() || tenantList.size() != tenantIdsList.size()) {
                     throw new RuntimeException("修改失败,厂别不存在");

+ 124 - 0
src/main/java/cn/ezhizao/project/business/domain/BizCompanyMaterial.java

@@ -0,0 +1,124 @@
+package cn.ezhizao.project.business.domain;
+
+import cn.ezhizao.framework.aspectj.lang.annotation.Excel;
+import cn.ezhizao.framework.web.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+/**
+ * 客户物料对象 biz_company_material
+ *
+ * @author ezhizao
+ * @date 2025-05-27
+ */
+@Data
+@TableName(value = "biz_company_material")
+public class BizCompanyMaterial extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 金碟id */
+    @ApiModelProperty(value = "${comment}")
+    private Long jdId;
+
+    /** 单据编号 */
+    @Excel(name = "单据编号")
+    @ApiModelProperty(value = "单据编号")
+    private String code;
+
+    /** 名称 */
+    @Excel(name = "名称")
+    @ApiModelProperty(value = "名称")
+    private String name;
+
+    /** 租户id */
+    @ApiModelProperty(value = "名称")
+    private Long tenantId;
+
+    /** 客户id */
+    @ApiModelProperty(value = "名称")
+    private Long companyId;
+
+    /** 客户编码 */
+    @Excel(name = "客户编码")
+    @ApiModelProperty(value = "客户编码")
+    private String companyCode;
+
+    /** 客户名称 */
+    @Excel(name = "客户名称")
+    @ApiModelProperty(value = "客户名称")
+    private String companyName;
+
+    /** 多选客户id */
+    @ApiModelProperty(value = "客户名称")
+    private String mutiCompanyIds;
+
+    /** 多选客户编码 */
+    @Excel(name = "多选客户编码")
+    @ApiModelProperty(value = "多选客户编码")
+    private String mutiCompanyCodes;
+
+    /** 多选客户名称 */
+    @Excel(name = "多选客户名称")
+    @ApiModelProperty(value = "多选客户名称")
+    private String mutiCompanyNames;
+
+    /** 单据状态 */
+    @Excel(name = "单据状态")
+    @ApiModelProperty(value = "单据状态")
+    private String status;
+
+    @ApiModelProperty(value = "客户物料主表编码")
+    private Long companyMaterialId;
+
+    /** 客户编码 */
+    @Excel(name = "客户编码")
+    @ApiModelProperty(value = "客户编码")
+    private String companyMaterialCode;
+
+    /** 客户名称 */
+    @Excel(name = "客户名称")
+    @ApiModelProperty(value = "客户名称")
+    private String companyMaterialName;
+
+    /** 产品id */
+    @ApiModelProperty(value = "客户名称")
+    private Long productId;
+
+    /** 产品编码 */
+    @Excel(name = "产品编码")
+    @ApiModelProperty(value = "产品编码")
+    private String productCode;
+
+    /** 产品名称 */
+    @Excel(name = "产品名称")
+    @ApiModelProperty(value = "产品名称")
+    private String description;
+
+    /** 规格型号 */
+    @Excel(name = "规格型号")
+    @ApiModelProperty(value = "规格型号")
+    private String specification;
+
+    /** 是否启用(0:是;1:否 */
+    @Excel(name = "是否启用(0:是;1:否")
+    @ApiModelProperty(value = "是否启用(0:是;1:否")
+    private Integer isStartUsing;
+
+    /** 默认携带(0:是,1:否) */
+    @Excel(name = "默认携带(0:是,1:否)")
+    @ApiModelProperty(value = "默认携带(0:是,1:否)")
+    private Integer isCarry;
+
+    /** 是否多选客户(0:是,1:否) */
+    @Excel(name = "是否多选客户(0:是,1:否)")
+    @ApiModelProperty(value = "是否多选客户(0:是,1:否)")
+    private Integer isMutiCompany;
+    @TableField(exist = false)
+    private List<String> companyCodes;
+
+}

+ 29 - 0
src/main/java/cn/ezhizao/project/business/mapper/BizCompanyMaterialMapper.java

@@ -0,0 +1,29 @@
+package cn.ezhizao.project.business.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import cn.ezhizao.project.business.domain.BizCompanyMaterial;
+
+/**
+ * 客户物料Mapper接口
+ *
+ * @author ezhizao
+ * @date 2025-05-27
+ */
+public interface BizCompanyMaterialMapper extends BaseMapper<BizCompanyMaterial>
+{
+    /**
+     * 查询客户物料列表
+     *
+     * @param bizCompanyMaterial 客户物料
+     * @return 客户物料集合
+     */
+    public List<BizCompanyMaterial> getList(BizCompanyMaterial bizCompanyMaterial);
+
+    /**
+     * 物理删除
+     * @param bizCompanyMaterial
+     * @return 删除结果
+    */
+    public int physicalDelete(BizCompanyMaterial bizCompanyMaterial);
+}

+ 30 - 0
src/main/java/cn/ezhizao/project/business/service/IBizCompanyMaterialService.java

@@ -0,0 +1,30 @@
+package cn.ezhizao.project.business.service;
+
+import java.util.List;
+import com.baomidou.mybatisplus.extension.service.IService;
+import cn.ezhizao.project.business.domain.BizCompanyMaterial;
+
+/**
+ * 客户物料Service接口
+ *
+ * @author ezhizao
+ * @date 2025-05-27
+ */
+public interface IBizCompanyMaterialService extends IService<BizCompanyMaterial>
+{
+    /**
+     * 查询客户物料列表
+     *
+     * @param bizCompanyMaterial 客户物料
+     * @return 客户物料集合
+     */
+    public List<BizCompanyMaterial> getList(BizCompanyMaterial bizCompanyMaterial);
+
+    /**
+     * 物理删除
+     * @param bizCompanyMaterial
+     * @return 删除结果
+     */
+    public int physicalDelete(BizCompanyMaterial bizCompanyMaterial);
+
+}

+ 43 - 0
src/main/java/cn/ezhizao/project/business/service/impl/BizCompanyMaterialServiceImpl.java

@@ -0,0 +1,43 @@
+package cn.ezhizao.project.business.service.impl;
+
+import java.util.List;
+import javax.annotation.Resource;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import cn.ezhizao.project.business.mapper.BizCompanyMaterialMapper;
+import cn.ezhizao.project.business.domain.BizCompanyMaterial;
+import cn.ezhizao.project.business.service.IBizCompanyMaterialService;
+
+/**
+ * 客户物料Service业务层处理
+ *
+ * @author ezhizao
+ * @date 2025-05-27
+ */
+@Service
+public class BizCompanyMaterialServiceImpl  extends ServiceImpl<BizCompanyMaterialMapper, BizCompanyMaterial> implements IBizCompanyMaterialService
+{
+    @Resource
+    private BizCompanyMaterialMapper bizCompanyMaterialMapper;
+
+    /**
+     * 查询客户物料列表
+     *
+     * @param bizCompanyMaterial 客户物料
+     * @return 客户物料
+     */
+    @Override
+    public List<BizCompanyMaterial> getList(BizCompanyMaterial bizCompanyMaterial)
+    {
+        return bizCompanyMaterialMapper.getList(bizCompanyMaterial);
+    }
+
+    /**
+     * 物理删除
+     * @param bizCompanyMaterial
+     * @return 删除结果
+     */
+    @Override
+    public int physicalDelete(BizCompanyMaterial bizCompanyMaterial){ return bizCompanyMaterialMapper.physicalDelete(bizCompanyMaterial); };
+
+}

+ 1 - 1
src/main/java/cn/ezhizao/project/system/service/impl/SysUserServiceImpl.java

@@ -63,7 +63,7 @@ public class SysUserServiceImpl implements ISysUserService {
     @Override
     public String checkPhoneUnique(SysUser user) {
         Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
-        SysUser info = userMapper.checkUserNameUnique(user.getUserName());
+        SysUser info = userMapper.checkUserNameUnique(user.getPhoneNumber());
         if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
 
             return UserConstants.NOT_UNIQUE;

+ 36 - 0
src/main/resources/mybatis/business/BizCompanyMaterialMapper.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.ezhizao.project.business.mapper.BizCompanyMaterialMapper">
+
+    <resultMap type="cn.ezhizao.project.business.domain.BizCompanyMaterial" id="BizCompanyMaterialResult">
+        <id column="id" property="id"/>
+    </resultMap>
+
+
+    <select id="getList" parameterType="BizCompanyMaterial" resultMap="BizCompanyMaterialResult">
+        SELECT * FROM biz_company_material
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            deleted = 0
+            <if test="code != null  and code != ''"> AND code like concat('%', #{code}, '%')</if>
+            <if test="jdId != null  and jdId != ''" > AND jd_id = #{jdId}</if>
+            <if test="name != null  and name != ''"> AND name like concat('%', #{name}, '%')</if>
+            <if test="companyCode != null  and companyCode != ''"> AND company_code = #{companyCode}</if>
+            <if test="companyName != null  and companyName != ''"> AND company_name like concat('%', #{companyName}, '%')</if>
+            <if test="mutiCompanyCodes != null  and mutiCompanyCodes != ''"> AND muti_company_codes = #{mutiCompanyCodes}</if>
+            <if test="mutiCompanyNames != null  and mutiCompanyNames != ''"> AND muti_company_names = #{mutiCompanyNames}</if>
+            <if test="status != null  and status != ''"> AND status = #{status}</if>
+        </trim>
+    </select>
+
+    <delete id="physicalDelete">
+        DELETE FROM biz_company_material
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            <if test="id != null">
+                id = #{id} AND
+            </if>
+       <!-- 删除条件为其他外键可以在这里加 -->
+        </trim>
+    </delete>
+</mapper>