Browse Source

修改库存盘点处理功能

lwx_dev
erdanergou 3 years ago
parent
commit
7d06acd38b
  1. 6
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java
  2. 87
      src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java
  3. 33
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  4. 4
      src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java
  5. 258
      src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java

6
src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java

@ -1208,7 +1208,7 @@ public class DepositoryRecordController {
List<String> placeCodes = (List<String>) map.get("placeCodes");
List<String> applyRemarks = (List<String>) map.get("applyRemarks");
List<String> units = (List<String>) map.get("units");
String errMsg = "";
StringBuilder errMsg = new StringBuilder();
Integer id = 0;
if ("in".equals(type)) {
for (int i = 0; i < mids.size(); i++) {
@ -1335,7 +1335,7 @@ public class DepositoryRecordController {
Material materialById = materialService.findMaterialById(mid);
// 获取失败的仓库信息
Depository depositoryRecordById = depositoryService.findDepositoryById(depositoryId);
errMsg += materialById.getMname() + "在" + depositoryRecordById.getDname() + "出库数量为" + quantity + "失败,数量不足;";
errMsg.append(materialById.getMname()).append("在").append(depositoryRecordById.getDname()).append("出库数量为").append(quantity).append("失败,数量不足;");
}
}
Integer finalId = id;
@ -1378,7 +1378,7 @@ public class DepositoryRecordController {
}
if (success < mids.size()) {
// 如果申请成功数量小于申请数量
return new RestResponse(errMsg, 1234, new StatusInfo("出库失败", "数量不足"));
return new RestResponse(errMsg.toString(), 1234, new StatusInfo("出库失败", "数量不足"));
}
return CrudUtil.postHandle(success, mids.size());
}

87
src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java

@ -16,6 +16,7 @@ import java.util.Map;
public interface DepositoryRecordService {
/**
* 提交申请插入一条仓库调度记录
*
* @param map 仓库调度信息
* @return 受影响的行数
*/
@ -23,6 +24,7 @@ public interface DepositoryRecordService {
/**
* 插入一条入库记录
*
* @param map
* @return
*/
@ -30,6 +32,7 @@ public interface DepositoryRecordService {
/**
* 转移申请
*
* @param map 仓库调度信息
* @return 受影响的行数
*/
@ -38,6 +41,7 @@ public interface DepositoryRecordService {
/**
* 出库审核申请
*
* @param map 仓库调度信息
* @return 受影响的行数
*/
@ -45,6 +49,7 @@ public interface DepositoryRecordService {
/**
* 入库审核申请
*
* @param map 仓库调度信息
* @return 受影响的行数
*/
@ -53,6 +58,7 @@ public interface DepositoryRecordService {
/**
* 用于企业微信的审核申请处理
*
* @param templateCard
* @return
*/
@ -61,6 +67,7 @@ public interface DepositoryRecordService {
/**
* 根据id修改仓库调度记录
*
* @param map 参数map
* @return 受影响的行数
*/
@ -68,6 +75,7 @@ public interface DepositoryRecordService {
/**
* 根据id主键查询数据
*
* @param id id
* @return 该id的数据记录
*/
@ -75,12 +83,14 @@ public interface DepositoryRecordService {
/**
* 查找所有仓库调度记录
*
* @return 所有的仓库调度记录集合
*/
List<DepositoryRecord> findDepositoryRecordAll();
/**
* 根据条件查询仓库调度记录同时支持分页查询需要begin和size参数
*
* @param map 查询参数
* @return 符合条件的仓库调度记录集合
*/
@ -89,6 +99,7 @@ public interface DepositoryRecordService {
/**
* 根据条件查询入库记录同时支持分页查询
*
* @param map
* @return
*/
@ -97,6 +108,7 @@ public interface DepositoryRecordService {
/**
* 查询当前用户入库记录及其管理仓库的入库记录
*
* @param userByPort 待查询用户
* @param map 查询条件
* @return
@ -105,16 +117,16 @@ public interface DepositoryRecordService {
/**
* 查询当前用户入库记录及其管理仓库的入库记录数目
*
* @param map 查询条件
* @return
*/
Integer findApplicationInRecordPCountByUser(UserByPort userByPort, Map<String, Object> map);
/**
* 查询当前用户出库记录及其管理仓库的出库记录
*
* @param userByPort 待查询用户
* @param map 查询条件
* @return
@ -123,6 +135,7 @@ public interface DepositoryRecordService {
/**
* 查询当前用户出库记录及其管理仓库的出库记录数目
*
* @param map 查询条件
* @return
*/
@ -131,6 +144,7 @@ public interface DepositoryRecordService {
/**
* 根据条件查询出库记录同时支持分页查询
*
* @param map
* @return
*/
@ -139,6 +153,7 @@ public interface DepositoryRecordService {
/**
* 查询当前仓库的入库记录
*
* @param depositoryId 待查询仓库id
* @return
*/
@ -146,6 +161,7 @@ public interface DepositoryRecordService {
/**
* 查询当前仓库的出库记录
*
* @param depositoryId 待查询仓库id
* @return
*/
@ -154,6 +170,7 @@ public interface DepositoryRecordService {
/**
* 根据条件查询出库记录数目
*
* @param map
* @return
*/
@ -161,6 +178,7 @@ public interface DepositoryRecordService {
/**
* 根据id查询出库申请
*
* @param id
* @return
*/
@ -168,12 +186,15 @@ public interface DepositoryRecordService {
/**
* 根据条件查询入库记录数目
*
* @param map
* @return
*/
Integer findApplicationInRecordPCountByCondition(Map<String, Object> map);
/**
* 根据条件查询自己的任务根据isDone来决定查询已完成或者未完成的任务同时支持分页查询需要begin和size参数
*
* @param map 查询参数
* @return 我的任务
*/
@ -181,6 +202,7 @@ public interface DepositoryRecordService {
/**
* 根据条件查询自己的任务根据isDone来决定查询已完成或者未完成的任务同时支持分页查询需要begin和size参数
*
* @param map 查询参数
* @return 我的任务
*/
@ -189,13 +211,15 @@ public interface DepositoryRecordService {
/**
* 根据id删除仓库记录
* @return 受影响的行数
*
* @param id
* @return 受影响的行数
*/
Integer deleteDepositoryRecordById(Integer id);
/**
* 根据id集合删除多条仓库记录
*
* @param list id集合
* @return 受影响的行数
*/
@ -203,29 +227,35 @@ public interface DepositoryRecordService {
/**
* 返回该表的总条数
*
* @return 条数
*/
Integer findCount();
/**
* 返回该我的任务数完成或者未完成
*
* @return 条数
*/
Integer findMyTaskCount(Map<String, Object> map);
/**
* 返回该我的任务数完成或者未完成
*
* @return 条数
*/
Integer findMyTaskOutCount(Map<String, Object> map);
/**
* 返回该我的任务数完成或者未完成
*
* @return 条数
*/
Integer findMyTaskInCount(Map<String, Object> map);
/**
* 根据查询条件返回该表的总条数
*
* @param map 条件参数
* @return 条数
*/
@ -234,22 +264,28 @@ public interface DepositoryRecordService {
/**
* 计算物料总数
*
* @return
*/
Double CalculateAllCount(Integer type, String state);
/**
* 计算物料总额
*
* @return
*/
Double CalculateAllPrice(Integer type, String state);
/**
* 计算入库物料总额
*
* @return
*/
Map<String, Object> CalculateAllApplicationInAll(List<Integer> list);
/**
* 计算出库物料总额
*
* @return
*/
Double CalculateAllApplicationOutPrice(String state);
@ -264,6 +300,7 @@ public interface DepositoryRecordService {
* @return
*/
Double findDepositoryRecordByDate(Long end, Long start, Integer type, Integer depositoryId);
/**
* 获取一段时间内的库存额度
*
@ -274,6 +311,7 @@ public interface DepositoryRecordService {
* @return
*/
Integer findApplicationRecordByDate(Long end, Long start, Integer type, Integer depositoryId);
/**
* 获取一段时间内的入库额度
*
@ -293,14 +331,18 @@ public interface DepositoryRecordService {
* @return
*/
Integer findApplicationOutRecordByDate(Long end, Long start, Integer depositoryId);
/**
* 根据条件获取月份中物料的总额
*
* @param map
* @return
*/
Integer findMaterialCountByMonth(Map<String, Object> map);
/**
* 根据条件获取月份中物料的总额
*
* @param map
* @return
*/
@ -308,6 +350,7 @@ public interface DepositoryRecordService {
/**
* 根据条件获取月份中物料的总额
*
* @param map 条件
* @return
*/
@ -315,12 +358,14 @@ public interface DepositoryRecordService {
/**
* 查询仓库当天流水
*
* @return
*/
Integer findWarehouseRecord(Map<String, Object> map);
/**
* 根据id查询入库记录
*
* @param id
* @return
*/
@ -328,13 +373,15 @@ public interface DepositoryRecordService {
/**
* 根据id删除入库记录
* @return 受影响的行数
*
* @param id
* @return 受影响的行数
*/
Integer deleteApplicationInRecordById(Integer id, UserByPort userToken, String userAgent);
/**
* 根据id集合删除多条入库记录
*
* @param list id集合
* @return 受影响的行数
*/
@ -342,6 +389,7 @@ public interface DepositoryRecordService {
/**
* 插入一条出库记录
*
* @param map
* @return
*/
@ -350,13 +398,15 @@ public interface DepositoryRecordService {
/**
* 根据id删除出库记录
* @return 受影响的行数
*
* @param id
* @return 受影响的行数
*/
Integer deleteApplicationOutRecordById(Integer id, UserByPort userToken);
/**
* 根据id集合删除多条出库记录
*
* @param list id集合
* @return 受影响的行数
*/
@ -365,11 +415,14 @@ public interface DepositoryRecordService {
/**
* 计算入库物料总数
*
* @return
*/
Map<String, Object> CalculateAllApplicationInCount(List<Integer> list);
/**
* 计算出库物料总数
*
* @return
*/
Map<String, Object> CalculateAllApplicationOutCount(String state, List<Integer> list);
@ -377,6 +430,7 @@ public interface DepositoryRecordService {
/**
* 将物料入库到库位
*
* @param map
* @return
*/
@ -393,6 +447,7 @@ public interface DepositoryRecordService {
/**
* 将刚入库的记录删除
*
* @param map
* @return
*/
@ -401,6 +456,7 @@ public interface DepositoryRecordService {
/**
* 插入一条出库子订单
*
* @param map
* @return
*/
@ -409,6 +465,7 @@ public interface DepositoryRecordService {
/**
* 根据主表获取所有子表
*
* @param id
* @return
*/
@ -416,6 +473,7 @@ public interface DepositoryRecordService {
/**
* 根据主键获取子表信息
*
* @param id
* @return
*/
@ -423,6 +481,7 @@ public interface DepositoryRecordService {
/**
* 根据条件获取子订单
*
* @param map
* @return
*/
@ -430,6 +489,7 @@ public interface DepositoryRecordService {
/**
* 根据主订单获取子订单
*
* @param parentId
* @return
*/
@ -438,6 +498,7 @@ public interface DepositoryRecordService {
/**
* 完成对应的子订单
*
* @param map
* @param userByPort
* @return
@ -446,6 +507,7 @@ public interface DepositoryRecordService {
/**
* 用于企业微信物料出库审批处理
*
* @param mainId 主表id
* @param userAgent 加密后的user-agent
* @param approvalInfo_details 审批详情
@ -456,6 +518,7 @@ public interface DepositoryRecordService {
/**
* 判断当前出库记录运行状态否可以直接删除
*
* @param id
* @return
*/
@ -463,6 +526,7 @@ public interface DepositoryRecordService {
/**
* 根据主键查询转移记录
*
* @param id
* @return
*/
@ -471,6 +535,7 @@ public interface DepositoryRecordService {
/**
* 用于企业微信的物料入库审批处理
*
* @param mainId 需要进行审批的单号
* @param approvalInfo_details 审批详情
* @param userAgent 加密后的user-agent
@ -480,4 +545,16 @@ public interface DepositoryRecordService {
void reviewByQyWxApprovalIn(String mainId, ApprovalInfo_Details approvalInfo_details, String userAgent, String spStatus, String spNo);
/**
* 用于有父级拆单记录的出库处理
*
* @param splitInfo 父级拆单记录
* @param materialAndPlace 当前库存记录
* @param quantity 当前出库总量
* @param nowQuantity 当前未出库数量
* @param realSplitInfo 实际出库的拆单记录
* @return
*/
RestResponse updateOutSplitInventoryInfo(SplitInfo splitInfo, MaterialAndPlace materialAndPlace, int quantity, int nowQuantity, SplitInfo realSplitInfo);
}

33
src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java

@ -1114,7 +1114,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功"));
} else {
}
else {
// 如果不能满足需求
// 获取对应的拆单记录
@ -1158,7 +1159,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
}
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent);
} else {
}
else {
// 如果当前拆单没有父级
@ -1243,7 +1245,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
restResponse.setData("");
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足"));
}
} else {
}
else {
// 如果大于
// 获取库存重要减少的数量
@ -1416,7 +1419,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @param realSplitInfo 实际出库的拆单记录
* @return
*/
RestResponse updateOutSplitInventoryInfo(SplitInfo splitInfo, MaterialAndPlace materialAndPlace, int quantity, int nowQuantity, SplitInfo realSplitInfo) {
public RestResponse updateOutSplitInventoryInfo(SplitInfo splitInfo, MaterialAndPlace materialAndPlace, int quantity, int nowQuantity, SplitInfo realSplitInfo) {
// 定义返回值
RestResponse restResponse = new RestResponse();
// 用于获取当前拆单记录对应的拆单库存记录
@ -4105,13 +4108,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 根据入库的物料id与仓库id获取库存记录
Inventory inventory = materialMapper.findInventoryByMidAndDid(paramForMidAndDid);
// 查询当前物料与库位的映射关系
Map<String, Object> paramForMaterialAndPlace = new HashMap<>();
paramForMaterialAndPlace.put("mid", inventory.getId());
paramForMaterialAndPlace.put("pid", placeId);
MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace);
if (unit.equals(material.getUnit())) {
// 如果存在库存记录
@ -4119,16 +4122,17 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Place place = placeMapper.findPlaceById(placeId);
if (placeAndMaterialByMidAndPid != null) {
// 修改当前库存记录
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - quantity);
place.setQuantity(place.getQuantity() - quantity);
inventory.setQuantity(inventory.getQuantity() - quantity);
placeAndMaterialByMidAndPid.setQuantity(Math.max(placeAndMaterialByMidAndPid.getQuantity() - quantity, 0));
place.setQuantity(Math.max(place.getQuantity() - quantity, 0));
inventory.setQuantity(Math.max(inventory.getQuantity() - quantity,0));
materialMapper.updateInventory(inventory);
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
placeMapper.UpdatePlace(place);
}
} else {
}
else {
// 如果不是基础单位
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("newUnit", unit);
@ -4150,7 +4154,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (splitInventory.getSaveQuantity() >= quantity) {
// 如果当前待处理数目可以满足需求
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - quantity);
splitInventory.setSaveQuantity(Math.max(splitInventory.getSaveQuantity() - quantity,0));
// 修改库存处理记录
splitUnitMapper.updateSplitInventory(splitInventory);
@ -4207,7 +4211,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (inventory.getQuantity() >= 1 && flag) {
// 令库存-1
inventory.setQuantity(inventory.getQuantity() - 1);
inventory.setQuantity(Math.max(inventory.getQuantity() - 1,0));
// 修改库存记录
@ -4215,12 +4219,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 修改当前库位存放物料的数量
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - 1);
placeAndMaterialByMidAndPid.setQuantity(Math.max(placeAndMaterialByMidAndPid.getQuantity() - 1,0));
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
// 修改库位数量
Place placeById = placeMapper.findPlaceById(placeId);
placeById.setQuantity(placeById.getQuantity() - 1);
placeById.setQuantity(Math.max(placeById.getQuantity() - 1,0));
placeMapper.UpdatePlace(placeById);
@ -4231,7 +4235,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
splitInventory.setOutQuantity(splitInventory.getOutQuantity() + quantity);
splitUnitMapper.updateSplitInventory(splitInventory);
}
} else {
}
else {
// 如果大于
// 获取库存重要减少的数量

4
src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java

@ -915,8 +915,8 @@ public class MaterialServiceImpl implements MaterialService {
Integer mid = inventory.getId();
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(mid, depositoryId);
StringBuilder placeCode = new StringBuilder();
for (int j = 0; j < placeByMidAndDid.size(); j++) {
placeCode.append(placeByMidAndDid.get(j).getCode()).append(" ");
for (PlaceP placeP : placeByMidAndDid) {
placeCode.append(placeP.getCode()).append(" ");
}
inventory.setPlaceCode(placeCode.toString());
if (inventory.getPrice() != null) {

258
src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java

@ -5,7 +5,9 @@ import com.dreamchaser.depository_manage.config.PortConfig;
import com.dreamchaser.depository_manage.entity.*;
import com.dreamchaser.depository_manage.exception.MyException;
import com.dreamchaser.depository_manage.mapper.*;
import com.dreamchaser.depository_manage.pojo.RestResponse;
import com.dreamchaser.depository_manage.pojo.SimpleStockTakingP;
import com.dreamchaser.depository_manage.pojo.StatusInfo;
import com.dreamchaser.depository_manage.pojo.StockTakingChildP;
import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details;
import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details_Approver;
@ -391,7 +393,6 @@ public class StockTakingServiceImpl implements StockTakingService {
MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace);
// 根据盘点结果重新计算物料的单价
@ -407,8 +408,7 @@ public class StockTakingServiceImpl implements StockTakingService {
int newNumberForPlace = 0;
// 用于计算新的库位与物料对应关系的数量
int newNumberForMatrialAndPlace = 0;
if ("Inventory_up".equals(takingResult))
{
if ("Inventory_up".equals(takingResult)) {
// 如果盘盈
// 更新当前库位数量
@ -432,8 +432,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 更新物料与库位对应关系的数量
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace);
}
else {
} else {
// 如果盘亏
newNumberForPlace = placeById.getQuantity() - inventory;
@ -594,6 +593,8 @@ public class StockTakingServiceImpl implements StockTakingService {
List<StockTakingChildP> minRecordList = stockTakingMapper.selectStockTakingChildByMainId(mainId);
// 遍历当前拆单的子单详情
for (StockTakingChildP minRecord : minRecordList) {
// 获取子单详情
Integer placeId = minRecord.getPid();
@ -605,13 +606,6 @@ public class StockTakingServiceImpl implements StockTakingService {
// 获取当前盘点的计量单位
String unit = minRecord.getUnit();
if ("Inventory_normal".equals(takingResult)) {
// 如果盘点结果正常
continue;
}
// 获取盈亏数量
Integer inventory = minRecord.getInventory();
// 获取盘点物料信息
Inventory inventoryById = materialMapper.findInventoryById(minRecord.getMid());
@ -623,6 +617,20 @@ public class StockTakingServiceImpl implements StockTakingService {
// 获取物料与库位的对应关系
MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace);
String key = "wms_stockTaking_" + userToken.getId() + "_" + DateUtil.getNowTime() + "_" + placeAndMaterialByMidAndPid.getId();
redisTemplate.delete(key);
if ("Inventory_normal".equals(takingResult)) {
// 如果盘点结果正常
continue;
}
// 获取盈亏数量
Integer inventory = minRecord.getInventory();
// 获取判断对应的生产日期
Long producedDate = minRecord.getProducedDate();
@ -667,18 +675,6 @@ public class StockTakingServiceImpl implements StockTakingService {
materialMapper.updateMaterialAndProducedDate(materialAndProducedDate);
}
else {
// 如果没有生产日期
// 获取当前库位以外的物料数量
Integer oldQuantity = inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity();
// 获取新的物料数目
int quantity = oldQuantity + newInventory;
// 更新物料数目
inventoryById.setQuantity(quantity);
}
// 用于计算新的库位数量
int newNumberForPlace = 0;
@ -706,13 +702,13 @@ public class StockTakingServiceImpl implements StockTakingService {
continue;
}
inventoryById.setQuantity(inventoryById.getQuantity() + inventory);
newNumberForMatrialAndPlace = placeAndMaterialByMidAndPid.getQuantity() + inventory;
// 更新物料与库位对应关系的数量
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace);
}
else {
} else {
// 如果是拆单单位
@ -759,8 +755,7 @@ public class StockTakingServiceImpl implements StockTakingService {
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + disposeQuantity);
}
}
else {
} else {
// 如果不需要进位
// 修改当前库存
@ -768,8 +763,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 修改拆单库存
splitUnitMapper.updateSplitInventory(splitInventory);
}
}
else{
} else {
// 如果不存在拆单库存记录
Map<String, Object> paramForUpdateSplitInventory = new HashMap<>();
@ -785,10 +779,8 @@ public class StockTakingServiceImpl implements StockTakingService {
}
}
}
}
else {
} else {
// 如果盘亏
if ("-1".equals(unit) || inventoryById.getUnit().equals(minRecord.getUnit())) {
@ -810,11 +802,11 @@ public class StockTakingServiceImpl implements StockTakingService {
newNumberForMatrialAndPlace = 0;
}
inventoryById.setQuantity(inventoryById.getQuantity() - inventory);
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace);
}
else {
} else {
// 如果是拆单单位
// 用于查找对应的拆单记录
Map<String, Object> paramForSplitInfo = new HashMap<>();
@ -828,23 +820,128 @@ public class StockTakingServiceImpl implements StockTakingService {
if (splitInventory != null) {
// 如果存在拆单记录
if (splitInventory.getSaveQuantity() - inventory > 0) {
// 如果当前数量没有下溢
if (splitInventory.getSaveQuantity() - inventory >= 0) {
// 如果单纯的拆单库存满足数量
// 设置当前拆单库存的数量
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - inventory);
// 修改拆单库存
splitUnitMapper.updateSplitInventory(splitInventory);
}
else {
// 如果发生下溢
} else {
// 拆单库存如果不能满足
// 获取当前拆单单位对应的所有库存
int allSplitInventory = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true);
if (allSplitInventory - inventory >= 0) {
// 设置当前拆单库存的数量
// 获取剩余不足的数量
int surplus = inventory - splitInventory.getSaveQuantity();
// 如果盘点后库存数大于0
if (splitInfo.getParentId() != null) {
// 如果当前拆单有父级
// 设置剩余拆单库存处理数量
// 设置当前拆单库存出库数量
splitInventory.setOutQuantity(splitInventory.getOutQuantity() + splitInventory.getSaveQuantity());
// 将当前库存设置为0
splitInventory.setSaveQuantity(0);
// 修改拆单库存
// 修改库存数量
splitUnitMapper.updateSplitInventory(splitInventory);
// 获取当前父级拆单记录
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId());
depositoryRecordService.updateOutSplitInventoryInfo(parentSplitInfo, placeAndMaterialByMidAndPid, inventory, surplus, splitInfo);
} else {
// 如果没有父级
if (surplus <= splitInfo.getQuantity()) {
// 如果当前未处理的数量小于当前拆单库存数量
// 如果物料数量可以出库并且库位数量充足
if (placeAndMaterialByMidAndPid.getQuantity() >= 1) {
// 令库存-1
inventoryById.setQuantity(inventoryById.getQuantity() - 1);
// 修改当前库位存放物料的数量
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - 1);
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
placeById.setQuantity(placeById.getQuantity() - 1);
// 设置剩余拆单库存处理数量
splitInventory.setSaveQuantity(splitInfo.getQuantity() + splitInventory.getSaveQuantity() - inventory);
splitInventory.setOutQuantity(splitInventory.getOutQuantity() + inventory);
splitUnitMapper.updateSplitInventory(splitInventory);
}
} else {
// 如果大于
// 获取库存重要减少的数量
int surplus_redundant = surplus / splitInfo.getQuantity();
// 获取拆单库存处理中要处理数量
int saveQuantity = surplus - surplus_redundant * splitInfo.getQuantity();
if (saveQuantity > splitInventory.getSaveQuantity()) {
// 如果要处理的数量大于剩余数量
// 获取一个数量
surplus_redundant += 1;
splitInventory.setSaveQuantity(splitInfo.getQuantity() + splitInventory.getSaveQuantity() - saveQuantity);
} else {
// 如果不大于
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - saveQuantity);
}
if (placeAndMaterialByMidAndPid.getQuantity() >= surplus_redundant) {
// 如果能够出库
// 令库存-1
inventoryById.setQuantity(inventoryById.getQuantity() - surplus_redundant);
// 修改当前库位存放物料的数量
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - surplus_redundant);
placeById.setQuantity(placeById.getQuantity() - surplus_redundant);
} else {
inventoryById.setQuantity(inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity());
placeById.setQuantity(placeById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity());
placeAndMaterialByMidAndPid.setQuantity(0);
}
}
}
} else {
// 如果盘点后的库存数非法
placeById.setQuantity(placeById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity());
inventoryById.setQuantity(inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity());
placeAndMaterialByMidAndPid.setQuantity(0);
List<SplitInventory> splitInventoryList = splitUnitMapper.findSplitInventoryByIid(placeAndMaterialByMidAndPid.getId());
for (SplitInventory si : splitInventoryList
) {
si.setSaveQuantity(0);
splitUnitMapper.updateSplitInventory(si);
}
}
}
} else {
// 如果不存在拆单记录
@ -872,7 +969,6 @@ public class StockTakingServiceImpl implements StockTakingService {
int residue_realQuantity = residue * scale - inventory;
// 更新库存数量
inventoryById.setQuantity(inventoryById.getQuantity() - residue);
@ -899,7 +995,6 @@ public class StockTakingServiceImpl implements StockTakingService {
}
}
}
@ -1106,8 +1201,7 @@ public class StockTakingServiceImpl implements StockTakingService {
inventoryById.setPrice(avgPrice);
materialMapper.updateMaterialAndProducedDate(materialAndProducedDate);
}
else {
} else {
// 如果没有生产日期
// 获取当前生产日期中的物料
@ -1196,8 +1290,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 更新物料与库位对应关系的数量
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace);
}
else {
} else {
// 如果是拆单单位
// 更新当前库位数量
newNumberForPlace = placeById.getQuantity() + inventory;
@ -1253,8 +1346,7 @@ public class StockTakingServiceImpl implements StockTakingService {
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + disposeQuantity);
}
}
else {
} else {
// 如果不需要进位
// 修改当前库存
@ -1262,8 +1354,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 修改拆单库存
splitUnitMapper.updateSplitInventory(splitInventory);
}
}
else{
} else {
// 获取进制数目
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
@ -1285,8 +1376,7 @@ public class StockTakingServiceImpl implements StockTakingService {
}
}
}
else {
} else {
// 如果盘亏
if ("-1".equals(unit)) {
@ -1311,8 +1401,7 @@ public class StockTakingServiceImpl implements StockTakingService {
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace);
}
else {
} else {
// 如果是拆单单位
// 用于查找对应的拆单记录
@ -1334,8 +1423,7 @@ public class StockTakingServiceImpl implements StockTakingService {
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - inventory);
// 修改拆单库存
splitUnitMapper.updateSplitInventory(splitInventory);
}
else {
} else {
// 如果发生下溢
@ -1542,7 +1630,6 @@ public class StockTakingServiceImpl implements StockTakingService {
// 根据盘点结果重新计算物料的单价
Integer newInventory = minRecord.getNewInventory();
// 获取当前库位上物料数量
@ -1786,8 +1873,7 @@ public class StockTakingServiceImpl implements StockTakingService {
newPlaceAndMaterial.setQuantity(newPlaceAndMaterial.getQuantity() + inventory_transfer);
placeMapper.updateMaterialAndPlace(newPlaceAndMaterial);
}
}
else {
} else {
// 如果盘点的是拆单单位
// 用于获取当前拆单记录
@ -1847,8 +1933,7 @@ public class StockTakingServiceImpl implements StockTakingService {
map.remove("id");
}
}
else {
} else {
// 如果不大于
@ -1859,8 +1944,7 @@ public class StockTakingServiceImpl implements StockTakingService {
}
}
else {
} else {
// 如果转移后的库位有该物料
// 用于查询对应的拆单库存
@ -1943,8 +2027,7 @@ public class StockTakingServiceImpl implements StockTakingService {
}
}
}
else {
} else {
// 如果不存在拆单记录
@ -2018,8 +2101,7 @@ public class StockTakingServiceImpl implements StockTakingService {
}
}
else {
} else {
// 如果不存在
// 定义库存对象
@ -2115,7 +2197,8 @@ public class StockTakingServiceImpl implements StockTakingService {
splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, ObjectFormatUtil.toInteger(paramForMaterialAndPlace.get("id")), map, disposeQuantity, splitInfo);
} else {
// 如果没有父级
map.put("price", String.valueOf(inventoryById.getPrice() / 100));;
map.put("price", String.valueOf(inventoryById.getPrice() / 100));
;
map.put("quantity", String.valueOf(disposeQuantity));
depositoryRecordService.applicationInPlace(map, false);
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
@ -2140,8 +2223,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 如果是基础单位
oldPlaceAndMaterial.setQuantity(newInventory);
placeMapper.updateMaterialAndPlace(oldPlaceAndMaterial);
}
else {
} else {
// 如果是拆单单位
// 用于获取拆单单位
@ -2165,8 +2247,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 修改当前拆单库存
splitUnitMapper.updateSplitInventory(splitInventory);
}
else {
} else {
// 如果不存在
// 用于添加一条拆单库存
@ -2183,8 +2264,7 @@ public class StockTakingServiceImpl implements StockTakingService {
}
}
else {
} else {
// 如果在同一仓库
// 更新物料容量
@ -2216,8 +2296,7 @@ public class StockTakingServiceImpl implements StockTakingService {
newPlaceAndMaterial.setQuantity(newPlaceAndMaterial.getQuantity() + inventory_transfer);
placeMapper.updateMaterialAndPlace(newPlaceAndMaterial);
}
}
else{
} else {
// 如果是拆单单位
@ -2247,8 +2326,7 @@ public class StockTakingServiceImpl implements StockTakingService {
oldSplitInventory.setSaveQuantity(newInventory);
// 修改当前物料库存
splitUnitMapper.updateSplitInventory(oldSplitInventory);
}
else{
} else {
// 如果该拆单库存不存在
// 添加相关数据
@ -2279,9 +2357,6 @@ public class StockTakingServiceImpl implements StockTakingService {
// 如果转移后的拆单库存存在
// 当前拆单库存最终存储数量
int realQuantity = (int) Math.round(saveQuantity) + newSplitInventory.getSaveQuantity();
@ -2341,8 +2416,7 @@ public class StockTakingServiceImpl implements StockTakingService {
}
}
}
else {
} else {
// 如果不存在拆单记录
@ -2401,8 +2475,7 @@ public class StockTakingServiceImpl implements StockTakingService {
map.remove("id");
}
}
else {
} else {
insertForSplitInventory.put("saveQuantity", realQuantity);
insertForSplitInventory.put("inQuantity", realQuantity);
@ -2413,8 +2486,7 @@ public class StockTakingServiceImpl implements StockTakingService {
}
}
}
else{
} else {
// 如果转移之后的库位没有该物料
paramForMaterialAndPlace.put("quantity", 0);
@ -2468,8 +2540,7 @@ public class StockTakingServiceImpl implements StockTakingService {
map.remove("id");
}
}
else {
} else {
// 如果不大于
insertForSplitInventory.put("saveQuantity", inventory_transfer);
@ -2584,8 +2655,6 @@ public class StockTakingServiceImpl implements StockTakingService {
List<String> err = new ArrayList<>();
// 获取所有子单
List<StockTakingChildP> minRecordList = stockTakingMapper.selectStockTakingChildByMainId(mainId);
for (int i = 0; i < minRecordList.size(); i++) {
@ -2618,7 +2687,6 @@ public class StockTakingServiceImpl implements StockTakingService {
// 根据盘点结果重新计算物料的单价
Integer newInventory = minRecord.getNewInventory();

Loading…
Cancel
Save