add:添加调拨其他出库下推功能 fix:修复sys菜单组件名称问题
This commit is contained in:
@@ -38,6 +38,7 @@ public class GlobalExceptionHandler {
|
||||
*/
|
||||
@ExceptionHandler(Throwable.class)
|
||||
public ResponseEntity handleException(Throwable e) {
|
||||
e.printStackTrace();
|
||||
return ResponseData.error(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -57,6 +58,7 @@ public class GlobalExceptionHandler {
|
||||
*/
|
||||
@ExceptionHandler(value = BadRequestException.class)
|
||||
public ResponseEntity badRequestException(BadRequestException e) {
|
||||
e.printStackTrace();
|
||||
return ResponseData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,4 +81,10 @@ public class PurchaseController {
|
||||
public ResponseEntity pushZD(@RequestBody BillChangeDto billChangeDto){
|
||||
return wmsToZDWmdService.syncPurchaseReceiving(billChangeDto);
|
||||
}
|
||||
@PostMapping("/outPush")
|
||||
@Log("下推出库单")
|
||||
public ResponseEntity outPush(@RequestBody PurchaseDto purchaseDto){
|
||||
purchaseService.pushPurchase(purchaseDto);
|
||||
return ResponseData.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,5 @@ public interface PurchaseService extends IService<Purchasemst> {
|
||||
void print(Set<String> ids);
|
||||
|
||||
List<PurchaseMatInfoVo> selectPdaInMat(HashMap of);
|
||||
void pushPurchase(PurchaseDto purchaseDto);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.nl.wms.pm_manage.purchase.service.dto;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -24,9 +26,11 @@ public class PurchaseDto implements Serializable {
|
||||
private String supplier_name;
|
||||
|
||||
private String creator;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date create_time;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date modify_date;
|
||||
|
||||
private Integer status;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package org.nl.wms.pm_manage.purchase.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -13,9 +15,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.ext_manage.enums.EXTConstant;
|
||||
import org.nl.wms.ext_manage.purchase.service.dto.EasAuditRequestDto;
|
||||
import org.nl.wms.ext_manage.service.WmsToErpService;
|
||||
import org.nl.wms.pda_manage.ios_manage.purchase.service.vo.PurchaseMatInfoVo;
|
||||
import org.nl.wms.pm_manage.SourceBillTypeEnum;
|
||||
import org.nl.wms.pm_manage.purchase.service.PurchaseService;
|
||||
import org.nl.wms.pm_manage.purchase.service.dao.Purchasedtl;
|
||||
import org.nl.wms.pm_manage.purchase.service.dao.Purchasemst;
|
||||
@@ -25,15 +31,20 @@ import org.nl.wms.pm_manage.purchase.service.dto.PurchaseDto;
|
||||
import org.nl.wms.pm_manage.purchase.service.vo.PurchasemstListVo;
|
||||
import org.nl.common.utils.ZplUtil;
|
||||
import org.nl.wms.system_manage.service.param.ISysParamService;
|
||||
import org.nl.wms.system_manage.service.param.dao.Param;
|
||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.IOutBillService;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -52,7 +63,10 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchasemstMapper, Purchase
|
||||
private WmsToErpService wmsToErpService;
|
||||
|
||||
@Autowired
|
||||
private ISysParamService sysParamService;
|
||||
private IOutBillService iOutBillService;
|
||||
|
||||
@Autowired
|
||||
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
|
||||
|
||||
@Override
|
||||
public IPage<PurchasemstListVo> queryAll(Map whereJson, PageQuery page) {
|
||||
@@ -227,4 +241,79 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchasemstMapper, Purchase
|
||||
public List<PurchaseMatInfoVo> selectPdaInMat(HashMap of) {
|
||||
return purchasemstMapper.selectPdaInMat(of);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void pushPurchase(PurchaseDto purchaseDto) {
|
||||
if (purchaseDto == null) {
|
||||
throw new BadRequestException("下推失败,下推出库单不能为空");
|
||||
}
|
||||
if (IOSEnum.BILL_STATUS.code("完成").equals(purchaseDto.getBill_status())) {
|
||||
throw new BadRequestException("下推失败,单据状态已经完成");
|
||||
}
|
||||
final List<Purchasedtl> purchasedtls = this.selectListByBillId(purchaseDto.getBill_id());
|
||||
if (CollectionUtils.isEmpty(purchasedtls)){
|
||||
throw new BadRequestException("下推失败,单据明细数据不存在");
|
||||
}
|
||||
Map<String, List<Purchasedtl>> detailsByHouse = purchasedtls.stream()
|
||||
.peek(detail -> {
|
||||
if (ObjectUtil.isEmpty(detail.getHouse_code())) {
|
||||
throw new BadRequestException("下推失败,物料" + detail.getSku_code() + "的仓库编码不能为空");
|
||||
}
|
||||
})
|
||||
.collect(Collectors.groupingBy(Purchasedtl::getHouse_code));
|
||||
|
||||
for (Map.Entry<String, List<Purchasedtl>> entry : detailsByHouse.entrySet()) {
|
||||
iOutBillService.saveBill(convertPurchaseToOutBillParam(purchaseDto, entry.getKey(), entry.getValue()));
|
||||
}
|
||||
this.update(new LambdaUpdateWrapper<Purchasemst>()
|
||||
.set(Purchasemst::getBill_status,IOSEnum.BILL_STATUS.code("分配完"))
|
||||
.eq(Purchasemst::getId,purchaseDto.getId()));
|
||||
}
|
||||
|
||||
private JSONObject convertPurchaseToOutBillParam(PurchaseDto purchase, String houseCode,
|
||||
List<Purchasedtl> details) {
|
||||
List<String> materialCodes = details.stream()
|
||||
.map(Purchasedtl::getSku_code)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<MdMeMaterialbase> materials = iMdMeMaterialbaseService.list(
|
||||
new LambdaQueryWrapper<MdMeMaterialbase>()
|
||||
.in(MdMeMaterialbase::getMaterial_code, materialCodes)
|
||||
.select(MdMeMaterialbase::getMaterial_id, MdMeMaterialbase::getMaterial_code,
|
||||
MdMeMaterialbase::getQty_unit_id));
|
||||
Map<String, MdMeMaterialbase> materialsByCode = materials.stream()
|
||||
.collect(Collectors.toMap(MdMeMaterialbase::getMaterial_code, Function.identity()));
|
||||
|
||||
List<JSONObject> tableData = new ArrayList<>();
|
||||
for (Purchasedtl detail : details) {
|
||||
MdMeMaterialbase material = materialsByCode.get(detail.getSku_code());
|
||||
if (material == null) {
|
||||
throw new BadRequestException("下推失败,物料" + detail.getSku_code() + "在WMS中不存在");
|
||||
}
|
||||
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("material_id", material.getMaterial_id());
|
||||
row.put("material_code", detail.getSku_code());
|
||||
row.put("qty_unit_id", material.getQty_unit_id());
|
||||
row.put("qty_unit_name", detail.getUnit());
|
||||
row.put("qty", detail.getQty());
|
||||
row.put("pcsn", detail.getBatch_no());
|
||||
row.put("source_bill_code", purchase.getBill_id());
|
||||
row.put("source_bill_type", SourceBillTypeEnum.PM_PURCHASE.getBillType());
|
||||
row.put("source_billdtl_id", detail.getItem_no());
|
||||
row.put("callback_strategy", "DealPurchaseRecBillCallback");
|
||||
row.put("remark", "关联采购单:" + purchase.getOrder_no());
|
||||
tableData.add(row);
|
||||
}
|
||||
|
||||
JSONObject billParam = new JSONObject();
|
||||
billParam.put("stor_code", houseCode);
|
||||
billParam.put("biz_date", DateUtil.today());
|
||||
billParam.put("bill_type", IOSEnum.BILL_TYPE.code("生产出库"));
|
||||
billParam.put("remark", "采购单下推生成,采购单号:" + purchase.getOrder_no());
|
||||
billParam.put("tableData", tableData);
|
||||
return billParam;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,7 @@
|
||||
FROM
|
||||
sys_menu
|
||||
WHERE
|
||||
type != '2'
|
||||
and system_type = #{systemType}
|
||||
system_type = #{systemType}
|
||||
and
|
||||
menu_id IN (
|
||||
SELECT
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -49,6 +50,11 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
|
||||
|
||||
private static final String MENU_TYPE_SYSTEM = "1";
|
||||
private static final String MENU_TYPE_DIRECTORY = "2";
|
||||
private static final String MENU_TYPE_MENU = "3";
|
||||
private static final String MENU_TYPE_BUTTON = "4";
|
||||
|
||||
@Autowired
|
||||
private SysMenuMapper baseMapper;
|
||||
|
||||
@@ -129,7 +135,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
resources.setPid(null);
|
||||
addSystemTypeDict(resources);
|
||||
}
|
||||
|
||||
if (MENU_TYPE_DIRECTORY.equals(resources.getType())){
|
||||
resources.setComponent("ParentView");
|
||||
}
|
||||
baseMapper.insert(resources);
|
||||
// 计算子节点数目
|
||||
resources.setSub_count(0);
|
||||
@@ -240,8 +248,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
updateSubCnt(oldPid);
|
||||
updateSubCnt(newPid);
|
||||
//更新SystemType
|
||||
if (!resources.getSystem_type().equals(menu.getSystem_type())){
|
||||
this.update(new UpdateWrapper<SysMenu>().set(DictConstantPool.DICT_SYS_CODE,resources.getSystem_type()).in("menu_id",allChildIds));
|
||||
if (!resources.getSystem_type().equals(menu.getSystem_type()) && !CollectionUtils.isEmpty(allChildIds)){
|
||||
this.update(new LambdaUpdateWrapper<SysMenu>()
|
||||
.set(SysMenu::getSystem_type,resources.getSystem_type())
|
||||
.in(SysMenu::getMenu_id,allChildIds));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -394,6 +404,27 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
return menuDto;
|
||||
}
|
||||
|
||||
private boolean isDirectoryType(MenuDto menuDTO) {
|
||||
return MENU_TYPE_DIRECTORY.equals(menuDTO.getType());
|
||||
}
|
||||
|
||||
private boolean isRootMenu(MenuDto menuDTO, String rootPid) {
|
||||
return rootPid.equals(menuDTO.getPid());
|
||||
}
|
||||
|
||||
private String resolveRouteComponent(MenuDto menuDTO, String rootPid) {
|
||||
if (menuDTO.getIframe()) {
|
||||
return null;
|
||||
}
|
||||
if (isRootMenu(menuDTO, rootPid)) {
|
||||
return StrUtil.isEmpty(menuDTO.getComponent()) ? "Layout" : menuDTO.getComponent();
|
||||
}
|
||||
if (isDirectoryType(menuDTO)) {
|
||||
return StrUtil.isEmpty(menuDTO.getComponent()) ? "ParentView" : menuDTO.getComponent();
|
||||
}
|
||||
return StrUtil.isEmpty(menuDTO.getComponent()) ? null : menuDTO.getComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuVo> buildMenus(String systemType) {
|
||||
Dict dict = sysDictMapper.selectOne(new QueryWrapper<Dict>().eq("code", DictConstantPool.DICT_SYS_CODE).eq("value", systemType));
|
||||
@@ -412,54 +443,44 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
public List<MenuVo> buildMenus(List<MenuDto> menuDtos, String pid) {
|
||||
List<MenuVo> list = new LinkedList<>();
|
||||
String lang = LocaleContextHolder.getLocale().getLanguage();
|
||||
//剔除系统级菜单
|
||||
menuDtos.forEach(menuDTO -> {
|
||||
if (menuDTO != null) {
|
||||
List<MenuDto> menuDtoList = menuDTO.getChildren();
|
||||
MenuVo menuVo = new MenuVo();
|
||||
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponent_name()) ? menuDTO.getComponent_name() : menuDTO.getLocalTitle(lang));
|
||||
// 一级目录需要加斜杠,不然会报警告
|
||||
menuVo.setPath(pid.equals(menuDTO.getPid())? "/" + menuDTO.getPath() : menuDTO.getPath());
|
||||
menuVo.setHidden(menuDTO.getHidden());
|
||||
// 如果不是外链
|
||||
if (!menuDTO.getIframe()) {
|
||||
if (pid.equals(menuDTO.getPid())) {
|
||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "Layout" : menuDTO.getComponent());
|
||||
} else if (!pid.equals(menuDTO.getPid()) && "0".equals(menuDTO.getType())) {
|
||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "ParentView" : menuDTO.getComponent());
|
||||
if (menuDTO != null) {
|
||||
List<MenuDto> menuDtoList = menuDTO.getChildren();
|
||||
MenuVo menuVo = new MenuVo();
|
||||
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponent_name()) ? menuDTO.getComponent_name() : menuDTO.getLocalTitle(lang));
|
||||
menuVo.setPath(isRootMenu(menuDTO, pid) ? "/" + menuDTO.getPath() : menuDTO.getPath());
|
||||
menuVo.setHidden(menuDTO.getHidden());
|
||||
|
||||
} else if (!StrUtil.isEmpty(menuDTO.getComponent())) {
|
||||
menuVo.setComponent(menuDTO.getComponent());
|
||||
}
|
||||
}
|
||||
menuVo.setMeta(new MenuMetaVo(menuDTO.getLocalTitle(lang), menuDTO.getIcon(), !menuDTO.getCache()));
|
||||
if (menuDtoList != null && menuDtoList.size() != 0) {
|
||||
menuVo.setAlwaysShow(true);
|
||||
menuVo.setRedirect("noredirect");
|
||||
menuVo.setChildren(buildMenus(menuDtoList,pid));
|
||||
// 处理是一级菜单并且没有子菜单的情况
|
||||
} else if (StrUtil.isEmpty(menuDTO.getPid())) {
|
||||
MenuVo menuVo1 = new MenuVo();
|
||||
menuVo1.setMeta(menuVo.getMeta());
|
||||
// 非外链
|
||||
if (!menuDTO.getIframe()) {
|
||||
menuVo1.setPath("index");
|
||||
menuVo1.setName(menuVo.getName());
|
||||
menuVo1.setComponent(menuVo.getComponent());
|
||||
} else {
|
||||
menuVo1.setPath(menuDTO.getPath());
|
||||
}
|
||||
menuVo.setName(null);
|
||||
menuVo.setMeta(null);
|
||||
menuVo.setComponent("Layout");
|
||||
List<MenuVo> list1 = new ArrayList<>();
|
||||
list1.add(menuVo1);
|
||||
menuVo.setChildren(list1);
|
||||
}
|
||||
list.add(menuVo);
|
||||
}
|
||||
String routeComponent = resolveRouteComponent(menuDTO, pid);
|
||||
if (StrUtil.isNotEmpty(routeComponent)) {
|
||||
menuVo.setComponent(routeComponent);
|
||||
}
|
||||
);
|
||||
|
||||
menuVo.setMeta(new MenuMetaVo(menuDTO.getLocalTitle(lang), menuDTO.getIcon(), !menuDTO.getCache()));
|
||||
if (menuDtoList != null && menuDtoList.size() != 0) {
|
||||
menuVo.setAlwaysShow(true);
|
||||
menuVo.setRedirect("noredirect");
|
||||
menuVo.setChildren(buildMenus(menuDtoList, pid));
|
||||
} else if (StrUtil.isEmpty(menuDTO.getPid())) {
|
||||
MenuVo menuVo1 = new MenuVo();
|
||||
menuVo1.setMeta(menuVo.getMeta());
|
||||
if (!menuDTO.getIframe()) {
|
||||
menuVo1.setPath("index");
|
||||
menuVo1.setName(menuVo.getName());
|
||||
menuVo1.setComponent(menuVo.getComponent());
|
||||
} else {
|
||||
menuVo1.setPath(menuDTO.getPath());
|
||||
}
|
||||
menuVo.setName(null);
|
||||
menuVo.setMeta(null);
|
||||
menuVo.setComponent("Layout");
|
||||
List<MenuVo> list1 = new ArrayList<>();
|
||||
list1.add(menuVo1);
|
||||
menuVo.setChildren(list1);
|
||||
}
|
||||
list.add(menuVo);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user