作者 张晓杰

1. 库存管理和贸易库存管理追加BOH单挑更新和批量更新;

2. 基本表追加导入功能;
3. 贸易物料表追加导入功能;
4. 库存管理新增单独的库存表,不再使用视图
正在显示 41 个修改的文件 包含 1210 行增加265 行删除
... ... @@ -18,15 +18,21 @@ import org.jeecg.modules.erp.baseLibrary.service.ITblFinishProductService;
import org.jeecg.modules.erp.baseLibrary.vo.TblFinishProductVO;
import org.jeecg.modules.erp.order_form.entity.TblWorkOrder;
import org.jeecg.modules.erp.order_form.mapper.TblWorkOrderMapper;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Api(tags = "成品管理")
@RestController
... ... @@ -124,4 +130,63 @@ public class TblFinishProductController extends JeecgController<TblFinishProduct
list.add(tree);
return Result.OK(list);
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<TblFinishProductVO> list = ExcelImportUtil.importExcel(file.getInputStream(), TblFinishProductVO.class, params);
List<String> partNumberList = list.stream() // 将beanList转换为Stream
.map(TblFinishProductVO::getPartNumber) // 使用map方法提取id字段
.collect(Collectors.toList()); // 收集结果到新的List中
List<String> allPartNumberList = iTblFinishProductService.getAllPartNumber();
//判断是否有重复编码
// boolean flag = partNumberList.stream().anyMatch(allPartNumberList::contains);
// 找出重复编码
List<String> duplicates = partNumberList.stream()
.filter(allPartNumberList::contains)
.distinct()
.collect(Collectors.toList());
if(duplicates.size() >0){
return Result.error("编码有重复,重复编码是: " + duplicates);
}
// iTblFinishProductService.saveBatch(list);
for (TblFinishProductVO page : list) {
TblFinishProduct po = new TblFinishProduct();
BeanUtils.copyProperties(page, po);
iTblFinishProductService.saveMain(po, page.getTblPartSemifinishedList());
}
return Result.OK("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("文件导入失败:" + e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.OK("文件导入失败!");
}
}
... ...
package org.jeecg.modules.erp.baseLibrary.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.erp.baseLibrary.entity.TblFinishProduct;
import java.util.List;
public interface TblFinishProductMapper extends BaseMapper<TblFinishProduct> {
TblFinishProduct selectByPartNumber(String partNumber);
@Select("select id from tbl_finish_product where part_number=#{partNumber}")
String getIdByPartNumber(@Param("partNumber") String partNumber);
List<String> getAllPartNumber();
}
... ...
... ... @@ -5,4 +5,8 @@
<select id="selectByPartNumber" parameterType="java.lang.String" resultType="org.jeecg.modules.erp.baseLibrary.entity.TblFinishProduct">
select id,part_number,product_name,spec,'type' from tbl_finish_product where part_number = #{partNumber}
</select>
<select id="getAllPartNumber" resultType="java.lang.String">
select part_number from tbl_finish_product
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -16,4 +16,14 @@ public interface ITblFinishProductService extends IService<TblFinishProduct> {
void addAll(TblFinishProduct tblFinishProduct, List<TblPartSemifinished> tblPartSemifinishedList);
TblFinishProduct selectByPartNumber(String partNumber);
/**
* 添加一对多
*
* @param tblFinishProduct
* @param tblPartSemifinishedList
*/
public void saveMain(TblFinishProduct tblFinishProduct, List<TblPartSemifinished> tblPartSemifinishedList);
List<String> getAllPartNumber();
}
... ...
... ... @@ -7,6 +7,7 @@ import org.jeecg.modules.erp.baseLibrary.entity.TblFinishProductRelation;
import org.jeecg.modules.erp.baseLibrary.mapper.TblFinishProductMapper;
import org.jeecg.modules.erp.baseLibrary.mapper.TblFinishProductRelationMapper;
import org.jeecg.modules.erp.baseLibrary.service.ITblFinishProductService;
import org.jeecg.modules.erp.depot.mapper.TblInventoryMapper;
import org.jeecg.modules.erp.meterial.entity.TblMaterial;
import org.jeecg.modules.erp.meterial.entity.TblPartSemifinished;
import org.jeecg.modules.erp.meterial.mapper.TblMaterialMapper;
... ... @@ -31,6 +32,9 @@ public class TblFinishProductServiceImpl extends ServiceImpl<TblFinishProductMap
@Autowired
private TblPartSemifinishedMapper tblPartSemifinishedMapper;
@Autowired
private TblInventoryMapper tblInventoryMapper;
@Override
public void updateAll(TblFinishProduct tblFinishProduct, List<TblPartSemifinished> tblPartSemifinishedList) {
tblFinishProductMapper.updateById(tblFinishProduct);
... ... @@ -97,6 +101,15 @@ public class TblFinishProductServiceImpl extends ServiceImpl<TblFinishProductMap
String id = "CP" + UUID.randomUUID();
tblFinishProduct.setId(id);
tblFinishProductMapper.insert(tblFinishProduct);
// TblInventory tblInventory1 = new TblInventory();
// tblInventory1.setPartNumber(tblFinishProduct.getPartNumber());//编号
// tblInventory1.setProductName(tblFinishProduct.getProductName());//品名
// tblInventory1.setSpec(tblFinishProduct.getSpec());//规格
// tblInventory1.setType(tblFinishProduct.getType());//型号
// tblInventory1.setBuyingClassify(tblFinishProduct.getBuyingClassify());//采购性质
//// tblInventory1.setCurrentInventory(tblMaterial.getOperNumber());//当前库存
// tblInventory1.setMeterialType(tblFinishProduct.getMeterialType());//类别
// tblInventoryMapper.insert(tblInventory1);
for (TblPartSemifinished tblPartSemifinished : tblPartSemifinishedList) {
QueryWrapper<TblMaterial> tblMaterialQueryWrapper = new QueryWrapper<>();
tblMaterialQueryWrapper.eq("part_number", tblPartSemifinished.getPartNumber());
... ... @@ -113,4 +126,25 @@ public class TblFinishProductServiceImpl extends ServiceImpl<TblFinishProductMap
public TblFinishProduct selectByPartNumber(String partNumber) {
return tblFinishProductMapper.selectByPartNumber(partNumber);
}
@Override
public void saveMain(TblFinishProduct tblFinishProduct, List<TblPartSemifinished> tblPartSemifinishedList) {
tblFinishProductMapper.insert(tblFinishProduct);
if (tblPartSemifinishedList != null && tblPartSemifinishedList.size() > 0) {
for (TblPartSemifinished entity : tblPartSemifinishedList) {
String id = tblFinishProductMapper.getIdByPartNumber(entity.getPartNumber());
if(!id.equals("") && id != ""){
entity.setSubclassId(id);
}
//外键设置
entity.setMaterialId(tblFinishProduct.getId());
tblPartSemifinishedMapper.insert(entity);
}
}
}
@Override
public List<String> getAllPartNumber() {
return tblFinishProductMapper.getAllPartNumber();
}
}
... ...
... ... @@ -3,6 +3,7 @@ package org.jeecg.modules.erp.depot.controller;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
... ... @@ -14,19 +15,24 @@ import org.jeecg.common.aspect.annotation.PermissionData;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.erp.depot.entity.TblDepot;
import org.jeecg.modules.erp.depot.entity.TblInventory;
import org.jeecg.modules.erp.depot.form.TblDepotForm;
import org.jeecg.modules.erp.depot.mapper.TblDepotTestMapper;
import org.jeecg.modules.erp.depot.service.ITblDepotService;
import org.jeecg.modules.erp.robot.service.impl.YjRobotService;
import org.jeecg.modules.erp.depot.service.ITblInventoryService;
import org.jeecg.modules.erp.meterial.entity.TblMaterial;
import org.jeecg.modules.erp.meterial.service.ITblMaterialService;
import org.jeecg.modules.erp.robot.service.impl.YjRobotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @Description: tbl_depot
... ... @@ -50,6 +56,9 @@ public class TblDepotController extends JeecgController<TblDepot, ITblDepotServi
@Autowired
TblDepotTestMapper tblDepotMapper;
@Autowired
private ITblInventoryService tblInventoryService;
@GetMapping("/updateData")
public void updateData(){
List<Map<String, Object>> maps = tblDepotMapper.selectPartNumberAndCreateTime();
... ... @@ -149,36 +158,58 @@ public class TblDepotController extends JeecgController<TblDepot, ITblDepotServi
* @param tblDepotForm
* @return
*/
@Transactional(rollbackFor = Exception.class)
@AutoLog(value = "tbl_depot-添加")
@ApiOperation(value="tbl_depot-添加", notes="tbl_depot-添加")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody TblDepotForm tblDepotForm) {
TblDepot tblDepot = new TblDepot();
BeanUtil.copyProperties(tblDepotForm, tblDepot);
TblDepot tblDepot1 = tblDepotService.selectByPartNumber(tblDepotForm.getPartNumber());
// TblDepot tblDepot1 = tblDepotService.selectByPartNumber(tblDepotForm.getPartNumber());
TblInventory tblInventory = tblInventoryService.getByPartNumber(tblDepotForm.getPartNumber());
if(tblDepot.getDepotType().equals("入库")){
tblDepot.setCurrentInventory((tblDepot1 != null && tblDepot1.getCurrentInventory() != null) ? tblDepot1.getCurrentInventory() + tblDepot.getOperNumber() : tblDepot.getOperNumber());
tblDepot.setCurrentInventory((tblInventory != null && tblInventory.getCurrentInventory() != null) ? tblInventory.getCurrentInventory() + tblDepot.getOperNumber() : tblDepot.getOperNumber());
//库存明细表保存
tblDepotService.save(tblDepot);
//库存表保存
tblInventoryService.saveOrUpdateInventory(tblDepotForm);
}else{
String partNumber = tblDepot.getPartNumber();
List<TblDepot> list = queryByDepotId(partNumber);
int max = 0;
int min = 0;
for (TblDepot tbl:list) {
if(tbl.getDepotType().equals("入库")){
max += tbl.getOperNumber();
}else {
if (tbl.getDepotType().equals("出库")){
min += tbl.getOperNumber();
}
}
// String partNumber = tblDepot.getPartNumber();
// List<TblDepot> list = queryByDepotId(partNumber);
// int max = 0;
// int min = 0;
//
// for (TblDepot tbl:list) {
// if(tbl.getDepotType().equals("入库")){
// max += tbl.getOperNumber();
// }else {
// if (tbl.getDepotType().equals("出库")){
// min += tbl.getOperNumber();
// }
// }
// }
//
// if (tblDepot.getOperNumber() > (max - min)){
// return Result.error("库存数量不足!");
// }else{
// tblDepot.setCurrentInventory((tblDepot1 != null && tblDepot1.getCurrentInventory() != null) ? tblDepot1.getCurrentInventory() - tblDepot.getOperNumber() : - tblDepot.getOperNumber());
// //库存明细表保存
// tblDepotService.save(tblDepot);
// }
// TblInventory tblInventory = tblInventoryService.getByPartNumber(tblDepotForm.getPartNumber());
if(null != tblInventory && tblInventory.getCurrentInventory() >= tblDepotForm.getOperNumber()){
tblDepot.setCurrentInventory((tblInventory != null && tblInventory.getCurrentInventory() != null) ? tblInventory.getCurrentInventory() - tblDepot.getOperNumber() : - tblDepot.getOperNumber());
//库存明细表保存
tblDepotService.save(tblDepot);
//库存表更新当前库存
// tblInventory.setCurrentInventory(tblInventory.getCurrentInventory() - tblDepotForm.getOperNumber());
UpdateWrapper<TblInventory> wrapper = new UpdateWrapper<>();
wrapper.set("current_inventory", tblInventory.getCurrentInventory() - tblDepotForm.getOperNumber()) // 设置更新字段
.eq("id", tblInventory.getId());
tblInventoryService.update(null, wrapper);
}
if (tblDepot.getOperNumber() > (max - min)){
else{
return Result.error("库存数量不足!");
}else{
tblDepot.setCurrentInventory((tblDepot1 != null && tblDepot1.getCurrentInventory() != null) ? tblDepot1.getCurrentInventory() - tblDepot.getOperNumber() : - tblDepot.getOperNumber());
tblDepotService.save(tblDepot);
}
}
// int code = 0;
... ...
package org.jeecg.modules.erp.depot.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.erp.depot.entity.TblDepot;
import org.jeecg.modules.erp.depot.entity.TblInventory;
import org.jeecg.modules.erp.depot.service.ITblDepotService;
import org.jeecg.modules.erp.depot.service.ITblInventoryService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.exception.excel.ExcelImportException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @Description: tbl_inventory
* @Author: jeecg-boot
* @Date: 2025-09-16
* @Version: V1.0
*/
@Api(tags="tbl_inventory")
@RestController
@RequestMapping("/depot/tblInventory")
@Slf4j
public class TblInventoryController extends JeecgController<TblInventory, ITblInventoryService> {
@Autowired
private ITblInventoryService tblInventoryService;
@Autowired
private ITblDepotService tblDepotService;
/**
* 分页列表查询
*
* @param tblInventory
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "tbl_inventory-分页列表查询")
@ApiOperation(value="tbl_inventory-分页列表查询", notes="tbl_inventory-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<TblInventory>> queryPageList(TblInventory tblInventory,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<TblInventory> queryWrapper = QueryGenerator.initQueryWrapper(tblInventory, req.getParameterMap());
Page<TblInventory> page = new Page<TblInventory>(pageNo, pageSize);
IPage<TblInventory> pageList = tblInventoryService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 更新BOH
*
* @param tblInventory
* @return
*/
@AutoLog(value = "库存表-BOH更新")
@ApiOperation(value = "库存表-BOH更新", notes = "库存表-BOH更新")
@RequestMapping(value = "/updateBoh", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> updateBoh(@RequestBody TblInventory tblInventory) {
tblInventoryService.updateBohAndCurrentInventory(tblInventory);
return Result.OK("BOH更新成功!");
}
/**
* 添加
*
* @param tblInventory
* @return
*/
@AutoLog(value = "tbl_inventory-添加")
@ApiOperation(value="tbl_inventory-添加", notes="tbl_inventory-添加")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody TblInventory tblInventory) {
tblInventoryService.save(tblInventory);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param tblInventory
* @return
*/
@AutoLog(value = "tbl_inventory-编辑")
@ApiOperation(value="tbl_inventory-编辑", notes="tbl_inventory-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody TblInventory tblInventory) {
tblInventoryService.updateById(tblInventory);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "tbl_inventory-通过id删除")
@ApiOperation(value="tbl_inventory-通过id删除", notes="tbl_inventory-通过id删除")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
tblInventoryService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "tbl_inventory-批量删除")
@ApiOperation(value="tbl_inventory-批量删除", notes="tbl_inventory-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.tblInventoryService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "tbl_inventory-通过id查询")
@ApiOperation(value="tbl_inventory-通过id查询", notes="tbl_inventory-通过id查询")
@GetMapping(value = "/queryById")
public Result<TblInventory> queryById(@RequestParam(name="id",required=true) String id) {
TblInventory tblInventory = tblInventoryService.getById(id);
if(tblInventory==null) {
return Result.error("未找到对应数据");
}
return Result.OK(tblInventory);
}
/**
* 导出excel
*
* @param request
* @param tblInventory
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, TblInventory tblInventory) {
return super.exportXls(request, tblInventory, TblInventory.class, "tbl_inventory");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, TblInventory.class);
}
/**
* 批量更新BOH
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcelBoh", method = RequestMethod.POST)
public Result<?> importExcelBoh(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<TblInventory> list = ExcelImportUtil.importExcel(file.getInputStream(), TblInventory.class, params);
List<TblDepot> tblDepotList = new ArrayList<>();
for (TblInventory tblInventory : list) {
if (tblInventory != null) {
if(StrUtil.isBlank(tblInventory.getPartNumber()) || StrUtil.isBlank(tblInventory.getProductName()) || (null == tblInventory.getInventoryBoh())){
return Result.error("文件导入失败,编码、物料长描述、BOH有空白!");
}
TblDepot tblDepot = new TblDepot();
tblDepot.setPartNumber(tblInventory.getPartNumber());
tblDepot.setProductName(tblInventory.getProductName());
tblDepot.setSpec(tblInventory.getSpec());
tblDepot.setType(tblInventory.getType());
tblDepot.setCurrentInventory(tblInventory.getInventoryBoh());
tblDepot.setDepotType("更新");
tblDepotList.add(tblDepot);
}
}
// 如果有数据需要保存,则批量保存
long start = System.currentTimeMillis();
tblInventoryService.updateBohAndCurrentInventoryBatch(list);
tblDepotService.saveBatch(tblDepotList);
log.info("批量保存消耗时间:" + (System.currentTimeMillis() - start) + "毫秒");
if(list.size()<=0){
return Result.error("没有有效的导入数据");
}
return Result.ok("文件导入成功!数据行数:" + list.size());
}catch (ExcelImportException e) {
return Result.error("文件导入失败,导入数据格式错误");
} catch (Exception e) {
log.error(e.getMessage());
String msg = e.getMessage();
log.error(msg, e);
if(msg!=null && msg.indexOf("Duplicate entry")>=0){
return Result.error("文件导入失败:有重复数据!");
}else{
return Result.error("文件导入失败:" + e.getMessage());
}
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.error("文件导入失败!");
}
}
... ...
package org.jeecg.modules.erp.depot.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: tbl_inventory
* @Author: jeecg-boot
* @Date: 2025-09-16
* @Version: V1.0
*/
@Data
@TableName("tbl_inventory")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="tbl_inventory对象", description="tbl_inventory")
public class TblInventory implements Serializable {
private static final long serialVersionUID = 1L;
/**id*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "id")
private String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "创建日期")
private Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "更新日期")
private Date updateTime;
/**编号*/
@Excel(name = "编号", width = 15)
@ApiModelProperty(value = "编号")
private java.lang.String partNumber;
/**品名*/
@Excel(name = "品名", width = 15)
@ApiModelProperty(value = "品名")
private String productName;
/**规格*/
@Excel(name = "规格", width = 15)
@ApiModelProperty(value = "规格")
private String spec;
/**型号*/
@Excel(name = "型号", width = 15)
@ApiModelProperty(value = "型号")
private String type;
/**采购性质 M:加工,P:采购*/
@Excel(name = "采购性质", width = 15)
@ApiModelProperty(value = "采购性质 M:加工,P:采购")
private String buyingClassify;
/**类别 1-零件 2-半成品 3-耗材*/
@Excel(name = "类别", width = 15)
@ApiModelProperty(value = "类别 1-零件 2-半成品 3-耗材")
private String meterialType;
/**当前库存量*/
@Excel(name = "当前库存量", width = 15)
@ApiModelProperty(value = "当前库存量")
private Integer currentInventory;
/**初始库存*/
@Excel(name = "BOH", width = 15)
@ApiModelProperty(value = "初始库存")
private Integer inventoryBoh;
}
... ...
package org.jeecg.modules.erp.depot.form;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: tbl_depot
... ... @@ -71,7 +65,8 @@ public class TblDepotForm implements Serializable {
private java.util.Date operTime;
/**当前库存量*/
private java.lang.Integer currentInventory;
//类别
private String meterialType;
private String isCallRobot;
private String robotName;
private String pointId;
... ...
package org.jeecg.modules.erp.depot.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.erp.depot.entity.TblInventory;
import java.util.List;
/**
* @Description: tbl_inventory
* @Author: jeecg-boot
* @Date: 2025-09-16
* @Version: V1.0
*/
public interface TblInventoryMapper extends BaseMapper<TblInventory> {
TblInventory getByPartNumber(@Param("partNumber") String partNumber);
void updateBohAndCurrentInventory(TblInventory tblInventory);
void updateBohAndCurrentInventoryBatch(@Param("list") List<TblInventory> list);
}
... ...
<?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="org.jeecg.modules.erp.depot.mapper.TblInventoryMapper">
<select id="getByPartNumber" parameterType="java.lang.String" resultType="org.jeecg.modules.erp.depot.entity.TblInventory">
select * from tbl_inventory where part_number = #{partNumber}
</select>
<update id="updateBohAndCurrentInventoryBatch" parameterType="java.util.ArrayList">
update tbl_inventory
set inventory_boh = CASE
<foreach collection="list" item="item">
WHEN part_number = #{item.partNumber}
THEN #{item.inventoryBoh}
</foreach>
END,
current_inventory = CASE
<foreach collection="list" item="item">
WHEN part_number = #{item.partNumber}
THEN #{item.inventoryBoh}
</foreach>
END
</update>
<update id="updateBohAndCurrentInventory" parameterType="org.jeecg.modules.erp.depot.entity.TblInventory">
update tbl_inventory set inventory_boh = #{inventoryBoh} ,current_inventory = #{inventoryBoh}
where part_number = #{partNumber}
</update>
</mapper>
\ No newline at end of file
... ...
package org.jeecg.modules.erp.depot.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.erp.depot.entity.TblInventory;
import org.jeecg.modules.erp.depot.form.TblDepotForm;
import java.util.List;
/**
* @Description: tbl_inventory
* @Author: jeecg-boot
* @Date: 2025-09-16
* @Version: V1.0
*/
public interface ITblInventoryService extends IService<TblInventory> {
/**
* 根据编号获取库存
* @param partNumber
* @return
*/
TblInventory getByPartNumber( String partNumber);
void saveOrUpdateInventory(TblDepotForm tblDepotForm);
// void updateInventory(TblDepotForm tblDepotForm);
/**
* 批量更新BOH
* @param list
*/
void updateBohAndCurrentInventoryBatch(List<TblInventory> list);
/**
* 单条更新BOH
* @param tblInventory
*/
void updateBohAndCurrentInventory(TblInventory tblInventory);
}
... ...
package org.jeecg.modules.erp.depot.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.erp.depot.entity.TblDepot;
import org.jeecg.modules.erp.depot.entity.TblInventory;
import org.jeecg.modules.erp.depot.form.TblDepotForm;
import org.jeecg.modules.erp.depot.mapper.TblDepotMapper;
import org.jeecg.modules.erp.depot.mapper.TblInventoryMapper;
import org.jeecg.modules.erp.depot.service.ITblInventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description: tbl_inventory
* @Author: jeecg-boot
* @Date: 2025-09-16
* @Version: V1.0
*/
@Service
public class TblInventoryServiceImpl extends ServiceImpl<TblInventoryMapper, TblInventory> implements ITblInventoryService {
@Autowired
private TblInventoryMapper tblInventoryMapper;
@Autowired
private TblDepotMapper tblDepotMapper;
@Override
public TblInventory getByPartNumber(String partNumber) {
return tblInventoryMapper.getByPartNumber(partNumber);
}
@Override
public void saveOrUpdateInventory(TblDepotForm tblDepotForm) {
TblInventory tblInventory = tblInventoryMapper.getByPartNumber(tblDepotForm.getPartNumber());
if(null != tblInventory){
// tblInventory.setCurrentInventory((null != tblInventory.getCurrentInventory() ? tblInventory.getCurrentInventory() : 0) + tblDepotForm.getOperNumber());
UpdateWrapper<TblInventory> wrapper = new UpdateWrapper<>();
wrapper.set("current_inventory", (null != tblInventory.getCurrentInventory() ? tblInventory.getCurrentInventory() : 0) + tblDepotForm.getOperNumber()) // 设置更新字段
.eq("id", tblInventory.getId());
tblInventoryMapper.update(null, wrapper);
}else{
TblInventory tblInventory1 = new TblInventory();
tblInventory1.setPartNumber(tblDepotForm.getPartNumber());//编号
tblInventory1.setProductName(tblDepotForm.getProductName());//品名
tblInventory1.setSpec(tblDepotForm.getSpec());//规格
tblInventory1.setType(tblDepotForm.getType());//型号
tblInventory1.setBuyingClassify(tblDepotForm.getBuyingClassify());//采购性质
tblInventory1.setCurrentInventory(tblDepotForm.getOperNumber());//当前库存
tblInventory1.setMeterialType(tblDepotForm.getMeterialType());//类别
tblInventoryMapper.insert(tblInventory);
}
}
// @Override
// public void updateInventory(TblDepotForm tblDepotForm) {
// TblInventory tblInventory = tblInventoryMapper.getByPartNumber(tblDepotForm.getPartNumber());
// tblInventory.setCurrentInventory(tblInventory.getCurrentInventory() - tblDepotForm.getOperNumber());
// UpdateWrapper<TblInventory> wrapper = new UpdateWrapper<>();
// wrapper.set("current_inventory", tblInventory.getCurrentInventory() - tblDepotForm.getOperNumber()) // 设置更新字段
// .gt("id", tblInventory.getId());
// tblInventoryMapper.update(null, wrapper);
// }
@Override
public void updateBohAndCurrentInventoryBatch(List<TblInventory> list) {
tblInventoryMapper.updateBohAndCurrentInventoryBatch(list);
}
@Override
public void updateBohAndCurrentInventory(TblInventory tblInventory) {
tblInventoryMapper.updateBohAndCurrentInventory(tblInventory);
TblDepot tblDepot = new TblDepot();
tblDepot.setPartNumber(tblInventory.getPartNumber());
tblDepot.setProductName(tblInventory.getProductName());
tblDepot.setSpec(tblInventory.getSpec());
tblDepot.setType(tblInventory.getType());
tblDepot.setCurrentInventory(tblInventory.getInventoryBoh());
tblDepot.setDepotType("更新");
tblDepotMapper.insert(tblDepot);
}
}
... ...
... ... @@ -58,7 +58,7 @@ public class TblConsumablesController {
private TblWorkOrderMapper tblWorkOrderMapper;
/**
* 分页列表查询
* 分页列表查询 成品管理
*
* @param tblMaterial
* @param pageNo
... ...
... ... @@ -41,6 +41,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Description: tbl_material
... ... @@ -65,7 +66,7 @@ public class TblMaterialController {
private TblWorkOrderMapper tblWorkOrderMapper;
/**
* 分页列表查询
* 分页列表查询 原物料管理
*
* @param tblMaterial
* @param pageNo
... ... @@ -88,6 +89,30 @@ public class TblMaterialController {
return Result.OK(pageList);
}
/**
* 分页列表查询 原物料管理
*
* @param tblMaterial
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@ApiOperation(value = "tbl_material-分页列表查询", notes = "tbl_material-分页列表查询")
@GetMapping(value = "/rawMaterialsList")
@PermissionData(pageComponent = "meterial/TblRawMaterialsList")
public Result<IPage<TblMaterial>> queryTblRawMaterialsList(TblMaterial tblMaterial,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
tblMaterial.setMeterialType("5");
QueryWrapper<TblMaterial> queryWrapper = QueryGenerator.initQueryWrapper(tblMaterial, req.getParameterMap());
queryWrapper.orderByDesc("id");
Page<TblMaterial> page = new Page<>(pageNo, pageSize);
IPage<TblMaterial> pageList = tblMaterialService.page(page, queryWrapper);
return Result.OK(pageList);
}
@GetMapping(value = "/listAll")
@PermissionData(pageComponent = "meterial/TblMaterialList")
public Result<List<TblMaterial>> queryListAll(
... ... @@ -265,6 +290,23 @@ public class TblMaterialController {
params.setNeedSave(true);
try {
List<TblMaterialPage> list = ExcelImportUtil.importExcel(file.getInputStream(), TblMaterialPage.class, params);
List<String> partNumberList = list.stream() // 将beanList转换为Stream
.map(TblMaterialPage::getPartNumber) // 使用map方法提取id字段
.collect(Collectors.toList()); // 收集结果到新的List中
List<String> allPartNumberList = tblMaterialService.getAllPartNumber();
//判断是否有重复编码
// boolean flag = partNumberList.stream().anyMatch(allPartNumberList::contains);
// 找出重复编码
List<String> duplicates = partNumberList.stream()
.filter(allPartNumberList::contains)
.distinct()
.collect(Collectors.toList());
if(duplicates.size() >0){
return Result.error("编码有重复,重复编码是: " + duplicates);
}
// tblMaterialService.saveBatch(list);
for (TblMaterialPage page : list) {
TblMaterial po = new TblMaterial();
BeanUtils.copyProperties(page, po);
... ...
... ... @@ -34,7 +34,7 @@ public class TblProtectionController {
private ITblMaterialService tblMaterialService;
/**
* 分页列表查询
* 分页列表查询 耗材管理
*
* @param tblMaterial
* @param pageNo
... ...
... ... @@ -66,7 +66,7 @@ public class TblSemiFinishedController {
private TblWorkOrderMapper tblWorkOrderMapper;
/**
* 分页列表查询
* 分页列表查询 半成品管理
*
* @param tblMaterial
* @param pageNo
... ...
... ... @@ -27,4 +27,6 @@ public interface TblMaterialMapper extends BaseMapper<TblMaterial> {
List<String> queryPartNumber(@Param("partNumber") String partNumber);
List<Map<String,String>> getOptions();
List<String> getAllPartNumber();
}
... ...
... ... @@ -13,4 +13,7 @@
<select id="getOptions" resultType="java.util.Map">
SELECT part_number as partNumber,CONCAT(product_name,if(spec != '' ,' - ',''),if(spec != '',spec,''),if(type != '',' - ',''),if(type != '',type,'')) productName from tbl_material
</select>
<select id="getAllPartNumber" resultType="java.lang.String">
select part_number from tbl_material
</select>
</mapper>
\ No newline at end of file
... ...
package org.jeecg.modules.erp.meterial.service;
import org.jeecg.modules.erp.meterial.entity.TblPartSemifinished;
import org.jeecg.modules.erp.meterial.entity.TblMaterial;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.erp.meterial.entity.TblMaterial;
import org.jeecg.modules.erp.meterial.entity.TblPartSemifinished;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* @Description: tbl_material
... ... @@ -50,4 +50,6 @@ public interface ITblMaterialService extends IService<TblMaterial> {
// List<Map<String,String>> getAll();
List<TblMaterial> getAll();
List<String> getAllPartNumber();
}
... ...
package org.jeecg.modules.erp.meterial.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.erp.depot.entity.TblInventory;
import org.jeecg.modules.erp.depot.mapper.TblInventoryMapper;
import org.jeecg.modules.erp.meterial.entity.TblMaterial;
import org.jeecg.modules.erp.meterial.entity.TblPartSemifinished;
import org.jeecg.modules.erp.meterial.mapper.TblMaterialMapper;
... ... @@ -14,7 +15,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* @Description: tbl_material
... ... @@ -30,10 +30,22 @@ public class TblMaterialServiceImpl extends ServiceImpl<TblMaterialMapper, TblMa
@Autowired
private TblPartSemifinishedMapper tblPartSemifinishedMapper;
@Autowired
private TblInventoryMapper tblInventoryMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public void saveMain(TblMaterial tblMaterial, List<TblPartSemifinished> tblPartSemifinishedList) {
tblMaterialMapper.insert(tblMaterial);
TblInventory tblInventory1 = new TblInventory();
tblInventory1.setPartNumber(tblMaterial.getPartNumber());//编号
tblInventory1.setProductName(tblMaterial.getProductName());//品名
tblInventory1.setSpec(tblMaterial.getSpec());//规格
tblInventory1.setType(tblMaterial.getType());//型号
tblInventory1.setBuyingClassify(tblMaterial.getBuyingClassify());//采购性质
// tblInventory1.setCurrentInventory(tblMaterial.getOperNumber());//当前库存
tblInventory1.setMeterialType(tblMaterial.getMeterialType());//类别
tblInventoryMapper.insert(tblInventory1);
if (tblPartSemifinishedList != null && tblPartSemifinishedList.size() > 0) {
for (TblPartSemifinished entity : tblPartSemifinishedList) {
String id = tblMaterialMapper.getIdByPartNumber(entity.getPartNumber());
... ... @@ -100,4 +112,9 @@ public class TblMaterialServiceImpl extends ServiceImpl<TblMaterialMapper, TblMa
return this.list();
}
@Override
public List<String> getAllPartNumber() {
return tblMaterialMapper.getAllPartNumber();
}
}
... ...
package org.jeecg.modules.erp.trade.controller;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.erp.trade.entity.*;
import org.jeecg.modules.erp.trade.mapper.TblTradeBidMaterialDetailsMapper;
import org.jeecg.modules.erp.trade.service.*;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.jeecg.modules.erp.trade.entity.TblTradeInventoryIn;
import org.jeecg.modules.erp.trade.entity.TblTradeTenderInfo;
import org.jeecg.modules.erp.trade.service.ITblTradeInventoryInService;
import org.jeecg.modules.erp.trade.service.ITblTradeTenderInfoService;
import org.jeecg.modules.erp.trade.vo.TblTradeBidSubPage;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.vo.LoginUser;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.erp.trade.vo.TblTradeBidSubPage;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @Description: 投标表
... ... @@ -400,8 +394,8 @@ public class TblTradeBidSubController {
return Result.OK(new TblTradePurchaseInfo());
}
TblTradePurchaseInfo sub = list.get(0);
Integer isl = sub.getPurchaseQuantity();
sub.setSl(String.valueOf(isl-yrksl));
Integer isl = sub.getPurchaseQuantity();//采购数量
sub.setSl(String.valueOf(isl-yrksl));//采购数量-已入库数量
return Result.OK(list.get(0));
}
... ...
package org.jeecg.modules.erp.trade.controller;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.erp.trade.entity.*;
import org.jeecg.modules.erp.trade.service.*;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.erp.trade.entity.*;
import org.jeecg.modules.erp.trade.service.*;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecgframework.poi.exception.excel.ExcelImportException;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
... ... @@ -41,10 +25,13 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* @Description: 贸易库存表
... ... @@ -92,10 +79,10 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento
QueryWrapper<TblTradeMeterial> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotBlank( tblTradeInventory.getMaterialDescription())){
queryWrapper.like("meterial_review", tblTradeInventory.getMaterialDescription());
queryWrapper.like("material_review", tblTradeInventory.getMaterialDescription());
}
if (StringUtils.isNotBlank(tblTradeInventory.getMaterialCode())){
queryWrapper.eq("meterial_code", tblTradeInventory.getMaterialCode());
queryWrapper.eq("material_code", tblTradeInventory.getMaterialCode());
}
if (StringUtils.isNotBlank(tblTradeInventory.getBrand())){
queryWrapper.like("brand", tblTradeInventory.getBrand());
... ... @@ -104,8 +91,8 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento
Page<TblTradeMeterial> page = new Page<TblTradeMeterial>(pageNo, pageSize);
IPage<TblTradeMeterial> pageList = tblTradeMeterialService.page(page, queryWrapper);
List<TblTradeMeterial> records = pageList.getRecords();
//meterialCode 物料编码list
List<String> collect = records.stream().map(TblTradeMeterial::getMeterialCode).collect(Collectors.toList());
//materialCode 物料编码list
List<String> collect = records.stream().map(TblTradeMeterial::getMaterialCode).collect(Collectors.toList());
//根据物料编码查询库存
QueryWrapper<TblTradeInventory> tblTradeInventoryQueryWrapper = new QueryWrapper<>();
... ... @@ -115,12 +102,13 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento
Map<String, TblTradeInventory> inventoryMap = list.stream().collect(Collectors.toMap(TblTradeInventory::getMaterialCode, e -> e));
for (TblTradeMeterial record : records) {
record.setActualInventory(inventoryMap.get(record.getMeterialCode()) == null ? 0 : inventoryMap.get(record.getMeterialCode()).getActualInventory() == null ? 0 : inventoryMap.get(record.getMeterialCode()).getActualInventory());
record.setQuantityInTransit(inventoryMap.get(record.getMeterialCode()) == null ? 0 : inventoryMap.get(record.getMeterialCode()).getQuantityInTransit() == null ? 0 : inventoryMap.get(record.getMeterialCode()).getQuantityInTransit());
record.setTotalQuantity(inventoryMap.get(record.getMeterialCode()) == null ? 0 : inventoryMap.get(record.getMeterialCode()).getTotalQuantity() == null ? 0 : inventoryMap.get(record.getMeterialCode()).getTotalQuantity());
record.setFirstStorageTime(inventoryMap.get(record.getMeterialCode()) == null ? null : inventoryMap.get(record.getMeterialCode()).getFirstStorageTime());
record.setLastOutboundTime(inventoryMap.get(record.getMeterialCode()) == null ? null : inventoryMap.get(record.getMeterialCode()).getLastOutboundTime());
if (record.getLastOutboundTime() != null) {
record.setInventoryBoh(inventoryMap.get(record.getMaterialCode()) == null ? 0 : inventoryMap.get(record.getMaterialCode()).getInventoryBoh() == null ? 0 : inventoryMap.get(record.getMaterialCode()).getInventoryBoh());
record.setActualInventory(inventoryMap.get(record.getMaterialCode()) == null ? 0 : inventoryMap.get(record.getMaterialCode()).getActualInventory() == null ? 0 : inventoryMap.get(record.getMaterialCode()).getActualInventory());
record.setQuantityInTransit(inventoryMap.get(record.getMaterialCode()) == null ? 0 : inventoryMap.get(record.getMaterialCode()).getQuantityInTransit() == null ? 0 : inventoryMap.get(record.getMaterialCode()).getQuantityInTransit());
record.setTotalQuantity(inventoryMap.get(record.getMaterialCode()) == null ? 0 : inventoryMap.get(record.getMaterialCode()).getTotalQuantity() == null ? 0 : inventoryMap.get(record.getMaterialCode()).getTotalQuantity());
record.setFirstStorageTime(inventoryMap.get(record.getMaterialCode()) == null ? null : inventoryMap.get(record.getMaterialCode()).getFirstStorageTime());
record.setLastOutboundTime(inventoryMap.get(record.getMaterialCode()) == null ? null : inventoryMap.get(record.getMaterialCode()).getLastOutboundTime());
if ((null != record.getLastOutboundTime()) && (null != record.getFirstStorageTime())) {
long daysDifference = calculateDaysDifference(new Date(), record.getFirstStorageTime());
record.setDaysInStock((int) daysDifference + 1);
}
... ... @@ -141,7 +129,7 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento
/**
* 添加
*
*备注:总数量的逻辑有问题
* @param tblTradeInventory
* @return
*/
... ... @@ -149,26 +137,25 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento
@ApiOperation(value = "贸易库存表-添加", notes = "贸易库存表-添加")
@PostMapping(value = "/add")
@Transactional(rollbackFor = Exception.class)
public Result<String> add(@RequestBody TblTradeInventory tblTradeInventory) {
//订单验证
public Result<String> add(@RequestBody TblTradeInventory tblTradeInventory){
Result<String> error = orderVerification(tblTradeInventory);
if (error != null) return error;
TblTradeInventoryIn tblTradeInventoryIn = new TblTradeInventoryIn();
//入库单号
tblTradeInventoryIn.setWaybillNum("BZSIN" + DatePattern.PURE_DATETIME_FORMAT.format(new Date()));
tblTradeInventoryIn.setMaterialCode(tblTradeInventory.getMaterialCode());
tblTradeInventoryIn.setMaterialDescription(tblTradeInventory.getMaterialDescription());
tblTradeInventoryIn.setMeasurementUnit(tblTradeInventory.getMeasurementUnit());
tblTradeInventoryIn.setBrand(tblTradeInventory.getBrand());
tblTradeInventoryIn.setInventoryQuantity(tblTradeInventory.getRksl());
tblTradeInventoryIn.setOperator(tblTradeInventory.getOperator());
tblTradeInventoryIn.setWaybillNum("BZSIN" + DatePattern.PURE_DATETIME_FORMAT.format(new Date()));//单号
tblTradeInventoryIn.setMaterialCode(tblTradeInventory.getMaterialCode());//物料编码
tblTradeInventoryIn.setMaterialDescription(tblTradeInventory.getMaterialDescription());//物料长描述
tblTradeInventoryIn.setMeasurementUnit(tblTradeInventory.getMeasurementUnit());//计量单位
tblTradeInventoryIn.setBrand(tblTradeInventory.getBrand());//品牌
tblTradeInventoryIn.setInventoryQuantity(tblTradeInventory.getRksl());//入库数量
tblTradeInventoryIn.setOperator(tblTradeInventory.getOperator());//采购员
tblTradeInventoryIn.setCreateTime(new Date());
tblTradeInventoryIn.setUpdateTime(new Date());
tblTradeInventoryIn.setDeliveryContractNumber(tblTradeInventory.getHth());
tblTradeInventoryIn.setExpressDeliveryNumber(tblTradeInventory.getWldh());
tblTradeInventoryIn.setSupplierName(tblTradeInventory.getCs());
tblTradeInventoryIn.setWarehouse(tblTradeInventory.getWarehouse());
tblTradeInventoryIn.setDeliveryContractNumber(tblTradeInventory.getHth());//交货合同编号
tblTradeInventoryIn.setExpressDeliveryNumber(tblTradeInventory.getWldh());//合同单号/快递单号
tblTradeInventoryIn.setSupplierName(tblTradeInventory.getCs());//供货商名称
tblTradeInventoryIn.setWarehouse(tblTradeInventory.getWarehouse());//仓库
tblTradeInventoryIn.setType("入库");
//根据 物流编码 查询库存信息 如存在库存信息则进行修改库存信息,不存在则新增库存信息
String hth = tblTradeInventory.getHth();
... ... @@ -181,12 +168,12 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento
//修改订单信息
String purchaseId = tblTradeInventory.getPurchaseId();
TblTradePurchaseInfo tblTradePurchaseInfo = tblTradePurchaseInfoService.getById(purchaseId);
Integer yrkNum = tblTradePurchaseInfo.getYrkNum() == null ? 0 : tblTradePurchaseInfo.getYrkNum();
Integer rksl = tblTradeInventory.getRksl() == null ? 0 : tblTradeInventory.getRksl();
Integer yrkNum = tblTradePurchaseInfo.getYrkNum() == null ? 0 : tblTradePurchaseInfo.getYrkNum();//已入库数量
Integer rksl = tblTradeInventory.getRksl() == null ? 0 : tblTradeInventory.getRksl();//入库数量
tblTradePurchaseInfo.setYrkNum(yrkNum + rksl);
Integer wrkNum = tblTradePurchaseInfo.getWrkNum() == null ? 0 : tblTradePurchaseInfo.getWrkNum();
tblTradePurchaseInfo.setWrkNum(wrkNum - rksl);
tblTradePurchaseInfoService.updateById(tblTradePurchaseInfo);
Integer wrkNum = tblTradePurchaseInfo.getWrkNum() == null ? 0 : tblTradePurchaseInfo.getWrkNum();//未入库数量
tblTradePurchaseInfo.setWrkNum( tblTradePurchaseInfo.getPurchaseQuantity()- rksl);
tblTradePurchaseInfoService.updateById(tblTradePurchaseInfo);//更新采购信息
if (tradeInventory == null) {
kcl = rksl;
... ... @@ -216,12 +203,12 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento
//当前库存
Integer actualInventory = tradeInventory.getActualInventory();
kcl = rksl + actualInventory;
kcl = rksl + (null == actualInventory ? 0 : actualInventory);
//在途数量
Integer wrk =tblTradePurchaseInfoService.getWrkNum(tblTradeInventory.getMaterialCode());
wrk = wrk == null ? 0 : wrk;
tblTradeInventory.setQuantityInTransit(wrk);
tblTradeInventory.setQuantityInTransit(wrk);//在途数量
Integer yrk = tblTradePurchaseInfoService.getYrkNumByMaterialCode(tblTradeInventory.getMaterialCode());
yrk = yrk == null ? 0 : yrk;
Integer ck = tblTradeInventoryOutService.getOutboundQuantityByMaterialCode(tblTradeInventory.getMaterialCode());
... ... @@ -344,6 +331,20 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento
return Result.OK("出库成功!");
}
/**
* 更新BOH
*
* @param tblTradeInventory
* @return
*/
@AutoLog(value = "贸易库存表-BOH更新")
@ApiOperation(value = "贸易库存表-BOH更新", notes = "贸易库存表-BOH更新")
@RequestMapping(value = "/updateBoh", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> updateBoh(@RequestBody TblTradeInventoryUpdateBoh tblTradeInventory) {
tblTradeInventoryService.updateBohAndActual(tblTradeInventory);
return Result.OK("BOH更新成功!");
}
/**
* 编辑
... ... @@ -427,4 +428,72 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento
return super.importExcel(request, response, TblTradeInventory.class);
}
/**
* 批量更新BOH
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcelBoh", method = RequestMethod.POST)
public Result<?> importExcelBoh(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<TblTradeInventoryUpdateBoh> list = ExcelImportUtil.importExcel(file.getInputStream(), TblTradeInventoryUpdateBoh.class, params);
// List<TblTradeInventory> tblTradeMeterialArrayList = new ArrayList<>();
for (TblTradeInventoryUpdateBoh tblTradeInventoryUpdateBoh : list) {
if (tblTradeInventoryUpdateBoh != null) {
if(StrUtil.isBlank(tblTradeInventoryUpdateBoh.getMaterialCode()) || StrUtil.isBlank(tblTradeInventoryUpdateBoh.getMaterialDescription()) || (null == tblTradeInventoryUpdateBoh.getInventoryBoh())){
return Result.error("文件导入失败,编码、物料长描述、BOH有空白!");
}
// tblTradeMeterialArrayList.add(new TblTradeInventory(tblTradeMeterial));
}
}
// if(!tblTradeMeterialArrayList.isEmpty()){
// 如果有数据需要保存,则批量保存
long start = System.currentTimeMillis();
tblTradeInventoryService.updateBohAndActualBatch(list);
log.info("批量保存消耗时间:" + (System.currentTimeMillis() - start) + "毫秒");
if(list.size()<=0){
return Result.error("没有有效的导入数据");
}
return Result.ok("文件导入成功!数据行数:" + list.size());
// } else {
// return Result.error("文件导入失败:没有有效的数据需要保存!");
// }
}catch (ExcelImportException e) {
return Result.error("文件导入失败,导入数据格式错误");
} catch (Exception e) {
log.error(e.getMessage());
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
String msg = e.getMessage();
log.error(msg, e);
if(msg!=null && msg.indexOf("Duplicate entry")>=0){
return Result.error("文件导入失败:有重复数据!");
}else{
return Result.error("文件导入失败:" + e.getMessage());
}
//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.error("文件导入失败!");
}
}
... ...
package org.jeecg.modules.erp.trade.controller;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.erp.trade.entity.TblTradeInventory;
import org.jeecg.modules.erp.trade.entity.TblTradeMeterial;
import org.jeecg.modules.erp.trade.service.ITblTradeInventoryService;
import org.jeecg.modules.erp.trade.service.ITblTradeMeterialService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecgframework.poi.exception.excel.ExcelImportException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
/**
* @Description: 贸易管理物料表
... ... @@ -63,9 +51,9 @@ public class TblTradeMeterialController extends JeecgController<TblTradeMeterial
@ApiOperation(value = "根据物料编号查询物料基础信息", notes = "根据物料编号查询物料基础信息")
@GetMapping(value = "/queryByMaterialCode")
public Result<TblTradeMeterial> queryByMaterialCode(TblTradeMeterial tblTradeMeterial) {
String meterialCode = tblTradeMeterial.getMeterialCode();
String materialCode = tblTradeMeterial.getMaterialCode();
QueryWrapper<TblTradeMeterial> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("meterial_code", meterialCode);
queryWrapper.eq("material_code", materialCode);
List<TblTradeMeterial> list = tblTradeMeterialService.list(queryWrapper);
if (CollectionUtil.isEmpty(list)) {
return Result.error("未找到对应物料信息");
... ... @@ -93,11 +81,11 @@ public class TblTradeMeterialController extends JeecgController<TblTradeMeterial
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<TblTradeMeterial> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotBlank(tblTradeMeterial.getMeterialReview())) {
queryWrapper.like("meterial_review", tblTradeMeterial.getMeterialReview());
if (StringUtils.isNotBlank(tblTradeMeterial.getMaterialReview())) {
queryWrapper.like("material_review", tblTradeMeterial.getMaterialReview());
}
if (StringUtils.isNotBlank(tblTradeMeterial.getMeterialCode())) {
queryWrapper.eq("meterial_code", tblTradeMeterial.getMeterialCode());
if (StringUtils.isNotBlank(tblTradeMeterial.getMaterialCode())) {
queryWrapper.eq("material_code", tblTradeMeterial.getMaterialCode());
}
if (StringUtils.isNotBlank(tblTradeMeterial.getBrand())){
queryWrapper.eq("brand", tblTradeMeterial.getBrand());
... ... @@ -113,6 +101,7 @@ public class TblTradeMeterialController extends JeecgController<TblTradeMeterial
* @param tblTradeMeterial
* @return
*/
@Transactional(rollbackFor = Exception.class)
@AutoLog(value = "贸易管理物料表-添加")
@ApiOperation(value = "贸易管理物料表-添加", notes = "贸易管理物料表-添加")
@PostMapping(value = "/add")
... ... @@ -246,9 +235,71 @@ public class TblTradeMeterialController extends JeecgController<TblTradeMeterial
* @param response
* @return
*/
// @Transactional(rollbackFor = Exception.class)
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, TblTradeMeterial.class);
// return super.importExcel(request, response, TblTradeMeterial.class);
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
// params.setKeyIndex(1);
params.setNeedSave(true);
try {
List<TblTradeMeterial> list = ExcelImportUtil.importExcel(file.getInputStream(), TblTradeMeterial.class, params);
// List<T> dataListToSave = new ArrayList<>();
List<TblTradeInventory> tblTradeMeterialArrayList = new ArrayList<>();
for (TblTradeMeterial tblTradeMeterial : list) {
if (tblTradeMeterial != null) {
if(StrUtil.isBlank(tblTradeMeterial.getMaterialCode()) || StrUtil.isBlank(tblTradeMeterial.getMaterialReview())){
return Result.error("文件导入失败,编码或者物料描述有空白!");
}
// tblTradeMeterialArrayList.add(tblTradeMeterial);
tblTradeMeterialArrayList.add(new TblTradeInventory(tblTradeMeterial));
}
}
// if(!tblTradeMeterialArrayList.isEmpty()){
// 如果有数据需要保存,则批量保存
long start = System.currentTimeMillis();
tblTradeMeterialService.saveBatch(list);
tblTradeInventoryService.saveBatch(tblTradeMeterialArrayList);
log.info("批量保存消耗时间:" + (System.currentTimeMillis() - start) + "毫秒");
if(list.size()<=0){
return Result.error("没有有效的导入数据");
}
return Result.ok("文件导入成功!数据行数:" + list.size());
// } else {
// return Result.error("文件导入失败:没有有效的数据需要保存!");
// }
}catch (ExcelImportException e) {
return Result.error("文件导入失败,导入数据格式错误");
} catch (Exception e) {
log.error(e.getMessage());
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
String msg = e.getMessage();
log.error(msg, e);
if(msg!=null && msg.indexOf("Duplicate entry")>=0){
return Result.error("文件导入失败:有重复数据!");
}else{
return Result.error("文件导入失败:" + e.getMessage());
}
//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.error("文件导入失败!");
}
}
... ...
package org.jeecg.modules.erp.trade.controller;
import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.erp.trade.entity.*;
import org.jeecg.modules.erp.trade.service.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.erp.trade.entity.*;
import org.jeecg.modules.erp.trade.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Description: tbl_trade_purchase_info
... ... @@ -219,7 +217,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc
List<TblTradeInventory> list1 = tblTradeInventoryService.list(wrapper);
QueryWrapper<TblTradeMeterial> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.eq("meterial_code", tblTradePurchaseInfo.getWlbh());
queryWrapper1.eq("material_code", tblTradePurchaseInfo.getWlbh());
List<TblTradeMeterial> tradeMeterials = tblTradeMeterialService.list(queryWrapper1);
if (!CollectionUtil.isEmpty(tradeMeterials)) {
... ... @@ -227,7 +225,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc
TblTradeInventory tblTradeInventory = new TblTradeInventory();
tblTradeInventory.setMaterialCode(tblTradePurchaseInfo.getWlbh());
tblTradeInventory.setHth(hth);
tblTradeInventory.setMaterialDescription(tblTradeMeterial.getMeterialReview());
tblTradeInventory.setMaterialDescription(tblTradeMeterial.getMaterialReview());
tblTradeInventory.setMeasurementUnit(tblTradeMeterial.getUnit());
tblTradeInventory.setBrand(tblTradeMeterial.getBrand());
tblTradeInventory.setActualInventory(0);
... ... @@ -313,7 +311,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc
// defectiveProduct.setWaybillNum("BZSOUT"+ DatePattern.PURE_DATETIME_FORMAT.format(new Date()));
// defectiveProduct.setMaterialCode(tblTradePurchaseInfo.getWlbh());
// QueryWrapper<TblTradeMeterial> queryWrapper1 = new QueryWrapper<>();
// queryWrapper1.eq("meterial_code", tblTradePurchaseInfo.getWlbh());
// queryWrapper1.eq("material_code", tblTradePurchaseInfo.getWlbh());
// //物料信息
// List<TblTradeMeterial> tradeMeterials = tblTradeMeterialService.list(queryWrapper1);
// if (!CollectionUtil.isEmpty(tradeMeterials)) {
... ... @@ -339,7 +337,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc
//库存信息
List<TblTradeInventory> list = tblTradeInventoryService.list(queryWrapper);
QueryWrapper<TblTradeMeterial> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.eq("meterial_code", wlbh);
queryWrapper1.eq("material_code", wlbh);
List<TblTradeMeterial> tradeMeterials = tblTradeMeterialService.list(queryWrapper1);
if (CollectionUtil.isEmpty(list)) {
//为空,新增库存记录
... ... @@ -352,20 +350,20 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc
TblTradeInventory tblTradeInventory = new TblTradeInventory();
tblTradeInventory.setMaterialCode(wlbh);
tblTradeInventory.setHth(hth);
tblTradeInventory.setMaterialDescription(tblTradeMeterial.getMeterialReview());
tblTradeInventory.setMaterialDescription(tblTradeMeterial.getMaterialReview());
tblTradeInventory.setMeasurementUnit(tblTradeMeterial.getUnit());
tblTradeInventory.setBrand(tblTradeMeterial.getBrand());
String meterialCode = tblTradeMeterial.getMeterialCode();
Integer yrk = tblTradePurchaseInfoService.getYrkNumByMaterialCode(meterialCode);
String materialCode = tblTradeMeterial.getMaterialCode();
Integer yrk = tblTradePurchaseInfoService.getYrkNumByMaterialCode(materialCode);
yrk = yrk == null ? 0 : yrk;
Integer ck = tblTradeInventoryOutService.getOutboundQuantityByMaterialCode(meterialCode);
Integer ck = tblTradeInventoryOutService.getOutboundQuantityByMaterialCode(materialCode);
ck = ck == null ? 0 : ck;
Integer wrk =tblTradePurchaseInfoService.getWrkNum(meterialCode);
Integer wrk =tblTradePurchaseInfoService.getWrkNum(materialCode);
wrk = wrk == null ? 0 : wrk;
tblTradeInventory.setActualInventory(yrk-ck);
tblTradeInventory.setQuantityInTransit(wrk);
Integer purchaseQuantityNum = tblTradePurchaseInfoService.getPurchaseQuantityNumByMaterialCode(meterialCode);
Integer purchaseQuantityNum = tblTradePurchaseInfoService.getPurchaseQuantityNumByMaterialCode(materialCode);
purchaseQuantityNum = purchaseQuantityNum == null ? 0 : purchaseQuantityNum;
tblTradeInventory.setTotalQuantity(purchaseQuantityNum);
//单价
... ... @@ -381,7 +379,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc
//入库单号
tblTradeInventoryIn.setWaybillNum("BZSIN" + DatePattern.PURE_DATETIME_FORMAT.format(new Date()));
tblTradeInventoryIn.setMaterialCode(wlbh);
tblTradeInventoryIn.setMaterialDescription(tblTradeMeterial.getMeterialReview());
tblTradeInventoryIn.setMaterialDescription(tblTradeMeterial.getMaterialReview());
tblTradeInventoryIn.setMeasurementUnit(tblTradeMeterial.getUnit());
tblTradeInventoryIn.setBrand(tblTradeMeterial.getBrand());
tblTradeInventoryIn.setActualInventory(rkNum);
... ... @@ -402,14 +400,14 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc
//更新实际库存量
// 获取该物料的所有订单的已入库数量 减去 该物料所有的出库记录中出库数量
// 获取该物料的所有订单的已入库数量
String meterialCode = tblTradeMeterial.getMeterialCode();
Integer yrk = tblTradePurchaseInfoService.getYrkNumByMaterialCode(meterialCode);
String materialCode = tblTradeMeterial.getMaterialCode();
Integer yrk = tblTradePurchaseInfoService.getYrkNumByMaterialCode(materialCode);
yrk = yrk == null ? 0 : yrk;
Integer ck = tblTradeInventoryOutService.getOutboundQuantityByMaterialCode(meterialCode);
Integer ck = tblTradeInventoryOutService.getOutboundQuantityByMaterialCode(materialCode);
ck = ck == null ? 0 : ck;
Integer wrk =tblTradePurchaseInfoService.getWrkNum(meterialCode);
Integer wrk =tblTradePurchaseInfoService.getWrkNum(materialCode);
wrk = wrk == null ? 0 : wrk;
Integer purchaseQuantityNum = tblTradePurchaseInfoService.getPurchaseQuantityNumByMaterialCode(meterialCode);
Integer purchaseQuantityNum = tblTradePurchaseInfoService.getPurchaseQuantityNumByMaterialCode(materialCode);
tblTradeInventory.setTotalQuantity(purchaseQuantityNum - ck);
tblTradeInventory.setActualInventory(yrk-ck);
... ... @@ -420,7 +418,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc
TblTradeInventoryIn tblTradeInventoryIn = new TblTradeInventoryIn();
tblTradeInventoryIn.setWaybillNum("BZSIN" + DatePattern.PURE_DATETIME_FORMAT.format(new Date()));
tblTradeInventoryIn.setMaterialCode(wlbh);
tblTradeInventoryIn.setMaterialDescription(tblTradeMeterial.getMeterialReview());
tblTradeInventoryIn.setMaterialDescription(tblTradeMeterial.getMaterialReview());
tblTradeInventoryIn.setMeasurementUnit(tblTradeMeterial.getUnit());
tblTradeInventoryIn.setBrand(tblTradeMeterial.getBrand());
tblTradeInventoryIn.setActualInventory(rkNum);
... ...
package org.jeecg.modules.erp.trade.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
/**
* @Description: 贸易库存表
... ... @@ -56,6 +53,10 @@ public class TblTradeInventory implements Serializable {
@Excel(name = "品牌", width = 15)
@ApiModelProperty(value = "品牌")
private java.lang.String brand;
/**初始库存总量*/
@Excel(name = "初始库存总量", width = 15)
@ApiModelProperty(value = "初始库存总量")
private java.lang.Integer inventoryBoh;
/**实际库存量*/
@Excel(name = "实际库存量", width = 15)
@ApiModelProperty(value = "实际库存量")
... ... @@ -157,8 +158,8 @@ public class TblTradeInventory implements Serializable {
public TblTradeInventory(TblTradeMeterial e){
this.id = e.getId();
this.materialCode=e.getMeterialCode();
this.materialDescription = e.getMeterialReview();
this.materialCode=e.getMaterialCode();
this.materialDescription = e.getMaterialReview();
this.measurementUnit = e.getUnit();
this.brand = e.getBrand();
... ...
package org.jeecg.modules.erp.trade.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
/**
* @Description: 贸易库存表
* @Author: jeecg-boot
* @Date: 2024-12-24
* @Version: V1.0
*/
@Data
@TableName("tbl_trade_inventory")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="tbl_trade_inventory对象", description="贸易库存表")
public class TblTradeInventoryUpdateBoh implements Serializable {
private static final long serialVersionUID = 1L;
/**id*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "id")
private String id;
/**id*/
@TableField(exist = false)
private String purchaseId;
/**物料编码*/
@Excel(name = "物料编码", width = 15)
@ApiModelProperty(value = "物料编码")
private String materialCode;
/**物料描述*/
@Excel(name = "物料描述", width = 15)
@ApiModelProperty(value = "物料描述")
private String materialDescription;
/**初始库存总量*/
@Excel(name = "BOH", width = 15)
@ApiModelProperty(value = "初始库存总量")
private Integer inventoryBoh;
/**实际库存量*/
@Excel(name = "实际库存量", width = 15)
@ApiModelProperty(value = "实际库存量")
private Integer actualInventory;
/**更新人*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
}
... ...
package org.jeecg.modules.erp.trade.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import java.util.Objects;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
/**
* @Description: 贸易管理物料表
... ... @@ -41,11 +38,11 @@ public class TblTradeMeterial implements Serializable {
/**物料编码*/
@Excel(name = "物料编码", width = 15)
@ApiModelProperty(value = "物料编码")
private java.lang.String meterialCode;
private java.lang.String materialCode;
/**物料长描述*/
@Excel(name = "物料长描述", width = 15)
@ApiModelProperty(value = "物料长描述")
private java.lang.String meterialReview;
private java.lang.String materialReview;
/**单位*/
@Excel(name = "单位", width = 15)
@ApiModelProperty(value = "单位")
... ... @@ -54,6 +51,8 @@ public class TblTradeMeterial implements Serializable {
@Excel(name = "品牌", width = 15)
@ApiModelProperty(value = "品牌")
private java.lang.String brand;
/**创建人*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
... ... @@ -104,6 +103,11 @@ public class TblTradeMeterial implements Serializable {
@ApiModelProperty(value = "日期时间")
private java.util.Date otherDate;
/**初始库存总量*/
// @Excel(name = "初始库存总量", width = 15)
@ApiModelProperty(value = "初始库存总量")
@TableField(exist = false)
private java.lang.Integer inventoryBoh;
/**
* 实际库存数量
*/
... ... @@ -147,11 +151,11 @@ public class TblTradeMeterial implements Serializable {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TblTradeMeterial that = (TblTradeMeterial) o;
return Objects.equals(meterialCode, that.meterialCode);
return Objects.equals(materialCode, that.materialCode);
}
@Override
public int hashCode() {
return Objects.hash(meterialCode);
return Objects.hash(materialCode);
}
}
... ...
package org.jeecg.modules.erp.trade.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Description: tbl_trade_purchase_info
* @Description: tbl_trade_purchase_info 采购
* @Author: jeecg-boot
* @Date: 2025-03-19
* @Version: V1.0
... ...
package org.jeecg.modules.erp.trade.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.erp.trade.entity.TblTradeInventory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.erp.trade.entity.TblTradeInventoryUpdateBoh;
import java.util.List;
/**
* @Description: 贸易库存表
... ... @@ -15,4 +16,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface TblTradeInventoryMapper extends BaseMapper<TblTradeInventory> {
Integer getInventoryNum(@Param("materialCode") String materialCode);
void updateBohAndActualBatch(@Param("list")List<TblTradeInventoryUpdateBoh> list);
void updateBohAndActual(TblTradeInventoryUpdateBoh list);
}
... ...
package org.jeecg.modules.erp.trade.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.erp.trade.entity.TblTradeInventoryOut;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: tbl_trade_inventory_out
... ... @@ -14,5 +12,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface TblTradeInventoryOutMapper extends BaseMapper<TblTradeInventoryOut> {
Integer getOutboundQuantityByMaterialCode(@Param("materialCode")String meterialCode);
Integer getOutboundQuantityByMaterialCode(@Param("materialCode")String materialCode);
}
... ...
package org.jeecg.modules.erp.trade.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.erp.trade.entity.TblTradePurchaseInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: tbl_trade_purchase_info
... ... @@ -16,8 +14,8 @@ public interface TblTradePurchaseInfoMapper extends BaseMapper<TblTradePurchaseI
Integer getPurchaseQuantityNumByMaterialCode(@Param("materialCode")String materialCode);
Integer getYrkNumByMaterialCode(@Param("materialCode")String meterialCode);
Integer getYrkNumByMaterialCode(@Param("materialCode")String materialCode);
Integer getWrkNum(@Param("materialCode")String meterialCode);
Integer getWrkNum(@Param("materialCode")String materialCode);
}
... ...
... ... @@ -5,4 +5,23 @@
<select id="getInventoryNum" resultType="java.lang.Integer">
select sum(actual_inventory) from tbl_trade_inventory where material_code = #{materialCode}
</select>
<update id="updateBohAndActualBatch" parameterType="java.util.ArrayList">
update tbl_trade_inventory
set inventory_boh = CASE
<foreach collection="list" item="item">
WHEN material_code = #{item.materialCode} AND material_description = #{item.materialDescription}
THEN #{item.inventoryBoh}
</foreach>
END,
actual_inventory = CASE
<foreach collection="list" item="item">
WHEN material_code = #{item.materialCode} AND material_description = #{item.materialDescription}
THEN #{item.inventoryBoh}
</foreach>
END
</update>
<update id="updateBohAndActual" parameterType="org.jeecg.modules.erp.trade.entity.TblTradeInventoryUpdateBoh">
update tbl_trade_inventory set inventory_boh = #{inventoryBoh} ,actual_inventory = #{inventoryBoh}
where material_code = #{materialCode} AND material_description = #{materialDescription}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -11,5 +11,5 @@ import org.jeecg.modules.erp.trade.entity.TblTradeInventoryOut;
*/
public interface ITblTradeInventoryOutService extends IService<TblTradeInventoryOut> {
Integer getOutboundQuantityByMaterialCode(String meterialCode);
Integer getOutboundQuantityByMaterialCode(String materialCode);
}
... ...
package org.jeecg.modules.erp.trade.service;
import org.jeecg.modules.erp.trade.entity.TblTradeInventory;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.erp.trade.entity.TblTradeInventory;
import org.jeecg.modules.erp.trade.entity.TblTradeInventoryUpdateBoh;
import java.util.List;
/**
* @Description: 贸易库存表
... ... @@ -12,4 +15,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
public interface ITblTradeInventoryService extends IService<TblTradeInventory> {
Integer getInventoryNum(String materialCode);
void updateBohAndActualBatch(List<TblTradeInventoryUpdateBoh> list);
void updateBohAndActual(TblTradeInventoryUpdateBoh tblTradeInventoryUpdateBoh);
}
... ...
... ... @@ -13,7 +13,7 @@ public interface ITblTradePurchaseInfoService extends IService<TblTradePurchaseI
Integer getPurchaseQuantityNumByMaterialCode(String materialCode);
Integer getYrkNumByMaterialCode(String meterialCode);
Integer getYrkNumByMaterialCode(String materialCode);
Integer getWrkNum(String meterialCode);
Integer getWrkNum(String materialCode);
}
... ...
... ... @@ -20,7 +20,7 @@ public class TblTradeInventoryOutServiceImpl extends ServiceImpl<TblTradeInvento
@Autowired
private TblTradeInventoryOutMapper tblTradeInventoryOutMapper;
@Override
public Integer getOutboundQuantityByMaterialCode(String meterialCode) {
return tblTradeInventoryOutMapper.getOutboundQuantityByMaterialCode(meterialCode);
public Integer getOutboundQuantityByMaterialCode(String materialCode) {
return tblTradeInventoryOutMapper.getOutboundQuantityByMaterialCode(materialCode);
}
}
... ...
package org.jeecg.modules.erp.trade.service.impl;
import org.jeecg.modules.erp.trade.entity.TblTradeInventory;
import org.jeecg.modules.erp.trade.entity.TblTradeInventoryUpdateBoh;
import org.jeecg.modules.erp.trade.mapper.TblTradeInventoryMapper;
import org.jeecg.modules.erp.trade.service.ITblTradeInventoryService;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -8,6 +9,8 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
/**
* @Description: 贸易库存表
* @Author: jeecg-boot
... ... @@ -23,4 +26,14 @@ public class TblTradeInventoryServiceImpl extends ServiceImpl<TblTradeInventoryM
public Integer getInventoryNum(String materialCode) {
return tblTradeInventoryMapper.getInventoryNum(materialCode);
}
@Override
public void updateBohAndActualBatch(List<TblTradeInventoryUpdateBoh> list) {
tblTradeInventoryMapper.updateBohAndActualBatch(list);
}
@Override
public void updateBohAndActual(TblTradeInventoryUpdateBoh tblTradeInventoryUpdateBoh) {
tblTradeInventoryMapper.updateBohAndActual(tblTradeInventoryUpdateBoh);
}
}
... ...
... ... @@ -24,12 +24,12 @@ public class TblTradePurchaseInfoServiceImpl extends ServiceImpl<TblTradePurchas
}
@Override
public Integer getYrkNumByMaterialCode(String meterialCode) {
return tblTradePurchaseInfoMapper.getYrkNumByMaterialCode(meterialCode);
public Integer getYrkNumByMaterialCode(String materialCode) {
return tblTradePurchaseInfoMapper.getYrkNumByMaterialCode(materialCode);
}
@Override
public Integer getWrkNum(String meterialCode) {
return tblTradePurchaseInfoMapper.getWrkNum(meterialCode);
public Integer getWrkNum(String materialCode) {
return tblTradePurchaseInfoMapper.getWrkNum(materialCode);
}
}
... ...
package org.jeecg.modules.erp.trade.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import org.jeecg.modules.erp.trade.entity.*;
... ... @@ -110,12 +108,12 @@ public class TblTradeTenderInfoServiceImpl extends ServiceImpl<TblTradeTenderInf
bidSub.setStatus("0");
bidSubList.add(bidSub);
// 排除掉库里已有的物料
TblTradeMeterial tradeMeterial = meterialList.stream().filter(i -> StrUtil.equals(i.getMeterialCode(), e.getCode()))
TblTradeMeterial tradeMeterial = meterialList.stream().filter(i -> StrUtil.equals(i.getMaterialCode(), e.getCode()))
.findFirst().orElse(null);
if (ObjectUtil.isNotNull(tradeMeterial)) return;
TblTradeMeterial insertObj = new TblTradeMeterial();
insertObj.setMeterialCode(e.getCode());
insertObj.setMeterialReview(e.getMiaoshu());
insertObj.setMaterialCode(e.getCode());
insertObj.setMaterialReview(e.getMiaoshu());
insertObj.setUnit(e.getJldw());
insertObj.setBrand(e.getPinpai());
meterialInsertList.add(insertObj);
... ...
... ... @@ -136,9 +136,9 @@ spring:
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
master:
url: jdbc:mysql://192.168.110.10:3306/jeecg?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
password: pass#word1
url: jdbc:mysql://127.0.0.1:3306/factory?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: factory
password: 5wWfCfKZGWhayMK3
driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#multi-datasource1:
... ... @@ -149,7 +149,7 @@ spring:
#redis 配置
redis:
database: 0
host: 192.168.1.199
host: 127.0.0.1
lettuce:
pool:
max-active: 8 #最大连接数据库连接数,设 -1 为没有限制
... ...