1. 库存管理和贸易库存管理追加BOH单挑更新和批量更新;
2. 基本表追加导入功能; 3. 贸易物料表追加导入功能; 4. 库存管理新增单独的库存表,不再使用视图
正在显示
41 个修改的文件
包含
1210 行增加
和
265 行删除
| @@ -18,15 +18,21 @@ import org.jeecg.modules.erp.baseLibrary.service.ITblFinishProductService; | @@ -18,15 +18,21 @@ import org.jeecg.modules.erp.baseLibrary.service.ITblFinishProductService; | ||
| 18 | import org.jeecg.modules.erp.baseLibrary.vo.TblFinishProductVO; | 18 | import org.jeecg.modules.erp.baseLibrary.vo.TblFinishProductVO; |
| 19 | import org.jeecg.modules.erp.order_form.entity.TblWorkOrder; | 19 | import org.jeecg.modules.erp.order_form.entity.TblWorkOrder; |
| 20 | import org.jeecg.modules.erp.order_form.mapper.TblWorkOrderMapper; | 20 | import org.jeecg.modules.erp.order_form.mapper.TblWorkOrderMapper; |
| 21 | +import org.jeecgframework.poi.excel.ExcelImportUtil; | ||
| 22 | +import org.jeecgframework.poi.excel.entity.ImportParams; | ||
| 21 | import org.springframework.beans.BeanUtils; | 23 | import org.springframework.beans.BeanUtils; |
| 22 | import org.springframework.beans.factory.annotation.Autowired; | 24 | import org.springframework.beans.factory.annotation.Autowired; |
| 23 | -import org.springframework.core.io.ClassPathResource; | ||
| 24 | import org.springframework.web.bind.annotation.*; | 25 | import org.springframework.web.bind.annotation.*; |
| 26 | +import org.springframework.web.multipart.MultipartFile; | ||
| 27 | +import org.springframework.web.multipart.MultipartHttpServletRequest; | ||
| 25 | 28 | ||
| 26 | import javax.servlet.http.HttpServletRequest; | 29 | import javax.servlet.http.HttpServletRequest; |
| 30 | +import javax.servlet.http.HttpServletResponse; | ||
| 31 | +import java.io.IOException; | ||
| 27 | import java.util.ArrayList; | 32 | import java.util.ArrayList; |
| 28 | import java.util.List; | 33 | import java.util.List; |
| 29 | import java.util.Map; | 34 | import java.util.Map; |
| 35 | +import java.util.stream.Collectors; | ||
| 30 | 36 | ||
| 31 | @Api(tags = "成品管理") | 37 | @Api(tags = "成品管理") |
| 32 | @RestController | 38 | @RestController |
| @@ -124,4 +130,63 @@ public class TblFinishProductController extends JeecgController<TblFinishProduct | @@ -124,4 +130,63 @@ public class TblFinishProductController extends JeecgController<TblFinishProduct | ||
| 124 | list.add(tree); | 130 | list.add(tree); |
| 125 | return Result.OK(list); | 131 | return Result.OK(list); |
| 126 | } | 132 | } |
| 133 | + | ||
| 134 | + /** | ||
| 135 | + * 通过excel导入数据 | ||
| 136 | + * | ||
| 137 | + * @param request | ||
| 138 | + * @param response | ||
| 139 | + * @return | ||
| 140 | + */ | ||
| 141 | + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) | ||
| 142 | + public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { | ||
| 143 | + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; | ||
| 144 | + Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); | ||
| 145 | + for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { | ||
| 146 | + // 获取上传文件对象 | ||
| 147 | + MultipartFile file = entity.getValue(); | ||
| 148 | + ImportParams params = new ImportParams(); | ||
| 149 | + params.setTitleRows(2); | ||
| 150 | + params.setHeadRows(1); | ||
| 151 | + params.setNeedSave(true); | ||
| 152 | + try { | ||
| 153 | + List<TblFinishProductVO> list = ExcelImportUtil.importExcel(file.getInputStream(), TblFinishProductVO.class, params); | ||
| 154 | + | ||
| 155 | + List<String> partNumberList = list.stream() // 将beanList转换为Stream | ||
| 156 | + .map(TblFinishProductVO::getPartNumber) // 使用map方法提取id字段 | ||
| 157 | + .collect(Collectors.toList()); // 收集结果到新的List中 | ||
| 158 | + List<String> allPartNumberList = iTblFinishProductService.getAllPartNumber(); | ||
| 159 | + | ||
| 160 | + //判断是否有重复编码 | ||
| 161 | +// boolean flag = partNumberList.stream().anyMatch(allPartNumberList::contains); | ||
| 162 | + | ||
| 163 | + // 找出重复编码 | ||
| 164 | + List<String> duplicates = partNumberList.stream() | ||
| 165 | + .filter(allPartNumberList::contains) | ||
| 166 | + .distinct() | ||
| 167 | + .collect(Collectors.toList()); | ||
| 168 | + if(duplicates.size() >0){ | ||
| 169 | + return Result.error("编码有重复,重复编码是: " + duplicates); | ||
| 170 | + } | ||
| 171 | +// iTblFinishProductService.saveBatch(list); | ||
| 172 | + | ||
| 173 | + for (TblFinishProductVO page : list) { | ||
| 174 | + TblFinishProduct po = new TblFinishProduct(); | ||
| 175 | + BeanUtils.copyProperties(page, po); | ||
| 176 | + iTblFinishProductService.saveMain(po, page.getTblPartSemifinishedList()); | ||
| 177 | + } | ||
| 178 | + return Result.OK("文件导入成功!数据行数:" + list.size()); | ||
| 179 | + } catch (Exception e) { | ||
| 180 | + log.error(e.getMessage(), e); | ||
| 181 | + return Result.error("文件导入失败:" + e.getMessage()); | ||
| 182 | + } finally { | ||
| 183 | + try { | ||
| 184 | + file.getInputStream().close(); | ||
| 185 | + } catch (IOException e) { | ||
| 186 | + e.printStackTrace(); | ||
| 187 | + } | ||
| 188 | + } | ||
| 189 | + } | ||
| 190 | + return Result.OK("文件导入失败!"); | ||
| 191 | + } | ||
| 127 | } | 192 | } |
| 1 | package org.jeecg.modules.erp.baseLibrary.mapper; | 1 | package org.jeecg.modules.erp.baseLibrary.mapper; |
| 2 | 2 | ||
| 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 4 | +import org.apache.ibatis.annotations.Param; | ||
| 5 | +import org.apache.ibatis.annotations.Select; | ||
| 4 | import org.jeecg.modules.erp.baseLibrary.entity.TblFinishProduct; | 6 | import org.jeecg.modules.erp.baseLibrary.entity.TblFinishProduct; |
| 5 | 7 | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 6 | public interface TblFinishProductMapper extends BaseMapper<TblFinishProduct> { | 10 | public interface TblFinishProductMapper extends BaseMapper<TblFinishProduct> { |
| 7 | 11 | ||
| 8 | TblFinishProduct selectByPartNumber(String partNumber); | 12 | TblFinishProduct selectByPartNumber(String partNumber); |
| 13 | + | ||
| 14 | + @Select("select id from tbl_finish_product where part_number=#{partNumber}") | ||
| 15 | + String getIdByPartNumber(@Param("partNumber") String partNumber); | ||
| 16 | + | ||
| 17 | + List<String> getAllPartNumber(); | ||
| 9 | } | 18 | } |
jeecg-boot-erp/src/main/java/org/jeecg/modules/erp/baseLibrary/mapper/xml/TblFinishProductMapper.xml
| @@ -5,4 +5,8 @@ | @@ -5,4 +5,8 @@ | ||
| 5 | <select id="selectByPartNumber" parameterType="java.lang.String" resultType="org.jeecg.modules.erp.baseLibrary.entity.TblFinishProduct"> | 5 | <select id="selectByPartNumber" parameterType="java.lang.String" resultType="org.jeecg.modules.erp.baseLibrary.entity.TblFinishProduct"> |
| 6 | select id,part_number,product_name,spec,'type' from tbl_finish_product where part_number = #{partNumber} | 6 | select id,part_number,product_name,spec,'type' from tbl_finish_product where part_number = #{partNumber} |
| 7 | </select> | 7 | </select> |
| 8 | + | ||
| 9 | + <select id="getAllPartNumber" resultType="java.lang.String"> | ||
| 10 | + select part_number from tbl_finish_product | ||
| 11 | + </select> | ||
| 8 | </mapper> | 12 | </mapper> |
jeecg-boot-erp/src/main/java/org/jeecg/modules/erp/baseLibrary/service/ITblFinishProductService.java
| @@ -16,4 +16,14 @@ public interface ITblFinishProductService extends IService<TblFinishProduct> { | @@ -16,4 +16,14 @@ public interface ITblFinishProductService extends IService<TblFinishProduct> { | ||
| 16 | void addAll(TblFinishProduct tblFinishProduct, List<TblPartSemifinished> tblPartSemifinishedList); | 16 | void addAll(TblFinishProduct tblFinishProduct, List<TblPartSemifinished> tblPartSemifinishedList); |
| 17 | 17 | ||
| 18 | TblFinishProduct selectByPartNumber(String partNumber); | 18 | TblFinishProduct selectByPartNumber(String partNumber); |
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 添加一对多 | ||
| 22 | + * | ||
| 23 | + * @param tblFinishProduct | ||
| 24 | + * @param tblPartSemifinishedList | ||
| 25 | + */ | ||
| 26 | + public void saveMain(TblFinishProduct tblFinishProduct, List<TblPartSemifinished> tblPartSemifinishedList); | ||
| 27 | + | ||
| 28 | + List<String> getAllPartNumber(); | ||
| 19 | } | 29 | } |
| @@ -7,6 +7,7 @@ import org.jeecg.modules.erp.baseLibrary.entity.TblFinishProductRelation; | @@ -7,6 +7,7 @@ import org.jeecg.modules.erp.baseLibrary.entity.TblFinishProductRelation; | ||
| 7 | import org.jeecg.modules.erp.baseLibrary.mapper.TblFinishProductMapper; | 7 | import org.jeecg.modules.erp.baseLibrary.mapper.TblFinishProductMapper; |
| 8 | import org.jeecg.modules.erp.baseLibrary.mapper.TblFinishProductRelationMapper; | 8 | import org.jeecg.modules.erp.baseLibrary.mapper.TblFinishProductRelationMapper; |
| 9 | import org.jeecg.modules.erp.baseLibrary.service.ITblFinishProductService; | 9 | import org.jeecg.modules.erp.baseLibrary.service.ITblFinishProductService; |
| 10 | +import org.jeecg.modules.erp.depot.mapper.TblInventoryMapper; | ||
| 10 | import org.jeecg.modules.erp.meterial.entity.TblMaterial; | 11 | import org.jeecg.modules.erp.meterial.entity.TblMaterial; |
| 11 | import org.jeecg.modules.erp.meterial.entity.TblPartSemifinished; | 12 | import org.jeecg.modules.erp.meterial.entity.TblPartSemifinished; |
| 12 | import org.jeecg.modules.erp.meterial.mapper.TblMaterialMapper; | 13 | import org.jeecg.modules.erp.meterial.mapper.TblMaterialMapper; |
| @@ -31,6 +32,9 @@ public class TblFinishProductServiceImpl extends ServiceImpl<TblFinishProductMap | @@ -31,6 +32,9 @@ public class TblFinishProductServiceImpl extends ServiceImpl<TblFinishProductMap | ||
| 31 | @Autowired | 32 | @Autowired |
| 32 | private TblPartSemifinishedMapper tblPartSemifinishedMapper; | 33 | private TblPartSemifinishedMapper tblPartSemifinishedMapper; |
| 33 | 34 | ||
| 35 | + @Autowired | ||
| 36 | + private TblInventoryMapper tblInventoryMapper; | ||
| 37 | + | ||
| 34 | @Override | 38 | @Override |
| 35 | public void updateAll(TblFinishProduct tblFinishProduct, List<TblPartSemifinished> tblPartSemifinishedList) { | 39 | public void updateAll(TblFinishProduct tblFinishProduct, List<TblPartSemifinished> tblPartSemifinishedList) { |
| 36 | tblFinishProductMapper.updateById(tblFinishProduct); | 40 | tblFinishProductMapper.updateById(tblFinishProduct); |
| @@ -97,6 +101,15 @@ public class TblFinishProductServiceImpl extends ServiceImpl<TblFinishProductMap | @@ -97,6 +101,15 @@ public class TblFinishProductServiceImpl extends ServiceImpl<TblFinishProductMap | ||
| 97 | String id = "CP" + UUID.randomUUID(); | 101 | String id = "CP" + UUID.randomUUID(); |
| 98 | tblFinishProduct.setId(id); | 102 | tblFinishProduct.setId(id); |
| 99 | tblFinishProductMapper.insert(tblFinishProduct); | 103 | tblFinishProductMapper.insert(tblFinishProduct); |
| 104 | +// TblInventory tblInventory1 = new TblInventory(); | ||
| 105 | +// tblInventory1.setPartNumber(tblFinishProduct.getPartNumber());//编号 | ||
| 106 | +// tblInventory1.setProductName(tblFinishProduct.getProductName());//品名 | ||
| 107 | +// tblInventory1.setSpec(tblFinishProduct.getSpec());//规格 | ||
| 108 | +// tblInventory1.setType(tblFinishProduct.getType());//型号 | ||
| 109 | +// tblInventory1.setBuyingClassify(tblFinishProduct.getBuyingClassify());//采购性质 | ||
| 110 | +//// tblInventory1.setCurrentInventory(tblMaterial.getOperNumber());//当前库存 | ||
| 111 | +// tblInventory1.setMeterialType(tblFinishProduct.getMeterialType());//类别 | ||
| 112 | +// tblInventoryMapper.insert(tblInventory1); | ||
| 100 | for (TblPartSemifinished tblPartSemifinished : tblPartSemifinishedList) { | 113 | for (TblPartSemifinished tblPartSemifinished : tblPartSemifinishedList) { |
| 101 | QueryWrapper<TblMaterial> tblMaterialQueryWrapper = new QueryWrapper<>(); | 114 | QueryWrapper<TblMaterial> tblMaterialQueryWrapper = new QueryWrapper<>(); |
| 102 | tblMaterialQueryWrapper.eq("part_number", tblPartSemifinished.getPartNumber()); | 115 | tblMaterialQueryWrapper.eq("part_number", tblPartSemifinished.getPartNumber()); |
| @@ -113,4 +126,25 @@ public class TblFinishProductServiceImpl extends ServiceImpl<TblFinishProductMap | @@ -113,4 +126,25 @@ public class TblFinishProductServiceImpl extends ServiceImpl<TblFinishProductMap | ||
| 113 | public TblFinishProduct selectByPartNumber(String partNumber) { | 126 | public TblFinishProduct selectByPartNumber(String partNumber) { |
| 114 | return tblFinishProductMapper.selectByPartNumber(partNumber); | 127 | return tblFinishProductMapper.selectByPartNumber(partNumber); |
| 115 | } | 128 | } |
| 129 | + | ||
| 130 | + @Override | ||
| 131 | + public void saveMain(TblFinishProduct tblFinishProduct, List<TblPartSemifinished> tblPartSemifinishedList) { | ||
| 132 | + tblFinishProductMapper.insert(tblFinishProduct); | ||
| 133 | + if (tblPartSemifinishedList != null && tblPartSemifinishedList.size() > 0) { | ||
| 134 | + for (TblPartSemifinished entity : tblPartSemifinishedList) { | ||
| 135 | + String id = tblFinishProductMapper.getIdByPartNumber(entity.getPartNumber()); | ||
| 136 | + if(!id.equals("") && id != ""){ | ||
| 137 | + entity.setSubclassId(id); | ||
| 138 | + } | ||
| 139 | + //外键设置 | ||
| 140 | + entity.setMaterialId(tblFinishProduct.getId()); | ||
| 141 | + tblPartSemifinishedMapper.insert(entity); | ||
| 142 | + } | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + @Override | ||
| 147 | + public List<String> getAllPartNumber() { | ||
| 148 | + return tblFinishProductMapper.getAllPartNumber(); | ||
| 149 | + } | ||
| 116 | } | 150 | } |
| @@ -3,6 +3,7 @@ package org.jeecg.modules.erp.depot.controller; | @@ -3,6 +3,7 @@ package org.jeecg.modules.erp.depot.controller; | ||
| 3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
| 4 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 4 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| 5 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 5 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 6 | +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | ||
| 6 | import com.baomidou.mybatisplus.core.metadata.IPage; | 7 | import com.baomidou.mybatisplus.core.metadata.IPage; |
| 7 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 8 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| 8 | import io.swagger.annotations.Api; | 9 | import io.swagger.annotations.Api; |
| @@ -14,19 +15,24 @@ import org.jeecg.common.aspect.annotation.PermissionData; | @@ -14,19 +15,24 @@ import org.jeecg.common.aspect.annotation.PermissionData; | ||
| 14 | import org.jeecg.common.system.base.controller.JeecgController; | 15 | import org.jeecg.common.system.base.controller.JeecgController; |
| 15 | import org.jeecg.common.system.query.QueryGenerator; | 16 | import org.jeecg.common.system.query.QueryGenerator; |
| 16 | import org.jeecg.modules.erp.depot.entity.TblDepot; | 17 | import org.jeecg.modules.erp.depot.entity.TblDepot; |
| 18 | +import org.jeecg.modules.erp.depot.entity.TblInventory; | ||
| 17 | import org.jeecg.modules.erp.depot.form.TblDepotForm; | 19 | import org.jeecg.modules.erp.depot.form.TblDepotForm; |
| 18 | import org.jeecg.modules.erp.depot.mapper.TblDepotTestMapper; | 20 | import org.jeecg.modules.erp.depot.mapper.TblDepotTestMapper; |
| 19 | import org.jeecg.modules.erp.depot.service.ITblDepotService; | 21 | import org.jeecg.modules.erp.depot.service.ITblDepotService; |
| 20 | -import org.jeecg.modules.erp.robot.service.impl.YjRobotService; | 22 | +import org.jeecg.modules.erp.depot.service.ITblInventoryService; |
| 21 | import org.jeecg.modules.erp.meterial.entity.TblMaterial; | 23 | import org.jeecg.modules.erp.meterial.entity.TblMaterial; |
| 22 | import org.jeecg.modules.erp.meterial.service.ITblMaterialService; | 24 | import org.jeecg.modules.erp.meterial.service.ITblMaterialService; |
| 25 | +import org.jeecg.modules.erp.robot.service.impl.YjRobotService; | ||
| 23 | import org.springframework.beans.factory.annotation.Autowired; | 26 | import org.springframework.beans.factory.annotation.Autowired; |
| 27 | +import org.springframework.transaction.annotation.Transactional; | ||
| 24 | import org.springframework.web.bind.annotation.*; | 28 | import org.springframework.web.bind.annotation.*; |
| 25 | import org.springframework.web.servlet.ModelAndView; | 29 | import org.springframework.web.servlet.ModelAndView; |
| 26 | 30 | ||
| 27 | import javax.servlet.http.HttpServletRequest; | 31 | import javax.servlet.http.HttpServletRequest; |
| 28 | import javax.servlet.http.HttpServletResponse; | 32 | import javax.servlet.http.HttpServletResponse; |
| 29 | -import java.util.*; | 33 | +import java.util.Arrays; |
| 34 | +import java.util.List; | ||
| 35 | +import java.util.Map; | ||
| 30 | 36 | ||
| 31 | /** | 37 | /** |
| 32 | * @Description: tbl_depot | 38 | * @Description: tbl_depot |
| @@ -50,6 +56,9 @@ public class TblDepotController extends JeecgController<TblDepot, ITblDepotServi | @@ -50,6 +56,9 @@ public class TblDepotController extends JeecgController<TblDepot, ITblDepotServi | ||
| 50 | @Autowired | 56 | @Autowired |
| 51 | TblDepotTestMapper tblDepotMapper; | 57 | TblDepotTestMapper tblDepotMapper; |
| 52 | 58 | ||
| 59 | + @Autowired | ||
| 60 | + private ITblInventoryService tblInventoryService; | ||
| 61 | + | ||
| 53 | @GetMapping("/updateData") | 62 | @GetMapping("/updateData") |
| 54 | public void updateData(){ | 63 | public void updateData(){ |
| 55 | List<Map<String, Object>> maps = tblDepotMapper.selectPartNumberAndCreateTime(); | 64 | List<Map<String, Object>> maps = tblDepotMapper.selectPartNumberAndCreateTime(); |
| @@ -149,36 +158,58 @@ public class TblDepotController extends JeecgController<TblDepot, ITblDepotServi | @@ -149,36 +158,58 @@ public class TblDepotController extends JeecgController<TblDepot, ITblDepotServi | ||
| 149 | * @param tblDepotForm | 158 | * @param tblDepotForm |
| 150 | * @return | 159 | * @return |
| 151 | */ | 160 | */ |
| 161 | + @Transactional(rollbackFor = Exception.class) | ||
| 152 | @AutoLog(value = "tbl_depot-添加") | 162 | @AutoLog(value = "tbl_depot-添加") |
| 153 | @ApiOperation(value="tbl_depot-添加", notes="tbl_depot-添加") | 163 | @ApiOperation(value="tbl_depot-添加", notes="tbl_depot-添加") |
| 154 | @PostMapping(value = "/add") | 164 | @PostMapping(value = "/add") |
| 155 | public Result<String> add(@RequestBody TblDepotForm tblDepotForm) { | 165 | public Result<String> add(@RequestBody TblDepotForm tblDepotForm) { |
| 156 | TblDepot tblDepot = new TblDepot(); | 166 | TblDepot tblDepot = new TblDepot(); |
| 157 | BeanUtil.copyProperties(tblDepotForm, tblDepot); | 167 | BeanUtil.copyProperties(tblDepotForm, tblDepot); |
| 158 | - TblDepot tblDepot1 = tblDepotService.selectByPartNumber(tblDepotForm.getPartNumber()); | 168 | +// TblDepot tblDepot1 = tblDepotService.selectByPartNumber(tblDepotForm.getPartNumber()); |
| 169 | + TblInventory tblInventory = tblInventoryService.getByPartNumber(tblDepotForm.getPartNumber()); | ||
| 159 | if(tblDepot.getDepotType().equals("入库")){ | 170 | if(tblDepot.getDepotType().equals("入库")){ |
| 160 | - tblDepot.setCurrentInventory((tblDepot1 != null && tblDepot1.getCurrentInventory() != null) ? tblDepot1.getCurrentInventory() + tblDepot.getOperNumber() : tblDepot.getOperNumber()); | 171 | + tblDepot.setCurrentInventory((tblInventory != null && tblInventory.getCurrentInventory() != null) ? tblInventory.getCurrentInventory() + tblDepot.getOperNumber() : tblDepot.getOperNumber()); |
| 172 | + //库存明细表保存 | ||
| 161 | tblDepotService.save(tblDepot); | 173 | tblDepotService.save(tblDepot); |
| 174 | + //库存表保存 | ||
| 175 | + tblInventoryService.saveOrUpdateInventory(tblDepotForm); | ||
| 162 | }else{ | 176 | }else{ |
| 163 | - String partNumber = tblDepot.getPartNumber(); | ||
| 164 | - List<TblDepot> list = queryByDepotId(partNumber); | ||
| 165 | - int max = 0; | ||
| 166 | - int min = 0; | ||
| 167 | - | ||
| 168 | - for (TblDepot tbl:list) { | ||
| 169 | - if(tbl.getDepotType().equals("入库")){ | ||
| 170 | - max += tbl.getOperNumber(); | ||
| 171 | - }else { | ||
| 172 | - if (tbl.getDepotType().equals("出库")){ | ||
| 173 | - min += tbl.getOperNumber(); | ||
| 174 | - } | ||
| 175 | - } | 177 | +// String partNumber = tblDepot.getPartNumber(); |
| 178 | +// List<TblDepot> list = queryByDepotId(partNumber); | ||
| 179 | +// int max = 0; | ||
| 180 | +// int min = 0; | ||
| 181 | +// | ||
| 182 | +// for (TblDepot tbl:list) { | ||
| 183 | +// if(tbl.getDepotType().equals("入库")){ | ||
| 184 | +// max += tbl.getOperNumber(); | ||
| 185 | +// }else { | ||
| 186 | +// if (tbl.getDepotType().equals("出库")){ | ||
| 187 | +// min += tbl.getOperNumber(); | ||
| 188 | +// } | ||
| 189 | +// } | ||
| 190 | +// } | ||
| 191 | +// | ||
| 192 | +// if (tblDepot.getOperNumber() > (max - min)){ | ||
| 193 | +// return Result.error("库存数量不足!"); | ||
| 194 | +// }else{ | ||
| 195 | +// tblDepot.setCurrentInventory((tblDepot1 != null && tblDepot1.getCurrentInventory() != null) ? tblDepot1.getCurrentInventory() - tblDepot.getOperNumber() : - tblDepot.getOperNumber()); | ||
| 196 | +// //库存明细表保存 | ||
| 197 | +// tblDepotService.save(tblDepot); | ||
| 198 | +// } | ||
| 199 | +// TblInventory tblInventory = tblInventoryService.getByPartNumber(tblDepotForm.getPartNumber()); | ||
| 200 | + if(null != tblInventory && tblInventory.getCurrentInventory() >= tblDepotForm.getOperNumber()){ | ||
| 201 | + tblDepot.setCurrentInventory((tblInventory != null && tblInventory.getCurrentInventory() != null) ? tblInventory.getCurrentInventory() - tblDepot.getOperNumber() : - tblDepot.getOperNumber()); | ||
| 202 | + //库存明细表保存 | ||
| 203 | + tblDepotService.save(tblDepot); | ||
| 204 | + //库存表更新当前库存 | ||
| 205 | +// tblInventory.setCurrentInventory(tblInventory.getCurrentInventory() - tblDepotForm.getOperNumber()); | ||
| 206 | + UpdateWrapper<TblInventory> wrapper = new UpdateWrapper<>(); | ||
| 207 | + wrapper.set("current_inventory", tblInventory.getCurrentInventory() - tblDepotForm.getOperNumber()) // 设置更新字段 | ||
| 208 | + .eq("id", tblInventory.getId()); | ||
| 209 | + tblInventoryService.update(null, wrapper); | ||
| 176 | } | 210 | } |
| 177 | - if (tblDepot.getOperNumber() > (max - min)){ | 211 | + else{ |
| 178 | return Result.error("库存数量不足!"); | 212 | return Result.error("库存数量不足!"); |
| 179 | - }else{ | ||
| 180 | - tblDepot.setCurrentInventory((tblDepot1 != null && tblDepot1.getCurrentInventory() != null) ? tblDepot1.getCurrentInventory() - tblDepot.getOperNumber() : - tblDepot.getOperNumber()); | ||
| 181 | - tblDepotService.save(tblDepot); | ||
| 182 | } | 213 | } |
| 183 | } | 214 | } |
| 184 | // int code = 0; | 215 | // int code = 0; |
jeecg-boot-erp/src/main/java/org/jeecg/modules/erp/depot/controller/TblInventoryController.java
0 → 100644
| 1 | +package org.jeecg.modules.erp.depot.controller; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.util.StrUtil; | ||
| 4 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 5 | +import com.baomidou.mybatisplus.core.metadata.IPage; | ||
| 6 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
| 7 | +import io.swagger.annotations.Api; | ||
| 8 | +import io.swagger.annotations.ApiOperation; | ||
| 9 | +import lombok.extern.slf4j.Slf4j; | ||
| 10 | +import org.jeecg.common.api.vo.Result; | ||
| 11 | +import org.jeecg.common.aspect.annotation.AutoLog; | ||
| 12 | +import org.jeecg.common.system.base.controller.JeecgController; | ||
| 13 | +import org.jeecg.common.system.query.QueryGenerator; | ||
| 14 | +import org.jeecg.modules.erp.depot.entity.TblDepot; | ||
| 15 | +import org.jeecg.modules.erp.depot.entity.TblInventory; | ||
| 16 | +import org.jeecg.modules.erp.depot.service.ITblDepotService; | ||
| 17 | +import org.jeecg.modules.erp.depot.service.ITblInventoryService; | ||
| 18 | +import org.jeecgframework.poi.excel.ExcelImportUtil; | ||
| 19 | +import org.jeecgframework.poi.excel.entity.ImportParams; | ||
| 20 | +import org.jeecgframework.poi.exception.excel.ExcelImportException; | ||
| 21 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 22 | +import org.springframework.web.bind.annotation.*; | ||
| 23 | +import org.springframework.web.multipart.MultipartFile; | ||
| 24 | +import org.springframework.web.multipart.MultipartHttpServletRequest; | ||
| 25 | +import org.springframework.web.servlet.ModelAndView; | ||
| 26 | + | ||
| 27 | +import javax.servlet.http.HttpServletRequest; | ||
| 28 | +import javax.servlet.http.HttpServletResponse; | ||
| 29 | +import java.io.IOException; | ||
| 30 | +import java.util.ArrayList; | ||
| 31 | +import java.util.Arrays; | ||
| 32 | +import java.util.List; | ||
| 33 | +import java.util.Map; | ||
| 34 | + | ||
| 35 | +/** | ||
| 36 | + * @Description: tbl_inventory | ||
| 37 | + * @Author: jeecg-boot | ||
| 38 | + * @Date: 2025-09-16 | ||
| 39 | + * @Version: V1.0 | ||
| 40 | + */ | ||
| 41 | +@Api(tags="tbl_inventory") | ||
| 42 | +@RestController | ||
| 43 | +@RequestMapping("/depot/tblInventory") | ||
| 44 | +@Slf4j | ||
| 45 | +public class TblInventoryController extends JeecgController<TblInventory, ITblInventoryService> { | ||
| 46 | + @Autowired | ||
| 47 | + private ITblInventoryService tblInventoryService; | ||
| 48 | + | ||
| 49 | + @Autowired | ||
| 50 | + private ITblDepotService tblDepotService; | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 分页列表查询 | ||
| 54 | + * | ||
| 55 | + * @param tblInventory | ||
| 56 | + * @param pageNo | ||
| 57 | + * @param pageSize | ||
| 58 | + * @param req | ||
| 59 | + * @return | ||
| 60 | + */ | ||
| 61 | + //@AutoLog(value = "tbl_inventory-分页列表查询") | ||
| 62 | + @ApiOperation(value="tbl_inventory-分页列表查询", notes="tbl_inventory-分页列表查询") | ||
| 63 | + @GetMapping(value = "/list") | ||
| 64 | + public Result<IPage<TblInventory>> queryPageList(TblInventory tblInventory, | ||
| 65 | + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, | ||
| 66 | + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, | ||
| 67 | + HttpServletRequest req) { | ||
| 68 | + QueryWrapper<TblInventory> queryWrapper = QueryGenerator.initQueryWrapper(tblInventory, req.getParameterMap()); | ||
| 69 | + Page<TblInventory> page = new Page<TblInventory>(pageNo, pageSize); | ||
| 70 | + IPage<TblInventory> pageList = tblInventoryService.page(page, queryWrapper); | ||
| 71 | + return Result.OK(pageList); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * 更新BOH | ||
| 76 | + * | ||
| 77 | + * @param tblInventory | ||
| 78 | + * @return | ||
| 79 | + */ | ||
| 80 | + @AutoLog(value = "库存表-BOH更新") | ||
| 81 | + @ApiOperation(value = "库存表-BOH更新", notes = "库存表-BOH更新") | ||
| 82 | + @RequestMapping(value = "/updateBoh", method = {RequestMethod.PUT, RequestMethod.POST}) | ||
| 83 | + public Result<String> updateBoh(@RequestBody TblInventory tblInventory) { | ||
| 84 | + tblInventoryService.updateBohAndCurrentInventory(tblInventory); | ||
| 85 | + return Result.OK("BOH更新成功!"); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * 添加 | ||
| 90 | + * | ||
| 91 | + * @param tblInventory | ||
| 92 | + * @return | ||
| 93 | + */ | ||
| 94 | + @AutoLog(value = "tbl_inventory-添加") | ||
| 95 | + @ApiOperation(value="tbl_inventory-添加", notes="tbl_inventory-添加") | ||
| 96 | + @PostMapping(value = "/add") | ||
| 97 | + public Result<String> add(@RequestBody TblInventory tblInventory) { | ||
| 98 | + tblInventoryService.save(tblInventory); | ||
| 99 | + return Result.OK("添加成功!"); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + /** | ||
| 103 | + * 编辑 | ||
| 104 | + * | ||
| 105 | + * @param tblInventory | ||
| 106 | + * @return | ||
| 107 | + */ | ||
| 108 | + @AutoLog(value = "tbl_inventory-编辑") | ||
| 109 | + @ApiOperation(value="tbl_inventory-编辑", notes="tbl_inventory-编辑") | ||
| 110 | + @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) | ||
| 111 | + public Result<String> edit(@RequestBody TblInventory tblInventory) { | ||
| 112 | + tblInventoryService.updateById(tblInventory); | ||
| 113 | + return Result.OK("编辑成功!"); | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + /** | ||
| 117 | + * 通过id删除 | ||
| 118 | + * | ||
| 119 | + * @param id | ||
| 120 | + * @return | ||
| 121 | + */ | ||
| 122 | + @AutoLog(value = "tbl_inventory-通过id删除") | ||
| 123 | + @ApiOperation(value="tbl_inventory-通过id删除", notes="tbl_inventory-通过id删除") | ||
| 124 | + @DeleteMapping(value = "/delete") | ||
| 125 | + public Result<String> delete(@RequestParam(name="id",required=true) String id) { | ||
| 126 | + tblInventoryService.removeById(id); | ||
| 127 | + return Result.OK("删除成功!"); | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + /** | ||
| 131 | + * 批量删除 | ||
| 132 | + * | ||
| 133 | + * @param ids | ||
| 134 | + * @return | ||
| 135 | + */ | ||
| 136 | + @AutoLog(value = "tbl_inventory-批量删除") | ||
| 137 | + @ApiOperation(value="tbl_inventory-批量删除", notes="tbl_inventory-批量删除") | ||
| 138 | + @DeleteMapping(value = "/deleteBatch") | ||
| 139 | + public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { | ||
| 140 | + this.tblInventoryService.removeByIds(Arrays.asList(ids.split(","))); | ||
| 141 | + return Result.OK("批量删除成功!"); | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + /** | ||
| 145 | + * 通过id查询 | ||
| 146 | + * | ||
| 147 | + * @param id | ||
| 148 | + * @return | ||
| 149 | + */ | ||
| 150 | + //@AutoLog(value = "tbl_inventory-通过id查询") | ||
| 151 | + @ApiOperation(value="tbl_inventory-通过id查询", notes="tbl_inventory-通过id查询") | ||
| 152 | + @GetMapping(value = "/queryById") | ||
| 153 | + public Result<TblInventory> queryById(@RequestParam(name="id",required=true) String id) { | ||
| 154 | + TblInventory tblInventory = tblInventoryService.getById(id); | ||
| 155 | + if(tblInventory==null) { | ||
| 156 | + return Result.error("未找到对应数据"); | ||
| 157 | + } | ||
| 158 | + return Result.OK(tblInventory); | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + /** | ||
| 162 | + * 导出excel | ||
| 163 | + * | ||
| 164 | + * @param request | ||
| 165 | + * @param tblInventory | ||
| 166 | + */ | ||
| 167 | + @RequestMapping(value = "/exportXls") | ||
| 168 | + public ModelAndView exportXls(HttpServletRequest request, TblInventory tblInventory) { | ||
| 169 | + return super.exportXls(request, tblInventory, TblInventory.class, "tbl_inventory"); | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + /** | ||
| 173 | + * 通过excel导入数据 | ||
| 174 | + * | ||
| 175 | + * @param request | ||
| 176 | + * @param response | ||
| 177 | + * @return | ||
| 178 | + */ | ||
| 179 | + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) | ||
| 180 | + public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { | ||
| 181 | + return super.importExcel(request, response, TblInventory.class); | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + /** | ||
| 185 | + * 批量更新BOH | ||
| 186 | + * | ||
| 187 | + * @param request | ||
| 188 | + * @param response | ||
| 189 | + * @return | ||
| 190 | + */ | ||
| 191 | + @RequestMapping(value = "/importExcelBoh", method = RequestMethod.POST) | ||
| 192 | + public Result<?> importExcelBoh(HttpServletRequest request, HttpServletResponse response) { | ||
| 193 | + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; | ||
| 194 | + Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); | ||
| 195 | + for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { | ||
| 196 | + // 获取上传文件对象 | ||
| 197 | + MultipartFile file = entity.getValue(); | ||
| 198 | + ImportParams params = new ImportParams(); | ||
| 199 | + params.setTitleRows(2); | ||
| 200 | + params.setHeadRows(1); | ||
| 201 | + params.setNeedSave(true); | ||
| 202 | + try { | ||
| 203 | + List<TblInventory> list = ExcelImportUtil.importExcel(file.getInputStream(), TblInventory.class, params); | ||
| 204 | + List<TblDepot> tblDepotList = new ArrayList<>(); | ||
| 205 | + for (TblInventory tblInventory : list) { | ||
| 206 | + if (tblInventory != null) { | ||
| 207 | + if(StrUtil.isBlank(tblInventory.getPartNumber()) || StrUtil.isBlank(tblInventory.getProductName()) || (null == tblInventory.getInventoryBoh())){ | ||
| 208 | + return Result.error("文件导入失败,编码、物料长描述、BOH有空白!"); | ||
| 209 | + } | ||
| 210 | + TblDepot tblDepot = new TblDepot(); | ||
| 211 | + tblDepot.setPartNumber(tblInventory.getPartNumber()); | ||
| 212 | + tblDepot.setProductName(tblInventory.getProductName()); | ||
| 213 | + tblDepot.setSpec(tblInventory.getSpec()); | ||
| 214 | + tblDepot.setType(tblInventory.getType()); | ||
| 215 | + tblDepot.setCurrentInventory(tblInventory.getInventoryBoh()); | ||
| 216 | + tblDepot.setDepotType("更新"); | ||
| 217 | + tblDepotList.add(tblDepot); | ||
| 218 | + } | ||
| 219 | + } | ||
| 220 | + // 如果有数据需要保存,则批量保存 | ||
| 221 | + long start = System.currentTimeMillis(); | ||
| 222 | + tblInventoryService.updateBohAndCurrentInventoryBatch(list); | ||
| 223 | + tblDepotService.saveBatch(tblDepotList); | ||
| 224 | + log.info("批量保存消耗时间:" + (System.currentTimeMillis() - start) + "毫秒"); | ||
| 225 | + if(list.size()<=0){ | ||
| 226 | + return Result.error("没有有效的导入数据"); | ||
| 227 | + } | ||
| 228 | + return Result.ok("文件导入成功!数据行数:" + list.size()); | ||
| 229 | + | ||
| 230 | + }catch (ExcelImportException e) { | ||
| 231 | + return Result.error("文件导入失败,导入数据格式错误"); | ||
| 232 | + } catch (Exception e) { | ||
| 233 | + log.error(e.getMessage()); | ||
| 234 | + String msg = e.getMessage(); | ||
| 235 | + log.error(msg, e); | ||
| 236 | + if(msg!=null && msg.indexOf("Duplicate entry")>=0){ | ||
| 237 | + return Result.error("文件导入失败:有重复数据!"); | ||
| 238 | + }else{ | ||
| 239 | + return Result.error("文件导入失败:" + e.getMessage()); | ||
| 240 | + } | ||
| 241 | + } finally { | ||
| 242 | + try { | ||
| 243 | + file.getInputStream().close(); | ||
| 244 | + } catch (IOException e) { | ||
| 245 | + e.printStackTrace(); | ||
| 246 | + } | ||
| 247 | + } | ||
| 248 | + } | ||
| 249 | + return Result.error("文件导入失败!"); | ||
| 250 | + } | ||
| 251 | + | ||
| 252 | + | ||
| 253 | +} |
| 1 | +package org.jeecg.modules.erp.depot.entity; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.annotation.IdType; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 6 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 7 | +import io.swagger.annotations.ApiModel; | ||
| 8 | +import io.swagger.annotations.ApiModelProperty; | ||
| 9 | +import lombok.Data; | ||
| 10 | +import lombok.EqualsAndHashCode; | ||
| 11 | +import lombok.experimental.Accessors; | ||
| 12 | +import org.jeecgframework.poi.excel.annotation.Excel; | ||
| 13 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 14 | + | ||
| 15 | +import java.io.Serializable; | ||
| 16 | +import java.util.Date; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * @Description: tbl_inventory | ||
| 20 | + * @Author: jeecg-boot | ||
| 21 | + * @Date: 2025-09-16 | ||
| 22 | + * @Version: V1.0 | ||
| 23 | + */ | ||
| 24 | +@Data | ||
| 25 | +@TableName("tbl_inventory") | ||
| 26 | +@Accessors(chain = true) | ||
| 27 | +@EqualsAndHashCode(callSuper = false) | ||
| 28 | +@ApiModel(value="tbl_inventory对象", description="tbl_inventory") | ||
| 29 | +public class TblInventory implements Serializable { | ||
| 30 | + private static final long serialVersionUID = 1L; | ||
| 31 | + | ||
| 32 | + /**id*/ | ||
| 33 | + @TableId(type = IdType.ASSIGN_ID) | ||
| 34 | + @ApiModelProperty(value = "id") | ||
| 35 | + private String id; | ||
| 36 | + /**创建人*/ | ||
| 37 | + @ApiModelProperty(value = "创建人") | ||
| 38 | + private String createBy; | ||
| 39 | + /**创建日期*/ | ||
| 40 | + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") | ||
| 41 | + @DateTimeFormat(pattern="yyyy-MM-dd") | ||
| 42 | + @ApiModelProperty(value = "创建日期") | ||
| 43 | + private Date createTime; | ||
| 44 | + /**更新人*/ | ||
| 45 | + @ApiModelProperty(value = "更新人") | ||
| 46 | + private String updateBy; | ||
| 47 | + /**更新日期*/ | ||
| 48 | + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") | ||
| 49 | + @DateTimeFormat(pattern="yyyy-MM-dd") | ||
| 50 | + @ApiModelProperty(value = "更新日期") | ||
| 51 | + private Date updateTime; | ||
| 52 | + | ||
| 53 | + /**编号*/ | ||
| 54 | + @Excel(name = "编号", width = 15) | ||
| 55 | + @ApiModelProperty(value = "编号") | ||
| 56 | + private java.lang.String partNumber; | ||
| 57 | + | ||
| 58 | + /**品名*/ | ||
| 59 | + @Excel(name = "品名", width = 15) | ||
| 60 | + @ApiModelProperty(value = "品名") | ||
| 61 | + private String productName; | ||
| 62 | + /**规格*/ | ||
| 63 | + @Excel(name = "规格", width = 15) | ||
| 64 | + @ApiModelProperty(value = "规格") | ||
| 65 | + private String spec; | ||
| 66 | + /**型号*/ | ||
| 67 | + @Excel(name = "型号", width = 15) | ||
| 68 | + @ApiModelProperty(value = "型号") | ||
| 69 | + private String type; | ||
| 70 | + /**采购性质 M:加工,P:采购*/ | ||
| 71 | + @Excel(name = "采购性质", width = 15) | ||
| 72 | + @ApiModelProperty(value = "采购性质 M:加工,P:采购") | ||
| 73 | + private String buyingClassify; | ||
| 74 | + /**类别 1-零件 2-半成品 3-耗材*/ | ||
| 75 | + @Excel(name = "类别", width = 15) | ||
| 76 | + @ApiModelProperty(value = "类别 1-零件 2-半成品 3-耗材") | ||
| 77 | + private String meterialType; | ||
| 78 | + /**当前库存量*/ | ||
| 79 | + @Excel(name = "当前库存量", width = 15) | ||
| 80 | + @ApiModelProperty(value = "当前库存量") | ||
| 81 | + private Integer currentInventory; | ||
| 82 | + /**初始库存*/ | ||
| 83 | + @Excel(name = "BOH", width = 15) | ||
| 84 | + @ApiModelProperty(value = "初始库存") | ||
| 85 | + private Integer inventoryBoh; | ||
| 86 | +} |
| 1 | package org.jeecg.modules.erp.depot.form; | 1 | package org.jeecg.modules.erp.depot.form; |
| 2 | 2 | ||
| 3 | -import com.baomidou.mybatisplus.annotation.IdType; | ||
| 4 | -import com.baomidou.mybatisplus.annotation.TableId; | ||
| 5 | -import com.baomidou.mybatisplus.annotation.TableName; | ||
| 6 | import com.fasterxml.jackson.annotation.JsonFormat; | 3 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 7 | import io.swagger.annotations.ApiModel; | 4 | import io.swagger.annotations.ApiModel; |
| 8 | -import io.swagger.annotations.ApiModelProperty; | ||
| 9 | import lombok.Data; | 5 | import lombok.Data; |
| 10 | import lombok.EqualsAndHashCode; | 6 | import lombok.EqualsAndHashCode; |
| 11 | import lombok.experimental.Accessors; | 7 | import lombok.experimental.Accessors; |
| 12 | import org.jeecg.common.aspect.annotation.Dict; | 8 | import org.jeecg.common.aspect.annotation.Dict; |
| 13 | -import org.jeecgframework.poi.excel.annotation.Excel; | ||
| 14 | import org.springframework.format.annotation.DateTimeFormat; | 9 | import org.springframework.format.annotation.DateTimeFormat; |
| 15 | 10 | ||
| 16 | import java.io.Serializable; | 11 | import java.io.Serializable; |
| 17 | -import java.util.Date; | ||
| 18 | 12 | ||
| 19 | /** | 13 | /** |
| 20 | * @Description: tbl_depot | 14 | * @Description: tbl_depot |
| @@ -71,7 +65,8 @@ public class TblDepotForm implements Serializable { | @@ -71,7 +65,8 @@ public class TblDepotForm implements Serializable { | ||
| 71 | private java.util.Date operTime; | 65 | private java.util.Date operTime; |
| 72 | /**当前库存量*/ | 66 | /**当前库存量*/ |
| 73 | private java.lang.Integer currentInventory; | 67 | private java.lang.Integer currentInventory; |
| 74 | - | 68 | + //类别 |
| 69 | + private String meterialType; | ||
| 75 | private String isCallRobot; | 70 | private String isCallRobot; |
| 76 | private String robotName; | 71 | private String robotName; |
| 77 | private String pointId; | 72 | private String pointId; |
| 1 | +package org.jeecg.modules.erp.depot.mapper; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
| 4 | +import org.apache.ibatis.annotations.Param; | ||
| 5 | +import org.jeecg.modules.erp.depot.entity.TblInventory; | ||
| 6 | + | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * @Description: tbl_inventory | ||
| 11 | + * @Author: jeecg-boot | ||
| 12 | + * @Date: 2025-09-16 | ||
| 13 | + * @Version: V1.0 | ||
| 14 | + */ | ||
| 15 | +public interface TblInventoryMapper extends BaseMapper<TblInventory> { | ||
| 16 | + | ||
| 17 | + TblInventory getByPartNumber(@Param("partNumber") String partNumber); | ||
| 18 | + void updateBohAndCurrentInventory(TblInventory tblInventory); | ||
| 19 | + void updateBohAndCurrentInventoryBatch(@Param("list") List<TblInventory> list); | ||
| 20 | + | ||
| 21 | +} |
jeecg-boot-erp/src/main/java/org/jeecg/modules/erp/depot/mapper/xml/TblInventoryMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 3 | +<mapper namespace="org.jeecg.modules.erp.depot.mapper.TblInventoryMapper"> | ||
| 4 | + | ||
| 5 | + <select id="getByPartNumber" parameterType="java.lang.String" resultType="org.jeecg.modules.erp.depot.entity.TblInventory"> | ||
| 6 | + select * from tbl_inventory where part_number = #{partNumber} | ||
| 7 | + </select> | ||
| 8 | + | ||
| 9 | + <update id="updateBohAndCurrentInventoryBatch" parameterType="java.util.ArrayList"> | ||
| 10 | + update tbl_inventory | ||
| 11 | + set inventory_boh = CASE | ||
| 12 | + <foreach collection="list" item="item"> | ||
| 13 | + WHEN part_number = #{item.partNumber} | ||
| 14 | + THEN #{item.inventoryBoh} | ||
| 15 | + </foreach> | ||
| 16 | + END, | ||
| 17 | + current_inventory = CASE | ||
| 18 | + <foreach collection="list" item="item"> | ||
| 19 | + WHEN part_number = #{item.partNumber} | ||
| 20 | + THEN #{item.inventoryBoh} | ||
| 21 | + </foreach> | ||
| 22 | + END | ||
| 23 | + </update> | ||
| 24 | + <update id="updateBohAndCurrentInventory" parameterType="org.jeecg.modules.erp.depot.entity.TblInventory"> | ||
| 25 | + update tbl_inventory set inventory_boh = #{inventoryBoh} ,current_inventory = #{inventoryBoh} | ||
| 26 | + where part_number = #{partNumber} | ||
| 27 | + </update> | ||
| 28 | +</mapper> |
jeecg-boot-erp/src/main/java/org/jeecg/modules/erp/depot/service/ITblInventoryService.java
0 → 100644
| 1 | +package org.jeecg.modules.erp.depot.service; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.extension.service.IService; | ||
| 4 | +import org.jeecg.modules.erp.depot.entity.TblInventory; | ||
| 5 | +import org.jeecg.modules.erp.depot.form.TblDepotForm; | ||
| 6 | + | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * @Description: tbl_inventory | ||
| 11 | + * @Author: jeecg-boot | ||
| 12 | + * @Date: 2025-09-16 | ||
| 13 | + * @Version: V1.0 | ||
| 14 | + */ | ||
| 15 | +public interface ITblInventoryService extends IService<TblInventory> { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 根据编号获取库存 | ||
| 19 | + * @param partNumber | ||
| 20 | + * @return | ||
| 21 | + */ | ||
| 22 | + TblInventory getByPartNumber( String partNumber); | ||
| 23 | + | ||
| 24 | + void saveOrUpdateInventory(TblDepotForm tblDepotForm); | ||
| 25 | +// void updateInventory(TblDepotForm tblDepotForm); | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 批量更新BOH | ||
| 29 | + * @param list | ||
| 30 | + */ | ||
| 31 | + void updateBohAndCurrentInventoryBatch(List<TblInventory> list); | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 单条更新BOH | ||
| 35 | + * @param tblInventory | ||
| 36 | + */ | ||
| 37 | + void updateBohAndCurrentInventory(TblInventory tblInventory); | ||
| 38 | +} |
jeecg-boot-erp/src/main/java/org/jeecg/modules/erp/depot/service/impl/TblInventoryServiceImpl.java
0 → 100644
| 1 | +package org.jeecg.modules.erp.depot.service.impl; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | ||
| 4 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||
| 5 | +import org.jeecg.modules.erp.depot.entity.TblDepot; | ||
| 6 | +import org.jeecg.modules.erp.depot.entity.TblInventory; | ||
| 7 | +import org.jeecg.modules.erp.depot.form.TblDepotForm; | ||
| 8 | +import org.jeecg.modules.erp.depot.mapper.TblDepotMapper; | ||
| 9 | +import org.jeecg.modules.erp.depot.mapper.TblInventoryMapper; | ||
| 10 | +import org.jeecg.modules.erp.depot.service.ITblInventoryService; | ||
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | +import org.springframework.stereotype.Service; | ||
| 13 | + | ||
| 14 | +import java.util.List; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * @Description: tbl_inventory | ||
| 18 | + * @Author: jeecg-boot | ||
| 19 | + * @Date: 2025-09-16 | ||
| 20 | + * @Version: V1.0 | ||
| 21 | + */ | ||
| 22 | +@Service | ||
| 23 | +public class TblInventoryServiceImpl extends ServiceImpl<TblInventoryMapper, TblInventory> implements ITblInventoryService { | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + @Autowired | ||
| 27 | + private TblInventoryMapper tblInventoryMapper; | ||
| 28 | + | ||
| 29 | + @Autowired | ||
| 30 | + private TblDepotMapper tblDepotMapper; | ||
| 31 | + | ||
| 32 | + @Override | ||
| 33 | + public TblInventory getByPartNumber(String partNumber) { | ||
| 34 | + return tblInventoryMapper.getByPartNumber(partNumber); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public void saveOrUpdateInventory(TblDepotForm tblDepotForm) { | ||
| 39 | + TblInventory tblInventory = tblInventoryMapper.getByPartNumber(tblDepotForm.getPartNumber()); | ||
| 40 | + if(null != tblInventory){ | ||
| 41 | +// tblInventory.setCurrentInventory((null != tblInventory.getCurrentInventory() ? tblInventory.getCurrentInventory() : 0) + tblDepotForm.getOperNumber()); | ||
| 42 | + UpdateWrapper<TblInventory> wrapper = new UpdateWrapper<>(); | ||
| 43 | + | ||
| 44 | + wrapper.set("current_inventory", (null != tblInventory.getCurrentInventory() ? tblInventory.getCurrentInventory() : 0) + tblDepotForm.getOperNumber()) // 设置更新字段 | ||
| 45 | + .eq("id", tblInventory.getId()); | ||
| 46 | + tblInventoryMapper.update(null, wrapper); | ||
| 47 | + }else{ | ||
| 48 | + TblInventory tblInventory1 = new TblInventory(); | ||
| 49 | + tblInventory1.setPartNumber(tblDepotForm.getPartNumber());//编号 | ||
| 50 | + tblInventory1.setProductName(tblDepotForm.getProductName());//品名 | ||
| 51 | + tblInventory1.setSpec(tblDepotForm.getSpec());//规格 | ||
| 52 | + tblInventory1.setType(tblDepotForm.getType());//型号 | ||
| 53 | + tblInventory1.setBuyingClassify(tblDepotForm.getBuyingClassify());//采购性质 | ||
| 54 | + tblInventory1.setCurrentInventory(tblDepotForm.getOperNumber());//当前库存 | ||
| 55 | + tblInventory1.setMeterialType(tblDepotForm.getMeterialType());//类别 | ||
| 56 | + tblInventoryMapper.insert(tblInventory); | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | +// @Override | ||
| 61 | +// public void updateInventory(TblDepotForm tblDepotForm) { | ||
| 62 | +// TblInventory tblInventory = tblInventoryMapper.getByPartNumber(tblDepotForm.getPartNumber()); | ||
| 63 | +// tblInventory.setCurrentInventory(tblInventory.getCurrentInventory() - tblDepotForm.getOperNumber()); | ||
| 64 | +// UpdateWrapper<TblInventory> wrapper = new UpdateWrapper<>(); | ||
| 65 | +// wrapper.set("current_inventory", tblInventory.getCurrentInventory() - tblDepotForm.getOperNumber()) // 设置更新字段 | ||
| 66 | +// .gt("id", tblInventory.getId()); | ||
| 67 | +// tblInventoryMapper.update(null, wrapper); | ||
| 68 | +// } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public void updateBohAndCurrentInventoryBatch(List<TblInventory> list) { | ||
| 72 | + tblInventoryMapper.updateBohAndCurrentInventoryBatch(list); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @Override | ||
| 76 | + public void updateBohAndCurrentInventory(TblInventory tblInventory) { | ||
| 77 | + tblInventoryMapper.updateBohAndCurrentInventory(tblInventory); | ||
| 78 | + TblDepot tblDepot = new TblDepot(); | ||
| 79 | + tblDepot.setPartNumber(tblInventory.getPartNumber()); | ||
| 80 | + tblDepot.setProductName(tblInventory.getProductName()); | ||
| 81 | + tblDepot.setSpec(tblInventory.getSpec()); | ||
| 82 | + tblDepot.setType(tblInventory.getType()); | ||
| 83 | + tblDepot.setCurrentInventory(tblInventory.getInventoryBoh()); | ||
| 84 | + tblDepot.setDepotType("更新"); | ||
| 85 | + tblDepotMapper.insert(tblDepot); | ||
| 86 | + } | ||
| 87 | +} |
jeecg-boot-erp/src/main/java/org/jeecg/modules/erp/meterial/controller/TblConsumablesController.java
| @@ -58,7 +58,7 @@ public class TblConsumablesController { | @@ -58,7 +58,7 @@ public class TblConsumablesController { | ||
| 58 | private TblWorkOrderMapper tblWorkOrderMapper; | 58 | private TblWorkOrderMapper tblWorkOrderMapper; |
| 59 | 59 | ||
| 60 | /** | 60 | /** |
| 61 | - * 分页列表查询 | 61 | + * 分页列表查询 成品管理 |
| 62 | * | 62 | * |
| 63 | * @param tblMaterial | 63 | * @param tblMaterial |
| 64 | * @param pageNo | 64 | * @param pageNo |
| @@ -41,6 +41,7 @@ import java.util.ArrayList; | @@ -41,6 +41,7 @@ import java.util.ArrayList; | ||
| 41 | import java.util.Arrays; | 41 | import java.util.Arrays; |
| 42 | import java.util.List; | 42 | import java.util.List; |
| 43 | import java.util.Map; | 43 | import java.util.Map; |
| 44 | +import java.util.stream.Collectors; | ||
| 44 | 45 | ||
| 45 | /** | 46 | /** |
| 46 | * @Description: tbl_material | 47 | * @Description: tbl_material |
| @@ -65,7 +66,7 @@ public class TblMaterialController { | @@ -65,7 +66,7 @@ public class TblMaterialController { | ||
| 65 | private TblWorkOrderMapper tblWorkOrderMapper; | 66 | private TblWorkOrderMapper tblWorkOrderMapper; |
| 66 | 67 | ||
| 67 | /** | 68 | /** |
| 68 | - * 分页列表查询 | 69 | + * 分页列表查询 原物料管理 |
| 69 | * | 70 | * |
| 70 | * @param tblMaterial | 71 | * @param tblMaterial |
| 71 | * @param pageNo | 72 | * @param pageNo |
| @@ -88,6 +89,30 @@ public class TblMaterialController { | @@ -88,6 +89,30 @@ public class TblMaterialController { | ||
| 88 | return Result.OK(pageList); | 89 | return Result.OK(pageList); |
| 89 | } | 90 | } |
| 90 | 91 | ||
| 92 | + /** | ||
| 93 | + * 分页列表查询 原物料管理 | ||
| 94 | + * | ||
| 95 | + * @param tblMaterial | ||
| 96 | + * @param pageNo | ||
| 97 | + * @param pageSize | ||
| 98 | + * @param req | ||
| 99 | + * @return | ||
| 100 | + */ | ||
| 101 | + @ApiOperation(value = "tbl_material-分页列表查询", notes = "tbl_material-分页列表查询") | ||
| 102 | + @GetMapping(value = "/rawMaterialsList") | ||
| 103 | + @PermissionData(pageComponent = "meterial/TblRawMaterialsList") | ||
| 104 | + public Result<IPage<TblMaterial>> queryTblRawMaterialsList(TblMaterial tblMaterial, | ||
| 105 | + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, | ||
| 106 | + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, | ||
| 107 | + HttpServletRequest req) { | ||
| 108 | + tblMaterial.setMeterialType("5"); | ||
| 109 | + QueryWrapper<TblMaterial> queryWrapper = QueryGenerator.initQueryWrapper(tblMaterial, req.getParameterMap()); | ||
| 110 | + queryWrapper.orderByDesc("id"); | ||
| 111 | + Page<TblMaterial> page = new Page<>(pageNo, pageSize); | ||
| 112 | + IPage<TblMaterial> pageList = tblMaterialService.page(page, queryWrapper); | ||
| 113 | + return Result.OK(pageList); | ||
| 114 | + } | ||
| 115 | + | ||
| 91 | @GetMapping(value = "/listAll") | 116 | @GetMapping(value = "/listAll") |
| 92 | @PermissionData(pageComponent = "meterial/TblMaterialList") | 117 | @PermissionData(pageComponent = "meterial/TblMaterialList") |
| 93 | public Result<List<TblMaterial>> queryListAll( | 118 | public Result<List<TblMaterial>> queryListAll( |
| @@ -265,6 +290,23 @@ public class TblMaterialController { | @@ -265,6 +290,23 @@ public class TblMaterialController { | ||
| 265 | params.setNeedSave(true); | 290 | params.setNeedSave(true); |
| 266 | try { | 291 | try { |
| 267 | List<TblMaterialPage> list = ExcelImportUtil.importExcel(file.getInputStream(), TblMaterialPage.class, params); | 292 | List<TblMaterialPage> list = ExcelImportUtil.importExcel(file.getInputStream(), TblMaterialPage.class, params); |
| 293 | + List<String> partNumberList = list.stream() // 将beanList转换为Stream | ||
| 294 | + .map(TblMaterialPage::getPartNumber) // 使用map方法提取id字段 | ||
| 295 | + .collect(Collectors.toList()); // 收集结果到新的List中 | ||
| 296 | + List<String> allPartNumberList = tblMaterialService.getAllPartNumber(); | ||
| 297 | + | ||
| 298 | + //判断是否有重复编码 | ||
| 299 | +// boolean flag = partNumberList.stream().anyMatch(allPartNumberList::contains); | ||
| 300 | + | ||
| 301 | + // 找出重复编码 | ||
| 302 | + List<String> duplicates = partNumberList.stream() | ||
| 303 | + .filter(allPartNumberList::contains) | ||
| 304 | + .distinct() | ||
| 305 | + .collect(Collectors.toList()); | ||
| 306 | + if(duplicates.size() >0){ | ||
| 307 | + return Result.error("编码有重复,重复编码是: " + duplicates); | ||
| 308 | + } | ||
| 309 | +// tblMaterialService.saveBatch(list); | ||
| 268 | for (TblMaterialPage page : list) { | 310 | for (TblMaterialPage page : list) { |
| 269 | TblMaterial po = new TblMaterial(); | 311 | TblMaterial po = new TblMaterial(); |
| 270 | BeanUtils.copyProperties(page, po); | 312 | BeanUtils.copyProperties(page, po); |
| @@ -34,7 +34,7 @@ public class TblProtectionController { | @@ -34,7 +34,7 @@ public class TblProtectionController { | ||
| 34 | private ITblMaterialService tblMaterialService; | 34 | private ITblMaterialService tblMaterialService; |
| 35 | 35 | ||
| 36 | /** | 36 | /** |
| 37 | - * 分页列表查询 | 37 | + * 分页列表查询 耗材管理 |
| 38 | * | 38 | * |
| 39 | * @param tblMaterial | 39 | * @param tblMaterial |
| 40 | * @param pageNo | 40 | * @param pageNo |
| @@ -66,7 +66,7 @@ public class TblSemiFinishedController { | @@ -66,7 +66,7 @@ public class TblSemiFinishedController { | ||
| 66 | private TblWorkOrderMapper tblWorkOrderMapper; | 66 | private TblWorkOrderMapper tblWorkOrderMapper; |
| 67 | 67 | ||
| 68 | /** | 68 | /** |
| 69 | - * 分页列表查询 | 69 | + * 分页列表查询 半成品管理 |
| 70 | * | 70 | * |
| 71 | * @param tblMaterial | 71 | * @param tblMaterial |
| 72 | * @param pageNo | 72 | * @param pageNo |
| @@ -27,4 +27,6 @@ public interface TblMaterialMapper extends BaseMapper<TblMaterial> { | @@ -27,4 +27,6 @@ public interface TblMaterialMapper extends BaseMapper<TblMaterial> { | ||
| 27 | List<String> queryPartNumber(@Param("partNumber") String partNumber); | 27 | List<String> queryPartNumber(@Param("partNumber") String partNumber); |
| 28 | 28 | ||
| 29 | List<Map<String,String>> getOptions(); | 29 | List<Map<String,String>> getOptions(); |
| 30 | + | ||
| 31 | + List<String> getAllPartNumber(); | ||
| 30 | } | 32 | } |
| @@ -13,4 +13,7 @@ | @@ -13,4 +13,7 @@ | ||
| 13 | <select id="getOptions" resultType="java.util.Map"> | 13 | <select id="getOptions" resultType="java.util.Map"> |
| 14 | SELECT part_number as partNumber,CONCAT(product_name,if(spec != '' ,' - ',''),if(spec != '',spec,''),if(type != '',' - ',''),if(type != '',type,'')) productName from tbl_material | 14 | SELECT part_number as partNumber,CONCAT(product_name,if(spec != '' ,' - ',''),if(spec != '',spec,''),if(type != '',' - ',''),if(type != '',type,'')) productName from tbl_material |
| 15 | </select> | 15 | </select> |
| 16 | + <select id="getAllPartNumber" resultType="java.lang.String"> | ||
| 17 | + select part_number from tbl_material | ||
| 18 | + </select> | ||
| 16 | </mapper> | 19 | </mapper> |
| 1 | package org.jeecg.modules.erp.meterial.service; | 1 | package org.jeecg.modules.erp.meterial.service; |
| 2 | 2 | ||
| 3 | -import org.jeecg.modules.erp.meterial.entity.TblPartSemifinished; | ||
| 4 | -import org.jeecg.modules.erp.meterial.entity.TblMaterial; | ||
| 5 | import com.baomidou.mybatisplus.extension.service.IService; | 3 | import com.baomidou.mybatisplus.extension.service.IService; |
| 4 | +import org.jeecg.modules.erp.meterial.entity.TblMaterial; | ||
| 5 | +import org.jeecg.modules.erp.meterial.entity.TblPartSemifinished; | ||
| 6 | + | ||
| 6 | import java.io.Serializable; | 7 | import java.io.Serializable; |
| 7 | import java.util.Collection; | 8 | import java.util.Collection; |
| 8 | import java.util.List; | 9 | import java.util.List; |
| 9 | -import java.util.Map; | ||
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| 12 | * @Description: tbl_material | 12 | * @Description: tbl_material |
| @@ -50,4 +50,6 @@ public interface ITblMaterialService extends IService<TblMaterial> { | @@ -50,4 +50,6 @@ public interface ITblMaterialService extends IService<TblMaterial> { | ||
| 50 | 50 | ||
| 51 | // List<Map<String,String>> getAll(); | 51 | // List<Map<String,String>> getAll(); |
| 52 | List<TblMaterial> getAll(); | 52 | List<TblMaterial> getAll(); |
| 53 | + | ||
| 54 | + List<String> getAllPartNumber(); | ||
| 53 | } | 55 | } |
jeecg-boot-erp/src/main/java/org/jeecg/modules/erp/meterial/service/impl/TblMaterialServiceImpl.java
| 1 | package org.jeecg.modules.erp.meterial.service.impl; | 1 | package org.jeecg.modules.erp.meterial.service.impl; |
| 2 | 2 | ||
| 3 | -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| 4 | +import org.jeecg.modules.erp.depot.entity.TblInventory; | ||
| 5 | +import org.jeecg.modules.erp.depot.mapper.TblInventoryMapper; | ||
| 5 | import org.jeecg.modules.erp.meterial.entity.TblMaterial; | 6 | import org.jeecg.modules.erp.meterial.entity.TblMaterial; |
| 6 | import org.jeecg.modules.erp.meterial.entity.TblPartSemifinished; | 7 | import org.jeecg.modules.erp.meterial.entity.TblPartSemifinished; |
| 7 | import org.jeecg.modules.erp.meterial.mapper.TblMaterialMapper; | 8 | import org.jeecg.modules.erp.meterial.mapper.TblMaterialMapper; |
| @@ -14,7 +15,6 @@ import org.springframework.transaction.annotation.Transactional; | @@ -14,7 +15,6 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 14 | import java.io.Serializable; | 15 | import java.io.Serializable; |
| 15 | import java.util.Collection; | 16 | import java.util.Collection; |
| 16 | import java.util.List; | 17 | import java.util.List; |
| 17 | -import java.util.Map; | ||
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| 20 | * @Description: tbl_material | 20 | * @Description: tbl_material |
| @@ -30,10 +30,22 @@ public class TblMaterialServiceImpl extends ServiceImpl<TblMaterialMapper, TblMa | @@ -30,10 +30,22 @@ public class TblMaterialServiceImpl extends ServiceImpl<TblMaterialMapper, TblMa | ||
| 30 | @Autowired | 30 | @Autowired |
| 31 | private TblPartSemifinishedMapper tblPartSemifinishedMapper; | 31 | private TblPartSemifinishedMapper tblPartSemifinishedMapper; |
| 32 | 32 | ||
| 33 | + @Autowired | ||
| 34 | + private TblInventoryMapper tblInventoryMapper; | ||
| 35 | + | ||
| 33 | @Override | 36 | @Override |
| 34 | @Transactional(rollbackFor = Exception.class) | 37 | @Transactional(rollbackFor = Exception.class) |
| 35 | public void saveMain(TblMaterial tblMaterial, List<TblPartSemifinished> tblPartSemifinishedList) { | 38 | public void saveMain(TblMaterial tblMaterial, List<TblPartSemifinished> tblPartSemifinishedList) { |
| 36 | tblMaterialMapper.insert(tblMaterial); | 39 | tblMaterialMapper.insert(tblMaterial); |
| 40 | + TblInventory tblInventory1 = new TblInventory(); | ||
| 41 | + tblInventory1.setPartNumber(tblMaterial.getPartNumber());//编号 | ||
| 42 | + tblInventory1.setProductName(tblMaterial.getProductName());//品名 | ||
| 43 | + tblInventory1.setSpec(tblMaterial.getSpec());//规格 | ||
| 44 | + tblInventory1.setType(tblMaterial.getType());//型号 | ||
| 45 | + tblInventory1.setBuyingClassify(tblMaterial.getBuyingClassify());//采购性质 | ||
| 46 | +// tblInventory1.setCurrentInventory(tblMaterial.getOperNumber());//当前库存 | ||
| 47 | + tblInventory1.setMeterialType(tblMaterial.getMeterialType());//类别 | ||
| 48 | + tblInventoryMapper.insert(tblInventory1); | ||
| 37 | if (tblPartSemifinishedList != null && tblPartSemifinishedList.size() > 0) { | 49 | if (tblPartSemifinishedList != null && tblPartSemifinishedList.size() > 0) { |
| 38 | for (TblPartSemifinished entity : tblPartSemifinishedList) { | 50 | for (TblPartSemifinished entity : tblPartSemifinishedList) { |
| 39 | String id = tblMaterialMapper.getIdByPartNumber(entity.getPartNumber()); | 51 | String id = tblMaterialMapper.getIdByPartNumber(entity.getPartNumber()); |
| @@ -100,4 +112,9 @@ public class TblMaterialServiceImpl extends ServiceImpl<TblMaterialMapper, TblMa | @@ -100,4 +112,9 @@ public class TblMaterialServiceImpl extends ServiceImpl<TblMaterialMapper, TblMa | ||
| 100 | return this.list(); | 112 | return this.list(); |
| 101 | } | 113 | } |
| 102 | 114 | ||
| 115 | + @Override | ||
| 116 | + public List<String> getAllPartNumber() { | ||
| 117 | + return tblMaterialMapper.getAllPartNumber(); | ||
| 118 | + } | ||
| 119 | + | ||
| 103 | } | 120 | } |
| 1 | package org.jeecg.modules.erp.trade.controller; | 1 | package org.jeecg.modules.erp.trade.controller; |
| 2 | 2 | ||
| 3 | -import java.io.UnsupportedEncodingException; | ||
| 4 | -import java.io.IOException; | ||
| 5 | -import java.math.BigDecimal; | ||
| 6 | -import java.net.URLDecoder; | ||
| 7 | -import java.util.*; | ||
| 8 | -import java.util.stream.Collectors; | ||
| 9 | - | ||
| 10 | -import javax.servlet.http.HttpServletRequest; | ||
| 11 | -import javax.servlet.http.HttpServletResponse; | ||
| 12 | - | ||
| 13 | import cn.hutool.core.collection.CollectionUtil; | 3 | import cn.hutool.core.collection.CollectionUtil; |
| 14 | import cn.hutool.core.lang.Opt; | 4 | import cn.hutool.core.lang.Opt; |
| 15 | import cn.hutool.core.util.ObjectUtil; | 5 | import cn.hutool.core.util.ObjectUtil; |
| 16 | import cn.hutool.core.util.StrUtil; | 6 | import cn.hutool.core.util.StrUtil; |
| 7 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 8 | +import com.baomidou.mybatisplus.core.metadata.IPage; | ||
| 9 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||
| 10 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
| 11 | +import io.swagger.annotations.Api; | ||
| 12 | +import io.swagger.annotations.ApiOperation; | ||
| 13 | +import lombok.extern.slf4j.Slf4j; | ||
| 14 | +import org.apache.shiro.SecurityUtils; | ||
| 15 | +import org.jeecg.common.api.vo.Result; | ||
| 16 | +import org.jeecg.common.aspect.annotation.AutoLog; | ||
| 17 | +import org.jeecg.common.system.query.QueryGenerator; | ||
| 18 | +import org.jeecg.common.system.vo.LoginUser; | ||
| 19 | +import org.jeecg.common.util.oConvertUtils; | ||
| 17 | import org.jeecg.modules.erp.trade.entity.*; | 20 | import org.jeecg.modules.erp.trade.entity.*; |
| 18 | import org.jeecg.modules.erp.trade.mapper.TblTradeBidMaterialDetailsMapper; | 21 | import org.jeecg.modules.erp.trade.mapper.TblTradeBidMaterialDetailsMapper; |
| 19 | import org.jeecg.modules.erp.trade.service.*; | 22 | import org.jeecg.modules.erp.trade.service.*; |
| 20 | -import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||
| 21 | -import org.jeecg.modules.erp.trade.entity.TblTradeInventoryIn; | ||
| 22 | -import org.jeecg.modules.erp.trade.entity.TblTradeTenderInfo; | ||
| 23 | -import org.jeecg.modules.erp.trade.service.ITblTradeInventoryInService; | ||
| 24 | -import org.jeecg.modules.erp.trade.service.ITblTradeTenderInfoService; | 23 | +import org.jeecg.modules.erp.trade.vo.TblTradeBidSubPage; |
| 25 | import org.jeecgframework.poi.excel.ExcelImportUtil; | 24 | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| 26 | import org.jeecgframework.poi.excel.def.NormalExcelConstants; | 25 | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| 27 | import org.jeecgframework.poi.excel.entity.ExportParams; | 26 | import org.jeecgframework.poi.excel.entity.ExportParams; |
| 28 | import org.jeecgframework.poi.excel.entity.ImportParams; | 27 | import org.jeecgframework.poi.excel.entity.ImportParams; |
| 29 | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; | 28 | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| 30 | -import org.jeecg.common.system.vo.LoginUser; | ||
| 31 | -import org.apache.shiro.SecurityUtils; | ||
| 32 | -import org.jeecg.common.api.vo.Result; | ||
| 33 | -import org.jeecg.common.system.query.QueryGenerator; | ||
| 34 | -import org.jeecg.common.util.oConvertUtils; | ||
| 35 | -import org.jeecg.modules.erp.trade.vo.TblTradeBidSubPage; | ||
| 36 | import org.springframework.beans.BeanUtils; | 29 | import org.springframework.beans.BeanUtils; |
| 37 | import org.springframework.beans.factory.annotation.Autowired; | 30 | import org.springframework.beans.factory.annotation.Autowired; |
| 38 | import org.springframework.web.bind.annotation.*; | 31 | import org.springframework.web.bind.annotation.*; |
| 39 | -import org.springframework.web.servlet.ModelAndView; | ||
| 40 | import org.springframework.web.multipart.MultipartFile; | 32 | import org.springframework.web.multipart.MultipartFile; |
| 41 | import org.springframework.web.multipart.MultipartHttpServletRequest; | 33 | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| 42 | -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 43 | -import com.baomidou.mybatisplus.core.metadata.IPage; | ||
| 44 | -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
| 45 | -import lombok.extern.slf4j.Slf4j; | ||
| 46 | -import com.alibaba.fastjson.JSON; | ||
| 47 | -import io.swagger.annotations.Api; | ||
| 48 | -import io.swagger.annotations.ApiOperation; | ||
| 49 | -import org.jeecg.common.aspect.annotation.AutoLog; | 34 | +import org.springframework.web.servlet.ModelAndView; |
| 35 | + | ||
| 36 | +import javax.servlet.http.HttpServletRequest; | ||
| 37 | +import javax.servlet.http.HttpServletResponse; | ||
| 38 | +import java.io.IOException; | ||
| 39 | +import java.math.BigDecimal; | ||
| 40 | +import java.util.ArrayList; | ||
| 41 | +import java.util.Arrays; | ||
| 42 | +import java.util.List; | ||
| 43 | +import java.util.Map; | ||
| 50 | 44 | ||
| 51 | /** | 45 | /** |
| 52 | * @Description: 投标表 | 46 | * @Description: 投标表 |
| @@ -400,8 +394,8 @@ public class TblTradeBidSubController { | @@ -400,8 +394,8 @@ public class TblTradeBidSubController { | ||
| 400 | return Result.OK(new TblTradePurchaseInfo()); | 394 | return Result.OK(new TblTradePurchaseInfo()); |
| 401 | } | 395 | } |
| 402 | TblTradePurchaseInfo sub = list.get(0); | 396 | TblTradePurchaseInfo sub = list.get(0); |
| 403 | - Integer isl = sub.getPurchaseQuantity(); | ||
| 404 | - sub.setSl(String.valueOf(isl-yrksl)); | 397 | + Integer isl = sub.getPurchaseQuantity();//采购数量 |
| 398 | + sub.setSl(String.valueOf(isl-yrksl));//采购数量-已入库数量 | ||
| 405 | return Result.OK(list.get(0)); | 399 | return Result.OK(list.get(0)); |
| 406 | } | 400 | } |
| 407 | 401 |
jeecg-boot-erp/src/main/java/org/jeecg/modules/erp/trade/controller/TblTradeInventoryController.java
| 1 | package org.jeecg.modules.erp.trade.controller; | 1 | package org.jeecg.modules.erp.trade.controller; |
| 2 | 2 | ||
| 3 | -import java.util.ArrayList; | ||
| 4 | -import java.util.Arrays; | ||
| 5 | -import java.util.Date; | ||
| 6 | -import java.util.List; | ||
| 7 | -import java.util.Map; | ||
| 8 | -import java.util.concurrent.TimeUnit; | ||
| 9 | -import java.util.stream.Collectors; | ||
| 10 | -import java.io.IOException; | ||
| 11 | -import java.io.UnsupportedEncodingException; | ||
| 12 | -import java.net.URLDecoder; | ||
| 13 | -import javax.servlet.http.HttpServletRequest; | ||
| 14 | -import javax.servlet.http.HttpServletResponse; | ||
| 15 | - | ||
| 16 | import cn.hutool.core.collection.CollectionUtil; | 3 | import cn.hutool.core.collection.CollectionUtil; |
| 17 | import cn.hutool.core.date.DatePattern; | 4 | import cn.hutool.core.date.DatePattern; |
| 18 | -import cn.hutool.core.date.DateUtil; | ||
| 19 | -import org.apache.commons.lang3.StringUtils; | ||
| 20 | -import org.jeecg.common.api.vo.Result; | ||
| 21 | -import org.jeecg.common.system.query.QueryGenerator; | ||
| 22 | -import org.jeecg.common.util.oConvertUtils; | ||
| 23 | -import org.jeecg.modules.erp.trade.entity.*; | ||
| 24 | -import org.jeecg.modules.erp.trade.service.*; | ||
| 25 | - | 5 | +import cn.hutool.core.util.StrUtil; |
| 26 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 6 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 27 | import com.baomidou.mybatisplus.core.metadata.IPage; | 7 | import com.baomidou.mybatisplus.core.metadata.IPage; |
| 28 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 8 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| 9 | +import io.swagger.annotations.Api; | ||
| 10 | +import io.swagger.annotations.ApiOperation; | ||
| 29 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| 30 | - | 12 | +import org.apache.commons.lang3.StringUtils; |
| 13 | +import org.jeecg.common.api.vo.Result; | ||
| 14 | +import org.jeecg.common.aspect.annotation.AutoLog; | ||
| 15 | +import org.jeecg.common.system.base.controller.JeecgController; | ||
| 16 | +import org.jeecg.modules.erp.trade.entity.*; | ||
| 17 | +import org.jeecg.modules.erp.trade.service.*; | ||
| 31 | import org.jeecgframework.poi.excel.ExcelImportUtil; | 18 | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| 32 | -import org.jeecgframework.poi.excel.def.NormalExcelConstants; | ||
| 33 | -import org.jeecgframework.poi.excel.entity.ExportParams; | ||
| 34 | import org.jeecgframework.poi.excel.entity.ImportParams; | 19 | import org.jeecgframework.poi.excel.entity.ImportParams; |
| 35 | -import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; | ||
| 36 | -import org.jeecg.common.system.base.controller.JeecgController; | 20 | +import org.jeecgframework.poi.exception.excel.ExcelImportException; |
| 37 | import org.jetbrains.annotations.Nullable; | 21 | import org.jetbrains.annotations.Nullable; |
| 38 | import org.springframework.beans.factory.annotation.Autowired; | 22 | import org.springframework.beans.factory.annotation.Autowired; |
| 39 | import org.springframework.transaction.annotation.Transactional; | 23 | import org.springframework.transaction.annotation.Transactional; |
| @@ -41,10 +25,13 @@ import org.springframework.web.bind.annotation.*; | @@ -41,10 +25,13 @@ import org.springframework.web.bind.annotation.*; | ||
| 41 | import org.springframework.web.multipart.MultipartFile; | 25 | import org.springframework.web.multipart.MultipartFile; |
| 42 | import org.springframework.web.multipart.MultipartHttpServletRequest; | 26 | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| 43 | import org.springframework.web.servlet.ModelAndView; | 27 | import org.springframework.web.servlet.ModelAndView; |
| 44 | -import com.alibaba.fastjson.JSON; | ||
| 45 | -import io.swagger.annotations.Api; | ||
| 46 | -import io.swagger.annotations.ApiOperation; | ||
| 47 | -import org.jeecg.common.aspect.annotation.AutoLog; | 28 | + |
| 29 | +import javax.servlet.http.HttpServletRequest; | ||
| 30 | +import javax.servlet.http.HttpServletResponse; | ||
| 31 | +import java.io.IOException; | ||
| 32 | +import java.util.*; | ||
| 33 | +import java.util.concurrent.TimeUnit; | ||
| 34 | +import java.util.stream.Collectors; | ||
| 48 | 35 | ||
| 49 | /** | 36 | /** |
| 50 | * @Description: 贸易库存表 | 37 | * @Description: 贸易库存表 |
| @@ -92,10 +79,10 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | @@ -92,10 +79,10 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | ||
| 92 | 79 | ||
| 93 | QueryWrapper<TblTradeMeterial> queryWrapper = new QueryWrapper<>(); | 80 | QueryWrapper<TblTradeMeterial> queryWrapper = new QueryWrapper<>(); |
| 94 | if (StringUtils.isNotBlank( tblTradeInventory.getMaterialDescription())){ | 81 | if (StringUtils.isNotBlank( tblTradeInventory.getMaterialDescription())){ |
| 95 | - queryWrapper.like("meterial_review", tblTradeInventory.getMaterialDescription()); | 82 | + queryWrapper.like("material_review", tblTradeInventory.getMaterialDescription()); |
| 96 | } | 83 | } |
| 97 | if (StringUtils.isNotBlank(tblTradeInventory.getMaterialCode())){ | 84 | if (StringUtils.isNotBlank(tblTradeInventory.getMaterialCode())){ |
| 98 | - queryWrapper.eq("meterial_code", tblTradeInventory.getMaterialCode()); | 85 | + queryWrapper.eq("material_code", tblTradeInventory.getMaterialCode()); |
| 99 | } | 86 | } |
| 100 | if (StringUtils.isNotBlank(tblTradeInventory.getBrand())){ | 87 | if (StringUtils.isNotBlank(tblTradeInventory.getBrand())){ |
| 101 | queryWrapper.like("brand", tblTradeInventory.getBrand()); | 88 | queryWrapper.like("brand", tblTradeInventory.getBrand()); |
| @@ -104,8 +91,8 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | @@ -104,8 +91,8 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | ||
| 104 | Page<TblTradeMeterial> page = new Page<TblTradeMeterial>(pageNo, pageSize); | 91 | Page<TblTradeMeterial> page = new Page<TblTradeMeterial>(pageNo, pageSize); |
| 105 | IPage<TblTradeMeterial> pageList = tblTradeMeterialService.page(page, queryWrapper); | 92 | IPage<TblTradeMeterial> pageList = tblTradeMeterialService.page(page, queryWrapper); |
| 106 | List<TblTradeMeterial> records = pageList.getRecords(); | 93 | List<TblTradeMeterial> records = pageList.getRecords(); |
| 107 | - //meterialCode 物料编码list | ||
| 108 | - List<String> collect = records.stream().map(TblTradeMeterial::getMeterialCode).collect(Collectors.toList()); | 94 | + //materialCode 物料编码list |
| 95 | + List<String> collect = records.stream().map(TblTradeMeterial::getMaterialCode).collect(Collectors.toList()); | ||
| 109 | 96 | ||
| 110 | //根据物料编码查询库存 | 97 | //根据物料编码查询库存 |
| 111 | QueryWrapper<TblTradeInventory> tblTradeInventoryQueryWrapper = new QueryWrapper<>(); | 98 | QueryWrapper<TblTradeInventory> tblTradeInventoryQueryWrapper = new QueryWrapper<>(); |
| @@ -115,12 +102,13 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | @@ -115,12 +102,13 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | ||
| 115 | Map<String, TblTradeInventory> inventoryMap = list.stream().collect(Collectors.toMap(TblTradeInventory::getMaterialCode, e -> e)); | 102 | Map<String, TblTradeInventory> inventoryMap = list.stream().collect(Collectors.toMap(TblTradeInventory::getMaterialCode, e -> e)); |
| 116 | 103 | ||
| 117 | for (TblTradeMeterial record : records) { | 104 | for (TblTradeMeterial record : records) { |
| 118 | - record.setActualInventory(inventoryMap.get(record.getMeterialCode()) == null ? 0 : inventoryMap.get(record.getMeterialCode()).getActualInventory() == null ? 0 : inventoryMap.get(record.getMeterialCode()).getActualInventory()); | ||
| 119 | - record.setQuantityInTransit(inventoryMap.get(record.getMeterialCode()) == null ? 0 : inventoryMap.get(record.getMeterialCode()).getQuantityInTransit() == null ? 0 : inventoryMap.get(record.getMeterialCode()).getQuantityInTransit()); | ||
| 120 | - record.setTotalQuantity(inventoryMap.get(record.getMeterialCode()) == null ? 0 : inventoryMap.get(record.getMeterialCode()).getTotalQuantity() == null ? 0 : inventoryMap.get(record.getMeterialCode()).getTotalQuantity()); | ||
| 121 | - record.setFirstStorageTime(inventoryMap.get(record.getMeterialCode()) == null ? null : inventoryMap.get(record.getMeterialCode()).getFirstStorageTime()); | ||
| 122 | - record.setLastOutboundTime(inventoryMap.get(record.getMeterialCode()) == null ? null : inventoryMap.get(record.getMeterialCode()).getLastOutboundTime()); | ||
| 123 | - if (record.getLastOutboundTime() != null) { | 105 | + record.setInventoryBoh(inventoryMap.get(record.getMaterialCode()) == null ? 0 : inventoryMap.get(record.getMaterialCode()).getInventoryBoh() == null ? 0 : inventoryMap.get(record.getMaterialCode()).getInventoryBoh()); |
| 106 | + record.setActualInventory(inventoryMap.get(record.getMaterialCode()) == null ? 0 : inventoryMap.get(record.getMaterialCode()).getActualInventory() == null ? 0 : inventoryMap.get(record.getMaterialCode()).getActualInventory()); | ||
| 107 | + record.setQuantityInTransit(inventoryMap.get(record.getMaterialCode()) == null ? 0 : inventoryMap.get(record.getMaterialCode()).getQuantityInTransit() == null ? 0 : inventoryMap.get(record.getMaterialCode()).getQuantityInTransit()); | ||
| 108 | + record.setTotalQuantity(inventoryMap.get(record.getMaterialCode()) == null ? 0 : inventoryMap.get(record.getMaterialCode()).getTotalQuantity() == null ? 0 : inventoryMap.get(record.getMaterialCode()).getTotalQuantity()); | ||
| 109 | + record.setFirstStorageTime(inventoryMap.get(record.getMaterialCode()) == null ? null : inventoryMap.get(record.getMaterialCode()).getFirstStorageTime()); | ||
| 110 | + record.setLastOutboundTime(inventoryMap.get(record.getMaterialCode()) == null ? null : inventoryMap.get(record.getMaterialCode()).getLastOutboundTime()); | ||
| 111 | + if ((null != record.getLastOutboundTime()) && (null != record.getFirstStorageTime())) { | ||
| 124 | long daysDifference = calculateDaysDifference(new Date(), record.getFirstStorageTime()); | 112 | long daysDifference = calculateDaysDifference(new Date(), record.getFirstStorageTime()); |
| 125 | record.setDaysInStock((int) daysDifference + 1); | 113 | record.setDaysInStock((int) daysDifference + 1); |
| 126 | } | 114 | } |
| @@ -141,7 +129,7 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | @@ -141,7 +129,7 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | ||
| 141 | 129 | ||
| 142 | /** | 130 | /** |
| 143 | * 添加 | 131 | * 添加 |
| 144 | - * | 132 | + *备注:总数量的逻辑有问题 |
| 145 | * @param tblTradeInventory | 133 | * @param tblTradeInventory |
| 146 | * @return | 134 | * @return |
| 147 | */ | 135 | */ |
| @@ -149,26 +137,25 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | @@ -149,26 +137,25 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | ||
| 149 | @ApiOperation(value = "贸易库存表-添加", notes = "贸易库存表-添加") | 137 | @ApiOperation(value = "贸易库存表-添加", notes = "贸易库存表-添加") |
| 150 | @PostMapping(value = "/add") | 138 | @PostMapping(value = "/add") |
| 151 | @Transactional(rollbackFor = Exception.class) | 139 | @Transactional(rollbackFor = Exception.class) |
| 152 | - public Result<String> add(@RequestBody TblTradeInventory tblTradeInventory) { | ||
| 153 | - //订单验证 | 140 | + public Result<String> add(@RequestBody TblTradeInventory tblTradeInventory){ |
| 154 | Result<String> error = orderVerification(tblTradeInventory); | 141 | Result<String> error = orderVerification(tblTradeInventory); |
| 155 | if (error != null) return error; | 142 | if (error != null) return error; |
| 156 | 143 | ||
| 157 | TblTradeInventoryIn tblTradeInventoryIn = new TblTradeInventoryIn(); | 144 | TblTradeInventoryIn tblTradeInventoryIn = new TblTradeInventoryIn(); |
| 158 | //入库单号 | 145 | //入库单号 |
| 159 | - tblTradeInventoryIn.setWaybillNum("BZSIN" + DatePattern.PURE_DATETIME_FORMAT.format(new Date())); | ||
| 160 | - tblTradeInventoryIn.setMaterialCode(tblTradeInventory.getMaterialCode()); | ||
| 161 | - tblTradeInventoryIn.setMaterialDescription(tblTradeInventory.getMaterialDescription()); | ||
| 162 | - tblTradeInventoryIn.setMeasurementUnit(tblTradeInventory.getMeasurementUnit()); | ||
| 163 | - tblTradeInventoryIn.setBrand(tblTradeInventory.getBrand()); | ||
| 164 | - tblTradeInventoryIn.setInventoryQuantity(tblTradeInventory.getRksl()); | ||
| 165 | - tblTradeInventoryIn.setOperator(tblTradeInventory.getOperator()); | 146 | + tblTradeInventoryIn.setWaybillNum("BZSIN" + DatePattern.PURE_DATETIME_FORMAT.format(new Date()));//单号 |
| 147 | + tblTradeInventoryIn.setMaterialCode(tblTradeInventory.getMaterialCode());//物料编码 | ||
| 148 | + tblTradeInventoryIn.setMaterialDescription(tblTradeInventory.getMaterialDescription());//物料长描述 | ||
| 149 | + tblTradeInventoryIn.setMeasurementUnit(tblTradeInventory.getMeasurementUnit());//计量单位 | ||
| 150 | + tblTradeInventoryIn.setBrand(tblTradeInventory.getBrand());//品牌 | ||
| 151 | + tblTradeInventoryIn.setInventoryQuantity(tblTradeInventory.getRksl());//入库数量 | ||
| 152 | + tblTradeInventoryIn.setOperator(tblTradeInventory.getOperator());//采购员 | ||
| 166 | tblTradeInventoryIn.setCreateTime(new Date()); | 153 | tblTradeInventoryIn.setCreateTime(new Date()); |
| 167 | tblTradeInventoryIn.setUpdateTime(new Date()); | 154 | tblTradeInventoryIn.setUpdateTime(new Date()); |
| 168 | - tblTradeInventoryIn.setDeliveryContractNumber(tblTradeInventory.getHth()); | ||
| 169 | - tblTradeInventoryIn.setExpressDeliveryNumber(tblTradeInventory.getWldh()); | ||
| 170 | - tblTradeInventoryIn.setSupplierName(tblTradeInventory.getCs()); | ||
| 171 | - tblTradeInventoryIn.setWarehouse(tblTradeInventory.getWarehouse()); | 155 | + tblTradeInventoryIn.setDeliveryContractNumber(tblTradeInventory.getHth());//交货合同编号 |
| 156 | + tblTradeInventoryIn.setExpressDeliveryNumber(tblTradeInventory.getWldh());//合同单号/快递单号 | ||
| 157 | + tblTradeInventoryIn.setSupplierName(tblTradeInventory.getCs());//供货商名称 | ||
| 158 | + tblTradeInventoryIn.setWarehouse(tblTradeInventory.getWarehouse());//仓库 | ||
| 172 | tblTradeInventoryIn.setType("入库"); | 159 | tblTradeInventoryIn.setType("入库"); |
| 173 | //根据 物流编码 查询库存信息 如存在库存信息则进行修改库存信息,不存在则新增库存信息 | 160 | //根据 物流编码 查询库存信息 如存在库存信息则进行修改库存信息,不存在则新增库存信息 |
| 174 | String hth = tblTradeInventory.getHth(); | 161 | String hth = tblTradeInventory.getHth(); |
| @@ -181,12 +168,12 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | @@ -181,12 +168,12 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | ||
| 181 | //修改订单信息 | 168 | //修改订单信息 |
| 182 | String purchaseId = tblTradeInventory.getPurchaseId(); | 169 | String purchaseId = tblTradeInventory.getPurchaseId(); |
| 183 | TblTradePurchaseInfo tblTradePurchaseInfo = tblTradePurchaseInfoService.getById(purchaseId); | 170 | TblTradePurchaseInfo tblTradePurchaseInfo = tblTradePurchaseInfoService.getById(purchaseId); |
| 184 | - Integer yrkNum = tblTradePurchaseInfo.getYrkNum() == null ? 0 : tblTradePurchaseInfo.getYrkNum(); | ||
| 185 | - Integer rksl = tblTradeInventory.getRksl() == null ? 0 : tblTradeInventory.getRksl(); | 171 | + Integer yrkNum = tblTradePurchaseInfo.getYrkNum() == null ? 0 : tblTradePurchaseInfo.getYrkNum();//已入库数量 |
| 172 | + Integer rksl = tblTradeInventory.getRksl() == null ? 0 : tblTradeInventory.getRksl();//入库数量 | ||
| 186 | tblTradePurchaseInfo.setYrkNum(yrkNum + rksl); | 173 | tblTradePurchaseInfo.setYrkNum(yrkNum + rksl); |
| 187 | - Integer wrkNum = tblTradePurchaseInfo.getWrkNum() == null ? 0 : tblTradePurchaseInfo.getWrkNum(); | ||
| 188 | - tblTradePurchaseInfo.setWrkNum(wrkNum - rksl); | ||
| 189 | - tblTradePurchaseInfoService.updateById(tblTradePurchaseInfo); | 174 | + Integer wrkNum = tblTradePurchaseInfo.getWrkNum() == null ? 0 : tblTradePurchaseInfo.getWrkNum();//未入库数量 |
| 175 | + tblTradePurchaseInfo.setWrkNum( tblTradePurchaseInfo.getPurchaseQuantity()- rksl); | ||
| 176 | + tblTradePurchaseInfoService.updateById(tblTradePurchaseInfo);//更新采购信息 | ||
| 190 | 177 | ||
| 191 | if (tradeInventory == null) { | 178 | if (tradeInventory == null) { |
| 192 | kcl = rksl; | 179 | kcl = rksl; |
| @@ -216,12 +203,12 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | @@ -216,12 +203,12 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | ||
| 216 | //当前库存 | 203 | //当前库存 |
| 217 | Integer actualInventory = tradeInventory.getActualInventory(); | 204 | Integer actualInventory = tradeInventory.getActualInventory(); |
| 218 | 205 | ||
| 219 | - kcl = rksl + actualInventory; | 206 | + kcl = rksl + (null == actualInventory ? 0 : actualInventory); |
| 220 | 207 | ||
| 221 | //在途数量 | 208 | //在途数量 |
| 222 | Integer wrk =tblTradePurchaseInfoService.getWrkNum(tblTradeInventory.getMaterialCode()); | 209 | Integer wrk =tblTradePurchaseInfoService.getWrkNum(tblTradeInventory.getMaterialCode()); |
| 223 | wrk = wrk == null ? 0 : wrk; | 210 | wrk = wrk == null ? 0 : wrk; |
| 224 | - tblTradeInventory.setQuantityInTransit(wrk); | 211 | + tblTradeInventory.setQuantityInTransit(wrk);//在途数量 |
| 225 | Integer yrk = tblTradePurchaseInfoService.getYrkNumByMaterialCode(tblTradeInventory.getMaterialCode()); | 212 | Integer yrk = tblTradePurchaseInfoService.getYrkNumByMaterialCode(tblTradeInventory.getMaterialCode()); |
| 226 | yrk = yrk == null ? 0 : yrk; | 213 | yrk = yrk == null ? 0 : yrk; |
| 227 | Integer ck = tblTradeInventoryOutService.getOutboundQuantityByMaterialCode(tblTradeInventory.getMaterialCode()); | 214 | Integer ck = tblTradeInventoryOutService.getOutboundQuantityByMaterialCode(tblTradeInventory.getMaterialCode()); |
| @@ -344,6 +331,20 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | @@ -344,6 +331,20 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | ||
| 344 | return Result.OK("出库成功!"); | 331 | return Result.OK("出库成功!"); |
| 345 | } | 332 | } |
| 346 | 333 | ||
| 334 | + /** | ||
| 335 | + * 更新BOH | ||
| 336 | + * | ||
| 337 | + * @param tblTradeInventory | ||
| 338 | + * @return | ||
| 339 | + */ | ||
| 340 | + @AutoLog(value = "贸易库存表-BOH更新") | ||
| 341 | + @ApiOperation(value = "贸易库存表-BOH更新", notes = "贸易库存表-BOH更新") | ||
| 342 | + @RequestMapping(value = "/updateBoh", method = {RequestMethod.PUT, RequestMethod.POST}) | ||
| 343 | + public Result<String> updateBoh(@RequestBody TblTradeInventoryUpdateBoh tblTradeInventory) { | ||
| 344 | + tblTradeInventoryService.updateBohAndActual(tblTradeInventory); | ||
| 345 | + return Result.OK("BOH更新成功!"); | ||
| 346 | + } | ||
| 347 | + | ||
| 347 | 348 | ||
| 348 | /** | 349 | /** |
| 349 | * 编辑 | 350 | * 编辑 |
| @@ -427,4 +428,72 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | @@ -427,4 +428,72 @@ public class TblTradeInventoryController extends JeecgController<TblTradeInvento | ||
| 427 | return super.importExcel(request, response, TblTradeInventory.class); | 428 | return super.importExcel(request, response, TblTradeInventory.class); |
| 428 | } | 429 | } |
| 429 | 430 | ||
| 431 | + /** | ||
| 432 | + * 批量更新BOH | ||
| 433 | + * | ||
| 434 | + * @param request | ||
| 435 | + * @param response | ||
| 436 | + * @return | ||
| 437 | + */ | ||
| 438 | + @RequestMapping(value = "/importExcelBoh", method = RequestMethod.POST) | ||
| 439 | + public Result<?> importExcelBoh(HttpServletRequest request, HttpServletResponse response) { | ||
| 440 | + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; | ||
| 441 | + Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); | ||
| 442 | + for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { | ||
| 443 | + // 获取上传文件对象 | ||
| 444 | + MultipartFile file = entity.getValue(); | ||
| 445 | + ImportParams params = new ImportParams(); | ||
| 446 | + params.setTitleRows(2); | ||
| 447 | + params.setHeadRows(1); | ||
| 448 | + params.setNeedSave(true); | ||
| 449 | + try { | ||
| 450 | + List<TblTradeInventoryUpdateBoh> list = ExcelImportUtil.importExcel(file.getInputStream(), TblTradeInventoryUpdateBoh.class, params); | ||
| 451 | + | ||
| 452 | +// List<TblTradeInventory> tblTradeMeterialArrayList = new ArrayList<>(); | ||
| 453 | + for (TblTradeInventoryUpdateBoh tblTradeInventoryUpdateBoh : list) { | ||
| 454 | + if (tblTradeInventoryUpdateBoh != null) { | ||
| 455 | + if(StrUtil.isBlank(tblTradeInventoryUpdateBoh.getMaterialCode()) || StrUtil.isBlank(tblTradeInventoryUpdateBoh.getMaterialDescription()) || (null == tblTradeInventoryUpdateBoh.getInventoryBoh())){ | ||
| 456 | + return Result.error("文件导入失败,编码、物料长描述、BOH有空白!"); | ||
| 457 | + } | ||
| 458 | +// tblTradeMeterialArrayList.add(new TblTradeInventory(tblTradeMeterial)); | ||
| 459 | + } | ||
| 460 | + } | ||
| 461 | +// if(!tblTradeMeterialArrayList.isEmpty()){ | ||
| 462 | + // 如果有数据需要保存,则批量保存 | ||
| 463 | + long start = System.currentTimeMillis(); | ||
| 464 | + tblTradeInventoryService.updateBohAndActualBatch(list); | ||
| 465 | + log.info("批量保存消耗时间:" + (System.currentTimeMillis() - start) + "毫秒"); | ||
| 466 | + if(list.size()<=0){ | ||
| 467 | + return Result.error("没有有效的导入数据"); | ||
| 468 | + } | ||
| 469 | + return Result.ok("文件导入成功!数据行数:" + list.size()); | ||
| 470 | +// } else { | ||
| 471 | +// return Result.error("文件导入失败:没有有效的数据需要保存!"); | ||
| 472 | +// } | ||
| 473 | + | ||
| 474 | + }catch (ExcelImportException e) { | ||
| 475 | + return Result.error("文件导入失败,导入数据格式错误"); | ||
| 476 | + } catch (Exception e) { | ||
| 477 | + log.error(e.getMessage()); | ||
| 478 | + //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示 | ||
| 479 | + String msg = e.getMessage(); | ||
| 480 | + log.error(msg, e); | ||
| 481 | + if(msg!=null && msg.indexOf("Duplicate entry")>=0){ | ||
| 482 | + return Result.error("文件导入失败:有重复数据!"); | ||
| 483 | + }else{ | ||
| 484 | + return Result.error("文件导入失败:" + e.getMessage()); | ||
| 485 | + } | ||
| 486 | + //update-end-author:taoyan date:20211124 for: 导入数据重复增加提示 | ||
| 487 | + } finally { | ||
| 488 | + try { | ||
| 489 | + file.getInputStream().close(); | ||
| 490 | + } catch (IOException e) { | ||
| 491 | + e.printStackTrace(); | ||
| 492 | + } | ||
| 493 | + } | ||
| 494 | + } | ||
| 495 | + return Result.error("文件导入失败!"); | ||
| 496 | + } | ||
| 497 | + | ||
| 498 | + | ||
| 430 | } | 499 | } |
| 1 | package org.jeecg.modules.erp.trade.controller; | 1 | package org.jeecg.modules.erp.trade.controller; |
| 2 | 2 | ||
| 3 | -import java.util.Arrays; | ||
| 4 | -import java.util.Date; | ||
| 5 | -import java.util.List; | ||
| 6 | -import java.util.Map; | ||
| 7 | -import java.util.stream.Collectors; | ||
| 8 | -import java.io.IOException; | ||
| 9 | -import java.io.UnsupportedEncodingException; | ||
| 10 | -import java.net.URLDecoder; | ||
| 11 | -import javax.servlet.http.HttpServletRequest; | ||
| 12 | -import javax.servlet.http.HttpServletResponse; | ||
| 13 | - | ||
| 14 | import cn.hutool.core.collection.CollectionUtil; | 3 | import cn.hutool.core.collection.CollectionUtil; |
| 15 | import cn.hutool.core.util.StrUtil; | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 6 | +import com.baomidou.mybatisplus.core.metadata.IPage; | ||
| 7 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
| 8 | +import io.swagger.annotations.Api; | ||
| 9 | +import io.swagger.annotations.ApiOperation; | ||
| 10 | +import lombok.extern.slf4j.Slf4j; | ||
| 16 | import org.apache.commons.lang3.StringUtils; | 11 | import org.apache.commons.lang3.StringUtils; |
| 17 | import org.jeecg.common.api.vo.Result; | 12 | import org.jeecg.common.api.vo.Result; |
| 18 | -import org.jeecg.common.system.query.QueryGenerator; | ||
| 19 | -import org.jeecg.common.util.oConvertUtils; | 13 | +import org.jeecg.common.aspect.annotation.AutoLog; |
| 14 | +import org.jeecg.common.system.base.controller.JeecgController; | ||
| 20 | import org.jeecg.modules.erp.trade.entity.TblTradeInventory; | 15 | import org.jeecg.modules.erp.trade.entity.TblTradeInventory; |
| 21 | import org.jeecg.modules.erp.trade.entity.TblTradeMeterial; | 16 | import org.jeecg.modules.erp.trade.entity.TblTradeMeterial; |
| 22 | import org.jeecg.modules.erp.trade.service.ITblTradeInventoryService; | 17 | import org.jeecg.modules.erp.trade.service.ITblTradeInventoryService; |
| 23 | import org.jeecg.modules.erp.trade.service.ITblTradeMeterialService; | 18 | import org.jeecg.modules.erp.trade.service.ITblTradeMeterialService; |
| 24 | - | ||
| 25 | -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 26 | -import com.baomidou.mybatisplus.core.metadata.IPage; | ||
| 27 | -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
| 28 | -import lombok.extern.slf4j.Slf4j; | ||
| 29 | - | ||
| 30 | import org.jeecgframework.poi.excel.ExcelImportUtil; | 19 | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| 31 | -import org.jeecgframework.poi.excel.def.NormalExcelConstants; | ||
| 32 | -import org.jeecgframework.poi.excel.entity.ExportParams; | ||
| 33 | import org.jeecgframework.poi.excel.entity.ImportParams; | 20 | import org.jeecgframework.poi.excel.entity.ImportParams; |
| 34 | -import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; | ||
| 35 | -import org.jeecg.common.system.base.controller.JeecgController; | 21 | +import org.jeecgframework.poi.exception.excel.ExcelImportException; |
| 36 | import org.springframework.beans.factory.annotation.Autowired; | 22 | import org.springframework.beans.factory.annotation.Autowired; |
| 23 | +import org.springframework.transaction.annotation.Transactional; | ||
| 37 | import org.springframework.web.bind.annotation.*; | 24 | import org.springframework.web.bind.annotation.*; |
| 38 | import org.springframework.web.multipart.MultipartFile; | 25 | import org.springframework.web.multipart.MultipartFile; |
| 39 | import org.springframework.web.multipart.MultipartHttpServletRequest; | 26 | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| 40 | import org.springframework.web.servlet.ModelAndView; | 27 | import org.springframework.web.servlet.ModelAndView; |
| 41 | -import com.alibaba.fastjson.JSON; | ||
| 42 | -import io.swagger.annotations.Api; | ||
| 43 | -import io.swagger.annotations.ApiOperation; | ||
| 44 | -import org.jeecg.common.aspect.annotation.AutoLog; | 28 | + |
| 29 | +import javax.servlet.http.HttpServletRequest; | ||
| 30 | +import javax.servlet.http.HttpServletResponse; | ||
| 31 | +import java.io.IOException; | ||
| 32 | +import java.util.*; | ||
| 45 | 33 | ||
| 46 | /** | 34 | /** |
| 47 | * @Description: 贸易管理物料表 | 35 | * @Description: 贸易管理物料表 |
| @@ -63,9 +51,9 @@ public class TblTradeMeterialController extends JeecgController<TblTradeMeterial | @@ -63,9 +51,9 @@ public class TblTradeMeterialController extends JeecgController<TblTradeMeterial | ||
| 63 | @ApiOperation(value = "根据物料编号查询物料基础信息", notes = "根据物料编号查询物料基础信息") | 51 | @ApiOperation(value = "根据物料编号查询物料基础信息", notes = "根据物料编号查询物料基础信息") |
| 64 | @GetMapping(value = "/queryByMaterialCode") | 52 | @GetMapping(value = "/queryByMaterialCode") |
| 65 | public Result<TblTradeMeterial> queryByMaterialCode(TblTradeMeterial tblTradeMeterial) { | 53 | public Result<TblTradeMeterial> queryByMaterialCode(TblTradeMeterial tblTradeMeterial) { |
| 66 | - String meterialCode = tblTradeMeterial.getMeterialCode(); | 54 | + String materialCode = tblTradeMeterial.getMaterialCode(); |
| 67 | QueryWrapper<TblTradeMeterial> queryWrapper = new QueryWrapper<>(); | 55 | QueryWrapper<TblTradeMeterial> queryWrapper = new QueryWrapper<>(); |
| 68 | - queryWrapper.eq("meterial_code", meterialCode); | 56 | + queryWrapper.eq("material_code", materialCode); |
| 69 | List<TblTradeMeterial> list = tblTradeMeterialService.list(queryWrapper); | 57 | List<TblTradeMeterial> list = tblTradeMeterialService.list(queryWrapper); |
| 70 | if (CollectionUtil.isEmpty(list)) { | 58 | if (CollectionUtil.isEmpty(list)) { |
| 71 | return Result.error("未找到对应物料信息"); | 59 | return Result.error("未找到对应物料信息"); |
| @@ -93,11 +81,11 @@ public class TblTradeMeterialController extends JeecgController<TblTradeMeterial | @@ -93,11 +81,11 @@ public class TblTradeMeterialController extends JeecgController<TblTradeMeterial | ||
| 93 | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, | 81 | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| 94 | HttpServletRequest req) { | 82 | HttpServletRequest req) { |
| 95 | QueryWrapper<TblTradeMeterial> queryWrapper = new QueryWrapper<>(); | 83 | QueryWrapper<TblTradeMeterial> queryWrapper = new QueryWrapper<>(); |
| 96 | - if (StringUtils.isNotBlank(tblTradeMeterial.getMeterialReview())) { | ||
| 97 | - queryWrapper.like("meterial_review", tblTradeMeterial.getMeterialReview()); | 84 | + if (StringUtils.isNotBlank(tblTradeMeterial.getMaterialReview())) { |
| 85 | + queryWrapper.like("material_review", tblTradeMeterial.getMaterialReview()); | ||
| 98 | } | 86 | } |
| 99 | - if (StringUtils.isNotBlank(tblTradeMeterial.getMeterialCode())) { | ||
| 100 | - queryWrapper.eq("meterial_code", tblTradeMeterial.getMeterialCode()); | 87 | + if (StringUtils.isNotBlank(tblTradeMeterial.getMaterialCode())) { |
| 88 | + queryWrapper.eq("material_code", tblTradeMeterial.getMaterialCode()); | ||
| 101 | } | 89 | } |
| 102 | if (StringUtils.isNotBlank(tblTradeMeterial.getBrand())){ | 90 | if (StringUtils.isNotBlank(tblTradeMeterial.getBrand())){ |
| 103 | queryWrapper.eq("brand", tblTradeMeterial.getBrand()); | 91 | queryWrapper.eq("brand", tblTradeMeterial.getBrand()); |
| @@ -113,6 +101,7 @@ public class TblTradeMeterialController extends JeecgController<TblTradeMeterial | @@ -113,6 +101,7 @@ public class TblTradeMeterialController extends JeecgController<TblTradeMeterial | ||
| 113 | * @param tblTradeMeterial | 101 | * @param tblTradeMeterial |
| 114 | * @return | 102 | * @return |
| 115 | */ | 103 | */ |
| 104 | + @Transactional(rollbackFor = Exception.class) | ||
| 116 | @AutoLog(value = "贸易管理物料表-添加") | 105 | @AutoLog(value = "贸易管理物料表-添加") |
| 117 | @ApiOperation(value = "贸易管理物料表-添加", notes = "贸易管理物料表-添加") | 106 | @ApiOperation(value = "贸易管理物料表-添加", notes = "贸易管理物料表-添加") |
| 118 | @PostMapping(value = "/add") | 107 | @PostMapping(value = "/add") |
| @@ -246,9 +235,71 @@ public class TblTradeMeterialController extends JeecgController<TblTradeMeterial | @@ -246,9 +235,71 @@ public class TblTradeMeterialController extends JeecgController<TblTradeMeterial | ||
| 246 | * @param response | 235 | * @param response |
| 247 | * @return | 236 | * @return |
| 248 | */ | 237 | */ |
| 238 | +// @Transactional(rollbackFor = Exception.class) | ||
| 249 | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) | 239 | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| 250 | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { | 240 | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| 251 | - return super.importExcel(request, response, TblTradeMeterial.class); | 241 | +// return super.importExcel(request, response, TblTradeMeterial.class); |
| 242 | + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; | ||
| 243 | + Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); | ||
| 244 | + for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { | ||
| 245 | + // 获取上传文件对象 | ||
| 246 | + MultipartFile file = entity.getValue(); | ||
| 247 | + ImportParams params = new ImportParams(); | ||
| 248 | + params.setTitleRows(2); | ||
| 249 | + params.setHeadRows(1); | ||
| 250 | + | ||
| 251 | +// params.setKeyIndex(1); | ||
| 252 | + params.setNeedSave(true); | ||
| 253 | + try { | ||
| 254 | + List<TblTradeMeterial> list = ExcelImportUtil.importExcel(file.getInputStream(), TblTradeMeterial.class, params); | ||
| 255 | + | ||
| 256 | +// List<T> dataListToSave = new ArrayList<>(); | ||
| 257 | + List<TblTradeInventory> tblTradeMeterialArrayList = new ArrayList<>(); | ||
| 258 | + for (TblTradeMeterial tblTradeMeterial : list) { | ||
| 259 | + if (tblTradeMeterial != null) { | ||
| 260 | + if(StrUtil.isBlank(tblTradeMeterial.getMaterialCode()) || StrUtil.isBlank(tblTradeMeterial.getMaterialReview())){ | ||
| 261 | + return Result.error("文件导入失败,编码或者物料描述有空白!"); | ||
| 262 | + } | ||
| 263 | +// tblTradeMeterialArrayList.add(tblTradeMeterial); | ||
| 264 | + tblTradeMeterialArrayList.add(new TblTradeInventory(tblTradeMeterial)); | ||
| 265 | + } | ||
| 266 | + } | ||
| 267 | +// if(!tblTradeMeterialArrayList.isEmpty()){ | ||
| 268 | + // 如果有数据需要保存,则批量保存 | ||
| 269 | + long start = System.currentTimeMillis(); | ||
| 270 | + tblTradeMeterialService.saveBatch(list); | ||
| 271 | + tblTradeInventoryService.saveBatch(tblTradeMeterialArrayList); | ||
| 272 | + log.info("批量保存消耗时间:" + (System.currentTimeMillis() - start) + "毫秒"); | ||
| 273 | + if(list.size()<=0){ | ||
| 274 | + return Result.error("没有有效的导入数据"); | ||
| 275 | + } | ||
| 276 | + return Result.ok("文件导入成功!数据行数:" + list.size()); | ||
| 277 | +// } else { | ||
| 278 | +// return Result.error("文件导入失败:没有有效的数据需要保存!"); | ||
| 279 | +// } | ||
| 280 | + | ||
| 281 | + }catch (ExcelImportException e) { | ||
| 282 | + return Result.error("文件导入失败,导入数据格式错误"); | ||
| 283 | + } catch (Exception e) { | ||
| 284 | + log.error(e.getMessage()); | ||
| 285 | + //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示 | ||
| 286 | + String msg = e.getMessage(); | ||
| 287 | + log.error(msg, e); | ||
| 288 | + if(msg!=null && msg.indexOf("Duplicate entry")>=0){ | ||
| 289 | + return Result.error("文件导入失败:有重复数据!"); | ||
| 290 | + }else{ | ||
| 291 | + return Result.error("文件导入失败:" + e.getMessage()); | ||
| 292 | + } | ||
| 293 | + //update-end-author:taoyan date:20211124 for: 导入数据重复增加提示 | ||
| 294 | + } finally { | ||
| 295 | + try { | ||
| 296 | + file.getInputStream().close(); | ||
| 297 | + } catch (IOException e) { | ||
| 298 | + e.printStackTrace(); | ||
| 299 | + } | ||
| 300 | + } | ||
| 301 | + } | ||
| 302 | + return Result.error("文件导入失败!"); | ||
| 252 | } | 303 | } |
| 253 | 304 | ||
| 254 | } | 305 | } |
| 1 | package org.jeecg.modules.erp.trade.controller; | 1 | package org.jeecg.modules.erp.trade.controller; |
| 2 | 2 | ||
| 3 | -import java.io.*; | ||
| 4 | -import java.math.BigDecimal; | ||
| 5 | -import java.nio.file.Files; | ||
| 6 | -import java.nio.file.Paths; | ||
| 7 | -import java.util.*; | ||
| 8 | -import java.util.stream.Collectors; | ||
| 9 | -import javax.servlet.http.HttpServletRequest; | ||
| 10 | -import javax.servlet.http.HttpServletResponse; | ||
| 11 | - | ||
| 12 | import cn.hutool.core.collection.CollectionUtil; | 3 | import cn.hutool.core.collection.CollectionUtil; |
| 13 | import cn.hutool.core.date.DatePattern; | 4 | import cn.hutool.core.date.DatePattern; |
| 14 | -import org.apache.commons.lang3.StringUtils; | ||
| 15 | -import org.jeecg.common.api.vo.Result; | ||
| 16 | -import org.jeecg.common.system.query.QueryGenerator; | ||
| 17 | -import org.jeecg.modules.erp.trade.entity.*; | ||
| 18 | -import org.jeecg.modules.erp.trade.service.*; | ||
| 19 | - | ||
| 20 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 5 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 21 | import com.baomidou.mybatisplus.core.metadata.IPage; | 6 | import com.baomidou.mybatisplus.core.metadata.IPage; |
| 22 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 7 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| 8 | +import io.swagger.annotations.Api; | ||
| 9 | +import io.swagger.annotations.ApiOperation; | ||
| 23 | import lombok.extern.slf4j.Slf4j; | 10 | import lombok.extern.slf4j.Slf4j; |
| 24 | - | 11 | +import org.apache.commons.lang3.StringUtils; |
| 12 | +import org.jeecg.common.api.vo.Result; | ||
| 13 | +import org.jeecg.common.aspect.annotation.AutoLog; | ||
| 25 | import org.jeecg.common.system.base.controller.JeecgController; | 14 | import org.jeecg.common.system.base.controller.JeecgController; |
| 15 | +import org.jeecg.common.system.query.QueryGenerator; | ||
| 16 | +import org.jeecg.modules.erp.trade.entity.*; | ||
| 17 | +import org.jeecg.modules.erp.trade.service.*; | ||
| 26 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 27 | import org.springframework.beans.factory.annotation.Value; | 19 | import org.springframework.beans.factory.annotation.Value; |
| 28 | import org.springframework.transaction.annotation.Transactional; | 20 | import org.springframework.transaction.annotation.Transactional; |
| 29 | import org.springframework.web.bind.annotation.*; | 21 | import org.springframework.web.bind.annotation.*; |
| 30 | import org.springframework.web.servlet.ModelAndView; | 22 | import org.springframework.web.servlet.ModelAndView; |
| 31 | -import io.swagger.annotations.Api; | ||
| 32 | -import io.swagger.annotations.ApiOperation; | ||
| 33 | -import org.jeecg.common.aspect.annotation.AutoLog; | 23 | + |
| 24 | +import javax.servlet.http.HttpServletRequest; | ||
| 25 | +import javax.servlet.http.HttpServletResponse; | ||
| 26 | +import java.io.IOException; | ||
| 27 | +import java.math.BigDecimal; | ||
| 28 | +import java.nio.file.Files; | ||
| 29 | +import java.nio.file.Paths; | ||
| 30 | +import java.util.*; | ||
| 31 | +import java.util.stream.Collectors; | ||
| 34 | 32 | ||
| 35 | /** | 33 | /** |
| 36 | * @Description: tbl_trade_purchase_info | 34 | * @Description: tbl_trade_purchase_info |
| @@ -219,7 +217,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | @@ -219,7 +217,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | ||
| 219 | List<TblTradeInventory> list1 = tblTradeInventoryService.list(wrapper); | 217 | List<TblTradeInventory> list1 = tblTradeInventoryService.list(wrapper); |
| 220 | 218 | ||
| 221 | QueryWrapper<TblTradeMeterial> queryWrapper1 = new QueryWrapper<>(); | 219 | QueryWrapper<TblTradeMeterial> queryWrapper1 = new QueryWrapper<>(); |
| 222 | - queryWrapper1.eq("meterial_code", tblTradePurchaseInfo.getWlbh()); | 220 | + queryWrapper1.eq("material_code", tblTradePurchaseInfo.getWlbh()); |
| 223 | List<TblTradeMeterial> tradeMeterials = tblTradeMeterialService.list(queryWrapper1); | 221 | List<TblTradeMeterial> tradeMeterials = tblTradeMeterialService.list(queryWrapper1); |
| 224 | 222 | ||
| 225 | if (!CollectionUtil.isEmpty(tradeMeterials)) { | 223 | if (!CollectionUtil.isEmpty(tradeMeterials)) { |
| @@ -227,7 +225,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | @@ -227,7 +225,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | ||
| 227 | TblTradeInventory tblTradeInventory = new TblTradeInventory(); | 225 | TblTradeInventory tblTradeInventory = new TblTradeInventory(); |
| 228 | tblTradeInventory.setMaterialCode(tblTradePurchaseInfo.getWlbh()); | 226 | tblTradeInventory.setMaterialCode(tblTradePurchaseInfo.getWlbh()); |
| 229 | tblTradeInventory.setHth(hth); | 227 | tblTradeInventory.setHth(hth); |
| 230 | - tblTradeInventory.setMaterialDescription(tblTradeMeterial.getMeterialReview()); | 228 | + tblTradeInventory.setMaterialDescription(tblTradeMeterial.getMaterialReview()); |
| 231 | tblTradeInventory.setMeasurementUnit(tblTradeMeterial.getUnit()); | 229 | tblTradeInventory.setMeasurementUnit(tblTradeMeterial.getUnit()); |
| 232 | tblTradeInventory.setBrand(tblTradeMeterial.getBrand()); | 230 | tblTradeInventory.setBrand(tblTradeMeterial.getBrand()); |
| 233 | tblTradeInventory.setActualInventory(0); | 231 | tblTradeInventory.setActualInventory(0); |
| @@ -313,7 +311,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | @@ -313,7 +311,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | ||
| 313 | // defectiveProduct.setWaybillNum("BZSOUT"+ DatePattern.PURE_DATETIME_FORMAT.format(new Date())); | 311 | // defectiveProduct.setWaybillNum("BZSOUT"+ DatePattern.PURE_DATETIME_FORMAT.format(new Date())); |
| 314 | // defectiveProduct.setMaterialCode(tblTradePurchaseInfo.getWlbh()); | 312 | // defectiveProduct.setMaterialCode(tblTradePurchaseInfo.getWlbh()); |
| 315 | // QueryWrapper<TblTradeMeterial> queryWrapper1 = new QueryWrapper<>(); | 313 | // QueryWrapper<TblTradeMeterial> queryWrapper1 = new QueryWrapper<>(); |
| 316 | -// queryWrapper1.eq("meterial_code", tblTradePurchaseInfo.getWlbh()); | 314 | +// queryWrapper1.eq("material_code", tblTradePurchaseInfo.getWlbh()); |
| 317 | // //物料信息 | 315 | // //物料信息 |
| 318 | // List<TblTradeMeterial> tradeMeterials = tblTradeMeterialService.list(queryWrapper1); | 316 | // List<TblTradeMeterial> tradeMeterials = tblTradeMeterialService.list(queryWrapper1); |
| 319 | // if (!CollectionUtil.isEmpty(tradeMeterials)) { | 317 | // if (!CollectionUtil.isEmpty(tradeMeterials)) { |
| @@ -339,7 +337,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | @@ -339,7 +337,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | ||
| 339 | //库存信息 | 337 | //库存信息 |
| 340 | List<TblTradeInventory> list = tblTradeInventoryService.list(queryWrapper); | 338 | List<TblTradeInventory> list = tblTradeInventoryService.list(queryWrapper); |
| 341 | QueryWrapper<TblTradeMeterial> queryWrapper1 = new QueryWrapper<>(); | 339 | QueryWrapper<TblTradeMeterial> queryWrapper1 = new QueryWrapper<>(); |
| 342 | - queryWrapper1.eq("meterial_code", wlbh); | 340 | + queryWrapper1.eq("material_code", wlbh); |
| 343 | List<TblTradeMeterial> tradeMeterials = tblTradeMeterialService.list(queryWrapper1); | 341 | List<TblTradeMeterial> tradeMeterials = tblTradeMeterialService.list(queryWrapper1); |
| 344 | if (CollectionUtil.isEmpty(list)) { | 342 | if (CollectionUtil.isEmpty(list)) { |
| 345 | //为空,新增库存记录 | 343 | //为空,新增库存记录 |
| @@ -352,20 +350,20 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | @@ -352,20 +350,20 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | ||
| 352 | TblTradeInventory tblTradeInventory = new TblTradeInventory(); | 350 | TblTradeInventory tblTradeInventory = new TblTradeInventory(); |
| 353 | tblTradeInventory.setMaterialCode(wlbh); | 351 | tblTradeInventory.setMaterialCode(wlbh); |
| 354 | tblTradeInventory.setHth(hth); | 352 | tblTradeInventory.setHth(hth); |
| 355 | - tblTradeInventory.setMaterialDescription(tblTradeMeterial.getMeterialReview()); | 353 | + tblTradeInventory.setMaterialDescription(tblTradeMeterial.getMaterialReview()); |
| 356 | tblTradeInventory.setMeasurementUnit(tblTradeMeterial.getUnit()); | 354 | tblTradeInventory.setMeasurementUnit(tblTradeMeterial.getUnit()); |
| 357 | tblTradeInventory.setBrand(tblTradeMeterial.getBrand()); | 355 | tblTradeInventory.setBrand(tblTradeMeterial.getBrand()); |
| 358 | 356 | ||
| 359 | - String meterialCode = tblTradeMeterial.getMeterialCode(); | ||
| 360 | - Integer yrk = tblTradePurchaseInfoService.getYrkNumByMaterialCode(meterialCode); | 357 | + String materialCode = tblTradeMeterial.getMaterialCode(); |
| 358 | + Integer yrk = tblTradePurchaseInfoService.getYrkNumByMaterialCode(materialCode); | ||
| 361 | yrk = yrk == null ? 0 : yrk; | 359 | yrk = yrk == null ? 0 : yrk; |
| 362 | - Integer ck = tblTradeInventoryOutService.getOutboundQuantityByMaterialCode(meterialCode); | 360 | + Integer ck = tblTradeInventoryOutService.getOutboundQuantityByMaterialCode(materialCode); |
| 363 | ck = ck == null ? 0 : ck; | 361 | ck = ck == null ? 0 : ck; |
| 364 | - Integer wrk =tblTradePurchaseInfoService.getWrkNum(meterialCode); | 362 | + Integer wrk =tblTradePurchaseInfoService.getWrkNum(materialCode); |
| 365 | wrk = wrk == null ? 0 : wrk; | 363 | wrk = wrk == null ? 0 : wrk; |
| 366 | tblTradeInventory.setActualInventory(yrk-ck); | 364 | tblTradeInventory.setActualInventory(yrk-ck); |
| 367 | tblTradeInventory.setQuantityInTransit(wrk); | 365 | tblTradeInventory.setQuantityInTransit(wrk); |
| 368 | - Integer purchaseQuantityNum = tblTradePurchaseInfoService.getPurchaseQuantityNumByMaterialCode(meterialCode); | 366 | + Integer purchaseQuantityNum = tblTradePurchaseInfoService.getPurchaseQuantityNumByMaterialCode(materialCode); |
| 369 | purchaseQuantityNum = purchaseQuantityNum == null ? 0 : purchaseQuantityNum; | 367 | purchaseQuantityNum = purchaseQuantityNum == null ? 0 : purchaseQuantityNum; |
| 370 | tblTradeInventory.setTotalQuantity(purchaseQuantityNum); | 368 | tblTradeInventory.setTotalQuantity(purchaseQuantityNum); |
| 371 | //单价 | 369 | //单价 |
| @@ -381,7 +379,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | @@ -381,7 +379,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | ||
| 381 | //入库单号 | 379 | //入库单号 |
| 382 | tblTradeInventoryIn.setWaybillNum("BZSIN" + DatePattern.PURE_DATETIME_FORMAT.format(new Date())); | 380 | tblTradeInventoryIn.setWaybillNum("BZSIN" + DatePattern.PURE_DATETIME_FORMAT.format(new Date())); |
| 383 | tblTradeInventoryIn.setMaterialCode(wlbh); | 381 | tblTradeInventoryIn.setMaterialCode(wlbh); |
| 384 | - tblTradeInventoryIn.setMaterialDescription(tblTradeMeterial.getMeterialReview()); | 382 | + tblTradeInventoryIn.setMaterialDescription(tblTradeMeterial.getMaterialReview()); |
| 385 | tblTradeInventoryIn.setMeasurementUnit(tblTradeMeterial.getUnit()); | 383 | tblTradeInventoryIn.setMeasurementUnit(tblTradeMeterial.getUnit()); |
| 386 | tblTradeInventoryIn.setBrand(tblTradeMeterial.getBrand()); | 384 | tblTradeInventoryIn.setBrand(tblTradeMeterial.getBrand()); |
| 387 | tblTradeInventoryIn.setActualInventory(rkNum); | 385 | tblTradeInventoryIn.setActualInventory(rkNum); |
| @@ -402,14 +400,14 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | @@ -402,14 +400,14 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | ||
| 402 | //更新实际库存量 | 400 | //更新实际库存量 |
| 403 | // 获取该物料的所有订单的已入库数量 减去 该物料所有的出库记录中出库数量 | 401 | // 获取该物料的所有订单的已入库数量 减去 该物料所有的出库记录中出库数量 |
| 404 | // 获取该物料的所有订单的已入库数量 | 402 | // 获取该物料的所有订单的已入库数量 |
| 405 | - String meterialCode = tblTradeMeterial.getMeterialCode(); | ||
| 406 | - Integer yrk = tblTradePurchaseInfoService.getYrkNumByMaterialCode(meterialCode); | 403 | + String materialCode = tblTradeMeterial.getMaterialCode(); |
| 404 | + Integer yrk = tblTradePurchaseInfoService.getYrkNumByMaterialCode(materialCode); | ||
| 407 | yrk = yrk == null ? 0 : yrk; | 405 | yrk = yrk == null ? 0 : yrk; |
| 408 | - Integer ck = tblTradeInventoryOutService.getOutboundQuantityByMaterialCode(meterialCode); | 406 | + Integer ck = tblTradeInventoryOutService.getOutboundQuantityByMaterialCode(materialCode); |
| 409 | ck = ck == null ? 0 : ck; | 407 | ck = ck == null ? 0 : ck; |
| 410 | - Integer wrk =tblTradePurchaseInfoService.getWrkNum(meterialCode); | 408 | + Integer wrk =tblTradePurchaseInfoService.getWrkNum(materialCode); |
| 411 | wrk = wrk == null ? 0 : wrk; | 409 | wrk = wrk == null ? 0 : wrk; |
| 412 | - Integer purchaseQuantityNum = tblTradePurchaseInfoService.getPurchaseQuantityNumByMaterialCode(meterialCode); | 410 | + Integer purchaseQuantityNum = tblTradePurchaseInfoService.getPurchaseQuantityNumByMaterialCode(materialCode); |
| 413 | tblTradeInventory.setTotalQuantity(purchaseQuantityNum - ck); | 411 | tblTradeInventory.setTotalQuantity(purchaseQuantityNum - ck); |
| 414 | 412 | ||
| 415 | tblTradeInventory.setActualInventory(yrk-ck); | 413 | tblTradeInventory.setActualInventory(yrk-ck); |
| @@ -420,7 +418,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | @@ -420,7 +418,7 @@ public class TblTradePurchaseInfoController extends JeecgController<TblTradePurc | ||
| 420 | TblTradeInventoryIn tblTradeInventoryIn = new TblTradeInventoryIn(); | 418 | TblTradeInventoryIn tblTradeInventoryIn = new TblTradeInventoryIn(); |
| 421 | tblTradeInventoryIn.setWaybillNum("BZSIN" + DatePattern.PURE_DATETIME_FORMAT.format(new Date())); | 419 | tblTradeInventoryIn.setWaybillNum("BZSIN" + DatePattern.PURE_DATETIME_FORMAT.format(new Date())); |
| 422 | tblTradeInventoryIn.setMaterialCode(wlbh); | 420 | tblTradeInventoryIn.setMaterialCode(wlbh); |
| 423 | - tblTradeInventoryIn.setMaterialDescription(tblTradeMeterial.getMeterialReview()); | 421 | + tblTradeInventoryIn.setMaterialDescription(tblTradeMeterial.getMaterialReview()); |
| 424 | tblTradeInventoryIn.setMeasurementUnit(tblTradeMeterial.getUnit()); | 422 | tblTradeInventoryIn.setMeasurementUnit(tblTradeMeterial.getUnit()); |
| 425 | tblTradeInventoryIn.setBrand(tblTradeMeterial.getBrand()); | 423 | tblTradeInventoryIn.setBrand(tblTradeMeterial.getBrand()); |
| 426 | tblTradeInventoryIn.setActualInventory(rkNum); | 424 | tblTradeInventoryIn.setActualInventory(rkNum); |
| 1 | package org.jeecg.modules.erp.trade.entity; | 1 | package org.jeecg.modules.erp.trade.entity; |
| 2 | 2 | ||
| 3 | -import java.io.Serializable; | ||
| 4 | -import java.io.UnsupportedEncodingException; | ||
| 5 | -import java.util.Date; | ||
| 6 | -import java.math.BigDecimal; | ||
| 7 | import com.baomidou.mybatisplus.annotation.IdType; | 3 | import com.baomidou.mybatisplus.annotation.IdType; |
| 8 | import com.baomidou.mybatisplus.annotation.TableField; | 4 | import com.baomidou.mybatisplus.annotation.TableField; |
| 9 | import com.baomidou.mybatisplus.annotation.TableId; | 5 | import com.baomidou.mybatisplus.annotation.TableId; |
| 10 | import com.baomidou.mybatisplus.annotation.TableName; | 6 | import com.baomidou.mybatisplus.annotation.TableName; |
| 11 | -import lombok.Data; | ||
| 12 | import com.fasterxml.jackson.annotation.JsonFormat; | 7 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 13 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 14 | -import org.jeecgframework.poi.excel.annotation.Excel; | ||
| 15 | -import org.jeecg.common.aspect.annotation.Dict; | ||
| 16 | import io.swagger.annotations.ApiModel; | 8 | import io.swagger.annotations.ApiModel; |
| 17 | import io.swagger.annotations.ApiModelProperty; | 9 | import io.swagger.annotations.ApiModelProperty; |
| 10 | +import lombok.Data; | ||
| 18 | import lombok.EqualsAndHashCode; | 11 | import lombok.EqualsAndHashCode; |
| 19 | import lombok.experimental.Accessors; | 12 | import lombok.experimental.Accessors; |
| 13 | +import org.jeecgframework.poi.excel.annotation.Excel; | ||
| 14 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 15 | + | ||
| 16 | +import java.io.Serializable; | ||
| 20 | 17 | ||
| 21 | /** | 18 | /** |
| 22 | * @Description: 贸易库存表 | 19 | * @Description: 贸易库存表 |
| @@ -56,6 +53,10 @@ public class TblTradeInventory implements Serializable { | @@ -56,6 +53,10 @@ public class TblTradeInventory implements Serializable { | ||
| 56 | @Excel(name = "品牌", width = 15) | 53 | @Excel(name = "品牌", width = 15) |
| 57 | @ApiModelProperty(value = "品牌") | 54 | @ApiModelProperty(value = "品牌") |
| 58 | private java.lang.String brand; | 55 | private java.lang.String brand; |
| 56 | + /**初始库存总量*/ | ||
| 57 | + @Excel(name = "初始库存总量", width = 15) | ||
| 58 | + @ApiModelProperty(value = "初始库存总量") | ||
| 59 | + private java.lang.Integer inventoryBoh; | ||
| 59 | /**实际库存量*/ | 60 | /**实际库存量*/ |
| 60 | @Excel(name = "实际库存量", width = 15) | 61 | @Excel(name = "实际库存量", width = 15) |
| 61 | @ApiModelProperty(value = "实际库存量") | 62 | @ApiModelProperty(value = "实际库存量") |
| @@ -157,8 +158,8 @@ public class TblTradeInventory implements Serializable { | @@ -157,8 +158,8 @@ public class TblTradeInventory implements Serializable { | ||
| 157 | 158 | ||
| 158 | public TblTradeInventory(TblTradeMeterial e){ | 159 | public TblTradeInventory(TblTradeMeterial e){ |
| 159 | this.id = e.getId(); | 160 | this.id = e.getId(); |
| 160 | - this.materialCode=e.getMeterialCode(); | ||
| 161 | - this.materialDescription = e.getMeterialReview(); | 161 | + this.materialCode=e.getMaterialCode(); |
| 162 | + this.materialDescription = e.getMaterialReview(); | ||
| 162 | this.measurementUnit = e.getUnit(); | 163 | this.measurementUnit = e.getUnit(); |
| 163 | this.brand = e.getBrand(); | 164 | this.brand = e.getBrand(); |
| 164 | 165 |
jeecg-boot-erp/src/main/java/org/jeecg/modules/erp/trade/entity/TblTradeInventoryUpdateBoh.java
0 → 100644
| 1 | +package org.jeecg.modules.erp.trade.entity; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.annotation.IdType; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.TableField; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 8 | +import io.swagger.annotations.ApiModel; | ||
| 9 | +import io.swagger.annotations.ApiModelProperty; | ||
| 10 | +import lombok.Data; | ||
| 11 | +import lombok.EqualsAndHashCode; | ||
| 12 | +import lombok.experimental.Accessors; | ||
| 13 | +import org.jeecgframework.poi.excel.annotation.Excel; | ||
| 14 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 15 | + | ||
| 16 | +import java.io.Serializable; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * @Description: 贸易库存表 | ||
| 20 | + * @Author: jeecg-boot | ||
| 21 | + * @Date: 2024-12-24 | ||
| 22 | + * @Version: V1.0 | ||
| 23 | + */ | ||
| 24 | +@Data | ||
| 25 | +@TableName("tbl_trade_inventory") | ||
| 26 | +@Accessors(chain = true) | ||
| 27 | +@EqualsAndHashCode(callSuper = false) | ||
| 28 | +@ApiModel(value="tbl_trade_inventory对象", description="贸易库存表") | ||
| 29 | +public class TblTradeInventoryUpdateBoh implements Serializable { | ||
| 30 | + private static final long serialVersionUID = 1L; | ||
| 31 | + | ||
| 32 | + /**id*/ | ||
| 33 | + @TableId(type = IdType.ASSIGN_ID) | ||
| 34 | + @ApiModelProperty(value = "id") | ||
| 35 | + private String id; | ||
| 36 | + | ||
| 37 | + /**id*/ | ||
| 38 | + @TableField(exist = false) | ||
| 39 | + private String purchaseId; | ||
| 40 | + /**物料编码*/ | ||
| 41 | + @Excel(name = "物料编码", width = 15) | ||
| 42 | + @ApiModelProperty(value = "物料编码") | ||
| 43 | + private String materialCode; | ||
| 44 | + /**物料描述*/ | ||
| 45 | + @Excel(name = "物料描述", width = 15) | ||
| 46 | + @ApiModelProperty(value = "物料描述") | ||
| 47 | + private String materialDescription; | ||
| 48 | + /**初始库存总量*/ | ||
| 49 | + @Excel(name = "BOH", width = 15) | ||
| 50 | + @ApiModelProperty(value = "初始库存总量") | ||
| 51 | + private Integer inventoryBoh; | ||
| 52 | + /**实际库存量*/ | ||
| 53 | + @Excel(name = "实际库存量", width = 15) | ||
| 54 | + @ApiModelProperty(value = "实际库存量") | ||
| 55 | + private Integer actualInventory; | ||
| 56 | + /**更新人*/ | ||
| 57 | + @ApiModelProperty(value = "更新人") | ||
| 58 | + private String updateBy; | ||
| 59 | + /**更新日期*/ | ||
| 60 | + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") | ||
| 61 | + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") | ||
| 62 | + @ApiModelProperty(value = "更新日期") | ||
| 63 | + private java.util.Date updateTime; | ||
| 64 | + | ||
| 65 | + | ||
| 66 | + | ||
| 67 | +} |
| 1 | package org.jeecg.modules.erp.trade.entity; | 1 | package org.jeecg.modules.erp.trade.entity; |
| 2 | 2 | ||
| 3 | -import java.io.Serializable; | ||
| 4 | -import java.io.UnsupportedEncodingException; | ||
| 5 | -import java.util.Date; | ||
| 6 | -import java.math.BigDecimal; | ||
| 7 | -import java.util.Objects; | ||
| 8 | - | ||
| 9 | import com.baomidou.mybatisplus.annotation.IdType; | 3 | import com.baomidou.mybatisplus.annotation.IdType; |
| 10 | import com.baomidou.mybatisplus.annotation.TableField; | 4 | import com.baomidou.mybatisplus.annotation.TableField; |
| 11 | import com.baomidou.mybatisplus.annotation.TableId; | 5 | import com.baomidou.mybatisplus.annotation.TableId; |
| 12 | import com.baomidou.mybatisplus.annotation.TableName; | 6 | import com.baomidou.mybatisplus.annotation.TableName; |
| 13 | -import lombok.Data; | ||
| 14 | import com.fasterxml.jackson.annotation.JsonFormat; | 7 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 15 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 16 | -import org.jeecgframework.poi.excel.annotation.Excel; | ||
| 17 | -import org.jeecg.common.aspect.annotation.Dict; | ||
| 18 | import io.swagger.annotations.ApiModel; | 8 | import io.swagger.annotations.ApiModel; |
| 19 | import io.swagger.annotations.ApiModelProperty; | 9 | import io.swagger.annotations.ApiModelProperty; |
| 10 | +import lombok.Data; | ||
| 20 | import lombok.EqualsAndHashCode; | 11 | import lombok.EqualsAndHashCode; |
| 21 | import lombok.experimental.Accessors; | 12 | import lombok.experimental.Accessors; |
| 13 | +import org.jeecgframework.poi.excel.annotation.Excel; | ||
| 14 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 15 | + | ||
| 16 | +import java.io.Serializable; | ||
| 17 | +import java.util.Date; | ||
| 18 | +import java.util.Objects; | ||
| 22 | 19 | ||
| 23 | /** | 20 | /** |
| 24 | * @Description: 贸易管理物料表 | 21 | * @Description: 贸易管理物料表 |
| @@ -41,11 +38,11 @@ public class TblTradeMeterial implements Serializable { | @@ -41,11 +38,11 @@ public class TblTradeMeterial implements Serializable { | ||
| 41 | /**物料编码*/ | 38 | /**物料编码*/ |
| 42 | @Excel(name = "物料编码", width = 15) | 39 | @Excel(name = "物料编码", width = 15) |
| 43 | @ApiModelProperty(value = "物料编码") | 40 | @ApiModelProperty(value = "物料编码") |
| 44 | - private java.lang.String meterialCode; | 41 | + private java.lang.String materialCode; |
| 45 | /**物料长描述*/ | 42 | /**物料长描述*/ |
| 46 | @Excel(name = "物料长描述", width = 15) | 43 | @Excel(name = "物料长描述", width = 15) |
| 47 | @ApiModelProperty(value = "物料长描述") | 44 | @ApiModelProperty(value = "物料长描述") |
| 48 | - private java.lang.String meterialReview; | 45 | + private java.lang.String materialReview; |
| 49 | /**单位*/ | 46 | /**单位*/ |
| 50 | @Excel(name = "单位", width = 15) | 47 | @Excel(name = "单位", width = 15) |
| 51 | @ApiModelProperty(value = "单位") | 48 | @ApiModelProperty(value = "单位") |
| @@ -54,6 +51,8 @@ public class TblTradeMeterial implements Serializable { | @@ -54,6 +51,8 @@ public class TblTradeMeterial implements Serializable { | ||
| 54 | @Excel(name = "品牌", width = 15) | 51 | @Excel(name = "品牌", width = 15) |
| 55 | @ApiModelProperty(value = "品牌") | 52 | @ApiModelProperty(value = "品牌") |
| 56 | private java.lang.String brand; | 53 | private java.lang.String brand; |
| 54 | + | ||
| 55 | + | ||
| 57 | /**创建人*/ | 56 | /**创建人*/ |
| 58 | @ApiModelProperty(value = "创建人") | 57 | @ApiModelProperty(value = "创建人") |
| 59 | private java.lang.String createBy; | 58 | private java.lang.String createBy; |
| @@ -104,6 +103,11 @@ public class TblTradeMeterial implements Serializable { | @@ -104,6 +103,11 @@ public class TblTradeMeterial implements Serializable { | ||
| 104 | @ApiModelProperty(value = "日期时间") | 103 | @ApiModelProperty(value = "日期时间") |
| 105 | private java.util.Date otherDate; | 104 | private java.util.Date otherDate; |
| 106 | 105 | ||
| 106 | + /**初始库存总量*/ | ||
| 107 | +// @Excel(name = "初始库存总量", width = 15) | ||
| 108 | + @ApiModelProperty(value = "初始库存总量") | ||
| 109 | + @TableField(exist = false) | ||
| 110 | + private java.lang.Integer inventoryBoh; | ||
| 107 | /** | 111 | /** |
| 108 | * 实际库存数量 | 112 | * 实际库存数量 |
| 109 | */ | 113 | */ |
| @@ -147,11 +151,11 @@ public class TblTradeMeterial implements Serializable { | @@ -147,11 +151,11 @@ public class TblTradeMeterial implements Serializable { | ||
| 147 | if (this == o) return true; | 151 | if (this == o) return true; |
| 148 | if (o == null || getClass() != o.getClass()) return false; | 152 | if (o == null || getClass() != o.getClass()) return false; |
| 149 | TblTradeMeterial that = (TblTradeMeterial) o; | 153 | TblTradeMeterial that = (TblTradeMeterial) o; |
| 150 | - return Objects.equals(meterialCode, that.meterialCode); | 154 | + return Objects.equals(materialCode, that.materialCode); |
| 151 | } | 155 | } |
| 152 | 156 | ||
| 153 | @Override | 157 | @Override |
| 154 | public int hashCode() { | 158 | public int hashCode() { |
| 155 | - return Objects.hash(meterialCode); | 159 | + return Objects.hash(materialCode); |
| 156 | } | 160 | } |
| 157 | } | 161 | } |
| 1 | package org.jeecg.modules.erp.trade.entity; | 1 | package org.jeecg.modules.erp.trade.entity; |
| 2 | 2 | ||
| 3 | -import java.io.Serializable; | ||
| 4 | -import java.io.UnsupportedEncodingException; | ||
| 5 | -import java.util.Date; | ||
| 6 | -import java.math.BigDecimal; | ||
| 7 | import com.baomidou.mybatisplus.annotation.IdType; | 3 | import com.baomidou.mybatisplus.annotation.IdType; |
| 8 | import com.baomidou.mybatisplus.annotation.TableField; | 4 | import com.baomidou.mybatisplus.annotation.TableField; |
| 9 | import com.baomidou.mybatisplus.annotation.TableId; | 5 | import com.baomidou.mybatisplus.annotation.TableId; |
| 10 | import com.baomidou.mybatisplus.annotation.TableName; | 6 | import com.baomidou.mybatisplus.annotation.TableName; |
| 11 | -import lombok.Data; | ||
| 12 | import com.fasterxml.jackson.annotation.JsonFormat; | 7 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 13 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 14 | -import org.jeecgframework.poi.excel.annotation.Excel; | ||
| 15 | -import org.jeecg.common.aspect.annotation.Dict; | ||
| 16 | import io.swagger.annotations.ApiModel; | 8 | import io.swagger.annotations.ApiModel; |
| 17 | import io.swagger.annotations.ApiModelProperty; | 9 | import io.swagger.annotations.ApiModelProperty; |
| 10 | +import lombok.Data; | ||
| 18 | import lombok.EqualsAndHashCode; | 11 | import lombok.EqualsAndHashCode; |
| 19 | import lombok.experimental.Accessors; | 12 | import lombok.experimental.Accessors; |
| 13 | +import org.jeecgframework.poi.excel.annotation.Excel; | ||
| 14 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 15 | + | ||
| 16 | +import java.io.Serializable; | ||
| 17 | +import java.math.BigDecimal; | ||
| 18 | +import java.util.Date; | ||
| 20 | 19 | ||
| 21 | /** | 20 | /** |
| 22 | - * @Description: tbl_trade_purchase_info | 21 | + * @Description: tbl_trade_purchase_info 采购 |
| 23 | * @Author: jeecg-boot | 22 | * @Author: jeecg-boot |
| 24 | * @Date: 2025-03-19 | 23 | * @Date: 2025-03-19 |
| 25 | * @Version: V1.0 | 24 | * @Version: V1.0 |
| 1 | package org.jeecg.modules.erp.trade.mapper; | 1 | package org.jeecg.modules.erp.trade.mapper; |
| 2 | 2 | ||
| 3 | -import java.util.List; | ||
| 4 | - | 3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 5 | import org.apache.ibatis.annotations.Param; | 4 | import org.apache.ibatis.annotations.Param; |
| 6 | import org.jeecg.modules.erp.trade.entity.TblTradeInventory; | 5 | import org.jeecg.modules.erp.trade.entity.TblTradeInventory; |
| 7 | -import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 6 | +import org.jeecg.modules.erp.trade.entity.TblTradeInventoryUpdateBoh; |
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 8 | 9 | ||
| 9 | /** | 10 | /** |
| 10 | * @Description: 贸易库存表 | 11 | * @Description: 贸易库存表 |
| @@ -15,4 +16,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | @@ -15,4 +16,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
| 15 | public interface TblTradeInventoryMapper extends BaseMapper<TblTradeInventory> { | 16 | public interface TblTradeInventoryMapper extends BaseMapper<TblTradeInventory> { |
| 16 | 17 | ||
| 17 | Integer getInventoryNum(@Param("materialCode") String materialCode); | 18 | Integer getInventoryNum(@Param("materialCode") String materialCode); |
| 19 | + | ||
| 20 | + void updateBohAndActualBatch(@Param("list")List<TblTradeInventoryUpdateBoh> list); | ||
| 21 | + void updateBohAndActual(TblTradeInventoryUpdateBoh list); | ||
| 18 | } | 22 | } |
| 1 | package org.jeecg.modules.erp.trade.mapper; | 1 | package org.jeecg.modules.erp.trade.mapper; |
| 2 | 2 | ||
| 3 | -import java.util.List; | ||
| 4 | - | 3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 5 | import org.apache.ibatis.annotations.Param; | 4 | import org.apache.ibatis.annotations.Param; |
| 6 | import org.jeecg.modules.erp.trade.entity.TblTradeInventoryOut; | 5 | import org.jeecg.modules.erp.trade.entity.TblTradeInventoryOut; |
| 7 | -import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
| 8 | 6 | ||
| 9 | /** | 7 | /** |
| 10 | * @Description: tbl_trade_inventory_out | 8 | * @Description: tbl_trade_inventory_out |
| @@ -14,5 +12,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | @@ -14,5 +12,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
| 14 | */ | 12 | */ |
| 15 | public interface TblTradeInventoryOutMapper extends BaseMapper<TblTradeInventoryOut> { | 13 | public interface TblTradeInventoryOutMapper extends BaseMapper<TblTradeInventoryOut> { |
| 16 | 14 | ||
| 17 | - Integer getOutboundQuantityByMaterialCode(@Param("materialCode")String meterialCode); | 15 | + Integer getOutboundQuantityByMaterialCode(@Param("materialCode")String materialCode); |
| 18 | } | 16 | } |
| 1 | package org.jeecg.modules.erp.trade.mapper; | 1 | package org.jeecg.modules.erp.trade.mapper; |
| 2 | 2 | ||
| 3 | -import java.util.List; | ||
| 4 | - | 3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 5 | import org.apache.ibatis.annotations.Param; | 4 | import org.apache.ibatis.annotations.Param; |
| 6 | import org.jeecg.modules.erp.trade.entity.TblTradePurchaseInfo; | 5 | import org.jeecg.modules.erp.trade.entity.TblTradePurchaseInfo; |
| 7 | -import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
| 8 | 6 | ||
| 9 | /** | 7 | /** |
| 10 | * @Description: tbl_trade_purchase_info | 8 | * @Description: tbl_trade_purchase_info |
| @@ -16,8 +14,8 @@ public interface TblTradePurchaseInfoMapper extends BaseMapper<TblTradePurchaseI | @@ -16,8 +14,8 @@ public interface TblTradePurchaseInfoMapper extends BaseMapper<TblTradePurchaseI | ||
| 16 | 14 | ||
| 17 | Integer getPurchaseQuantityNumByMaterialCode(@Param("materialCode")String materialCode); | 15 | Integer getPurchaseQuantityNumByMaterialCode(@Param("materialCode")String materialCode); |
| 18 | 16 | ||
| 19 | - Integer getYrkNumByMaterialCode(@Param("materialCode")String meterialCode); | 17 | + Integer getYrkNumByMaterialCode(@Param("materialCode")String materialCode); |
| 20 | 18 | ||
| 21 | - Integer getWrkNum(@Param("materialCode")String meterialCode); | 19 | + Integer getWrkNum(@Param("materialCode")String materialCode); |
| 22 | 20 | ||
| 23 | } | 21 | } |
| @@ -5,4 +5,23 @@ | @@ -5,4 +5,23 @@ | ||
| 5 | <select id="getInventoryNum" resultType="java.lang.Integer"> | 5 | <select id="getInventoryNum" resultType="java.lang.Integer"> |
| 6 | select sum(actual_inventory) from tbl_trade_inventory where material_code = #{materialCode} | 6 | select sum(actual_inventory) from tbl_trade_inventory where material_code = #{materialCode} |
| 7 | </select> | 7 | </select> |
| 8 | + <update id="updateBohAndActualBatch" parameterType="java.util.ArrayList"> | ||
| 9 | + update tbl_trade_inventory | ||
| 10 | + set inventory_boh = CASE | ||
| 11 | + <foreach collection="list" item="item"> | ||
| 12 | + WHEN material_code = #{item.materialCode} AND material_description = #{item.materialDescription} | ||
| 13 | + THEN #{item.inventoryBoh} | ||
| 14 | + </foreach> | ||
| 15 | + END, | ||
| 16 | + actual_inventory = CASE | ||
| 17 | + <foreach collection="list" item="item"> | ||
| 18 | + WHEN material_code = #{item.materialCode} AND material_description = #{item.materialDescription} | ||
| 19 | + THEN #{item.inventoryBoh} | ||
| 20 | + </foreach> | ||
| 21 | + END | ||
| 22 | + </update> | ||
| 23 | + <update id="updateBohAndActual" parameterType="org.jeecg.modules.erp.trade.entity.TblTradeInventoryUpdateBoh"> | ||
| 24 | + update tbl_trade_inventory set inventory_boh = #{inventoryBoh} ,actual_inventory = #{inventoryBoh} | ||
| 25 | + where material_code = #{materialCode} AND material_description = #{materialDescription} | ||
| 26 | + </update> | ||
| 8 | </mapper> | 27 | </mapper> |
| @@ -11,5 +11,5 @@ import org.jeecg.modules.erp.trade.entity.TblTradeInventoryOut; | @@ -11,5 +11,5 @@ import org.jeecg.modules.erp.trade.entity.TblTradeInventoryOut; | ||
| 11 | */ | 11 | */ |
| 12 | public interface ITblTradeInventoryOutService extends IService<TblTradeInventoryOut> { | 12 | public interface ITblTradeInventoryOutService extends IService<TblTradeInventoryOut> { |
| 13 | 13 | ||
| 14 | - Integer getOutboundQuantityByMaterialCode(String meterialCode); | 14 | + Integer getOutboundQuantityByMaterialCode(String materialCode); |
| 15 | } | 15 | } |
| 1 | package org.jeecg.modules.erp.trade.service; | 1 | package org.jeecg.modules.erp.trade.service; |
| 2 | 2 | ||
| 3 | -import org.jeecg.modules.erp.trade.entity.TblTradeInventory; | ||
| 4 | import com.baomidou.mybatisplus.extension.service.IService; | 3 | import com.baomidou.mybatisplus.extension.service.IService; |
| 4 | +import org.jeecg.modules.erp.trade.entity.TblTradeInventory; | ||
| 5 | +import org.jeecg.modules.erp.trade.entity.TblTradeInventoryUpdateBoh; | ||
| 6 | + | ||
| 7 | +import java.util.List; | ||
| 5 | 8 | ||
| 6 | /** | 9 | /** |
| 7 | * @Description: 贸易库存表 | 10 | * @Description: 贸易库存表 |
| @@ -12,4 +15,6 @@ import com.baomidou.mybatisplus.extension.service.IService; | @@ -12,4 +15,6 @@ import com.baomidou.mybatisplus.extension.service.IService; | ||
| 12 | public interface ITblTradeInventoryService extends IService<TblTradeInventory> { | 15 | public interface ITblTradeInventoryService extends IService<TblTradeInventory> { |
| 13 | 16 | ||
| 14 | Integer getInventoryNum(String materialCode); | 17 | Integer getInventoryNum(String materialCode); |
| 18 | + void updateBohAndActualBatch(List<TblTradeInventoryUpdateBoh> list); | ||
| 19 | + void updateBohAndActual(TblTradeInventoryUpdateBoh tblTradeInventoryUpdateBoh); | ||
| 15 | } | 20 | } |
| @@ -13,7 +13,7 @@ public interface ITblTradePurchaseInfoService extends IService<TblTradePurchaseI | @@ -13,7 +13,7 @@ public interface ITblTradePurchaseInfoService extends IService<TblTradePurchaseI | ||
| 13 | 13 | ||
| 14 | Integer getPurchaseQuantityNumByMaterialCode(String materialCode); | 14 | Integer getPurchaseQuantityNumByMaterialCode(String materialCode); |
| 15 | 15 | ||
| 16 | - Integer getYrkNumByMaterialCode(String meterialCode); | 16 | + Integer getYrkNumByMaterialCode(String materialCode); |
| 17 | 17 | ||
| 18 | - Integer getWrkNum(String meterialCode); | 18 | + Integer getWrkNum(String materialCode); |
| 19 | } | 19 | } |
| @@ -20,7 +20,7 @@ public class TblTradeInventoryOutServiceImpl extends ServiceImpl<TblTradeInvento | @@ -20,7 +20,7 @@ public class TblTradeInventoryOutServiceImpl extends ServiceImpl<TblTradeInvento | ||
| 20 | @Autowired | 20 | @Autowired |
| 21 | private TblTradeInventoryOutMapper tblTradeInventoryOutMapper; | 21 | private TblTradeInventoryOutMapper tblTradeInventoryOutMapper; |
| 22 | @Override | 22 | @Override |
| 23 | - public Integer getOutboundQuantityByMaterialCode(String meterialCode) { | ||
| 24 | - return tblTradeInventoryOutMapper.getOutboundQuantityByMaterialCode(meterialCode); | 23 | + public Integer getOutboundQuantityByMaterialCode(String materialCode) { |
| 24 | + return tblTradeInventoryOutMapper.getOutboundQuantityByMaterialCode(materialCode); | ||
| 25 | } | 25 | } |
| 26 | } | 26 | } |
| 1 | package org.jeecg.modules.erp.trade.service.impl; | 1 | package org.jeecg.modules.erp.trade.service.impl; |
| 2 | 2 | ||
| 3 | import org.jeecg.modules.erp.trade.entity.TblTradeInventory; | 3 | import org.jeecg.modules.erp.trade.entity.TblTradeInventory; |
| 4 | +import org.jeecg.modules.erp.trade.entity.TblTradeInventoryUpdateBoh; | ||
| 4 | import org.jeecg.modules.erp.trade.mapper.TblTradeInventoryMapper; | 5 | import org.jeecg.modules.erp.trade.mapper.TblTradeInventoryMapper; |
| 5 | import org.jeecg.modules.erp.trade.service.ITblTradeInventoryService; | 6 | import org.jeecg.modules.erp.trade.service.ITblTradeInventoryService; |
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -8,6 +9,8 @@ import org.springframework.stereotype.Service; | @@ -8,6 +9,8 @@ import org.springframework.stereotype.Service; | ||
| 8 | 9 | ||
| 9 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 10 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| 10 | 11 | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 11 | /** | 14 | /** |
| 12 | * @Description: 贸易库存表 | 15 | * @Description: 贸易库存表 |
| 13 | * @Author: jeecg-boot | 16 | * @Author: jeecg-boot |
| @@ -23,4 +26,14 @@ public class TblTradeInventoryServiceImpl extends ServiceImpl<TblTradeInventoryM | @@ -23,4 +26,14 @@ public class TblTradeInventoryServiceImpl extends ServiceImpl<TblTradeInventoryM | ||
| 23 | public Integer getInventoryNum(String materialCode) { | 26 | public Integer getInventoryNum(String materialCode) { |
| 24 | return tblTradeInventoryMapper.getInventoryNum(materialCode); | 27 | return tblTradeInventoryMapper.getInventoryNum(materialCode); |
| 25 | } | 28 | } |
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public void updateBohAndActualBatch(List<TblTradeInventoryUpdateBoh> list) { | ||
| 32 | + tblTradeInventoryMapper.updateBohAndActualBatch(list); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public void updateBohAndActual(TblTradeInventoryUpdateBoh tblTradeInventoryUpdateBoh) { | ||
| 37 | + tblTradeInventoryMapper.updateBohAndActual(tblTradeInventoryUpdateBoh); | ||
| 38 | + } | ||
| 26 | } | 39 | } |
| @@ -24,12 +24,12 @@ public class TblTradePurchaseInfoServiceImpl extends ServiceImpl<TblTradePurchas | @@ -24,12 +24,12 @@ public class TblTradePurchaseInfoServiceImpl extends ServiceImpl<TblTradePurchas | ||
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | @Override | 26 | @Override |
| 27 | - public Integer getYrkNumByMaterialCode(String meterialCode) { | ||
| 28 | - return tblTradePurchaseInfoMapper.getYrkNumByMaterialCode(meterialCode); | 27 | + public Integer getYrkNumByMaterialCode(String materialCode) { |
| 28 | + return tblTradePurchaseInfoMapper.getYrkNumByMaterialCode(materialCode); | ||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | @Override | 31 | @Override |
| 32 | - public Integer getWrkNum(String meterialCode) { | ||
| 33 | - return tblTradePurchaseInfoMapper.getWrkNum(meterialCode); | 32 | + public Integer getWrkNum(String materialCode) { |
| 33 | + return tblTradePurchaseInfoMapper.getWrkNum(materialCode); | ||
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| 1 | package org.jeecg.modules.erp.trade.service.impl; | 1 | package org.jeecg.modules.erp.trade.service.impl; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | -import cn.hutool.core.collection.ListUtil; | ||
| 5 | import cn.hutool.core.date.DatePattern; | 4 | import cn.hutool.core.date.DatePattern; |
| 6 | -import cn.hutool.core.date.DateUtil; | ||
| 7 | import cn.hutool.core.util.ObjectUtil; | 5 | import cn.hutool.core.util.ObjectUtil; |
| 8 | import cn.hutool.core.util.StrUtil; | 6 | import cn.hutool.core.util.StrUtil; |
| 9 | import org.jeecg.modules.erp.trade.entity.*; | 7 | import org.jeecg.modules.erp.trade.entity.*; |
| @@ -110,12 +108,12 @@ public class TblTradeTenderInfoServiceImpl extends ServiceImpl<TblTradeTenderInf | @@ -110,12 +108,12 @@ public class TblTradeTenderInfoServiceImpl extends ServiceImpl<TblTradeTenderInf | ||
| 110 | bidSub.setStatus("0"); | 108 | bidSub.setStatus("0"); |
| 111 | bidSubList.add(bidSub); | 109 | bidSubList.add(bidSub); |
| 112 | // 排除掉库里已有的物料 | 110 | // 排除掉库里已有的物料 |
| 113 | - TblTradeMeterial tradeMeterial = meterialList.stream().filter(i -> StrUtil.equals(i.getMeterialCode(), e.getCode())) | 111 | + TblTradeMeterial tradeMeterial = meterialList.stream().filter(i -> StrUtil.equals(i.getMaterialCode(), e.getCode())) |
| 114 | .findFirst().orElse(null); | 112 | .findFirst().orElse(null); |
| 115 | if (ObjectUtil.isNotNull(tradeMeterial)) return; | 113 | if (ObjectUtil.isNotNull(tradeMeterial)) return; |
| 116 | TblTradeMeterial insertObj = new TblTradeMeterial(); | 114 | TblTradeMeterial insertObj = new TblTradeMeterial(); |
| 117 | - insertObj.setMeterialCode(e.getCode()); | ||
| 118 | - insertObj.setMeterialReview(e.getMiaoshu()); | 115 | + insertObj.setMaterialCode(e.getCode()); |
| 116 | + insertObj.setMaterialReview(e.getMiaoshu()); | ||
| 119 | insertObj.setUnit(e.getJldw()); | 117 | insertObj.setUnit(e.getJldw()); |
| 120 | insertObj.setBrand(e.getPinpai()); | 118 | insertObj.setBrand(e.getPinpai()); |
| 121 | meterialInsertList.add(insertObj); | 119 | meterialInsertList.add(insertObj); |
| @@ -136,9 +136,9 @@ spring: | @@ -136,9 +136,9 @@ spring: | ||
| 136 | connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 | 136 | connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 |
| 137 | datasource: | 137 | datasource: |
| 138 | master: | 138 | master: |
| 139 | - url: jdbc:mysql://192.168.110.10:3306/jeecg?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai | ||
| 140 | - username: root | ||
| 141 | - password: pass#word1 | 139 | + url: jdbc:mysql://127.0.0.1:3306/factory?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai |
| 140 | + username: factory | ||
| 141 | + password: 5wWfCfKZGWhayMK3 | ||
| 142 | driver-class-name: com.mysql.cj.jdbc.Driver | 142 | driver-class-name: com.mysql.cj.jdbc.Driver |
| 143 | # 多数据源配置 | 143 | # 多数据源配置 |
| 144 | #multi-datasource1: | 144 | #multi-datasource1: |
| @@ -149,7 +149,7 @@ spring: | @@ -149,7 +149,7 @@ spring: | ||
| 149 | #redis 配置 | 149 | #redis 配置 |
| 150 | redis: | 150 | redis: |
| 151 | database: 0 | 151 | database: 0 |
| 152 | - host: 192.168.1.199 | 152 | + host: 127.0.0.1 |
| 153 | lettuce: | 153 | lettuce: |
| 154 | pool: | 154 | pool: |
| 155 | max-active: 8 #最大连接数据库连接数,设 -1 为没有限制 | 155 | max-active: 8 #最大连接数据库连接数,设 -1 为没有限制 |
-
请 注册 或 登录 后发表评论