|
|
|
@ -7,6 +7,8 @@ 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.*; |
|
|
|
import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details; |
|
|
|
import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details_Approver; |
|
|
|
import com.dreamchaser.depository_manage.pojo.callBackXml.callBackXml_button_templatecard.TemplateCard; |
|
|
|
import com.dreamchaser.depository_manage.service.DepositoryRecordService; |
|
|
|
import com.dreamchaser.depository_manage.service.RoleService; |
|
|
|
@ -442,7 +444,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
Integer placeId = ObjectFormatUtil.toInteger(param.get("placeId")); |
|
|
|
if (istransfer == 1) {// 如果是库存转移
|
|
|
|
// 获取库存转移订单
|
|
|
|
TransferRecord transferRecordById = transferRecordMapper.findTransferRecordById(record.getTransferId()); |
|
|
|
TransferRecord transferRecordById = transferRecordMapper.findTransferRecordById(applicationOutMinById.getTransferId()); |
|
|
|
placeId = transferRecordById.getFromPlaceId();// 获取转出库位
|
|
|
|
} |
|
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = null; |
|
|
|
@ -515,11 +517,14 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
|
|
|
|
// 获取当前订单中所有管理员
|
|
|
|
String manager = (String) redisTemplate.opsForHash().get(redisMinRecordKey, "manager"); |
|
|
|
String[] managerSplit = new String[0]; |
|
|
|
if (manager != null) { |
|
|
|
// 获取其他管理员
|
|
|
|
String[] managerSplit = manager.replace(userByPort.getId() + ",", "").split(","); |
|
|
|
managerSplit = manager.replace(userByPort.getId() + ",", "").split(","); |
|
|
|
if (managerSplit.length == 0) { |
|
|
|
managerSplit = new String[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
for (int i = 0; i < managerSplit.length; i++) { |
|
|
|
// 删除其他管理员的订单记录
|
|
|
|
String otherManager = "user:" + managerSplit[i]; |
|
|
|
@ -604,7 +609,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
|
|
|
|
// 将最终完成的订单抄送给仓储负责人
|
|
|
|
String depositoryManagerIds = record.getDepositoryManager(); |
|
|
|
String[] depositoryManagers = depositoryManagerIds.split(","); |
|
|
|
String[] depositoryManagers = new String[0]; |
|
|
|
if (depositoryManagerIds != null) { |
|
|
|
depositoryManagers = depositoryManagerIds.split(","); |
|
|
|
} |
|
|
|
StringBuilder depositoryManagerByQyWx = new StringBuilder(); |
|
|
|
for (int i = 0; i < depositoryManagers.length; i++) { |
|
|
|
Integer uid = ObjectFormatUtil.toInteger(depositoryManagers[i]); |
|
|
|
@ -623,8 +631,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
if (record.getIstransfer() == 1) { |
|
|
|
map.put("quantity", record.getQuantity().toString()); |
|
|
|
map.put("applicantId", record.getApplicantId()); |
|
|
|
map.put("transferId", record.getTransferId()); |
|
|
|
map.put("recordId", record.getId()); // 出库订单编号
|
|
|
|
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
|
|
|
|
transferMaterial(map); |
|
|
|
} |
|
|
|
restResponse.setStatus(200); |
|
|
|
@ -638,6 +645,217 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
return restResponse; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于企业微信物料出库审批处理 |
|
|
|
* |
|
|
|
* @param mainId 主表id |
|
|
|
* @param userAgent 加密后的user-agent |
|
|
|
* @param approvalInfo_details 审批详情 |
|
|
|
* @param spStatus // 审批状态
|
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Integer reviewByQyWxApproval(String mainId, ApprovalInfo_Details approvalInfo_details, String userAgent, String spStatus, String spNo) { |
|
|
|
|
|
|
|
// 用于更新订单
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
// 获取分支审批人
|
|
|
|
ApprovalInfo_Details_Approver approver = approvalInfo_details.getApprover(); |
|
|
|
// 获取审批人userId
|
|
|
|
String userId = approver.getUserId(); |
|
|
|
// 获取审批人
|
|
|
|
Map<String, Object> portInfo = PortConfig.findUserByQyWxUserId(userId); |
|
|
|
UserByPort userByPort = (UserByPort) portInfo.get("user"); |
|
|
|
|
|
|
|
// 用于标志是否更新当前申请明细
|
|
|
|
Boolean flag = true; |
|
|
|
// 获取审核订单
|
|
|
|
Integer outId = ObjectFormatUtil.toInteger(mainId); |
|
|
|
// 获取对应的出库订单
|
|
|
|
ApplicationOutRecordP recordP = depositoryRecordMapper.findApplicationOutRecordPById(outId); |
|
|
|
|
|
|
|
// 获取当前审批所在部门
|
|
|
|
Integer maindeparment = userByPort.getMaindeparment(); |
|
|
|
if (Integer.compare(361, maindeparment) == 0) { |
|
|
|
// if(true){
|
|
|
|
// 如果是仓储中心负责人
|
|
|
|
|
|
|
|
String depositoryManagerTime = recordP.getDepositoryManagerTime(); |
|
|
|
if ("0".equals(depositoryManagerTime)) { |
|
|
|
// 如果当前申请没有处理
|
|
|
|
|
|
|
|
flag = false; |
|
|
|
// 如果点击的是通过
|
|
|
|
String simpleTime = DateUtil.getSimpleTime(new Date()); |
|
|
|
map.put("depositoryManagerTime", DateUtil.DateTimeToTimeStamp(simpleTime)); |
|
|
|
map.put("depositoryManager", userByPort.getId()); |
|
|
|
map.put("depositoryId", recordP.getDepositoryId()); |
|
|
|
if ("2".equals(spStatus)) { |
|
|
|
// 如果点击的是通过
|
|
|
|
map.put("depositoryManagerPass", 1); |
|
|
|
StringBuilder minRecordByMain = new StringBuilder("[]"); |
|
|
|
|
|
|
|
// 根据仓库分类明细
|
|
|
|
Map<String, Object> minIdByDepository = new HashMap<>(); |
|
|
|
// 定义仓库列表
|
|
|
|
List<Integer> depositoryIdList = new ArrayList<>(); |
|
|
|
// 获取所有详情
|
|
|
|
List<ApplicationOutRecordMin> applicationOutRecordMinByParent = depositoryRecordMapper.findApplicationOutRecordMinByParent(recordP.getId()); |
|
|
|
for (int i = 0; i < applicationOutRecordMinByParent.size(); i++) { |
|
|
|
// 获取子单信息
|
|
|
|
ApplicationOutRecordMin applicationOutRecordMin = applicationOutRecordMinByParent.get(i); |
|
|
|
|
|
|
|
// 获取当前仓库下的子订单
|
|
|
|
Integer depositoryId = applicationOutRecordMin.getDepositoryId(); |
|
|
|
if (!findThisIdIsExist(depositoryIdList, depositoryId)) { |
|
|
|
// 如果当前仓库id没有存入过
|
|
|
|
depositoryIdList.add(depositoryId); |
|
|
|
} |
|
|
|
List<Integer> minIdList = new ArrayList<>(); |
|
|
|
Object o = minIdByDepository.get("depository" + depositoryId); |
|
|
|
if (o != null) { |
|
|
|
minIdList = (List<Integer>) o; |
|
|
|
} |
|
|
|
// 将当前子订单添加到该仓库下的子订单列表中
|
|
|
|
minIdList.add(applicationOutRecordMin.getId()); |
|
|
|
minIdByDepository.put("depository" + depositoryId, minIdList); |
|
|
|
|
|
|
|
//设置子订单在redis中的主键
|
|
|
|
String minRecordKey = "minRecord:" + applicationOutRecordMin.getId(); |
|
|
|
minRecordByMain.insert(1, minRecordKey + ","); // 将子订单主键插入到主订单的子订单列表
|
|
|
|
// 设置当前子订单对应仓库管理员记录
|
|
|
|
StringBuilder minRecordManage = new StringBuilder(); |
|
|
|
// 将要存储到redis中的子订单信息
|
|
|
|
Map<String, Object> minRecord = new HashMap<>(); |
|
|
|
minRecord.put("parentId", recordP.getId().toString()); // 当前子订单主订单
|
|
|
|
minRecord.put("state", "1"); // 当前子订单状态 1待处理2处理
|
|
|
|
// 获取对应的物料编号
|
|
|
|
Integer mid = applicationOutRecordMin.getMid(); |
|
|
|
// 获取物料信息
|
|
|
|
Material materialById = materialMapper.findMaterialById(mid); |
|
|
|
// 获取该物料所处仓库的仓库管理员
|
|
|
|
List<Integer> userIdByDid = new ArrayList<>(); |
|
|
|
userIdByDid = roleService.findUserIdByDid(materialById.getDepositoryId()); |
|
|
|
StringBuilder QyWxUid = new StringBuilder(); |
|
|
|
for (int j = 0; j < userIdByDid.size(); j++) { |
|
|
|
// 获取仓库管理员信息
|
|
|
|
UserByPort manager = PageController.FindUserById(userIdByDid.get(j), userByPort); |
|
|
|
// 仓库管理员订单信息
|
|
|
|
Map<String, Object> userRecord = new HashMap<>(); |
|
|
|
// 用户当前子订单
|
|
|
|
String userMinRecord = (String) redisTemplate.opsForHash().get("user:" + userIdByDid.get(j), "minRecord"); |
|
|
|
if (userMinRecord == null) { // 如果当前用户没有子订单
|
|
|
|
userRecord.put("minRecord", "[" + minRecordKey + "," + "]"); // 插入一条子订单
|
|
|
|
} else { // 如果当前用户已经有子订单
|
|
|
|
StringBuilder minRecordList = new StringBuilder(userMinRecord); // 转为stringbuilder类型
|
|
|
|
minRecordList.insert(1, minRecordKey + ",");// 将当前子订单插入头部
|
|
|
|
userRecord.put("minRecord", minRecordList.toString()); |
|
|
|
} |
|
|
|
// 更新redis中用户记录
|
|
|
|
redisTemplate.opsForHash().putAll("user:" + userIdByDid.get(j), userRecord); |
|
|
|
minRecordManage.append(userIdByDid.get(j)).append(","); |
|
|
|
// QyWxUid.append(manager.getWorkwechat()+",");
|
|
|
|
} |
|
|
|
QyWxUid.append("PangFuZhen,"); |
|
|
|
minRecord.put("manager", minRecordManage.toString()); |
|
|
|
// 添加子订单到redis中
|
|
|
|
redisTemplate.opsForHash().putAll(minRecordKey, minRecord); |
|
|
|
// 开启线程向仓库管理员发送消息
|
|
|
|
/*new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(),userAgent); |
|
|
|
} |
|
|
|
}).start();*/ |
|
|
|
|
|
|
|
} |
|
|
|
for (int i = 0; i < depositoryIdList.size(); i++) { |
|
|
|
Object o = minIdByDepository.get("depository" + depositoryIdList.get(i)); |
|
|
|
if (o != null) { |
|
|
|
List<Integer> minIdList = (List<Integer>) o; |
|
|
|
List<Integer> userIdByDid = roleService.findUserIdByDid(depositoryIdList.get(i)); |
|
|
|
StringBuilder QyWxUid = new StringBuilder(); |
|
|
|
for (int j = 0; j < userIdByDid.size(); j++) { |
|
|
|
UserByPort manager = PageController.FindUserById(userIdByDid.get(j), userByPort); |
|
|
|
// QyWxUid.append(manager.getWorkwechat()+",");
|
|
|
|
} |
|
|
|
QyWxUid.append("PangFuZhen,"); |
|
|
|
// 根据仓库向仓库管理员发送审批
|
|
|
|
JSONObject jsonObject = qyWxOperationService.sendOutApprovalTemplateOut(userAgent, userByPort, ObjectFormatUtil.toInteger(mainId), minIdList, QyWxUid.toString()); |
|
|
|
String sp_no = jsonObject.getString("sp_no"); |
|
|
|
Map<String, Object> QyWxApprovalMap = new HashMap<>(); |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
for (int j = 0; j < minIdList.size(); j++) { |
|
|
|
sb.append(minIdList.get(j)).append(","); |
|
|
|
} |
|
|
|
QyWxApprovalMap.put("sp_no", sp_no); |
|
|
|
QyWxApprovalMap.put("minIdList", sb.toString()); |
|
|
|
redisTemplate.opsForHash().putAll(sp_no, QyWxApprovalMap); |
|
|
|
// 设置过期时间为7天
|
|
|
|
redisTemplate.expire(sp_no, 7, TimeUnit.DAYS); |
|
|
|
} else { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 将主订单插入到redis中
|
|
|
|
redisTemplate.opsForHash().put("record:" + recordP.getId(), "minRecord", minRecordByMain.toString()); |
|
|
|
map.put("state", "仓储中心负责人审核通过"); |
|
|
|
} else { |
|
|
|
// 如果是不通过
|
|
|
|
map.put("depositoryManagerPass", 2); |
|
|
|
map.put("pass", 2); |
|
|
|
map.put("state", "仓储中心负责人审核未通过"); |
|
|
|
} |
|
|
|
// 将当前redis中存储的spno删除
|
|
|
|
redisTemplate.delete(spNo); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 如果是部门负责人
|
|
|
|
|
|
|
|
String departmentheadTime = recordP.getDepartmentheadTime(); |
|
|
|
if ("0".equals(departmentheadTime)) { |
|
|
|
|
|
|
|
flag = false; |
|
|
|
String simpleTime = DateUtil.getSimpleTime(new Date()); |
|
|
|
map.put("departmentheadTime", DateUtil.DateTimeToTimeStamp(simpleTime)); |
|
|
|
map.put("departmenthead", userByPort.getId()); |
|
|
|
// 获取点击的按钮类型
|
|
|
|
if ("2".equals(spStatus)) { |
|
|
|
// 如果点击的是通过
|
|
|
|
map.put("departmentheadPass", 1); |
|
|
|
map.put("state", "待仓储中心负责人审核"); |
|
|
|
// 获取仓储中心详情
|
|
|
|
Administration company = PageController.getCompany(361, null); |
|
|
|
// 获取仓储中心负责人
|
|
|
|
List<UserByPort> departmentHeadByUser = PortConfig.findDepartmentHeadByUser(company, null); |
|
|
|
StringBuilder depositoryManager = new StringBuilder(); |
|
|
|
StringBuilder QyWxUid = new StringBuilder(); |
|
|
|
for (int i = 0; i < departmentHeadByUser.size(); i++) { |
|
|
|
depositoryManager.append(departmentHeadByUser.get(i).getId() + ","); |
|
|
|
// QyWxUid.append(departmentHeadByUser.get(i).getWorkwechat()+",");
|
|
|
|
} |
|
|
|
QyWxUid.append("PangFuZhen" + ","); |
|
|
|
map.put("depositoryManager", depositoryManager.toString()); |
|
|
|
} else { |
|
|
|
// 如果点击的是驳回
|
|
|
|
map.put("pass", 2); |
|
|
|
map.put("departmentheadPass", 2); |
|
|
|
map.put("state", "部门负责人审核未通过"); |
|
|
|
redisTemplate.delete(spNo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
if (flag) { |
|
|
|
return 1; |
|
|
|
} |
|
|
|
map.put("id", outId); |
|
|
|
return depositoryRecordMapper.updateApplicationOutRecord(map); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 转移申请 |
|
|
|
* |
|
|
|
@ -684,12 +902,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
if (placeId == null || "".equals(placeId.toString()) || "0".equals(placeId.toString())) { |
|
|
|
map.put("placeId", 0); |
|
|
|
} |
|
|
|
|
|
|
|
Object parentId = map.get("parentId"); |
|
|
|
if (parentId == null) { |
|
|
|
// 插入主表
|
|
|
|
depositoryRecordMapper.insertApplicationOutRecord(map); |
|
|
|
Object id = map.get("id"); |
|
|
|
// 清除主键
|
|
|
|
map.remove("id"); |
|
|
|
map.put("parentId", id); |
|
|
|
} |
|
|
|
return depositoryRecordMapper.insertApplicationOutRecordMin(map); |
|
|
|
} |
|
|
|
|
|
|
|
@ -714,6 +936,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
if (departmentheadPass == 1) { |
|
|
|
result = "通过"; |
|
|
|
map.put("state", "待仓储中心负责人审核"); |
|
|
|
|
|
|
|
|
|
|
|
// 获取仓储中心详情
|
|
|
|
Administration company = PageController.getCompany(361, userToken); |
|
|
|
// 获取仓储中心负责人
|
|
|
|
@ -742,6 +966,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
redisTemplate.expire("user:" + userToken.getNumber() + ":QyWxOutId:" + id, 72, TimeUnit.HOURS); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
result = "驳回"; |
|
|
|
map.put("pass", 2); |
|
|
|
@ -761,6 +987,27 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
qyWxOperationService.updateTemplateCard(responseCode, userToken.getName(), finalResult, userAgent); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
|
|
|
|
// 开启流程通知其他人忽略审批流程
|
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
String departmenthead = record.getDepartmenthead(); |
|
|
|
String[] split = departmenthead.split(","); |
|
|
|
StringBuilder QyWxUid = new StringBuilder(); |
|
|
|
for (int i = 0; i < split.length; i++) { |
|
|
|
String s = split[i]; |
|
|
|
if ("".equals(s)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
UserByPort userByPort = PageController.FindUserById(ObjectFormatUtil.toInteger(s), null); |
|
|
|
QyWxUid.append(userByPort.getWorkwechat()).append(","); |
|
|
|
} |
|
|
|
String s = QyWxUid.toString(); |
|
|
|
s = "PangFuZhen,"; |
|
|
|
qyWxOperationService.sendMessageForOtherUserByCard(ObjectFormatUtil.toInteger(id), s, userAgent, 1); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} else { |
|
|
|
String result = ""; |
|
|
|
// 开启线程更改其他用户卡片模板样式
|
|
|
|
@ -768,6 +1015,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
map.put("depositoryManagerTime", DateUtil.DateTimeToTimeStamp(simpleTime)); |
|
|
|
map.put("depositoryManager", userid); |
|
|
|
map.put("depositoryId", record.getDepositoryId()); |
|
|
|
|
|
|
|
|
|
|
|
// map.put("mid", record.getMid());
|
|
|
|
// Material material = materialMapper.findMaterialById(record.getMid());
|
|
|
|
Integer depositoryManagerPass = (Integer) map.get("depositoryManagerPass"); |
|
|
|
@ -775,11 +1024,34 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
// 如果审核通过
|
|
|
|
result = "通过"; |
|
|
|
// 获取主单下的所有子单
|
|
|
|
|
|
|
|
// 根据仓库分类明细
|
|
|
|
Map<String, Object> minIdByDepository = new HashMap<>(); |
|
|
|
// 定义仓库列表
|
|
|
|
List<Integer> depositoryIdList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
StringBuilder minRecordByMain = new StringBuilder("[]"); |
|
|
|
List<ApplicationOutRecordMin> applicationOutRecordMinByParent = depositoryRecordMapper.findApplicationOutRecordMinByParent(record.getId()); |
|
|
|
for (int i = 0; i < applicationOutRecordMinByParent.size(); i++) { |
|
|
|
// 获取子单信息
|
|
|
|
ApplicationOutRecordMin applicationOutRecordMin = applicationOutRecordMinByParent.get(i); |
|
|
|
|
|
|
|
// 获取当前仓库下的子订单
|
|
|
|
Integer depositoryId = applicationOutRecordMin.getDepositoryId(); |
|
|
|
if (!findThisIdIsExist(depositoryIdList, depositoryId)) { |
|
|
|
// 如果当前仓库id没有存入过
|
|
|
|
depositoryIdList.add(depositoryId); |
|
|
|
} |
|
|
|
List<Integer> minIdList = new ArrayList<>(); |
|
|
|
Object o = minIdByDepository.get("depository" + depositoryId); |
|
|
|
if (o != null) { |
|
|
|
minIdList = (List<Integer>) o; |
|
|
|
} |
|
|
|
// 将当前子订单添加到该仓库下的子订单列表中
|
|
|
|
minIdList.add(applicationOutRecordMin.getId()); |
|
|
|
minIdByDepository.put("depository" + depositoryId, minIdList); |
|
|
|
|
|
|
|
//设置子订单在redis中的主键
|
|
|
|
String minRecordKey = "minRecord:" + applicationOutRecordMin.getId(); |
|
|
|
minRecordByMain.insert(1, minRecordKey + ","); // 将子订单主键插入到主订单的子订单列表
|
|
|
|
@ -822,15 +1094,67 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
minRecord.put("manager", minRecordManage.toString()); |
|
|
|
// 添加子订单到redis中
|
|
|
|
redisTemplate.opsForHash().putAll(minRecordKey, minRecord); |
|
|
|
// 开启线程向仓库管理员发送消息
|
|
|
|
|
|
|
|
|
|
|
|
/*// 开启线程向仓库管理员发送消息
|
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
}).start();*/ |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < depositoryIdList.size(); i++) { |
|
|
|
Object o = minIdByDepository.get("depository" + depositoryIdList.get(i)); |
|
|
|
if (o != null) { |
|
|
|
List<Integer> minIdList = (List<Integer>) o; |
|
|
|
List<Integer> userIdByDid = roleService.findUserIdByDid(depositoryIdList.get(i)); |
|
|
|
StringBuilder QyWxUid = new StringBuilder(); |
|
|
|
for (int j = 0; j < userIdByDid.size(); j++) { |
|
|
|
UserByPort manager = PageController.FindUserById(userIdByDid.get(j), userToken); |
|
|
|
// QyWxUid.append(manager.getWorkwechat()+",");
|
|
|
|
} |
|
|
|
QyWxUid.append("PangFuZhen,"); |
|
|
|
// 根据仓库向仓库管理员发送审批
|
|
|
|
JSONObject jsonObject = qyWxOperationService.sendOutApprovalTemplateOut(userAgent, userToken, ObjectFormatUtil.toInteger(id), minIdList, QyWxUid.toString()); |
|
|
|
String sp_no = jsonObject.getString("sp_no"); |
|
|
|
Map<String, Object> QyWxApprovalMap = new HashMap<>(); |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
for (int j = 0; j < minIdList.size(); j++) { |
|
|
|
sb.append(minIdList.get(j)).append(","); |
|
|
|
} |
|
|
|
QyWxApprovalMap.put("sp_no", sp_no); |
|
|
|
QyWxApprovalMap.put("minIdList", sb.toString()); |
|
|
|
redisTemplate.opsForHash().putAll(sp_no, QyWxApprovalMap); |
|
|
|
// 设置过期时间为7天
|
|
|
|
redisTemplate.expire(sp_no, 7, TimeUnit.DAYS); |
|
|
|
} else { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 开启流程通知其他人忽略审批流程
|
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
String depositoryManager = record.getDepositoryManager(); |
|
|
|
String[] split = depositoryManager.split(","); |
|
|
|
StringBuilder QyWxUid = new StringBuilder(); |
|
|
|
for (int i = 0; i < split.length; i++) { |
|
|
|
String s = split[i]; |
|
|
|
if ("".equals(s)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
UserByPort userByPort = PageController.FindUserById(ObjectFormatUtil.toInteger(s), null); |
|
|
|
QyWxUid.append(userByPort.getWorkwechat()).append(","); |
|
|
|
} |
|
|
|
String s = QyWxUid.toString(); |
|
|
|
s = "PangFuZhen,"; |
|
|
|
qyWxOperationService.sendMessageForOtherUserByCard(ObjectFormatUtil.toInteger(id), s, userAgent, 1); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
|
|
|
|
// 将主订单插入到redis中
|
|
|
|
redisTemplate.opsForHash().put("record:" + record.getId(), "minRecord", minRecordByMain.toString()); |
|
|
|
map.put("state", "仓储中心负责人审核通过"); |
|
|
|
@ -853,6 +1177,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
map.put("id", id); |
|
|
|
return depositoryRecordMapper.updateApplicationOutRecord(map); |
|
|
|
} |
|
|
|
@ -925,8 +1251,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
map.put("state", "部门负责人审核未通过"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
} else { |
|
|
|
// 如果是仓储中心负责人
|
|
|
|
// 获取点击的按钮类型
|
|
|
|
String clickKey = templateCard.getEventKey().split("_")[1]; |
|
|
|
@ -938,11 +1263,31 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
if ("pass".equals(clickKey)) { |
|
|
|
// 如果点击的是通过
|
|
|
|
map.put("depositoryManagerPass", 1); |
|
|
|
|
|
|
|
// 根据仓库分类明细
|
|
|
|
Map<String, Object> minIdByDepository = new HashMap<>(); |
|
|
|
// 定义仓库列表
|
|
|
|
List<Integer> depositoryIdList = new ArrayList<>(); |
|
|
|
|
|
|
|
StringBuilder minRecordByMain = new StringBuilder("[]"); |
|
|
|
List<ApplicationOutRecordMin> applicationOutRecordMinByParent = depositoryRecordMapper.findApplicationOutRecordMinByParent(recordP.getId()); |
|
|
|
for (int i = 0; i < applicationOutRecordMinByParent.size(); i++) { |
|
|
|
// 获取子单信息
|
|
|
|
ApplicationOutRecordMin applicationOutRecordMin = applicationOutRecordMinByParent.get(i); |
|
|
|
// 获取当前仓库下的子订单
|
|
|
|
Integer depositoryId = applicationOutRecordMin.getDepositoryId(); |
|
|
|
if (!findThisIdIsExist(depositoryIdList, depositoryId)) { |
|
|
|
// 如果当前仓库id没有存入过
|
|
|
|
depositoryIdList.add(depositoryId); |
|
|
|
} |
|
|
|
List<Integer> minIdList = new ArrayList<>(); |
|
|
|
Object o = minIdByDepository.get("depository" + depositoryId); |
|
|
|
if (o != null) { |
|
|
|
minIdList = (List<Integer>) o; |
|
|
|
} |
|
|
|
// 将当前子订单添加到该仓库下的子订单列表中
|
|
|
|
minIdList.add(applicationOutRecordMin.getId()); |
|
|
|
minIdByDepository.put("depository" + depositoryId, minIdList); |
|
|
|
//设置子订单在redis中的主键
|
|
|
|
String minRecordKey = "minRecord:" + applicationOutRecordMin.getId(); |
|
|
|
minRecordByMain.insert(1, minRecordKey + ","); // 将子订单主键插入到主订单的子订单列表
|
|
|
|
@ -992,6 +1337,34 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
}).start(); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < depositoryIdList.size(); i++) { |
|
|
|
Object o = minIdByDepository.get("depository" + depositoryIdList.get(i)); |
|
|
|
if (o != null) { |
|
|
|
List<Integer> minIdList = (List<Integer>) o; |
|
|
|
List<Integer> userIdByDid = roleService.findUserIdByDid(depositoryIdList.get(i)); |
|
|
|
StringBuilder QyWxUid = new StringBuilder(); |
|
|
|
for (int j = 0; j < userIdByDid.size(); j++) { |
|
|
|
UserByPort manager = PageController.FindUserById(userIdByDid.get(j), userByPort); |
|
|
|
// QyWxUid.append(manager.getWorkwechat()+",");
|
|
|
|
} |
|
|
|
QyWxUid.append("PangFuZhen,"); |
|
|
|
// 根据仓库向仓库管理员发送审批
|
|
|
|
JSONObject jsonObject = qyWxOperationService.sendOutApprovalTemplateOut(userAgent, userByPort, ObjectFormatUtil.toInteger(outId), minIdList, QyWxUid.toString()); |
|
|
|
String sp_no = jsonObject.getString("sp_no"); |
|
|
|
Map<String, Object> QyWxApprovalMap = new HashMap<>(); |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
for (int j = 0; j < minIdList.size(); j++) { |
|
|
|
sb.append(minIdList.get(j)).append(","); |
|
|
|
} |
|
|
|
QyWxApprovalMap.put("sp_no", sp_no); |
|
|
|
QyWxApprovalMap.put("minIdList", sb.toString()); |
|
|
|
redisTemplate.opsForHash().putAll(sp_no, QyWxApprovalMap); |
|
|
|
// 设置过期时间为7天
|
|
|
|
redisTemplate.expire(sp_no, 7, TimeUnit.DAYS); |
|
|
|
} else { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
// 将主订单插入到redis中
|
|
|
|
redisTemplate.opsForHash().put("record:" + recordP.getId(), "minRecord", minRecordByMain.toString()); |
|
|
|
map.put("state", "仓储中心负责人审核通过"); |
|
|
|
@ -1011,11 +1384,17 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
* |
|
|
|
* @param map |
|
|
|
*/ |
|
|
|
@Transactional |
|
|
|
public void transferMaterial(Map<String, Object> map) { |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
|
|
|
|
// 获取出库订单
|
|
|
|
Integer minRecordId = ObjectFormatUtil.toInteger(map.get("minRecordId")); |
|
|
|
|
|
|
|
// 获取子订单
|
|
|
|
ApplicationOutRecordMin recordMin = depositoryRecordMapper.findApplicationOutMinById(minRecordId); |
|
|
|
// 获取转移详情
|
|
|
|
Integer transferId = ObjectFormatUtil.toInteger(map.get("transferId")); |
|
|
|
TransferRecord transferRecor = transferRecordMapper.findTransferRecordById(transferId); |
|
|
|
TransferRecord transferRecor = transferRecordMapper.findTransferRecordById(recordMin.getTransferId()); |
|
|
|
Integer mid = transferRecor.getMid(); |
|
|
|
Material material = materialMapper.findMaterialById(mid); |
|
|
|
param.put("code", material.getCode()); |
|
|
|
@ -1072,18 +1451,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
MaterialAndPlace toMaterialAndPlace = placeMapper.findPlaceAndMaterialByMidAndPid(toPlaceTemp); |
|
|
|
if (toMaterialAndPlace == null) { |
|
|
|
placeMapper.addMaterialOnPlace(toPlaceTemp); |
|
|
|
} else { |
|
|
|
toMaterialAndPlace.setQuantity(toMaterialAndPlace.getQuantity() + quantity); |
|
|
|
placeMapper.updateMaterialAndPlace(toMaterialAndPlace); |
|
|
|
} |
|
|
|
// 转出库位
|
|
|
|
Place fromPlace = placeMapper.findPlaceById(transferRecor.getFromPlaceId()); |
|
|
|
fromPlace.setQuantity(fromPlace.getQuantity() - quantity); |
|
|
|
placeMapper.UpdatePlace(fromPlace); // 修改转出库位额度
|
|
|
|
fromPlaceTemp.put("mid", materialById.getId()); |
|
|
|
fromPlaceTemp.put("pid", toPlace.getId()); |
|
|
|
// 获取转出物料具体所在库位
|
|
|
|
MaterialAndPlace fromMaterialAndPlace = placeMapper.findPlaceAndMaterialByMidAndPid(fromPlaceTemp); |
|
|
|
fromMaterialAndPlace.setQuantity(fromMaterialAndPlace.getQuantity() - quantity); |
|
|
|
placeMapper.updateMaterialAndPlace(fromMaterialAndPlace); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -1420,7 +1794,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
ApplicationOutRecordMin applicationOutRecordMin = minByCondition.get(k); |
|
|
|
Integer mid = applicationOutRecordMin.getMid(); |
|
|
|
Material materialById = materialMapper.findMaterialById(mid); |
|
|
|
sum += ((double) materialById.getPrice() / 100) * applicationOutRecordMin.getQuantity(); |
|
|
|
sum += (materialById.getPrice() / 100) * applicationOutRecordMin.getQuantity(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -1431,7 +1805,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
ApplicationOutRecordMin recordMin = applicationOutMinForComplete.get(i); |
|
|
|
Integer mid = recordMin.getMid(); |
|
|
|
Material materialById = materialMapper.findMaterialById(mid); |
|
|
|
sum += ((double) materialById.getPrice() / 100) * recordMin.getQuantity(); |
|
|
|
sum += (materialById.getPrice() / 100) * recordMin.getQuantity(); |
|
|
|
} |
|
|
|
} |
|
|
|
BigDecimal bg = new BigDecimal(sum); |
|
|
|
@ -1751,4 +2125,22 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 判断当前id是否在ids中 |
|
|
|
* |
|
|
|
* @param ids |
|
|
|
* @param id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Boolean findThisIdIsExist(List<Integer> ids, Integer id) { |
|
|
|
for (Integer depositoryId : |
|
|
|
ids) { |
|
|
|
if (Integer.compare(id, depositoryId) == 0) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|