|
|
|
@ -2,12 +2,11 @@ package com.dreamchaser.depository_manage.service.impl; |
|
|
|
|
|
|
|
import com.dreamchaser.depository_manage.entity.*; |
|
|
|
import com.dreamchaser.depository_manage.exception.MyException; |
|
|
|
import com.dreamchaser.depository_manage.mapper.DepositoryMapper; |
|
|
|
import com.dreamchaser.depository_manage.mapper.DepositoryRecordMapper; |
|
|
|
import com.dreamchaser.depository_manage.mapper.GroupMapper; |
|
|
|
import com.dreamchaser.depository_manage.mapper.MaterialMapper; |
|
|
|
import com.dreamchaser.depository_manage.mapper.*; |
|
|
|
import com.dreamchaser.depository_manage.pojo.GroupInfoP; |
|
|
|
import com.dreamchaser.depository_manage.pojo.MaterialAndPlaceForView; |
|
|
|
import com.dreamchaser.depository_manage.service.GroupService; |
|
|
|
import com.dreamchaser.depository_manage.service.SplitUnitService; |
|
|
|
import com.dreamchaser.depository_manage.utils.DateUtil; |
|
|
|
import com.dreamchaser.depository_manage.utils.LinkInterfaceUtil; |
|
|
|
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|
|
|
@ -33,16 +32,21 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
DepositoryRecordMapper depositoryRecordMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
DepositoryMapper depositoryMapper; |
|
|
|
@Autowired |
|
|
|
RedissonClient redissonClient; |
|
|
|
@Autowired |
|
|
|
RedisTemplate<String, String> redisTemplate; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedissonClient redissonClient; |
|
|
|
SplitUnitMapper splitUnitMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisTemplate<String, String> redisTemplate; |
|
|
|
SplitUnitService splitUnitService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
DepositoryMapper depositoryMapper; |
|
|
|
PlaceMapper placeMapper; |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于查找所有组合 |
|
|
|
@ -56,6 +60,7 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据组合id获取具体信息 |
|
|
|
* |
|
|
|
* @param gid 组合id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -66,6 +71,7 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据组合id查询对应组合 |
|
|
|
* |
|
|
|
* @param gid 组合id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -76,6 +82,7 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于添加组合与二维码的对应关系 |
|
|
|
* |
|
|
|
* @param map 具体添加数据 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -107,7 +114,9 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
for (GroupInfo groupInfo : groupByCondition) { |
|
|
|
if ("-1".equals(groupInfo.getUnit())) { |
|
|
|
Material material = materialMapper.findMaterialById(groupInfo.getMid()); |
|
|
|
groupInfo.setUnit(material.getUnit()); |
|
|
|
groupInfo.setShowUnit(material.getUnit()); |
|
|
|
} else { |
|
|
|
groupInfo.setShowUnit(groupInfo.getUnit()); |
|
|
|
} |
|
|
|
} |
|
|
|
return groupByCondition; |
|
|
|
@ -197,7 +206,7 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
|
|
|
|
//获取要使用的gid
|
|
|
|
Integer gid = null; |
|
|
|
if(map.containsKey("gid")){ |
|
|
|
if (map.containsKey("gid")) { |
|
|
|
// 如果是重新添加对应物料
|
|
|
|
gid = ObjectFormatUtil.toInteger(map.get("gid")); |
|
|
|
} |
|
|
|
@ -206,7 +215,7 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
if (groupCount == null) { |
|
|
|
groupCount = 0; |
|
|
|
} |
|
|
|
if(gid == null) { |
|
|
|
if (gid == null) { |
|
|
|
// 构造组合编码
|
|
|
|
String code = createCode(groupCount); |
|
|
|
insertForGroup.put("code", code); |
|
|
|
@ -217,7 +226,7 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
// 插入到数据库
|
|
|
|
groupMapper.addGroup(insertForGroup); |
|
|
|
gid = ObjectFormatUtil.toInteger(insertForGroup.get("id")); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
Group groupOnlyById = groupMapper.findGroupOnlyById(gid); |
|
|
|
groupOnlyById.setGname(map.get("gname").toString()); |
|
|
|
groupOnlyById.setRemark(map.get("applyRemark").toString()); |
|
|
|
@ -234,21 +243,21 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
materialForGroupMap.put("gid", gid); |
|
|
|
|
|
|
|
Integer result = 0; |
|
|
|
if(len > 1){ |
|
|
|
if (len > 1) { |
|
|
|
List<Integer> params = (List<Integer>) map.get("params"); |
|
|
|
for (Integer temp : params) { |
|
|
|
materialForGroupMap.put("mid", map.get("mid" + temp)); |
|
|
|
materialForGroupMap.put("quantity", map.get("quantity" + temp)); |
|
|
|
materialForGroupMap.put("unit",map.get("unit"+temp)); |
|
|
|
materialForGroupMap.put("unit", map.get("unit" + temp)); |
|
|
|
result += groupMapper.addGroupForMaterial(materialForGroupMap); |
|
|
|
} |
|
|
|
materialForGroupMap.put("mid",map.get("mid")); |
|
|
|
materialForGroupMap.put("quantity",map.get("quantity")); |
|
|
|
materialForGroupMap.put("unit",map.get("unit")); |
|
|
|
materialForGroupMap.put("mid", map.get("mid")); |
|
|
|
materialForGroupMap.put("quantity", map.get("quantity")); |
|
|
|
materialForGroupMap.put("unit", map.get("unit")); |
|
|
|
result += groupMapper.addGroupForMaterial(materialForGroupMap); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// 添加
|
|
|
|
map.put("gid",gid); |
|
|
|
map.put("gid", gid); |
|
|
|
result += groupMapper.addGroupForMaterial(map); |
|
|
|
} |
|
|
|
return result; |
|
|
|
@ -543,14 +552,19 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Integer insertApplicationOutRecord(Map<String, Object> map, UserByPort userToken) { |
|
|
|
|
|
|
|
// 用于存储出库数据
|
|
|
|
Map<String, Object> paramForOut = new HashMap<>(); |
|
|
|
paramForOut.put("departmenthead", map.get("departmenthead")); |
|
|
|
paramForOut.put("applicantId", userToken.getId()); |
|
|
|
|
|
|
|
// 获取当前提交数
|
|
|
|
List<String> params = (List<String>) map.get("params"); |
|
|
|
|
|
|
|
// 用于存储申请数
|
|
|
|
Integer result = 0; |
|
|
|
|
|
|
|
// 定义出库订单的主订单编号
|
|
|
|
Object parentId = null; |
|
|
|
|
|
|
|
// 获取当前要出库的组合数量
|
|
|
|
@ -560,19 +574,57 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
|
|
|
|
// 获取要出库组合的具体信息
|
|
|
|
List<GroupInfo> groupInfoByGid = groupMapper.findGroupInfoByGid(gid); |
|
|
|
|
|
|
|
// 获取当前部门所拥有的仓库
|
|
|
|
List<Depository> depositoryByAdminorg = depositoryMapper.findDepositoryByAdminorg(userToken.getMaindeparment().toString()); |
|
|
|
|
|
|
|
// 用于统计出库物料总数
|
|
|
|
Integer quantityForTotal = 0; |
|
|
|
|
|
|
|
// 用于统计出库物料金额总数
|
|
|
|
double priceForTotal = 0; |
|
|
|
|
|
|
|
for (GroupInfo groupInfo : groupInfoByGid) { |
|
|
|
// 获取具体信息
|
|
|
|
// 获取当前物料库存信息
|
|
|
|
Map<String, Object> paramForMid = new HashMap<>(); |
|
|
|
paramForMid.put("mid", groupInfo.getMid()); |
|
|
|
List<Inventory> inventory = materialMapper.findInventory(paramForMid); |
|
|
|
quantityForTotal += quantityForGroup * groupInfo.getQuantity(); |
|
|
|
priceForTotal += inventory.get(0).getPrice() * 100 * quantityForGroup; |
|
|
|
// 循环遍历当前部门所拥有的仓库
|
|
|
|
for (Depository depository : |
|
|
|
depositoryByAdminorg) { |
|
|
|
// 用于获取当前物料库存信息
|
|
|
|
Map<String, Object> paramForMidAndDid = new HashMap<>(); |
|
|
|
paramForMidAndDid.put("depositoryId", depository.getId()); |
|
|
|
// 遍历当前组合中的详细信息
|
|
|
|
for (GroupInfo groupInfo : groupInfoByGid) { |
|
|
|
// 获取具体信息
|
|
|
|
|
|
|
|
// 获取当前单位
|
|
|
|
String unit = groupInfo.getUnit(); |
|
|
|
paramForMidAndDid.put("mid", groupInfo.getMid()); |
|
|
|
List<Inventory> inventory = materialMapper.findInventory(paramForMidAndDid); |
|
|
|
if ("-1".equals(unit)) { |
|
|
|
// 如果当前是基础单位
|
|
|
|
if (inventory.size() > 0) { |
|
|
|
quantityForTotal += quantityForGroup * groupInfo.getQuantity(); |
|
|
|
priceForTotal += inventory.get(0).getPrice() * 100 * quantityForGroup; |
|
|
|
paramForOut.put("depositoryId", depository.getId()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 如果是拆单单位
|
|
|
|
|
|
|
|
// 用于获取当前拆单单位
|
|
|
|
Map<String, Object> paramForSplitInfo = new HashMap<>(); |
|
|
|
paramForSplitInfo.put("newUnit", unit); |
|
|
|
paramForSplitInfo.put("mid", groupInfo.getMid()); |
|
|
|
// 获取拆单记录
|
|
|
|
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); |
|
|
|
/// 获取当前拆单与基础单位之间的进制
|
|
|
|
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); |
|
|
|
if (inventory.size() > 0) { |
|
|
|
quantityForTotal += quantityForGroup * groupInfo.getQuantity(); |
|
|
|
priceForTotal += inventory.get(0).getPrice() * 100 / scale * quantityForGroup; |
|
|
|
paramForOut.put("depositoryId", depository.getId()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
paramForOut.put("quantity", quantityForTotal); |
|
|
|
paramForOut.put("price", priceForTotal); |
|
|
|
@ -580,14 +632,17 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
paramForOut.put("istransfer", 2); |
|
|
|
paramForOut.put("state", "待部门负责人审核"); |
|
|
|
paramForOut.put("applyRemark", map.get("applyRemark")); |
|
|
|
// 获取当前部门名称
|
|
|
|
Administration company = LinkInterfaceUtil.getCompany(userToken.getMaindeparment(), userToken); |
|
|
|
// 构造出库订单编码
|
|
|
|
String code = createOutCode("outOrderNumber", company.getName()); |
|
|
|
paramForOut.put("code", code); |
|
|
|
paramForOut.put("pass", 3); |
|
|
|
// 插入一条出库订单的主订单
|
|
|
|
depositoryRecordMapper.insertApplicationOutRecord(paramForOut); |
|
|
|
parentId = paramForOut.get("id"); |
|
|
|
|
|
|
|
// 插入子订单
|
|
|
|
result += insertApplicationOutMinRecord(userToken, code, parentId, gid, quantityForGroup); |
|
|
|
|
|
|
|
if (params != null && params.size() > 0) { |
|
|
|
@ -596,7 +651,7 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
// 循环其他
|
|
|
|
for (String temp : params) { |
|
|
|
// 获取当前要出库的组合数量
|
|
|
|
quantityForGroup = ObjectFormatUtil.toInteger(map.get("quantity" + temp)); |
|
|
|
quantityForGroup = ObjectFormatUtil.toInteger(map.get("quantity" + temp)); |
|
|
|
// 获取要出库的组合
|
|
|
|
gid = ObjectFormatUtil.toInteger(map.get("gid" + temp)); |
|
|
|
// 获取当前要出库组合的具体信息
|
|
|
|
@ -636,37 +691,95 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
|
|
|
|
// 获取当前部门仓库
|
|
|
|
List<Depository> depositoryByAdminorg = depositoryMapper.findDepositoryByAdminorg(userToken.getMaindeparment().toString()); |
|
|
|
|
|
|
|
// 获取要出库组合的具体信息
|
|
|
|
List<GroupInfo> groupInfoByGid = groupMapper.findGroupInfoByGid(gid); |
|
|
|
|
|
|
|
|
|
|
|
// 循环所有详细信息
|
|
|
|
for (GroupInfo groupInfo : groupInfoByGid) { |
|
|
|
// 用于存储出库数据
|
|
|
|
Map<String, Object> paramForOutMin = new HashMap<>(); |
|
|
|
paramForOutMin.put("parentId", parentId); |
|
|
|
// 组合中的具体信息
|
|
|
|
|
|
|
|
// 实际要出库的物料库存数量
|
|
|
|
Integer quantity = groupInfo.getQuantity() * quantityForGroup; |
|
|
|
// 定义出库时的单位
|
|
|
|
String unit = groupInfo.getUnit(); |
|
|
|
// 实际出库的仓库编号
|
|
|
|
int did = -1; |
|
|
|
// 实际出库的库存编号
|
|
|
|
int mid = -1; |
|
|
|
// 用于查询各仓库中对应物料的库存
|
|
|
|
Map<String, Object> paramForInventory = new HashMap<>(); |
|
|
|
paramForInventory.put("mid", groupInfo.getMid()); |
|
|
|
// 查询各仓库中是否有符合对应数量的库存
|
|
|
|
for (Depository depository : depositoryByAdminorg) { |
|
|
|
paramForInventory.put("did", depository.getId()); |
|
|
|
// 获取对应库存
|
|
|
|
Inventory inventoryByMidAndDid = materialMapper.findInventoryByMidAndDid(paramForInventory); |
|
|
|
if (inventoryByMidAndDid.getQuantity() > quantity) { |
|
|
|
// 如果当前库存充足
|
|
|
|
did = depository.getId(); |
|
|
|
mid = inventoryByMidAndDid.getId(); |
|
|
|
break; |
|
|
|
|
|
|
|
if ("-1".equals(unit)) { |
|
|
|
// 如果是基础单位
|
|
|
|
|
|
|
|
// 用于查询各仓库中对应物料的库存
|
|
|
|
Map<String, Object> paramForInventory = new HashMap<>(); |
|
|
|
paramForInventory.put("mid", groupInfo.getMid()); |
|
|
|
// 查询各仓库中是否有符合对应数量的库存
|
|
|
|
for (Depository depository : depositoryByAdminorg) { |
|
|
|
paramForInventory.put("did", depository.getId()); |
|
|
|
// 获取对应库存
|
|
|
|
Inventory inventoryByMidAndDid = materialMapper.findInventoryByMidAndDid(paramForInventory); |
|
|
|
if (inventoryByMidAndDid.getQuantity() >= quantity) { |
|
|
|
// 如果当前库存充足
|
|
|
|
did = depository.getId(); |
|
|
|
mid = inventoryByMidAndDid.getId(); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 如果是拆单单位
|
|
|
|
|
|
|
|
// 用于获取拆单信息
|
|
|
|
Map<String, Object> paramForSplitInfo = new HashMap<>(); |
|
|
|
paramForSplitInfo.put("newUnit", unit); |
|
|
|
paramForSplitInfo.put("mid", groupInfo.getMid()); |
|
|
|
// 获取拆单信息
|
|
|
|
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); |
|
|
|
|
|
|
|
// 用于获取物料与库位的对应关系
|
|
|
|
Map<String, Object> paramForPlace = new HashMap<>(); |
|
|
|
// 待查询物料
|
|
|
|
paramForPlace.put("mid", groupInfo.getMid()); |
|
|
|
for (Depository depository : depositoryByAdminorg) { |
|
|
|
paramForPlace.put("depositoryId", depository.getId()); |
|
|
|
// 获取当前仓库中该物料与库位的对应关系
|
|
|
|
List<MaterialAndPlaceForView> materialAndPlaceForViews = placeMapper.findPlaceAndMaterialByDidAndMid(paramForPlace); |
|
|
|
|
|
|
|
// 定义标志位用于判断是否跳出循环
|
|
|
|
boolean flag = false; |
|
|
|
for (MaterialAndPlaceForView materialAndPlaceForView : |
|
|
|
materialAndPlaceForViews) { |
|
|
|
// 定义物料与库位的对应关系
|
|
|
|
MaterialAndPlace mp = new MaterialAndPlace(); |
|
|
|
// 设置id
|
|
|
|
mp.setId(materialAndPlaceForView.getId()); |
|
|
|
// 设置数量
|
|
|
|
mp.setQuantity(materialAndPlaceForView.getInventory()); |
|
|
|
// 获取当前库位下该拆单单位库存数
|
|
|
|
int allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, mp, splitInfo.getId(), 0, true); |
|
|
|
if (allInventoryForSplitInfo >= quantity) { |
|
|
|
// 如果当前库存充足
|
|
|
|
did = materialAndPlaceForView.getDepository_id(); |
|
|
|
mid = materialAndPlaceForView.getIid(); |
|
|
|
flag = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (flag) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (did != -1) { |
|
|
|
// 如果有正确的仓库
|
|
|
|
|
|
|
|
// 用于存储出库数据
|
|
|
|
Map<String, Object> paramForOutMin = new HashMap<>(); |
|
|
|
paramForOutMin.put("parentId", parentId); |
|
|
|
paramForOutMin.put("depositoryId", did); |
|
|
|
paramForOutMin.put("unit", groupInfo.getUnit()); |
|
|
|
paramForOutMin.put("mid", mid); |
|
|
|
paramForOutMin.put("trueOut", 0); |
|
|
|
paramForOutMin.put("quantity", quantity); |
|
|
|
@ -689,7 +802,90 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<GroupInfo> findGroupInfoByGid(Integer gid) { |
|
|
|
return groupMapper.findGroupInfoByGid(gid); |
|
|
|
List<GroupInfo> groupInfoByGid = groupMapper.findGroupInfoByGid(gid); |
|
|
|
for (GroupInfo groupInfo : |
|
|
|
groupInfoByGid) { |
|
|
|
if ("-1".equals(groupInfo.getUnit())) { |
|
|
|
Material material = materialMapper.findMaterialById(groupInfo.getMid()); |
|
|
|
groupInfo.setShowUnit(material.getUnit()); |
|
|
|
} else { |
|
|
|
groupInfo.setShowUnit(groupInfo.getUnit()); |
|
|
|
} |
|
|
|
} |
|
|
|
return groupInfoByGid; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 构造树形组件数据模板 |
|
|
|
* |
|
|
|
* @param g 组合 |
|
|
|
* @param children 子类 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Map<String, Object> InitTreeMenus(Group g, List<Object> children) { |
|
|
|
if (g != null) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("title", g.getGname()); |
|
|
|
map.put("id", g.getId()); |
|
|
|
map.put("children", children); |
|
|
|
return map; |
|
|
|
} else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 构造树形组件的子组件模板 |
|
|
|
* |
|
|
|
* @param g 组合详细信息 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Map<String, Object> InitTreeMenus(GroupInfo g) { |
|
|
|
if (g != null) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("title", g.getMname() + ",数量:" + g.getQuantity()); |
|
|
|
map.put("id", g.getId()); |
|
|
|
return map; |
|
|
|
} else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于创建组合编码 |
|
|
|
* |
|
|
|
* @param num 第几个组合 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String createCode(Integer num) { |
|
|
|
String code = String.format("%04d", num + 1); |
|
|
|
return code; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成出库单号 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String createOutCode(String key, String mainDeparmentName) { |
|
|
|
RLock lock = redissonClient.getLock(key); |
|
|
|
// 入库单号(公司简称+仓库简称+年月日+数字(位数设置>=9))
|
|
|
|
String code = "GK"; |
|
|
|
String nowTime = DateUtil.getNowTime(); |
|
|
|
lock.lock(5, TimeUnit.SECONDS); |
|
|
|
String orderNumber = redisTemplate.opsForValue().get(key); |
|
|
|
if (orderNumber == null) { |
|
|
|
redisTemplate.opsForValue().set(key, "1", DateUtil.getSecondsNextEarlyMorning(), TimeUnit.SECONDS); |
|
|
|
orderNumber = "1"; |
|
|
|
} |
|
|
|
int newNumber = ObjectFormatUtil.toInteger(orderNumber) + 1; |
|
|
|
redisTemplate.boundValueOps(key).set(String.valueOf(newNumber), DateUtil.getSecondsNextEarlyMorning(), TimeUnit.SECONDS); |
|
|
|
lock.unlock(); |
|
|
|
orderNumber = String.format("%09d", ObjectFormatUtil.toInteger(orderNumber)); |
|
|
|
mainDeparmentName = WordUtil.getPinYinHeadChar(mainDeparmentName); |
|
|
|
code = code + mainDeparmentName + nowTime + orderNumber; |
|
|
|
|
|
|
|
return code; |
|
|
|
} |
|
|
|
|
|
|
|
// 用于执行线程任务
|
|
|
|
@ -769,81 +965,4 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
return stringObjectMap; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 构造树形组件数据模板 |
|
|
|
* |
|
|
|
* @param g 组合 |
|
|
|
* @param children 子类 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Map<String, Object> InitTreeMenus(Group g, List<Object> children) { |
|
|
|
if (g != null) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("title", g.getGname()); |
|
|
|
map.put("id", g.getId()); |
|
|
|
map.put("children", children); |
|
|
|
return map; |
|
|
|
} else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 构造树形组件的子组件模板 |
|
|
|
* |
|
|
|
* @param g 组合详细信息 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Map<String, Object> InitTreeMenus(GroupInfo g) { |
|
|
|
if (g != null) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("title", g.getMname() + ",数量:" + g.getQuantity()); |
|
|
|
map.put("id", g.getId()); |
|
|
|
return map; |
|
|
|
} else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 用于创建组合编码 |
|
|
|
* |
|
|
|
* @param num 第几个组合 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String createCode(Integer num) { |
|
|
|
String code = String.format("%04d", num + 1); |
|
|
|
return code; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 生成出库单号 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String createOutCode(String key, String mainDeparmentName) { |
|
|
|
RLock lock = redissonClient.getLock(key); |
|
|
|
// 入库单号(公司简称+仓库简称+年月日+数字(位数设置>=9))
|
|
|
|
String code = "GK"; |
|
|
|
String nowTime = DateUtil.getNowTime(); |
|
|
|
lock.lock(5, TimeUnit.SECONDS); |
|
|
|
String orderNumber = redisTemplate.opsForValue().get(key); |
|
|
|
if (orderNumber == null) { |
|
|
|
redisTemplate.opsForValue().set(key, "1", DateUtil.getSecondsNextEarlyMorning(), TimeUnit.SECONDS); |
|
|
|
orderNumber = "1"; |
|
|
|
} |
|
|
|
int newNumber = ObjectFormatUtil.toInteger(orderNumber) + 1; |
|
|
|
redisTemplate.boundValueOps(key).set(String.valueOf(newNumber), DateUtil.getSecondsNextEarlyMorning(), TimeUnit.SECONDS); |
|
|
|
lock.unlock(); |
|
|
|
orderNumber = String.format("%09d", ObjectFormatUtil.toInteger(orderNumber)); |
|
|
|
mainDeparmentName = WordUtil.getPinYinHeadChar(mainDeparmentName); |
|
|
|
code = code + mainDeparmentName + nowTime + orderNumber; |
|
|
|
|
|
|
|
return code; |
|
|
|
} |
|
|
|
} |
|
|
|
|