From 394748542f107cd4540c7ed7ee46685bf7dfefaa Mon Sep 17 00:00:00 2001 From: yuejiayang <146344614+YangLei105@users.noreply.github.com> Date: Mon, 20 Jan 2025 19:55:45 +0800 Subject: [PATCH] =?UTF-8?q?2025.01.20=20Part=20Export=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/base/entity/Chooselist.java | 4 ++++ .../service/Impl/ChooselistServiceImpl.java | 3 ++- .../part/controller/PartController.java | 24 +++++++++++++++++++ .../modules/part/mapper/CategoryMapper.java | 2 +- .../service/impl/CategoryServiceImpl.java | 6 ++++- .../part/service/impl/PartServiceImpl.java | 3 +++ .../resources/mapper/part/CategoryMapper.xml | 8 +++++++ 7 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/mapper/part/CategoryMapper.xml diff --git a/src/main/java/com/gaotao/modules/base/entity/Chooselist.java b/src/main/java/com/gaotao/modules/base/entity/Chooselist.java index 2b8540d..8588be7 100644 --- a/src/main/java/com/gaotao/modules/base/entity/Chooselist.java +++ b/src/main/java/com/gaotao/modules/base/entity/Chooselist.java @@ -1,5 +1,6 @@ package com.gaotao.modules.base.entity; +import com.baomidou.mybatisplus.annotation.TableField; import lombok.Data; import java.io.Serializable; @@ -24,6 +25,9 @@ public class Chooselist implements Serializable { private String fieldname2; + @TableField(exist = false) + private String conditionSql; + private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/gaotao/modules/base/service/Impl/ChooselistServiceImpl.java b/src/main/java/com/gaotao/modules/base/service/Impl/ChooselistServiceImpl.java index 070d5ba..486571e 100644 --- a/src/main/java/com/gaotao/modules/base/service/Impl/ChooselistServiceImpl.java +++ b/src/main/java/com/gaotao/modules/base/service/Impl/ChooselistServiceImpl.java @@ -27,7 +27,8 @@ public class ChooselistServiceImpl extends ServiceImpl>> getChooselistData(String sqlcode) { SqlUtils.specialFilterContentForOnlineReport(sqlcode); - return this.baseMapper.getChooselistData(sqlcode); + List>> chooselistData = this.baseMapper.getChooselistData(sqlcode); + return chooselistData; } } diff --git a/src/main/java/com/gaotao/modules/part/controller/PartController.java b/src/main/java/com/gaotao/modules/part/controller/PartController.java index 05be31a..49c173c 100644 --- a/src/main/java/com/gaotao/modules/part/controller/PartController.java +++ b/src/main/java/com/gaotao/modules/part/controller/PartController.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gaotao.common.constant.SysMsgConstant; import com.gaotao.common.utils.R; +import com.gaotao.modules.base.entity.Chooselist; +import com.gaotao.modules.base.service.ChooselistService; import com.gaotao.modules.oss.entity.SysOssEntity; import com.gaotao.modules.part.entity.Part; import com.gaotao.modules.part.entity.Unit; @@ -12,12 +14,15 @@ import com.gaotao.modules.part.service.UnitService; import com.gaotao.modules.part.vo.PartVo; import com.gaotao.modules.sys.controller.AbstractController; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.UnsupportedEncodingException; +import java.text.DecimalFormat; import java.util.List; +import java.util.Map; @RestController @RequestMapping("/part") @@ -26,6 +31,8 @@ public class PartController extends AbstractController { private PartService partService; @Autowired private UnitService unitService; + @Autowired + private ChooselistService chooselistService; @PostMapping("/list") public R selectPartList(@RequestBody Part part){ @@ -103,4 +110,21 @@ public class PartController extends AbstractController { List list = partService.selectPartList(part); return R.ok().put("rows",list); } + + @PostMapping("/partInformation/verifyData") + public R verifyData(@RequestBody Chooselist data){ + // 根据 tagNo 查出 chooseList 中的 sqlCode + DecimalFormat df = new DecimalFormat("0"); // 不显示小数部分 + Chooselist chooselist = chooselistService.getChooselist(df.format(data.getTagno())); + if (chooselist != null) { + // 拼接sql + List>> baseListData = chooselistService.getChooselistData(chooselist.getSqlcode() + data.getConditionSql()); + if (!CollectionUtils.isEmpty(baseListData) && baseListData.size() >= 200) { + return R.ok().put("baseListData", baseListData.subList(0, 200)); + } + return R.ok().put("baseListData", baseListData); + } else { + return R.error(500, "未查到相应配置信息!"); + } + } } diff --git a/src/main/java/com/gaotao/modules/part/mapper/CategoryMapper.java b/src/main/java/com/gaotao/modules/part/mapper/CategoryMapper.java index 2ff0bc5..18d82fe 100644 --- a/src/main/java/com/gaotao/modules/part/mapper/CategoryMapper.java +++ b/src/main/java/com/gaotao/modules/part/mapper/CategoryMapper.java @@ -8,5 +8,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface CategoryMapper extends BaseMapper { - + Category getCategoryByValue(String categoryValue); } diff --git a/src/main/java/com/gaotao/modules/part/service/impl/CategoryServiceImpl.java b/src/main/java/com/gaotao/modules/part/service/impl/CategoryServiceImpl.java index 6d4b743..422fa4b 100644 --- a/src/main/java/com/gaotao/modules/part/service/impl/CategoryServiceImpl.java +++ b/src/main/java/com/gaotao/modules/part/service/impl/CategoryServiceImpl.java @@ -1,11 +1,13 @@ package com.gaotao.modules.part.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gaotao.common.utils.Constant; import com.gaotao.modules.part.entity.Category; import com.gaotao.modules.part.mapper.CategoryMapper; import com.gaotao.modules.part.service.CategoryService; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -16,6 +18,8 @@ import java.util.List; @Slf4j public class CategoryServiceImpl extends ServiceImpl implements CategoryService { + @Autowired + private CategoryMapper categoryMapper; @Override public List selectCategoryList(Category category) { @@ -27,7 +31,7 @@ public class CategoryServiceImpl extends ServiceImpl im if (StringUtils.isEmpty(categoryValue)){ throw new RuntimeException("Part Category is null"); } - return lambdaQuery().eq(Category::getCategoryValue, categoryValue).one(); + return categoryMapper.getCategoryByValue(categoryValue); } } diff --git a/src/main/java/com/gaotao/modules/part/service/impl/PartServiceImpl.java b/src/main/java/com/gaotao/modules/part/service/impl/PartServiceImpl.java index aa41816..b850fc8 100644 --- a/src/main/java/com/gaotao/modules/part/service/impl/PartServiceImpl.java +++ b/src/main/java/com/gaotao/modules/part/service/impl/PartServiceImpl.java @@ -481,6 +481,9 @@ public class PartServiceImpl extends ServiceImpl implements Pa Category categoryByValue = categoryService.getCategoryByValue(task.getCategory()); + if (categoryByValue == null) { + throw new RuntimeException("Print Label Format does not exist!(Print Label Format:"+ task.getCategory() + ")"); + } task.setManufacturerRequired(categoryByValue.getManufacturerRequired()); task.setMoldCodeRequired(categoryByValue.getMoldCodeRequired()); task.setSerialNumberRequired(categoryByValue.getSerialNumberRequired()); diff --git a/src/main/resources/mapper/part/CategoryMapper.xml b/src/main/resources/mapper/part/CategoryMapper.xml new file mode 100644 index 0000000..fc2b61b --- /dev/null +++ b/src/main/resources/mapper/part/CategoryMapper.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file