diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java index 0b82d456..b760a777 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java @@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.io.IOException; import java.util.*; +import java.util.concurrent.TimeUnit; /** * @author Dreamchaser @@ -62,6 +63,30 @@ public class MaterialController { } + /** + * 用于在盘点时获取到盘点位置的所有库存 + * + * @param map + * @param request + * @return + */ + @GetMapping("/findInventoryForStockTaking") + public RestResponse findInventoryForStockTaking(@RequestParam Map map, HttpServletRequest request) { + Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId")); + UserByPort userToken = (UserByPort) request.getAttribute("userToken"); + if (Integer.compare(depositoryId, -1) == 0) { + return new RestResponse(null); + } else { + map.put("userTokenId",userToken.getId()); + List inventoryForStockTaking = materialService.findInventoryForStockTaking(map); + return new RestResponse(inventoryForStockTaking,placeService.findPlaceAndMaterialCountByCondition(map),200); + } + } + + + + + /** * 用于查询当前组合中物料的数量 * @@ -118,7 +143,7 @@ public class MaterialController { UserByPort userToken = (UserByPort) request.getAttribute("userToken"); List list = new ArrayList<>(); Integer total = 0; - if(Integer.compare(userToken.getMaindeparment(),361) != 0){ + if (Integer.compare(userToken.getMaindeparment(), 361) != 0) { // 查询当前用户管理的仓库 List depositoryAndRole = roleService.findDepositoryAndRole(userToken.getId()); // 查询当前用户部门拥有的仓库 @@ -204,8 +229,7 @@ public class MaterialController { ) { inventoryP.setSplitInfoList(splitUnitService.findSplitInfoByMid(inventoryP.getMid())); } - } - else{ + } else { list = materialService.findInventory(map); total = materialService.findInventoryCount(map); } @@ -430,7 +454,7 @@ public class MaterialController { depositoryIdList.add(rad.getDepositoryId()); } } - for (Integer depositoryId :depositoryIdList + for (Integer depositoryId : depositoryIdList ) { param.put("depositoryId", depositoryId); List inventoryPS = materialService.findInventory(param); @@ -458,8 +482,7 @@ public class MaterialController { List splitInfoByMid = splitUnitService.findSplitInfoByMid(ip.getMid()); ip.setSplitInfoList(splitInfoByMid); return new RestResponse(ip, 1, 200); - } - else if ("in".equals(type)) { + } else if ("in".equals(type)) { param.put("code", code); materialPByCondition = materialService.findMaterialPByCondition(param); if (materialPByCondition.size() > 0) { @@ -513,8 +536,8 @@ public class MaterialController { depositoryIdList.add(rad.getDepositoryId()); } } - for (Integer depositoryId :depositoryIdList - ) { + for (Integer depositoryId : depositoryIdList + ) { map.put("depositoryId", depositoryId); List inventoryPS = materialService.findInventory(map); inventoryPList.addAll(inventoryPS); @@ -566,7 +589,7 @@ public class MaterialController { } try { // 二维码保存信息 - return RestResponse.CreateBarCode(qrCode,material.getMname()); + return RestResponse.CreateBarCode(qrCode, material.getMname()); } catch (IOException e) { return new RestResponse("err: " + e.getMessage(), 678, new StatusInfo("失败", "请联系开发人员")); } @@ -897,12 +920,12 @@ public class MaterialController { depositoryIdList.add(depository.getId()); } for (RoleAndDepository depository : depositoryAndRole) { - if(!depositoryIdList.contains(depository.getDepositoryId())){ + if (!depositoryIdList.contains(depository.getDepositoryId())) { depositoryIdList.add(depository.getDepositoryId()); } } - for (Integer depositoryId:depositoryIdList){ + for (Integer depositoryId : depositoryIdList) { param.put("mcode", mcode); param.put("depositoryId", depositoryId); // 获取当前仓库下是否有当前物料的库存 @@ -1214,13 +1237,13 @@ public class MaterialController { depositoryIdList.add(depository.getId()); } for (RoleAndDepository depository : depositoryAndRole) { - if(!depositoryIdList.contains(depository.getDepositoryId())){ + if (!depositoryIdList.contains(depository.getDepositoryId())) { depositoryIdList.add(depository.getDepositoryId()); } } List placePList = new ArrayList<>(); - for (Integer depositoryId:depositoryIdList) { + for (Integer depositoryId : depositoryIdList) { Boolean isExist = false; Map param = new HashMap<>(); param.put("depositoryId", depositoryId); @@ -1310,8 +1333,8 @@ public class MaterialController { if (isExist) { materialList.add(mp); } - } else { // 如果当前条形码不存对应物料 + } else { barCodeListByNoMaterial.add(barCode); } } @@ -1516,7 +1539,7 @@ public class MaterialController { // 获取当前物料 InventoryP materialP = inventory.get(0); MaterialAndPlace pm = placeService.findPlaceAndMaterialByMidAndPid(0, materialP.getId()); - if(pm!=null) { + if (pm != null) { Map paramForCode = new HashMap<>(); paramForCode.put("mcode", materialP.getCode()); paramForCode.put("codeFlag", 1); @@ -1526,7 +1549,7 @@ public class MaterialController { materialP.setMaterialAndBarCodeList(materialByBarCodeByCondition); materialP.setBaseUnitQuantity(pm.getQuantity()); return new RestResponse(materialP, 1, 200); - }else { + } else { return new RestResponse("", 0, 200); } } diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/StockTakingController.java b/src/main/java/com/dreamchaser/depository_manage/controller/StockTakingController.java index dc7b9c8a..2de8b57d 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/StockTakingController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/StockTakingController.java @@ -3,6 +3,8 @@ package com.dreamchaser.depository_manage.controller; import com.alibaba.fastjson.JSONObject; import com.dreamchaser.depository_manage.config.PortConfig; +import com.dreamchaser.depository_manage.entity.Inventory; +import com.dreamchaser.depository_manage.entity.MaterialAndPlace; import com.dreamchaser.depository_manage.entity.Place; import com.dreamchaser.depository_manage.entity.UserByPort; import com.dreamchaser.depository_manage.pojo.RestResponse; @@ -14,6 +16,7 @@ import com.dreamchaser.depository_manage.service.PlaceService; import com.dreamchaser.depository_manage.service.StockTakingService; import com.dreamchaser.depository_manage.service.impl.QyWxOperationService; import com.dreamchaser.depository_manage.utils.CrudUtil; +import com.dreamchaser.depository_manage.utils.DateUtil; import com.dreamchaser.depository_manage.utils.Md5; import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -21,10 +24,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; /** @@ -277,9 +277,8 @@ public class StockTakingController { String minIds = (String) map.get("minIds"); String[] split = minIds.split(","); List minIdList = new ArrayList<>(); - for (int i = 0; i < split.length; i++) { - String s = split[i]; - if("".equals(s)){ + for (String s : split) { + if ("".equals(s)) { continue; } minIdList.add(ObjectFormatUtil.toInteger(s)); @@ -290,4 +289,81 @@ public class StockTakingController { Integer transfer = stockTakingService.stockTakingTransfer(map, userToken,crypt); return CrudUtil.postHandle(transfer,minIdList.size()); } + + @PostMapping("/temporaryStorageForTakingResult") + public void temporaryStorageForTakingResult(@RequestBody Map map,HttpServletRequest request){ + // 获取当前盘点人 + UserByPort userToken = (UserByPort) request.getAttribute("userToken"); + // 获取当前暂存的结果id + String key = "wms_stockTaking_" + userToken.getId() + "_"+ DateUtil.getNowTime()+"_"+map.get("id"); + map.put("flagForSubmit","false"); + redisTemplateForHash.opsForHash().putAll(key,map); + // 存储到今天的12点 + redisTemplateForHash.expire(key,DateUtil.getSecondsNextEarlyMorning(), TimeUnit.SECONDS); + + } + + + @PostMapping("/submitStockTaking") + public RestResponse submitStockTaking(@RequestBody Map map,HttpServletRequest request){ + UserByPort userToken = (UserByPort) request.getAttribute("userToken"); + + String header = request.getHeader("user-agent"); + String crypt = Md5.crypt(header); + // 获取所有有关当前key的键 + String keyPatten = "wms_stockTaking_"+userToken.getId()+"_"+DateUtil.getNowTime()+"*"; + Set keys = redisTemplateForHash.keys(keyPatten); + int success = 0; + int size = 0; + if (keys != null && keys.size() > 0) { + size = keys.size(); + // 定义用于插入的盘点记录 + Map param = new HashMap<>(); + // 如果存在 + for (String key : keys) { + Boolean flagForSubmit = ObjectFormatUtil.toBoolean(redisTemplateForHash.opsForHash().get(key, "flagForSubmit")); + if(flagForSubmit != null && !flagForSubmit){ + // 如果是第一次提交 + + // 获取盘点时的物料与库位的对应关系id + Integer id = ObjectFormatUtil.toInteger(redisTemplateForHash.opsForHash().get(key, "id")); + // 获取物料与库位的对应关系 + MaterialAndPlace placeAndMaterial = placeService.findPlaceAndMaterialById(id); + + Object unit = redisTemplateForHash.opsForHash().get(key, "unit"); + String takingResult = (String) redisTemplateForHash.opsForHash().get(key, "takingResult"); + Object number = redisTemplateForHash.opsForHash().get(key, "number"); + Object oldInventory = redisTemplateForHash.opsForHash().get(key, "oldInventory"); + Integer newInventory = ObjectFormatUtil.toInteger(oldInventory); + if ("Inventory_down".equals(takingResult)) { + // 如果盘亏 + newInventory -= ObjectFormatUtil.toInteger(number); + + }else if("Inventory_up".equals(takingResult)){ + // 如果盘盈 + newInventory += ObjectFormatUtil.toInteger(number); + } + param.put("newInventory", newInventory); + param.put("depositoryId",map.get("depositoryId")); + param.put("placeId",map.get("placeId")); + param.put("departmentManager",map.get("departmentManager")); + param.put("state",3); + param.put("departmentManagerState",3); + param.put("originator",userToken.getId()); + + param.put("mid", placeAndMaterial.getMid()); + param.put("oldInventory", oldInventory); + + param.put("takingResult", takingResult); + param.put("inventory", number); + param.put("unit",unit); + success += stockTakingService.insertStockTaking(param); + param.remove("id"); + + } + redisTemplateForHash.opsForHash().put(key,"flagForSubmit","true"); + } + } + return CrudUtil.putHandle(success,size); + } } diff --git a/src/main/java/com/dreamchaser/depository_manage/entity/Inventory.java b/src/main/java/com/dreamchaser/depository_manage/entity/Inventory.java index 5136630d..4d1148fc 100644 --- a/src/main/java/com/dreamchaser/depository_manage/entity/Inventory.java +++ b/src/main/java/com/dreamchaser/depository_manage/entity/Inventory.java @@ -1,5 +1,6 @@ package com.dreamchaser.depository_manage.entity; +import com.dreamchaser.depository_manage.pojo.MaterialAndPlaceForView; import lombok.Data; import java.util.List; @@ -150,4 +151,27 @@ public class Inventory { * 该物料对应的拆单记录 */ private List splitInfoList; + + + public Inventory() { + } + + public Inventory(MaterialAndPlaceForView mpv) { + this.id = mpv.getIid(); + this.mid = mpv.getMid(); + this.mname = mpv.getMname(); + this.code = mpv.getMcode(); + this.materialTypeId = Long.valueOf(mpv.getType_id()); + this.typeName = mpv.getTname(); + this.version = mpv.getVersion(); + this.quantity = mpv.getInventory(); + } + + public Inventory(MaterialAndPlace mp) { + this.id = mp.getMid(); + this.quantity = mp.getQuantity(); + } + + + } diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.java b/src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.java index dd99cc1d..2c3d2257 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.java +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.java @@ -143,6 +143,19 @@ public interface PlaceMapper { */ List findPlaceAndMaterialByDidAndMid(Map map); + /** + * 根据条件获取对应库位存储的物料 + * @param map 待查询条件 + * @return + */ + List findPlaceAndMaterialByCondition(Map map); + + /** + * 根据条件获取对应库位存储的物料数量 + * @param map 待查询条件 + * @return + */ + Integer findPlaceAndMaterialCountByCondition(Map map); /** * 根据当前库位编号及物料编号获取具体库位 */ diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml b/src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml index 20bb1ade..9854eb80 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/PlaceMapper.xml @@ -115,6 +115,48 @@ and pstate != 3 + + + + + + \ No newline at end of file diff --git a/src/main/java/com/dreamchaser/depository_manage/pojo/MaterialAndPlaceForView.java b/src/main/java/com/dreamchaser/depository_manage/pojo/MaterialAndPlaceForView.java index 0c1b8d3d..087cefb0 100644 --- a/src/main/java/com/dreamchaser/depository_manage/pojo/MaterialAndPlaceForView.java +++ b/src/main/java/com/dreamchaser/depository_manage/pojo/MaterialAndPlaceForView.java @@ -1,7 +1,11 @@ package com.dreamchaser.depository_manage.pojo; +import com.dreamchaser.depository_manage.entity.SplitInfo; import lombok.Data; +import java.util.List; +import java.util.Map; + @Data public class MaterialAndPlaceForView { /** @@ -82,5 +86,40 @@ public class MaterialAndPlaceForView { private String mname; + /** + * 盘点数量 + */ + private Integer stockTakingQuantity; + + /** + * 盘点结果 + */ + private String takingResult; + + /** + * 盈亏数量 + */ + private String takingInventory; + + /** + * 盘点结果(用于展示) + */ + private String takingResultString; + + /** + * 盘点单位 + */ + private String takingUnit; + + /** + * 拆单单位 + */ + private List splitInfoList; + + /** + * 对应库存 + */ + private Map splitInventory; + } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java b/src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java index 9304457c..90d77325 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java @@ -2,6 +2,7 @@ package com.dreamchaser.depository_manage.service; import com.dreamchaser.depository_manage.entity.*; import com.dreamchaser.depository_manage.pojo.InventoryP; +import com.dreamchaser.depository_manage.pojo.MaterialAndPlaceForView; import com.dreamchaser.depository_manage.pojo.MaterialP; import java.util.List; @@ -409,4 +410,12 @@ public interface MaterialService { * @return */ Integer findInventoryCountByDepository(List depositoryIds); + + + /** + * 用于获取当前盘点位置的库存计量 + * @param map 具体条件 + * @return + */ + List findInventoryForStockTaking(Map map); } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/PlaceService.java b/src/main/java/com/dreamchaser/depository_manage/service/PlaceService.java index fbefe6e3..ec288ffb 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/PlaceService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/PlaceService.java @@ -124,6 +124,22 @@ public interface PlaceService { */ List findPlaceAndMaterialByDidAndMid(Integer did, Integer mid); + /** + * 根据条件获取对应库位存储的物料 + * @param map 待查询条件 + * @return + */ + List findPlaceAndMaterialByCondition(Map map); + /** + * 根据条件获取对应库位存储的物料数量 + * @param map 待查询条件 + * @return + */ + Integer findPlaceAndMaterialCountByCondition(Map map); + + + + /** * 根据当前库位编号及物料编号获取具体库位 */ diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java index b5c01ab8..014f5b47 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java @@ -113,7 +113,6 @@ public class ExcelServiceImpl implements ExcelService { } log.info("【导入Excel文件】删除临时文件成功,临时文件路径为:{}", filePath); return ResultVoUtil.returnResultVo(200, readResult, "结果"); -// return ResultVoUtil.success(excelVos); } /** diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java index 8fe35df8..08c176d8 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java @@ -14,6 +14,7 @@ import com.dreamchaser.depository_manage.utils.DateUtil; import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; import lombok.Data; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisOperations; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -2591,6 +2592,87 @@ public class MaterialServiceImpl implements MaterialService { return materialMapper.findInventoryCountByDepository(depositoryIds); } + /** + * 用于获取当前盘点位置的库存计量 + * + * @param map 具体条件 + * @return + */ + @Override + public List findInventoryForStockTaking(Map map) { + Integer size = 10, page = 1; + if (map.containsKey("size")) { + size = ObjectFormatUtil.toInteger(map.get("size")); + map.put("size", size); + } + if (map.containsKey("page")) { + page = ObjectFormatUtil.toInteger(map.get("page")); + map.put("begin", (page - 1) * size); + } + Integer placeId = ObjectFormatUtil.toInteger(map.get("placeId")); + if (Integer.compare(placeId, 0) == 0) { + map.remove("placeId"); + } + List placeAndMaterialByCondition = placeService.findPlaceAndMaterialByCondition(map); + + for (MaterialAndPlaceForView mpv : placeAndMaterialByCondition + ) { + // 获取其对应的拆单记录 + List list = splitUnitMapper.findSplitInfoByMid(mpv.getMid()); + // 用于获取对应的拆单记录库存 + Map splitInventory = new HashMap<>(); + // 获取对应物料 + MaterialAndPlace placeAndMaterial = placeService.findPlaceAndMaterialById(mpv.getId()); + for (SplitInfo si : list + ) { + // 获取当前拆单单位对应的库存数 + int allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterial, si.getId(), 0, true); + splitInventory.put(si.getNewUnit(), allInventoryForSplitInfo); + } + // 创建默认单位的拆单信息 + SplitInfo s = new SplitInfo(); + s.setNewUnit(mpv.getUnit()); + list.add(s); + splitInventory.put(mpv.getUnit(), mpv.getInventory()); + // 设置拆单对应的库存 + mpv.setSplitInventory(splitInventory); + // 设置拆单记录 + mpv.setSplitInfoList(list); + // 定义存储在redis中的hash的key + String key = "wms_stockTaking_" + map.get("userTokenId") + "_" + DateUtil.getNowTime() + "_" + mpv.getId(); + // 获取用于展示的盘点结果 + String takingResultString = (String) redisTemplate.opsForHash().get(key, "takingResultString"); + // 获取盘点结果 + String takingResult = (String) redisTemplate.opsForHash().get(key, "takingResult"); + // 获取盈亏数量 + String number = (String) redisTemplate.opsForHash().get(key, "number"); + // 获取盘点时的计量单位 + String unit = (String) redisTemplate.opsForHash().get(key, "unit"); + // 设置盘点单位 + mpv.setTakingUnit(unit); + // 设置盈亏数量 + if (number != null) { + mpv.setTakingInventory(number); + if ("Inventory_down".equals(takingResult)) { + // 如果盘亏 + mpv.setStockTakingQuantity(splitInventory.get(unit) - ObjectFormatUtil.toInteger(number)); + }else if("Inventory_up".equals(takingResult)){ + // 如果盘盈 + mpv.setStockTakingQuantity(splitInventory.get(unit) + ObjectFormatUtil.toInteger(number)); + }else{ + // 如果正常 + mpv.setStockTakingQuantity(splitInventory.get(unit)); + + } + } + // 设置用于展示的盘点结果 + mpv.setTakingResultString(takingResultString); + // 设置盘点结果 + mpv.setTakingResult(takingResult); + } + return placeAndMaterialByCondition; + } + // 构造树形组件数据模板(通过物料名称搜索) public Map InitTreeMenusForSelectName(MaterialType mt, List children) { if (mt != null) { diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java index 39461ac0..56bf1057 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/PlaceServiceImpl.java @@ -287,6 +287,27 @@ public class PlaceServiceImpl implements PlaceService { return placeMapper.findPlaceAndMaterialByDidAndMid(map); } + /** + * 根据条件获取对应库位存储的物料 + * @param map 待查询条件 + * @return + */ + @Override + public List findPlaceAndMaterialByCondition(Map map) { + return placeMapper.findPlaceAndMaterialByCondition(map); + } + + /** + * 根据条件获取对应库位存储的物料数量 + * @param map 待查询条件 + * @return + */ + @Override + public Integer findPlaceAndMaterialCountByCondition(Map map) { + return placeMapper.findPlaceAndMaterialCountByCondition(map); + } + + /** * 根据当前库位编号及物料编号获取具体库位 */ diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java index 3db447bc..3f1f3de2 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java @@ -362,14 +362,11 @@ public class StockTakingServiceImpl implements StockTakingService { // 获取库位详情 Place placeById = placeMapper.findPlaceById(placeId); Integer depositoryId = mainRecord.getDepositoryId(); - // 获取仓库详情 - Depository depositoryById = depositoryMapper.findDepositoryById(depositoryId); // 获取所有子单 List minRecordList = stockTakingMapper.selectStockTakingChildByMainId(mainId); - for (int i = 0; i < minRecordList.size(); i++) { + for (StockTakingChildP minRecord : minRecordList) { // 获取子单详情 - StockTakingChildP minRecord = minRecordList.get(i); // 获取盘点的物料详情 // 获取当前盘点结果 @@ -393,20 +390,8 @@ public class StockTakingServiceImpl implements StockTakingService { // 根据盘点结果重新计算物料的单价 - // 数据库中的总额 - Double amounts = (inventoryById.getAmounts() / 100); Integer newInventory = minRecord.getNewInventory(); - Double avgPrice = 0.0; - if (Integer.compare(newInventory, 0) != 0) { - // 如果新的库存不是0 - - // 新的均价 - avgPrice = (amounts / newInventory) * 100; - BigDecimal bg = new BigDecimal(avgPrice); - avgPrice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - } - inventoryById.setPrice(avgPrice); // 获取当前库位上物料数量 Integer oldQuantity = inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity(); @@ -415,9 +400,9 @@ public class StockTakingServiceImpl implements StockTakingService { // 用于计算新的库位数量 - Integer newNumberForPlace = 0; + int newNumberForPlace = 0; // 用于计算新的库位与物料对应关系的数量 - Integer newNumberForMatrialAndPlace = 0; + int newNumberForMatrialAndPlace = 0; if ("Inventory_up".equals(takingResult)) { // 如果盘盈 @@ -639,8 +624,6 @@ public class StockTakingServiceImpl implements StockTakingService { Long producedDate = minRecord.getProducedDate(); - // 数据库中的总额 - double amounts = (inventoryById.getAmounts() / 100); // 当前盘点数目 Integer newInventory = minRecord.getNewInventory(); @@ -679,18 +662,8 @@ public class StockTakingServiceImpl implements StockTakingService { inventoryById.setQuantity(inventoryById.getQuantity() - oldInventroy + newInventory); } - // 定义平均价格 - Double avgPrice = 0.0; // 获取当前物料数目 Integer quantity = inventoryById.getQuantity(); - if (quantity > 0) { - // 如果当前物料数目不为零 - avgPrice = amounts / quantity; - BigDecimal bg = new BigDecimal(avgPrice); - avgPrice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - } - // 更新物料单价 - inventoryById.setPrice(avgPrice); materialMapper.updateMaterialAndProducedDate(materialAndProducedDate); } else { @@ -701,18 +674,6 @@ public class StockTakingServiceImpl implements StockTakingService { // 获取新的物料数目 int quantity = oldQuantity + newInventory; - // 平均价格 - Double avgPrice = 0.0; - if (Integer.compare(newInventory, 0) != 0) { - // 如果新的库存不是0 - - // 新的均价 - avgPrice = (amounts / (quantity)) * 100; - BigDecimal bg = new BigDecimal(avgPrice); - avgPrice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - } - // 更新物料单价 - inventoryById.setPrice(avgPrice); // 更新物料数目 inventoryById.setQuantity(quantity); @@ -798,7 +759,6 @@ public class StockTakingServiceImpl implements StockTakingService { splitUnitMapper.updateSplitInventory(splitInventory); if (splitInfo.getParentId() != null) { SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); - map.put("price", String.valueOf(inventoryById.getPrice() / 100)); map.put("quantity", String.valueOf(disposeQuantity)); splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, placeAndMaterialByMidAndPid.getId(), map, inventory, splitInfo); } else { @@ -1517,20 +1477,9 @@ public class StockTakingServiceImpl implements StockTakingService { // 根据盘点结果重新计算物料的单价 - // 数据库中的总额 - Double amounts = (inventoryById.getAmounts() / 100); + Integer newInventory = minRecord.getNewInventory(); - Double avgPrice = 0.0; - if (Integer.compare(newInventory, 0) != 0) { - // 如果新的库存不是0 - - // 新的均价 - avgPrice = (amounts / newInventory) * 100; - BigDecimal bg = new BigDecimal(avgPrice); - avgPrice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - } - inventoryById.setPrice(avgPrice); // 获取当前库位上物料数量 Integer oldQuantity = inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity(); @@ -2606,22 +2555,10 @@ public class StockTakingServiceImpl implements StockTakingService { // 根据盘点结果重新计算物料的单价 - // 数据库中的总额 - Double amounts = (materialById.getAmounts() / 100); - Integer newInventory = minRecord.getNewInventory(); - Double avgPrice = 0.0; - if (Integer.compare(newInventory, 0) != 0) { - // 如果新的库存不是0 - - // 新的均价 - avgPrice = (amounts / newInventory) * 100; - BigDecimal bg = new BigDecimal(avgPrice); - avgPrice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - } + Integer newInventory = minRecord.getNewInventory(); - materialById.setPrice(avgPrice); // 获取当前库位上物料数量 Integer oldQuantity = materialById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity(); diff --git a/src/main/java/com/dreamchaser/depository_manage/utils/DateUtil.java b/src/main/java/com/dreamchaser/depository_manage/utils/DateUtil.java index 202eb0cf..26f89939 100644 --- a/src/main/java/com/dreamchaser/depository_manage/utils/DateUtil.java +++ b/src/main/java/com/dreamchaser/depository_manage/utils/DateUtil.java @@ -170,8 +170,7 @@ public class DateUtil { public static String getNowTime(){ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); Calendar instance = Calendar.getInstance(); - String format = simpleDateFormat.format(instance.getTime()); - return format; + return simpleDateFormat.format(instance.getTime()); } // 获取本周周一 diff --git a/src/main/resources/templates/pages/stockTaking/stockTaking.html b/src/main/resources/templates/pages/stockTaking/stockTaking.html index f0f4ca18..a5a972d2 100644 --- a/src/main/resources/templates/pages/stockTaking/stockTaking.html +++ b/src/main/resources/templates/pages/stockTaking/stockTaking.html @@ -43,79 +43,76 @@ +
+ + diff --git a/target/classes/templates/pages/material/material-out.html b/target/classes/templates/pages/material/material-out.html index b5494059..87668265 100644 --- a/target/classes/templates/pages/material/material-out.html +++ b/target/classes/templates/pages/material/material-out.html @@ -104,6 +104,9 @@
@@ -83,6 +89,9 @@