Browse Source

2025.01.20 Part Export 优化

dev
yuejiayang 1 year ago
parent
commit
394748542f
  1. 4
      src/main/java/com/gaotao/modules/base/entity/Chooselist.java
  2. 3
      src/main/java/com/gaotao/modules/base/service/Impl/ChooselistServiceImpl.java
  3. 24
      src/main/java/com/gaotao/modules/part/controller/PartController.java
  4. 2
      src/main/java/com/gaotao/modules/part/mapper/CategoryMapper.java
  5. 6
      src/main/java/com/gaotao/modules/part/service/impl/CategoryServiceImpl.java
  6. 3
      src/main/java/com/gaotao/modules/part/service/impl/PartServiceImpl.java
  7. 8
      src/main/resources/mapper/part/CategoryMapper.xml

4
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;

3
src/main/java/com/gaotao/modules/base/service/Impl/ChooselistServiceImpl.java

@ -27,7 +27,8 @@ public class ChooselistServiceImpl extends ServiceImpl<ChooselistDao, Chooselist
@Override
public List<Map<String, Map<String,Object>>> getChooselistData(String sqlcode) {
SqlUtils.specialFilterContentForOnlineReport(sqlcode);
return this.baseMapper.getChooselistData(sqlcode);
List<Map<String, Map<String, Object>>> chooselistData = this.baseMapper.getChooselistData(sqlcode);
return chooselistData;
}
}

24
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<PartVo> 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<Map<String, Map<String, Object>>> 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, "未查到相应配置信息!");
}
}
}

2
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> {
Category getCategoryByValue(String categoryValue);
}

6
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<CategoryMapper,Category> implements CategoryService {
@Autowired
private CategoryMapper categoryMapper;
@Override
public List<Category> selectCategoryList(Category category) {
@ -27,7 +31,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper,Category> im
if (StringUtils.isEmpty(categoryValue)){
throw new RuntimeException("Part Category is null");
}
return lambdaQuery().eq(Category::getCategoryValue, categoryValue).one();
return categoryMapper.getCategoryByValue(categoryValue);
}
}

3
src/main/java/com/gaotao/modules/part/service/impl/PartServiceImpl.java

@ -481,6 +481,9 @@ public class PartServiceImpl extends ServiceImpl<PartMapper, Part> 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());

8
src/main/resources/mapper/part/CategoryMapper.xml

@ -0,0 +1,8 @@
<?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="com.gaotao.modules.part.mapper.CategoryMapper">
<select id="getCategoryByValue" resultType="com.gaotao.modules.part.entity.Category">
SELECT id,category_name,category_value,seq_no,manufacturer_required,mold_code_required,serial_number_required,roll_label_required,qty_per_roll_label,carton_count_label,roll_count_label,show_roll_qty_per_roll,show_carton_qty_per_roll,show_carton_rolls_per_carton,edit_qty_per_carton,qty_per_roll_part,active FROM category WHERE category_value = #{categoryValue}
</select>
</mapper>
Loading…
Cancel
Save