fix:修改添加产品物料档案及库区打印模板

main
HuangHuiKang 1 week ago
parent 46d11ae2c8
commit aace821b91

@ -82,6 +82,7 @@ public class WarehouseAreaController {
WarehouseAreaDO warehouseArea = warehouseAreaService.getWarehouseArea(id);
WarehouseAreaRespVO respVO = BeanUtils.toBean(warehouseArea, WarehouseAreaRespVO.class);
fillQrcodeUrl(respVO, warehouseArea);
fillTemplateJson(respVO);
return success(respVO);
}
@ -92,6 +93,7 @@ public class WarehouseAreaController {
PageResult<WarehouseAreaDO> pageResult = warehouseAreaService.getWarehouseAreaPage(pageReqVO);
PageResult<WarehouseAreaRespVO> result = BeanUtils.toBean(pageResult, WarehouseAreaRespVO.class);
fillQrcodeUrl(result.getList());
fillTemplateJson(result.getList());
return success(result);
}
@ -126,6 +128,23 @@ public class WarehouseAreaController {
}
}
private void fillTemplateJson(WarehouseAreaRespVO respVO) {
if (respVO == null) {
return;
}
respVO.setTemplateJson(warehouseAreaService.selectPrintTemplate());
}
private void fillTemplateJson(List<WarehouseAreaRespVO> list) {
if (list == null || list.isEmpty()) {
return;
}
String templateJson = warehouseAreaService.selectPrintTemplate();
for (WarehouseAreaRespVO respVO : list) {
respVO.setTemplateJson(templateJson);
}
}
@GetMapping("/export-excel")
@Operation(summary = "导出ERP 库区信息 Excel")

@ -28,6 +28,9 @@ public class WarehouseAreaRespVO {
@Schema(description = "二维码 URL")
private String qrcodeUrl;
@Schema(description = "打印模板Json", example = "")
private String templateJson;
@Schema(description = "库区名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@ExcelProperty("库区名称")
private String areaName;

@ -9,6 +9,7 @@ import com.alibaba.excel.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.poi.util.StringUtil;
import java.util.Arrays;
import java.util.List;
@ -18,8 +19,22 @@ import java.util.stream.Collectors;
public interface ErpStockOutMapper extends BaseMapperX<ErpStockOutDO> {
default PageResult<ErpStockOutDO> selectPage(ErpStockOutPageReqVO reqVO) {
MPJLambdaWrapperX<ErpStockOutDO> query = new MPJLambdaWrapperX<ErpStockOutDO>()
.likeIfPresent(ErpStockOutDO::getNo, reqVO.getNo())
MPJLambdaWrapperX<ErpStockOutDO> query = new MPJLambdaWrapperX<>();
Long productId = reqVO.getProductId();
if (StringUtil.isNotBlank(reqVO.getNo())) {
if (reqVO.getNo().contains("PRODUCTMATERIAL-")) {
productId = Long.valueOf(reqVO.getNo().replace("PRODUCTMATERIAL-", ""));
} else {
query.likeIfPresent(ErpStockOutDO::getNo, reqVO.getNo());
}
}
if (productId != null || reqVO.getWarehouseId() != null) {
query.inSql(ErpStockOutDO::getId, buildItemFilterSql(productId, reqVO.getWarehouseId()));
}
query
.eqIfPresent(ErpStockOutDO::getCustomerId, reqVO.getCustomerId())
.eqIfPresent(ErpStockOutDO::getStockUserId, reqVO.getStockUserId())
.eqIfPresent(ErpStockOutDO::getOutType, reqVO.getOutType())
@ -40,6 +55,17 @@ public interface ErpStockOutMapper extends BaseMapperX<ErpStockOutDO> {
return selectJoinPage(reqVO, ErpStockOutDO.class, query);
}
default String buildItemFilterSql(Long productId, Long warehouseId) {
StringBuilder itemFilterSql = new StringBuilder("select distinct out_id from erp_stock_out_item where deleted = 0");
if (productId != null) {
itemFilterSql.append(" and product_id = ").append(productId);
}
if (warehouseId != null) {
itemFilterSql.append(" and warehouse_id = ").append(warehouseId);
}
return itemFilterSql.toString();
}
default int updateByIdAndStatus(Long id, Integer status, ErpStockOutDO updateObj) {
return update(updateObj, new LambdaUpdateWrapper<ErpStockOutDO>()
.eq(ErpStockOutDO::getId, id)

@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.dal.dataobject.warehousearea.WarehouseAreaDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo.*;
/**
@ -50,4 +51,6 @@ public interface WarehouseAreaMapper extends BaseMapperX<WarehouseAreaDO> {
return selectCount(WarehouseAreaDO::getWarehouseId, warehouseId);
}
String selectPrintTemplate(@Param("templateType") Integer templateType);
}

@ -10,11 +10,11 @@ import java.util.Arrays;
@AllArgsConstructor
public enum ProductTypeEnum implements IntArrayValuable {
ITEM(1, "原料"),
PRODUCT(2, "产品"),
TOOL(3, "工具"),
ITEM(1, "产品"),
PRODUCT(2, "物料"),
BEIJIAN(3, "备件"),
HAOCAI(4, "耗材"),
BEIJIAN(5, "备件");
TOOL(5, "工具");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductTypeEnum::getTypeId).toArray();
/**

@ -33,6 +33,7 @@ import cn.iocoder.yudao.module.erp.dal.mysql.productpackagingschemerel.ProductPa
import cn.iocoder.yudao.module.erp.dal.mysql.productmoldrel.ProductMoldRelMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.productsupplierrel.ProductSupplierRelMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMapper;
import cn.iocoder.yudao.module.erp.framework.bean.ProductTypeEnum;
import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService;
import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService;
import cn.iocoder.yudao.module.erp.service.stock.ErpStockService;
@ -503,12 +504,7 @@ public class ErpProductServiceImpl implements ErpProductService {
if (id != null) {
ErpProductRespVO product = getProduct(id);
if (product != null) {
Integer templateType = 0;
if (product.getCategoryType() == 1 ) {
templateType = 1; // 打印模板产品值
} else if(product.getCategoryId() == 5){
templateType = 5; // 打印模板备件值
}
Integer templateType = isSpareProductCategory(product) ? 5 : 1;
String template = productMapper.selectPrintTemplate(templateType);
product.setTemplateJson(template);
}
@ -526,6 +522,15 @@ public class ErpProductServiceImpl implements ErpProductService {
throw exception(PRODUCT_NOT_EXISTS);
}
private boolean isSpareProductCategory(ErpProductRespVO product) {
Long categoryId = product.getSubCategoryId() != null ? product.getSubCategoryId() : product.getCategoryId();
if (categoryId == null) {
return Objects.equals(product.getCategoryType(), ProductTypeEnum.BEIJIAN.getTypeId());
}
ErpProductCategoryDO category = productCategoryMapper.selectById(categoryId);
return category != null && Objects.equals(category.getType(), ProductTypeEnum.BEIJIAN.getTypeId());
}

@ -68,5 +68,7 @@ public interface WarehouseAreaService {
List<WarehouseAreaDO> getWarehouseListByStatusAndWarehouseId(Integer status, Long warehouseId);
String selectPrintTemplate();
void regenerateCode(Long id, String code) throws UnsupportedEncodingException;
}

@ -33,6 +33,8 @@ import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_ARE
@Slf4j
public class WarehouseAreaServiceImpl implements WarehouseAreaService {
private static final int WAREHOUSE_AREA_PRINT_TEMPLATE_TYPE = 7;
@Resource
private WarehouseAreaMapper warehouseAreaMapper;
@ -128,6 +130,11 @@ public class WarehouseAreaServiceImpl implements WarehouseAreaService {
return result;
}
@Override
public String selectPrintTemplate() {
return warehouseAreaMapper.selectPrintTemplate(WAREHOUSE_AREA_PRINT_TEMPLATE_TYPE);
}
@Override
public void regenerateCode(Long id, String code) throws UnsupportedEncodingException {
if (warehouseAreaMapper.selectById(id) == null) {

@ -9,4 +9,12 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
<select id="selectPrintTemplate" resultType="java.lang.String">
select template_json
from mes_print_template
where deleted = 0
and template_type = #{templateType}
and template_biz_type = 1
</select>
</mapper>

Loading…
Cancel
Save