Commit 6543ce56 by 杨浩

bug修复

parent 42bb38df
......@@ -380,6 +380,7 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
.set(ErpPurchaseOrderItemDO::getAnnex, purchaseOrderItem.getAnnex())
.eq(ErpPurchaseOrderItemDO::getOrderId, item.getId())
.eq(ErpPurchaseOrderItemDO::getProductId, purchaseOrderItem.getProductId()));
customerOrderApi.updatePurchaseAnnex(item.getCustomerOrderId(), item.getSupplierId(), purchaseOrderItem.getProductId(), purchaseOrderItem.getAnnex());
});
}
}
......
......@@ -5,6 +5,11 @@ import cn.iocoder.foodnexus.framework.common.util.collection.MapUtils;
import cn.iocoder.foodnexus.module.erp.api.service.ErpCustomerApi;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpCustomerDO;
import cn.iocoder.foodnexus.module.erp.service.sale.ErpCustomerService;
import cn.iocoder.foodnexus.module.product.service.category.ProductCategoryService;
import cn.iocoder.foodnexus.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.foodnexus.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.foodnexus.module.system.service.dept.DeptService;
import cn.iocoder.foodnexus.module.system.service.user.AdminUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
......@@ -47,6 +52,15 @@ public class CustomerRequireController {
@Autowired
private ErpCustomerService customerService;
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
private AdminUserService userService;
@Autowired
private DeptService deptService;
@PostMapping("/require")
@Operation(summary = "受理客户需求")
@Parameter(name = "id", description = "编号", required = true)
......@@ -80,10 +94,16 @@ public class CustomerRequireController {
public CommonResult<CustomerRequireRespVO> getCustomerRequire(@RequestParam("id") Long id) {
CustomerRequireDO customerRequire = customerRequireService.getCustomerRequire(id);
return success(BeanUtils.toBean(customerRequire, CustomerRequireRespVO.class, item -> {
item.setCategoryName(productCategoryService.queryNameById(item.getCategoryId()));
AdminUserDO user = userService.getUser(Long.parseLong(item.getCreator()));
DeptDO dept = deptService.getDept(user.getDeptId());
if (CommonUtil.isNotEmpty(dept)) {
item.setDeptName(dept.getName());
item.setCustomerMobile(dept.getPhone());
}
ErpCustomerDO customer = customerService.getCustomer(item.getCustomerId());
if (CommonUtil.isNotEmpty(customer)) {
item.setCustomerName(customer.getName());
item.setCustomerMobile(customer.getMobile());
}
}));
}
......@@ -94,11 +114,16 @@ public class CustomerRequireController {
public CommonResult<PageResult<CustomerRequireRespVO>> getCustomerRequirePage(@Valid CustomerRequirePageReqVO pageReqVO) {
PageResult<CustomerRequireDO> pageResult = customerRequireService.getCustomerRequirePage(pageReqVO);
Map<Long, ErpCustomerDO> customerMap = customerService.getCustomerMap(CommonUtil.listConvertSet(pageResult.getList(), CustomerRequireDO::getCustomerId));
Map<Long, DeptDO> userDeptMap = deptService.queryDeptByUserId(CommonUtil.listConvertSet(pageResult.getList(), item -> Long.parseLong(item.getCreator())));
return success(BeanUtils.toBean(pageResult, CustomerRequireRespVO.class, item -> {
MapUtils.findAndThen(customerMap, item.getCustomerId(), customer -> {
item.setCustomerName(customer.getName());
item.setCustomerMobile(customer.getMobile());
});
MapUtils.findAndThen(userDeptMap, Long.parseLong(item.getCreator()), dept -> {
item.setDeptName(dept.getName());
item.setCustomerMobile(dept.getPhone());
});
item.setCategoryName(productCategoryService.queryNameById(item.getCategoryId()));
}));
}
......
......@@ -23,6 +23,9 @@ public class CustomerRequireRespVO {
@Schema(description = "客户名称")
private String customerName;
@Schema(description = "客户单位")
private String deptName;
@Schema(description = "客户联系方式")
private String customerMobile;
......
......@@ -11,7 +11,9 @@ import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.excel.core.util.ExcelUtils;
import cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.foodnexus.module.erp.api.service.ErpCustomerApi;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpCustomerDO;
import cn.iocoder.foodnexus.module.erp.service.product.ErpProductService;
import cn.iocoder.foodnexus.module.erp.service.sale.ErpCustomerService;
import cn.iocoder.foodnexus.module.operations.controller.admin.customerrequire.vo.CustomerRequirePageReqVO;
import cn.iocoder.foodnexus.module.operations.controller.admin.customerrequire.vo.CustomerRequireRespVO;
import cn.iocoder.foodnexus.module.operations.controller.admin.customerrequire.vo.CustomerRequireSaveReqVO;
......@@ -19,6 +21,10 @@ import cn.iocoder.foodnexus.module.operations.dal.dataobject.customerrequire.Cus
import cn.iocoder.foodnexus.module.operations.service.customerrequire.CustomerRequireService;
import cn.iocoder.foodnexus.module.product.service.category.ProductCategoryService;
import cn.iocoder.foodnexus.module.system.annotations.AppSystemAuth;
import cn.iocoder.foodnexus.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.foodnexus.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.foodnexus.module.system.service.dept.DeptService;
import cn.iocoder.foodnexus.module.system.service.user.AdminUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
......@@ -51,8 +57,17 @@ public class AppCustomerRequireController {
private ErpCustomerApi customerApi;
@Autowired
private ErpCustomerService customerService;
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
private AdminUserService userService;
@Autowired
private DeptService deptService;
@PostMapping("/create")
@Operation(summary = "创建客户需求")
public CommonResult<Long> createCustomerRequire(@Valid @RequestBody CustomerRequireSaveReqVO createReqVO) {
......@@ -74,7 +89,17 @@ public class AppCustomerRequireController {
public CommonResult<CustomerRequireRespVO> getCustomerRequire(@RequestParam("id") Long id) {
CustomerRequireDO customerRequire = customerRequireService.getCustomerRequire(id);
return success(BeanUtils.toBean(customerRequire, CustomerRequireRespVO.class, item -> {
item.setCategoryName(productCategoryService.queryNameById(customerRequire.getCategoryId()));
item.setCategoryName(productCategoryService.queryNameById(item.getCategoryId()));
AdminUserDO user = userService.getUser(Long.parseLong(item.getCreator()));
DeptDO dept = deptService.getDept(user.getDeptId());
if (CommonUtil.isNotEmpty(dept)) {
item.setDeptName(dept.getName());
item.setCustomerMobile(dept.getPhone());
}
ErpCustomerDO customer = customerService.getCustomer(item.getCustomerId());
if (CommonUtil.isNotEmpty(customer)) {
item.setCustomerName(customer.getName());
}
}));
}
......@@ -83,9 +108,17 @@ public class AppCustomerRequireController {
public CommonResult<PageResult<CustomerRequireRespVO>> getCustomerRequirePage(@Valid CustomerRequirePageReqVO pageReqVO) {
pageReqVO.setCreator(SecurityFrameworkUtils.getLoginUserId());
PageResult<CustomerRequireDO> pageResult = customerRequireService.getCustomerRequirePage(pageReqVO);
Map<Long, String> map = productCategoryService.getMap(CommonUtil.listConvertSet(pageResult.getList(), CustomerRequireDO::getCategoryId));
Map<Long, ErpCustomerDO> customerMap = customerService.getCustomerMap(CommonUtil.listConvertSet(pageResult.getList(), CustomerRequireDO::getCustomerId));
Map<Long, DeptDO> userDeptMap = deptService.queryDeptByUserId(CommonUtil.listConvertSet(pageResult.getList(), item -> Long.parseLong(item.getCreator())));
return success(BeanUtils.toBean(pageResult, CustomerRequireRespVO.class, item -> {
MapUtils.findAndThen(map, item.getCategoryId(), item::setCategoryName);
MapUtils.findAndThen(customerMap, item.getCustomerId(), customer -> {
item.setCustomerName(customer.getName());
});
MapUtils.findAndThen(userDeptMap, Long.parseLong(item.getCreator()), dept -> {
item.setDeptName(dept.getName());
item.setCustomerMobile(dept.getPhone());
});
item.setCategoryName(productCategoryService.queryNameById(item.getCategoryId()));
}));
}
......
......@@ -31,4 +31,6 @@ public interface CustomerOrderApi {
Map<Long, String> getCodeMap(Collection<Long> longs);
void updateActualAmount(Long id, int addAmount);
void updatePurchaseAnnex(Long customerOrderId, Long supplierId, Long productId, String annex);
}
......@@ -65,4 +65,6 @@ public class CheckTaskItemsRespVO {
@Schema(description = "附件")
private String annex;
@Schema(description = "采购附件")
private String purchaseAnnex;
}
\ No newline at end of file
......@@ -88,4 +88,7 @@ public class CustomerOrderItemRespVO {
@Schema(description = "客户下单备注")
private String customerRemark;
@Schema(description = "采购附件")
private String purchaseAnnex;
}
\ No newline at end of file
......@@ -74,4 +74,9 @@ public class CheckTaskItemsDO extends BaseDO {
*/
private String annex;
/**
* 采购附件
*/
private String purchaseAnnex;
}
\ No newline at end of file
......@@ -106,4 +106,9 @@ public class CustomerOrderItemDO extends BaseDO {
* 客户下单备注
*/
private String customerRemark;
/**
* 采购附件
*/
private String purchaseAnnex;
}
\ No newline at end of file
......@@ -934,4 +934,13 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
}
}
@Override
public void updatePurchaseAnnex(Long customerOrderId, Long supplierId, Long productId, String annex) {
customerOrderItemMapper.update(Wrappers.<CustomerOrderItemDO>lambdaUpdate()
.set(CustomerOrderItemDO::getPurchaseAnnex, annex)
.eq(CustomerOrderItemDO::getOrderId, customerOrderId)
.eq(CustomerOrderItemDO::getSupplierId, supplierId)
.eq(CustomerOrderItemDO::getProductId, productId));
}
}
\ No newline at end of file
......@@ -136,4 +136,6 @@ public interface DeptService {
}
Map<Long, String> queryNameMapByIds(Collection<Long> ids, boolean fullName);
Map<Long, DeptDO> queryDeptByUserId(Collection<Long> userId);
}
......@@ -13,14 +13,17 @@ import cn.iocoder.foodnexus.module.system.controller.admin.dept.vo.dept.DeptList
import cn.iocoder.foodnexus.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
import cn.iocoder.foodnexus.module.system.controller.admin.dept.vo.dept.DeptSaveRespVO;
import cn.iocoder.foodnexus.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.foodnexus.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.foodnexus.module.system.dal.mysql.dept.DeptMapper;
import cn.iocoder.foodnexus.module.system.dal.redis.RedisKeyConstants;
import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum;
import cn.iocoder.foodnexus.module.system.service.user.AdminUserService;
import com.google.common.annotations.VisibleForTesting;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
......@@ -51,6 +54,10 @@ public class DeptServiceImpl implements DeptService {
@Autowired
private ErpCustomerApi customerApi;
@Autowired
@Lazy
private AdminUserService userService;
@Override
@CacheEvict(cacheNames = RedisKeyConstants.DEPT_CHILDREN_ID_LIST ,
allEntries = true) // allEntries 清空所有缓存,因为操作一个部门,涉及到多个缓存
......@@ -320,6 +327,22 @@ public class DeptServiceImpl implements DeptService {
});
}
@Override
public Map<Long, DeptDO> queryDeptByUserId(Collection<Long> userId) {
if (CommonUtil.isEmpty(userId)) {
return new HashMap<>();
}
List<AdminUserDO> userList = userService.getUserList(userId);
if (CommonUtil.isEmpty(userList)) {
return new HashMap<>();
}
Map<Long, DeptDO> userDeptMap = new HashMap<>();
userList.forEach(item -> {
userDeptMap.put(item.getId(), deptMapper.selectById(item.getDeptId()));
});
return userDeptMap;
}
private String recursion(String deptName, Long parentId) {
if (DeptDO.PARENT_ID_ROOT.equals(parentId) || CommonUtil.isEmpty(parentId)) {
return deptName;
......
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