Browse Source

出库审批修改

lwx_dev
erdanergou 3 years ago
parent
commit
40703638dc
  1. 330
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  2. 116
      src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java

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

@ -224,7 +224,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @return * @return
*/ */
@Override @Override
public Integer insertApplicationOutRecord(Map<String, Object> map, UserByPort userToken,String userKey,String token) { public Integer insertApplicationOutRecord(Map<String, Object> map, UserByPort userToken, String userKey, String token) {
String placeId = ""; String placeId = "";
Object temp = map.get("placeId"); Object temp = map.get("placeId");
String depositoryId = (String) map.get("depositoryId"); String depositoryId = (String) map.get("depositoryId");
@ -263,7 +263,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Depository depositoryRecordById = depositoryMapper.findDepositoryById(materialById.getDepositoryId()); Depository depositoryRecordById = depositoryMapper.findDepositoryById(materialById.getDepositoryId());
dname = depositoryRecordById.getDname(); dname = depositoryRecordById.getDname();
} }
Administration company = LinkInterfaceUtil.getCompany(userToken.getMaindeparment(), userKey,token); Administration company = LinkInterfaceUtil.getCompany(userToken.getMaindeparment(), userKey, token);
String code = createCode(dname, "outOrderNumber", "out", company.getName()); String code = createCode(dname, "outOrderNumber", "out", company.getName());
map.put("code", code); map.put("code", code);
map.put("pass", 3); map.put("pass", 3);
@ -332,34 +332,34 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Integer integer = depositoryRecordMapper.deleteApplicationOutRecordByIds(list); Integer integer = depositoryRecordMapper.deleteApplicationOutRecordByIds(list);
// 开启一个线程去删除redis中的数据 // 开启一个线程去删除redis中的数据
HandlesOtherFunctionalThreadPool.execute(() -> { HandlesOtherFunctionalThreadPool.execute(() -> {
for (ApplicationOutRecord recordP : recordPList for (ApplicationOutRecord recordP : recordPList
) { ) {
// 获取该用户在redis中的订单记录 // 获取该用户在redis中的订单记录
String key = "user:" + recordP.getApplicantId(); String key = "user:" + recordP.getApplicantId();
List<ApplicationOutRecordMin> recordMinList = depositoryRecordMapper.findApplicationOutRecordMinByParent(recordP.getId()); List<ApplicationOutRecordMin> recordMinList = depositoryRecordMapper.findApplicationOutRecordMinByParent(recordP.getId());
for (ApplicationOutRecordMin recordMin : recordMinList for (ApplicationOutRecordMin recordMin : recordMinList
) { ) {
// 获取当前用户所有订单 // 获取当前用户所有订单
String minRecord = (String) redisPool.getRedisTemplateByDb(15).opsForHash().get(key, "minRecord"); String minRecord = (String) redisPool.getRedisTemplateByDb(15).opsForHash().get(key, "minRecord");
String redisMinRecordKey = "minRecord:" + recordMin.getId(); String redisMinRecordKey = "minRecord:" + recordMin.getId();
minRecord = minRecord.replace(redisMinRecordKey + ",", ""); minRecord = minRecord.replace(redisMinRecordKey + ",", "");
if (minRecord.length() == 2) { if (minRecord.length() == 2) {
// [] // []
// 如果当前用户已经没有剩余订单,则删除 // 如果当前用户已经没有剩余订单,则删除
redisPool.getRedisTemplateByDb(15).delete(key); redisPool.getRedisTemplateByDb(15).delete(key);
} else { } else {
redisPool.getRedisTemplateByDb(15).opsForHash().put(key, "minRecord", minRecord); redisPool.getRedisTemplateByDb(15).opsForHash().put(key, "minRecord", minRecord);
} }
redisPool.getRedisTemplateByDb(15).delete(redisMinRecordKey); redisPool.getRedisTemplateByDb(15).delete(redisMinRecordKey);
} }
String redisMainRecordKey = "record:" + recordP.getId(); // 设置redis中主订单键值 String redisMainRecordKey = "record:" + recordP.getId(); // 设置redis中主订单键值
redisPool.getRedisTemplateByDb(15).delete(redisMainRecordKey); redisPool.getRedisTemplateByDb(15).delete(redisMainRecordKey);
} }
}); });
// 开启一个线程用于删除 // 开启一个线程用于删除
HandlesOtherFunctionalThreadPool.execute(() -> depositoryRecordMapper.deleteApplicationOutRecordMinByIds(list)); HandlesOtherFunctionalThreadPool.execute(() -> depositoryRecordMapper.deleteApplicationOutRecordMinByIds(list));
@ -985,7 +985,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public RestResponse completeApplicationOutMinRecord(Map<String, Object> param, UserByPort userByPort, String userAgent,String userKey,String token) { public RestResponse completeApplicationOutMinRecord(Map<String, Object> param, UserByPort userByPort, String userAgent, String userKey, String token) {
// 最终返回值 // 最终返回值
RestResponse restResponse = new RestResponse(); RestResponse restResponse = new RestResponse();
@ -1096,30 +1096,30 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功"));
// 进行子订单的相关处理 // 进行子订单的相关处理
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent,userKey,token); updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent, userKey, token);
// 更新入库批次中的物料数量 // 更新入库批次中的物料数量
HandlesOtherFunctionalThreadPool.execute(() -> { HandlesOtherFunctionalThreadPool.execute(() -> {
// 获取出库物料id // 获取出库物料id
Integer mid1 = inventory.getId(); Integer mid1 = inventory.getId();
// 获取当前物料对应的生产日期 // 获取当前物料对应的生产日期
List<MaterialAndProducedDate> materialAndProducedDateByMid = materialMapper.findMaterialAndProducedDateByMid(mid1); List<MaterialAndProducedDate> materialAndProducedDateByMid = materialMapper.findMaterialAndProducedDateByMid(mid1);
if (materialAndProducedDateByMid.size() > 0) { if (materialAndProducedDateByMid.size() > 0) {
// 获取距今生产日期远的(即生产日期最早的) // 获取距今生产日期远的(即生产日期最早的)
for (MaterialAndProducedDate materialAndProducedDate : for (MaterialAndProducedDate materialAndProducedDate :
materialAndProducedDateByMid) { materialAndProducedDateByMid) {
if (materialAndProducedDate.getInventory() > quantity) { if (materialAndProducedDate.getInventory() > quantity) {
// 设置使用的数量 // 设置使用的数量
materialAndProducedDate.setExpendnum(materialAndProducedDate.getExpendnum() + (int) quantity); materialAndProducedDate.setExpendnum(materialAndProducedDate.getExpendnum() + (int) quantity);
// 设置剩余的数量 // 设置剩余的数量
materialAndProducedDate.setInventory(materialAndProducedDate.getInventory() - (int) quantity); materialAndProducedDate.setInventory(materialAndProducedDate.getInventory() - (int) quantity);
materialMapper.updateMaterialAndProducedDate(materialAndProducedDate); materialMapper.updateMaterialAndProducedDate(materialAndProducedDate);
// 跳出循环 // 跳出循环
break; break;
} }
} }
} }
}); });
} else { } else {
restResponse.setStatus(508); restResponse.setStatus(508);
restResponse.setData(""); restResponse.setData("");
@ -1181,7 +1181,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
// 进行子订单的相关处理 // 进行子订单的相关处理
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent,userKey,token); updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent, userKey, token);
restResponse.setStatus(200); restResponse.setStatus(200);
@ -1239,7 +1239,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
splitUnitMapper.updateSplitInventory(splitInventory); splitUnitMapper.updateSplitInventory(splitInventory);
} }
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent,userKey,token); updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent, userKey, token);
} else { } else {
// 如果当前拆单没有父级 // 如果当前拆单没有父级
@ -1314,7 +1314,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent,userKey,token); updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent, userKey, token);
restResponse.setStatus(200); restResponse.setStatus(200);
restResponse.setData(""); restResponse.setData("");
@ -1399,7 +1399,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
transferMaterial(map); transferMaterial(map);
} }
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent,userKey,token); updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent, userKey, token);
restResponse.setStatus(200); restResponse.setStatus(200);
restResponse.setData(""); restResponse.setData("");
@ -1474,7 +1474,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
transferMaterial(map); transferMaterial(map);
} }
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent,userKey,token); updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent, userKey, token);
restResponse.setStatus(200); restResponse.setStatus(200);
restResponse.setData(""); restResponse.setData("");
@ -1756,7 +1756,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public Integer updateOutMinRecordInfo(Map<String, Object> map, UserByPort userToken, String userAgent,String userKey,String token) { public Integer updateOutMinRecordInfo(Map<String, Object> map, UserByPort userToken, String userAgent, String userKey, String token) {
Integer result = 0; Integer result = 0;
Integer id = ObjectFormatUtil.toInteger(map.get("id")); Integer id = ObjectFormatUtil.toInteger(map.get("id"));
@ -1865,10 +1865,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 强行完成出库 // 强行完成出库
// 获取当前出库人员 // 获取当前出库人员
UserByPort userByPort = LinkInterfaceUtil.FindUserById(outRecordMin.getCheckId(), userKey,token); UserByPort userByPort = LinkInterfaceUtil.FindUserById(outRecordMin.getCheckId(), userKey, token);
outRecord.setPass(1); outRecord.setPass(1);
updateApplicationMinOutInfo(id, outRecordMin, outRecord, (double) (quantity), userByPort, placeById.getId(), userAgent,userKey,token); updateApplicationMinOutInfo(id, outRecordMin, outRecord, (double) (quantity), userByPort, placeById.getId(), userAgent, userKey, token);
} }
@ -1884,7 +1884,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
for (RoleAndMaterialType mt : materialTypeIdForIn for (RoleAndMaterialType mt : materialTypeIdForIn
) { ) {
// 获取管理员数据 // 获取管理员数据
UserByPort userByPort = LinkInterfaceUtil.FindUserById(mt.getUid(), userKey,token); UserByPort userByPort = LinkInterfaceUtil.FindUserById(mt.getUid(), userKey, token);
String workwechat = userByPort.getWorkwechat(); String workwechat = userByPort.getWorkwechat();
if (workwechat == null || "".equals(workwechat)) { if (workwechat == null || "".equals(workwechat)) {
workwechat = userByPort.getWechat(); workwechat = userByPort.getWechat();
@ -1897,7 +1897,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
for (RoleAndDepository mt : materialTypeIdForIn for (RoleAndDepository mt : materialTypeIdForIn
) { ) {
// 获取管理员数据 // 获取管理员数据
UserByPort userByPort = LinkInterfaceUtil.FindUserById(mt.getUserId(), userKey,token); UserByPort userByPort = LinkInterfaceUtil.FindUserById(mt.getUserId(), userKey, token);
String workwechat = userByPort.getWorkwechat(); String workwechat = userByPort.getWorkwechat();
if (workwechat == null || "".equals(workwechat)) { if (workwechat == null || "".equals(workwechat)) {
workwechat = userByPort.getWechat(); workwechat = userByPort.getWechat();
@ -1908,14 +1908,14 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
List<Integer> integerList = new ArrayList<>(); List<Integer> integerList = new ArrayList<>();
integerList.add(ObjectFormatUtil.toInteger(applicationInId)); integerList.add(ObjectFormatUtil.toInteger(applicationInId));
JSONObject jsonObject = qyWxOperationService.sendApprovalTemplateIn(userAgent, userToken, integerList, sb.toString(),userKey,token); JSONObject jsonObject = qyWxOperationService.sendApprovalTemplateIn(userAgent, userToken, integerList, sb.toString(), userKey, token);
String sp_no = jsonObject.getString("sp_no"); String sp_no = jsonObject.getString("sp_no");
Map<String, Object> QyWxApprovalMap = new HashMap<>(); Map<String, Object> QyWxApprovalMap = new HashMap<>();
QyWxApprovalMap.put("sp_no", sp_no); QyWxApprovalMap.put("sp_no", sp_no);
QyWxApprovalMap.put("mainId", integerList.toString()); QyWxApprovalMap.put("mainId", integerList.toString());
redisPool.getRedisTemplateByDb(14).opsForHash().putAll("wms_QyWxMessage_"+sp_no, QyWxApprovalMap); redisPool.getRedisTemplateByDb(14).opsForHash().putAll("wms_QyWxMessage_" + sp_no, QyWxApprovalMap);
// 设置过期为7天 // 设置过期为7天
redisPool.getRedisTemplateByDb(14).expire("wms_QyWxMessage_"+sp_no, 7, TimeUnit.DAYS); redisPool.getRedisTemplateByDb(14).expire("wms_QyWxMessage_" + sp_no, 7, TimeUnit.DAYS);
} }
@ -2015,7 +2015,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @param userAgent user-agent * @param userAgent user-agent
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
void updateApplicationMinOutInfo(Integer id, ApplicationOutRecordMin applicationOutMinById, ApplicationOutRecord record, Double trueOut, UserByPort userByPort, Integer placeId, String userAgent,String userKey,String token) { void updateApplicationMinOutInfo(Integer id, ApplicationOutRecordMin applicationOutMinById, ApplicationOutRecord record, Double trueOut, UserByPort userByPort, Integer placeId, String userAgent, String userKey, String token) {
String redisMinRecordKey = "minRecord:" + id; // 设置redis中子订单键值 String redisMinRecordKey = "minRecord:" + id; // 设置redis中子订单键值
// 修改当前已经出库的数量 // 修改当前已经出库的数量
applicationOutMinById.setTrueOut((int) ((trueOut * 100) + applicationOutMinById.getTrueOut())); applicationOutMinById.setTrueOut((int) ((trueOut * 100) + applicationOutMinById.getTrueOut()));
@ -2077,9 +2077,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取主订单单号 // 获取主订单单号
StringBuilder code = new StringBuilder(record.getCode()); StringBuilder code = new StringBuilder(record.getCode());
// 获取申请用户信息 // 获取申请用户信息
UserByPort applicantUser = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userKey,token); UserByPort applicantUser = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userKey, token);
// 获取申请用户行政组织 // 获取申请用户行政组织
Administration company = LinkInterfaceUtil.getCompany(applicantUser.getMaindeparment(), userKey,token); Administration company = LinkInterfaceUtil.getCompany(applicantUser.getMaindeparment(), userKey, token);
// 获取部门名称简写 // 获取部门名称简写
String conpanyName = WordUtil.getPinYinHeadChar(company.getName()); String conpanyName = WordUtil.getPinYinHeadChar(company.getName());
// 获取仓库名称简写 // 获取仓库名称简写
@ -2137,7 +2137,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
continue; continue;
} }
Integer uid = ObjectFormatUtil.toInteger(s); Integer uid = ObjectFormatUtil.toInteger(s);
UserByPort depositoryManager = LinkInterfaceUtil.FindUserById(uid, userKey,token); UserByPort depositoryManager = LinkInterfaceUtil.FindUserById(uid, userKey, token);
String workwechat = depositoryManager.getWorkwechat(); String workwechat = depositoryManager.getWorkwechat();
if (workwechat == null || "".equals(workwechat)) { if (workwechat == null || "".equals(workwechat)) {
workwechat = userByPort.getWechat(); workwechat = userByPort.getWechat();
@ -2145,7 +2145,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// depositoryManagerByQyWx.append(workwechat+","); // depositoryManagerByQyWx.append(workwechat+",");
} }
depositoryManagerByQyWx.append("PangFuZhen,"); depositoryManagerByQyWx.append("PangFuZhen,");
JSONObject jsonObject = qyWxOperationService.sendCcMessageToUsers(depositoryManagerByQyWx.toString(), record.getId(), userAgent,userKey,token); JSONObject jsonObject = qyWxOperationService.sendCcMessageToUsers(depositoryManagerByQyWx.toString(), record.getId(), userAgent, userKey, token);
// 删除redis中本订单 // 删除redis中本订单
redisPool.getRedisTemplateByDb(15).delete("record:" + record.getId()); redisPool.getRedisTemplateByDb(15).delete("record:" + record.getId());
@ -2286,7 +2286,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
StringBuilder QyWxUid = new StringBuilder(); StringBuilder QyWxUid = new StringBuilder();
for (Integer integer : userIdByDid) { for (Integer integer : userIdByDid) {
// 获取仓库管理员信息 // 获取仓库管理员信息
UserByPort manager = LinkInterfaceUtil.FindUserById(integer, null,null); UserByPort manager = LinkInterfaceUtil.FindUserById(integer, null, null);
// 仓库管理员订单信息 // 仓库管理员订单信息
Map<String, Object> userRecord = new HashMap<>(); Map<String, Object> userRecord = new HashMap<>();
// 用户当前子订单 // 用户当前子订单
@ -2312,9 +2312,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 添加子订单到redis中 // 添加子订单到redis中
redisPool.getRedisTemplateByDb(15).opsForHash().putAll(minRecordKey, minRecord); redisPool.getRedisTemplateByDb(15).opsForHash().putAll(minRecordKey, minRecord);
// 开启线程向仓库管理员发送消息 // 开启线程向仓库管理员发送消息
SendQyWxMessageThreadPool.execute(() -> { SendQyWxMessageThreadPool.execute(() -> {
JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent,userKey,token); JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent, userKey, token);
}); });
} else { } else {
// 如果是通过仓库 // 如果是通过仓库
@ -2338,7 +2338,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
StringBuilder QyWxUid = new StringBuilder(); StringBuilder QyWxUid = new StringBuilder();
for (Integer integer : userIdByDid) { for (Integer integer : userIdByDid) {
// 获取仓库管理员信息 // 获取仓库管理员信息
UserByPort manager = LinkInterfaceUtil.FindUserById(integer, null,null); UserByPort manager = LinkInterfaceUtil.FindUserById(integer, null, null);
// 仓库管理员订单信息 // 仓库管理员订单信息
Map<String, Object> userRecord = new HashMap<>(); Map<String, Object> userRecord = new HashMap<>();
// 用户当前子订单 // 用户当前子订单
@ -2366,7 +2366,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 开启线程向仓库管理员发送消息 // 开启线程向仓库管理员发送消息
SendQyWxMessageThreadPool.execute(() -> { SendQyWxMessageThreadPool.execute(() -> {
JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent,userKey,token); JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent, userKey, token);
}); });
} }
@ -2399,10 +2399,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
} }
// 将当前redis中存储的spno删除 // 将当前redis中存储的spno删除
redisPool.getRedisTemplateByDb(14).delete("wms_QyWxMessage_"+spNo); redisPool.getRedisTemplateByDb(14).delete("wms_QyWxMessage_" + spNo);
} }
} } else {
else {
// 如果是部门负责人 // 如果是部门负责人
String departmentheadTime = recordP.getDepartmentheadTime(); String departmentheadTime = recordP.getDepartmentheadTime();
@ -2423,14 +2422,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Depository depositoryById = depositoryMapper.findDepositoryById(recordP.getDepositoryId()); Depository depositoryById = depositoryMapper.findDepositoryById(recordP.getDepositoryId());
// 获取当前仓库所属的部门 // 获取当前仓库所属的部门
String adminorg = depositoryById.getAdminorg(); String adminorg = depositoryById.getAdminorg();
List<UserByPort> departmentHeadByUser = PublicConfig.findDepartmentHeadByUser(ObjectFormatUtil.toInteger(adminorg),null,null); List<UserByPort> departmentHeadByUser = PublicConfig.findDepartmentHeadByUser(ObjectFormatUtil.toInteger(adminorg), null, null);
for (UserByPort departmentHead:departmentHeadByUser for (UserByPort departmentHead : departmentHeadByUser
) { ) {
depositoryManager.append(departmentHead.getId()).append(","); depositoryManager.append(departmentHead.getId()).append(",");
} }
} else {
}else{
map.put("state", "待仓储中心负责人审核"); map.put("state", "待仓储中心负责人审核");
// 获取仓储中心负责人标签的用户userId // 获取仓储中心负责人标签的用户userId
List<String> qyWxLabelUserList = QyWxConfig.getQyWxLabelUserList(userAgent); List<String> qyWxLabelUserList = QyWxConfig.getQyWxLabelUserList(userAgent);
@ -2440,15 +2437,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
depositoryManager.append(user.getId()).append(","); depositoryManager.append(user.getId()).append(",");
} }
} }
if (recordP.getDepositoryManager() == null) {
map.put("depositoryManager", depositoryManager.toString()); map.put("depositoryManager", depositoryManager.toString());
}
} else { } else {
// 如果点击的是驳回 // 如果点击的是驳回
updateInventoryForOutRefused(recordP); updateInventoryForOutRefused(recordP);
map.put("pass", 2); map.put("pass", 2);
map.put("departmentheadPass", 2); map.put("departmentheadPass", 2);
map.put("state", "部门负责人审核未通过"); map.put("state", "部门负责人审核未通过");
redisPool.getRedisTemplateByDb(14).delete("wms_QyWxMessage_"+spNo); redisPool.getRedisTemplateByDb(14).delete("wms_QyWxMessage_" + spNo);
} }
} }
@ -2660,7 +2658,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
} }
} }
redisPool.getRedisTemplateByDb(14).delete("wms_QyWxMessage_"+spNo); redisPool.getRedisTemplateByDb(14).delete("wms_QyWxMessage_" + spNo);
} }
@ -2672,7 +2670,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Integer transferApply(Map<String, Object> map, UserByPort userByPort,String userKey,String token) { public Integer transferApply(Map<String, Object> map, UserByPort userByPort, String userKey, String token) {
Integer mid = ObjectFormatUtil.toInteger(map.get("mid")); Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
double quantity = Double.parseDouble((String) map.get("quantity")); double quantity = Double.parseDouble((String) map.get("quantity"));
Inventory material = materialMapper.findInventoryById(mid); Inventory material = materialMapper.findInventoryById(mid);
@ -2706,7 +2704,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
map.put("transferId", transferId); map.put("transferId", transferId);
// 获取当前转移物料仓库 // 获取当前转移物料仓库
Depository depositoryRecordById = depositoryMapper.findDepositoryById(material.getDepositoryId()); Depository depositoryRecordById = depositoryMapper.findDepositoryById(material.getDepositoryId());
Administration company = LinkInterfaceUtil.getCompany(userByPort.getMaindeparment(), userKey,token); Administration company = LinkInterfaceUtil.getCompany(userByPort.getMaindeparment(), userKey, token);
// 生成出库订单 // 生成出库订单
map.put("code", createCode(depositoryRecordById.getDname(), "outOrderNumber", "out", company.getName())); map.put("code", createCode(depositoryRecordById.getDname(), "outOrderNumber", "out", company.getName()));
Object placeId = map.get("fromPlaceId"); Object placeId = map.get("fromPlaceId");
@ -2717,7 +2715,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Object parentId = map.get("parentId"); Object parentId = map.get("parentId");
if (parentId == null) { if (parentId == null) {
// 插入主表 // 插入主表
map.put("flagForOpenDepository",2); map.put("flagForOpenDepository", 2);
depositoryRecordMapper.insertApplicationOutRecord(map); depositoryRecordMapper.insertApplicationOutRecord(map);
Object id = map.get("id"); Object id = map.get("id");
// 清除主键 // 清除主键
@ -2767,14 +2765,14 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Integer review(Map<String, Object> map, Integer userid, UserByPort userToken, String userAgent,String userKey,String token) { public Integer review(Map<String, Object> map, Integer userid, UserByPort userToken, String userAgent, String userKey, String token) {
Object id = map.get("id"); // 主订单编号 Object id = map.get("id"); // 主订单编号
ApplicationOutRecord record = depositoryRecordMapper.findApplicationOutRecordPById(ObjectFormatUtil.toInteger(id)); ApplicationOutRecord record = depositoryRecordMapper.findApplicationOutRecordPById(ObjectFormatUtil.toInteger(id));
map.remove("id"); map.remove("id");
List<ApplicationOutRecordMin> minByParent = depositoryRecordMapper.findApplicationOutRecordMinByParent(record.getId()); List<ApplicationOutRecordMin> minByParent = depositoryRecordMapper.findApplicationOutRecordMinByParent(record.getId());
// 获取申请用户 // 获取申请用户
UserByPort applicantUser = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userKey,token); UserByPort applicantUser = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userKey, token);
// 用于标志该仓库是否为前置仓下的仓库 // 用于标志该仓库是否为前置仓下的仓库
boolean flagForHasOtherDepository = true; //默认是前置仓下的仓库 boolean flagForHasOtherDepository = true; //默认是前置仓下的仓库
// 获取当前出库是否为开放出库 // 获取当前出库是否为开放出库
@ -2818,31 +2816,31 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
StringBuilder depositoryManager = new StringBuilder(); StringBuilder depositoryManager = new StringBuilder();
// 用于存储下节点审批人的企业微信id // 用于存储下节点审批人的企业微信id
StringBuilder QyWxUid = new StringBuilder(); StringBuilder QyWxUid = new StringBuilder();
if(flagForOpenDepository == 2){ if (flagForOpenDepository == 2) {
// 如果是开放仓库 // 如果是开放仓库
map.put("state","待部门负责人审核"); map.put("state", "待部门负责人审核");
// 获取当前选中的仓库 // 获取当前选中的仓库
Depository depositoryById = depositoryMapper.findDepositoryById(record.getDepositoryId()); Depository depositoryById = depositoryMapper.findDepositoryById(record.getDepositoryId());
// 获取当前仓库所属的部门 // 获取当前仓库所属的部门
String adminorg = depositoryById.getAdminorg(); String adminorg = depositoryById.getAdminorg();
List<UserByPort> departmentHeadByUser = PublicConfig.findDepartmentHeadByUser(ObjectFormatUtil.toInteger(adminorg),null,null); List<UserByPort> departmentHeadByUser = PublicConfig.findDepartmentHeadByUser(ObjectFormatUtil.toInteger(adminorg), null, null);
for (UserByPort departmentHead:departmentHeadByUser for (UserByPort departmentHead : departmentHeadByUser
) { ) {
depositoryManager.append(departmentHead.getId()).append(","); depositoryManager.append(departmentHead.getId()).append(",");
String workwechat = departmentHead.getWorkwechat(); String workwechat = departmentHead.getWorkwechat();
if(workwechat == null || "".equals(workwechat)){ if (workwechat == null || "".equals(workwechat)) {
workwechat = departmentHead.getWechat(); workwechat = departmentHead.getWechat();
} }
QyWxUid.append(workwechat).append(","); QyWxUid.append(workwechat).append(",");
} }
}else{ } else {
// 如果是正常仓库 // 如果是正常仓库
// 获取仓储中心负责人 // 获取仓储中心负责人
List<UserByPort> departmentHeadByUser = PublicConfig.findDepartmentHeadByUser(361,userKey,token); List<UserByPort> departmentHeadByUser = PublicConfig.findDepartmentHeadByUser(361, userKey, token);
for (UserByPort userByPort : departmentHeadByUser) { for (UserByPort userByPort : departmentHeadByUser) {
depositoryManager.append(userByPort.getId()).append(","); depositoryManager.append(userByPort.getId()).append(",");
@ -2855,12 +2853,28 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
QyWxUid.append("PangFuZhen,"); QyWxUid.append("PangFuZhen,");
map.put("depositoryManager", depositoryManager.toString()); if (record.getDepositoryManager() == null) {
map.put("depositoryManager", depositoryManager.toString());
} else {
String[] depositoryManagerS = record.getDepositoryManager().split(",");
for (String depositorymanager : depositoryManagerS
) {
if ("".equals(depositorymanager)) {
continue;
}
UserByPort depositoryManage = LinkInterfaceUtil.FindUserById(ObjectFormatUtil.toInteger(depositorymanager), userKey, token);
String departmentHeadWorkwechat = depositoryManage.getWorkwechat();
if (departmentHeadWorkwechat == null || "".equals(departmentHeadWorkwechat)) {
departmentHeadWorkwechat = depositoryManage.getWechat();
}
QyWxUid.append(departmentHeadWorkwechat).append(",");
}
}
// 向仓储中心负责人发送新的消息 // 向仓储中心负责人发送新的消息
SendQyWxMessageThreadPool.execute(() -> { SendQyWxMessageThreadPool.execute(() -> {
JSONObject jsonObject = qyWxOperationService.sendQyWxToApplicationOutMessage(QyWxUid.toString(), ObjectFormatUtil.toInteger(id), false, userAgent,userKey,token); JSONObject jsonObject = qyWxOperationService.sendQyWxToApplicationOutMessage(QyWxUid.toString(), ObjectFormatUtil.toInteger(id), false, userAgent, userKey, token);
// 将当前返回结果保存到redis中 // 将当前返回结果保存到redis中
Map<String, Object> QyWxMessageMap = new HashMap<>(); Map<String, Object> QyWxMessageMap = new HashMap<>();
QyWxMessageMap.put("MsgId", jsonObject.getString("msgid")); QyWxMessageMap.put("MsgId", jsonObject.getString("msgid"));
@ -2883,13 +2897,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 开启线程更改其他用户卡片模板样式 // 开启线程更改其他用户卡片模板样式
String finalResult = result; String finalResult = result;
SendQyWxMessageThreadPool.execute(() -> { SendQyWxMessageThreadPool.execute(() -> {
// 获取responseCode(key为申请人number) // 获取responseCode(key为申请人number)
//获取申请人信息 //获取申请人信息
String key = "user:" + applicantUser.getNumber() + ":QyWxOutId:" + id; String key = "user:" + applicantUser.getNumber() + ":QyWxOutId:" + id;
String responseCode = (String) redisPool.getRedisTemplateByDb(15).opsForHash().get(key, "responseCode"); String responseCode = (String) redisPool.getRedisTemplateByDb(15).opsForHash().get(key, "responseCode");
qyWxOperationService.updateButtonTemplateCardToUnEnable(responseCode, userToken.getName(), finalResult, userAgent); qyWxOperationService.updateButtonTemplateCardToUnEnable(responseCode, userToken.getName(), finalResult, userAgent);
}); });
// 开启流程通知其他人忽略审批流程 // 开启流程通知其他人忽略审批流程
SendQyWxMessageThreadPool.execute(() -> { SendQyWxMessageThreadPool.execute(() -> {
@ -2900,7 +2914,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if ("".equals(s)) { if ("".equals(s)) {
continue; continue;
} }
UserByPort userByPort = LinkInterfaceUtil.FindUserById(ObjectFormatUtil.toInteger(s), userKey,token); UserByPort userByPort = LinkInterfaceUtil.FindUserById(ObjectFormatUtil.toInteger(s), userKey, token);
String workwechat = userByPort.getWorkwechat(); String workwechat = userByPort.getWorkwechat();
if (workwechat == null || "".equals(workwechat)) { if (workwechat == null || "".equals(workwechat)) {
workwechat = userByPort.getWechat(); workwechat = userByPort.getWechat();
@ -2909,10 +2923,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
String s = QyWxUid.toString(); String s = QyWxUid.toString();
s = "PangFuZhen,"; s = "PangFuZhen,";
qyWxOperationService.sendMessageForOtherUserByCard(ObjectFormatUtil.toInteger(id), s, userAgent, 1,userKey,token); qyWxOperationService.sendMessageForOtherUserByCard(ObjectFormatUtil.toInteger(id), s, userAgent, 1, userKey, token);
}); });
} } else {
else {
String result = ""; String result = "";
// 开启线程更改其他用户卡片模板样式 // 开启线程更改其他用户卡片模板样式
String simpleTime = DateUtil.getSimpleTime(new Date()); String simpleTime = DateUtil.getSimpleTime(new Date());
@ -2999,7 +3012,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
StringBuilder QyWxUid = new StringBuilder(); StringBuilder QyWxUid = new StringBuilder();
for (Integer integer : userIdByDid) { for (Integer integer : userIdByDid) {
// 获取仓库管理员信息 // 获取仓库管理员信息
UserByPort manager = LinkInterfaceUtil.FindUserById(integer, userKey,token); UserByPort manager = LinkInterfaceUtil.FindUserById(integer, userKey, token);
// 仓库管理员订单信息 // 仓库管理员订单信息
Map<String, Object> userRecord = new HashMap<>(); Map<String, Object> userRecord = new HashMap<>();
// 用户当前子订单 // 用户当前子订单
@ -3026,10 +3039,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
redisPool.getRedisTemplateByDb(15).opsForHash().putAll(minRecordKey, minRecord); redisPool.getRedisTemplateByDb(15).opsForHash().putAll(minRecordKey, minRecord);
// 开启线程向仓库管理员发送消息 // 开启线程向仓库管理员发送消息
SendQyWxMessageThreadPool.execute(() -> { SendQyWxMessageThreadPool.execute(() -> {
JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent,userKey,token); JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent, userKey, token);
}); });
} } else {
else {
// 如果是通过仓库 // 如果是通过仓库
@ -3052,7 +3064,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
StringBuilder QyWxUid = new StringBuilder(); StringBuilder QyWxUid = new StringBuilder();
for (Integer integer : userIdByDid) { for (Integer integer : userIdByDid) {
// 获取仓库管理员信息 // 获取仓库管理员信息
UserByPort manager = LinkInterfaceUtil.FindUserById(integer, userKey,token); UserByPort manager = LinkInterfaceUtil.FindUserById(integer, userKey, token);
// 仓库管理员订单信息 // 仓库管理员订单信息
Map<String, Object> userRecord = new HashMap<>(); Map<String, Object> userRecord = new HashMap<>();
// 用户当前子订单 // 用户当前子订单
@ -3079,7 +3091,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
redisPool.getRedisTemplateByDb(15).opsForHash().putAll(minRecordKey, minRecord); redisPool.getRedisTemplateByDb(15).opsForHash().putAll(minRecordKey, minRecord);
// 开启线程向仓库管理员发送消息 // 开启线程向仓库管理员发送消息
SendQyWxMessageThreadPool.execute(() -> { SendQyWxMessageThreadPool.execute(() -> {
JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent,userKey,token); JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent, userKey, token);
}); });
} }
} }
@ -3094,7 +3106,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if ("".equals(s)) { if ("".equals(s)) {
continue; continue;
} }
UserByPort userByPort = LinkInterfaceUtil.FindUserById(ObjectFormatUtil.toInteger(s), userKey,token); UserByPort userByPort = LinkInterfaceUtil.FindUserById(ObjectFormatUtil.toInteger(s), userKey, token);
String workwechat = userByPort.getWorkwechat(); String workwechat = userByPort.getWorkwechat();
if (workwechat == null || "".equals(workwechat)) { if (workwechat == null || "".equals(workwechat)) {
workwechat = userByPort.getWechat(); workwechat = userByPort.getWechat();
@ -3103,7 +3115,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
String s = QyWxUid.toString(); String s = QyWxUid.toString();
s = "PangFuZhen,"; s = "PangFuZhen,";
qyWxOperationService.sendMessageForOtherUserByCard(ObjectFormatUtil.toInteger(id), s, userAgent, 1,userKey,token); qyWxOperationService.sendMessageForOtherUserByCard(ObjectFormatUtil.toInteger(id), s, userAgent, 1, userKey, token);
}); });
// 将主订单插入到redis中 // 将主订单插入到redis中
@ -3118,8 +3130,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
map.put("departmentheadPass", 1); map.put("departmentheadPass", 1);
} }
} } else {
else {
updateInventoryForOutRefused(record); updateInventoryForOutRefused(record);
result = "驳回"; result = "驳回";
map.put("pass", 2); map.put("pass", 2);
@ -3134,14 +3145,14 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
// 开启线程更改其他用户卡片模板样式 // 开启线程更改其他用户卡片模板样式
String finalResult = result; String finalResult = result;
SendQyWxMessageThreadPool.execute(() -> { SendQyWxMessageThreadPool.execute(() -> {
// 获取responseCode(key为申请人number) // 获取responseCode(key为申请人number)
//获取部门负责人信息 //获取部门负责人信息
UserByPort departHead = LinkInterfaceUtil.FindUserById(ObjectFormatUtil.toInteger(record.getDepartmenthead()), userKey,token); UserByPort departHead = LinkInterfaceUtil.FindUserById(ObjectFormatUtil.toInteger(record.getDepartmenthead()), userKey, token);
String key = "user:" + departHead.getNumber() + ":QyWxOutId:" + id; String key = "user:" + departHead.getNumber() + ":QyWxOutId:" + id;
String responseCode = (String) redisPool.getRedisTemplateByDb(15).opsForHash().get(key, "responseCode"); String responseCode = (String) redisPool.getRedisTemplateByDb(15).opsForHash().get(key, "responseCode");
qyWxOperationService.updateButtonTemplateCardToUnEnable(responseCode, userToken.getName(), finalResult, userAgent); qyWxOperationService.updateButtonTemplateCardToUnEnable(responseCode, userToken.getName(), finalResult, userAgent);
}); });
} }
map.put("id", id); map.put("id", id);
return depositoryRecordMapper.updateApplicationOutRecord(map); return depositoryRecordMapper.updateApplicationOutRecord(map);
@ -3299,7 +3310,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
map.put("departmentheadPass", 1); map.put("departmentheadPass", 1);
map.put("state", "待仓储中心负责人审核"); map.put("state", "待仓储中心负责人审核");
// 获取仓储中心负责人 // 获取仓储中心负责人
List<UserByPort> departmentHeadByUser = PublicConfig.findDepartmentHeadByUser(361,null,null); List<UserByPort> departmentHeadByUser = PublicConfig.findDepartmentHeadByUser(361, null, null);
StringBuilder depositoryManager = new StringBuilder(); StringBuilder depositoryManager = new StringBuilder();
StringBuilder QyWxUid = new StringBuilder(); StringBuilder QyWxUid = new StringBuilder();
// for (int i = 0; i < departmentHeadByUser.size(); i++) { // for (int i = 0; i < departmentHeadByUser.size(); i++) {
@ -3313,7 +3324,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
QyWxUid.append("PangFuZhen" + ","); QyWxUid.append("PangFuZhen" + ",");
map.put("depositoryManager", depositoryManager.toString()); map.put("depositoryManager", depositoryManager.toString());
// 向仓储中心负责人发送新的消息 // 向仓储中心负责人发送新的消息
JSONObject jsonObject = qyWxOperationService.sendQyWxToApplicationOutMessage(QyWxUid.toString(), ObjectFormatUtil.toInteger(outId), false, userAgent,userKey,token); JSONObject jsonObject = qyWxOperationService.sendQyWxToApplicationOutMessage(QyWxUid.toString(), ObjectFormatUtil.toInteger(outId), false, userAgent, userKey, token);
// 将当前返回结果保存到redis中 // 将当前返回结果保存到redis中
Map<String, Object> QyWxMessageMap = new HashMap<>(); Map<String, Object> QyWxMessageMap = new HashMap<>();
QyWxMessageMap.put("MsgId", jsonObject.getString("msgid")); QyWxMessageMap.put("MsgId", jsonObject.getString("msgid"));
@ -3386,7 +3397,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
StringBuilder QyWxUid = new StringBuilder(); StringBuilder QyWxUid = new StringBuilder();
for (Integer integer : userIdByDid) { for (Integer integer : userIdByDid) {
// 获取仓库管理员信息 // 获取仓库管理员信息
UserByPort manager = LinkInterfaceUtil.FindUserById(integer, userKey,token); UserByPort manager = LinkInterfaceUtil.FindUserById(integer, userKey, token);
// 仓库管理员订单信息 // 仓库管理员订单信息
Map<String, Object> userRecord = new HashMap<>(); Map<String, Object> userRecord = new HashMap<>();
// 用户当前子订单 // 用户当前子订单
@ -3413,7 +3424,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
redisPool.getRedisTemplateByDb(15).opsForHash().putAll(minRecordKey, minRecord); redisPool.getRedisTemplateByDb(15).opsForHash().putAll(minRecordKey, minRecord);
// 开启线程向仓库管理员发送消息 // 开启线程向仓库管理员发送消息
SendQyWxMessageThreadPool.execute(() -> { SendQyWxMessageThreadPool.execute(() -> {
JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent,userKey,token); JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent, userKey, token);
}); });
} }
@ -3875,7 +3886,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @return * @return
*/ */
@Override @Override
public List<ApplicationInRecordP> findApplicationInRecordPByCondition(Map<String, Object> map, UserByPort userToken,String userKey,String token) { public List<ApplicationInRecordP> findApplicationInRecordPByCondition(Map<String, Object> map, UserByPort userToken, String userKey, String token) {
Integer size = 10, page = 1; Integer size = 10, page = 1;
if (map.containsKey("size")) { if (map.containsKey("size")) {
size = ObjectFormatUtil.toInteger(map.get("size")); size = ObjectFormatUtil.toInteger(map.get("size"));
@ -3893,7 +3904,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
List<ApplicationInRecordP> result = new ArrayList<>(); List<ApplicationInRecordP> result = new ArrayList<>();
for (ApplicationInRecord applicationInRecord : list) { for (ApplicationInRecord applicationInRecord : list) {
UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecord.getApplicantId(), userKey,token); UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecord.getApplicantId(), userKey, token);
String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecord.getApplicantTime())); String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecord.getApplicantTime()));
applicationInRecord.setApplicantName(userByPortById.getName()); applicationInRecord.setApplicantName(userByPortById.getName());
applicationInRecord.setApplicantTime(time); applicationInRecord.setApplicantTime(time);
@ -3920,7 +3931,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @return * @return
*/ */
@Override @Override
public List<ApplicationInRecordP> findApplicationInRecordPByUser(UserByPort userByPort, Map<String, Object> map,String userKey,String token) { public List<ApplicationInRecordP> findApplicationInRecordPByUser(UserByPort userByPort, Map<String, Object> map, String userKey, String token) {
Integer size = 10, page = 1; Integer size = 10, page = 1;
if (map.containsKey("size")) { if (map.containsKey("size")) {
size = ObjectFormatUtil.toInteger(map.get("size")); size = ObjectFormatUtil.toInteger(map.get("size"));
@ -3947,7 +3958,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
List<ApplicationInRecord> list = depositoryRecordMapper.findApplicationInRecordPByUser(map); List<ApplicationInRecord> list = depositoryRecordMapper.findApplicationInRecordPByUser(map);
List<ApplicationInRecordP> result = new ArrayList<>(); List<ApplicationInRecordP> result = new ArrayList<>();
for (ApplicationInRecord applicationInRecord : list) { for (ApplicationInRecord applicationInRecord : list) {
UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecord.getApplicantId(), userKey,token); UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecord.getApplicantId(), userKey, token);
String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecord.getApplicantTime())); String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecord.getApplicantTime()));
applicationInRecord.setApplicantName(userByPortById.getName()); applicationInRecord.setApplicantName(userByPortById.getName());
applicationInRecord.setApplicantTime(time); applicationInRecord.setApplicantTime(time);
@ -3989,7 +4000,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @return * @return
*/ */
@Override @Override
public List<ApplicationOutRecordP> findApplicationOutRecordPByUser(UserByPort userByPort, Map<String, Object> map,String userKey,String token) { public List<ApplicationOutRecordP> findApplicationOutRecordPByUser(UserByPort userByPort, Map<String, Object> map, String userKey, String token) {
if (map.containsKey("applyTime")) { if (map.containsKey("applyTime")) {
String applyTime = (String) map.get("applyTime"); String applyTime = (String) map.get("applyTime");
map.put("applicantTime", DateUtil.DateTimeByDayToTimeStamp(applyTime)); map.put("applicantTime", DateUtil.DateTimeByDayToTimeStamp(applyTime));
@ -4017,7 +4028,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
List<ApplicationOutRecord> list = depositoryRecordMapper.findApplicationOutRecordPByUser(map); List<ApplicationOutRecord> list = depositoryRecordMapper.findApplicationOutRecordPByUser(map);
List<ApplicationOutRecordP> result = new ArrayList<>(); List<ApplicationOutRecordP> result = new ArrayList<>();
for (ApplicationOutRecord record : list) { for (ApplicationOutRecord record : list) {
UserByPort userByPortById = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userKey,token); UserByPort userByPortById = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userKey, token);
String time = DateUtil.TimeStampToDateTime(Long.valueOf(record.getApplicantTime())); String time = DateUtil.TimeStampToDateTime(Long.valueOf(record.getApplicantTime()));
record.setApplicantName(userByPortById.getName()); record.setApplicantName(userByPortById.getName());
record.setApplicantTime(time); record.setApplicantTime(time);
@ -4070,7 +4081,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @return * @return
*/ */
@Override @Override
public List<ApplicationOutRecordP> findApplicationOutRecordPByCondition(Map<String, Object> map, UserByPort userToken,String userKey,String token) { public List<ApplicationOutRecordP> findApplicationOutRecordPByCondition(Map<String, Object> map, UserByPort userToken, String userKey, String token) {
Integer size = 10, page = 1; Integer size = 10, page = 1;
if (map.containsKey("size")) { if (map.containsKey("size")) {
size = ObjectFormatUtil.toInteger(map.get("size")); size = ObjectFormatUtil.toInteger(map.get("size"));
@ -4087,7 +4098,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
List<ApplicationOutRecord> list = depositoryRecordMapper.findApplicationOutRecordPByCondition(map); List<ApplicationOutRecord> list = depositoryRecordMapper.findApplicationOutRecordPByCondition(map);
List<ApplicationOutRecordP> result = new ArrayList<>(); List<ApplicationOutRecordP> result = new ArrayList<>();
for (ApplicationOutRecord recordP : list) { for (ApplicationOutRecord recordP : list) {
UserByPort userByPortById = LinkInterfaceUtil.FindUserById(recordP.getApplicantId(), userKey,token); UserByPort userByPortById = LinkInterfaceUtil.FindUserById(recordP.getApplicantId(), userKey, token);
String time = DateUtil.TimeStampToDateTime(Long.valueOf(recordP.getApplicantTime())); String time = DateUtil.TimeStampToDateTime(Long.valueOf(recordP.getApplicantTime()));
recordP.setApplicantName(userByPortById.getName()); recordP.setApplicantName(userByPortById.getName());
recordP.setApplicantTime(time); recordP.setApplicantTime(time);
@ -4175,7 +4186,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @return 我的任务 * @return 我的任务
*/ */
@Override @Override
public List<SimpleApplicationOutOrInRecordP> findMyTaskOut(Map<String, Object> map, String userKey,String token) { public List<SimpleApplicationOutOrInRecordP> findMyTaskOut(Map<String, Object> map, String userKey, String token) {
Integer size = 10, page = 1; Integer size = 10, page = 1;
if (map.containsKey("size")) { if (map.containsKey("size")) {
size = ObjectFormatUtil.toInteger(map.get("size")); size = ObjectFormatUtil.toInteger(map.get("size"));
@ -4186,7 +4197,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
map.put("begin", (page - 1) * size); map.put("begin", (page - 1) * size);
} }
List<SimpleApplicationOutRecord> myTaskOut = depositoryRecordMapper.findMyTaskOut(map); List<SimpleApplicationOutRecord> myTaskOut = depositoryRecordMapper.findMyTaskOut(map);
return simplePackOut(myTaskOut, userKey,token); return simplePackOut(myTaskOut, userKey, token);
} }
/** /**
@ -4196,7 +4207,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @return 我的任务 * @return 我的任务
*/ */
@Override @Override
public List<SimpleApplicationOutOrInRecordP> findMyTaskIn(Map<String, Object> map, String userKey,String token) { public List<SimpleApplicationOutOrInRecordP> findMyTaskIn(Map<String, Object> map, String userKey, String token) {
Integer size = 10, page = 1; Integer size = 10, page = 1;
if (map.containsKey("size")) { if (map.containsKey("size")) {
size = ObjectFormatUtil.toInteger(map.get("size")); size = ObjectFormatUtil.toInteger(map.get("size"));
@ -4207,7 +4218,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
map.put("begin", (page - 1) * size); map.put("begin", (page - 1) * size);
} }
List<SimpleApplicationInRecord> myTaskIn = depositoryRecordMapper.findMyTaskIn(map); List<SimpleApplicationInRecord> myTaskIn = depositoryRecordMapper.findMyTaskIn(map);
return simplePackIn(myTaskIn, userKey,token); return simplePackIn(myTaskIn, userKey, token);
} }
/** /**
@ -4379,7 +4390,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
/** /**
* 根据条件获取月份中的仓库库存数 * 根据条件获取月份中的仓库库存数
* *
@ -4740,11 +4750,11 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @param list SimpleDepositoryRecord集合 * @param list SimpleDepositoryRecord集合
* @return 包装好的集合 * @return 包装好的集合
*/ */
private List<SimpleApplicationOutOrInRecordP> simplePackOut(List<SimpleApplicationOutRecord> list, String userKey,String token) { private List<SimpleApplicationOutOrInRecordP> simplePackOut(List<SimpleApplicationOutRecord> list, String userKey, String token) {
List<SimpleApplicationOutOrInRecordP> result = new ArrayList<>(list.size()); List<SimpleApplicationOutOrInRecordP> result = new ArrayList<>(list.size());
for (SimpleApplicationOutRecord record : list) { for (SimpleApplicationOutRecord record : list) {
SimpleApplicationOutOrInRecordP d = new SimpleApplicationOutOrInRecordP(record); SimpleApplicationOutOrInRecordP d = new SimpleApplicationOutOrInRecordP(record);
UserByPort userByPort = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userKey,token); UserByPort userByPort = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userKey, token);
d.setApplyRemark(d.getApplyRemark() == null ? "" : d.getApplyRemark()); d.setApplyRemark(d.getApplyRemark() == null ? "" : d.getApplyRemark());
d.setApplicantName(userByPort.getName()); d.setApplicantName(userByPort.getName());
result.add(d); result.add(d);
@ -4752,11 +4762,11 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
return result; return result;
} }
private List<SimpleApplicationOutOrInRecordP> simplePackIn(List<SimpleApplicationInRecord> list,String userKey,String token) { private List<SimpleApplicationOutOrInRecordP> simplePackIn(List<SimpleApplicationInRecord> list, String userKey, String token) {
List<SimpleApplicationOutOrInRecordP> result = new ArrayList<>(list.size()); List<SimpleApplicationOutOrInRecordP> result = new ArrayList<>(list.size());
for (SimpleApplicationInRecord record : list) { for (SimpleApplicationInRecord record : list) {
SimpleApplicationOutOrInRecordP d = new SimpleApplicationOutOrInRecordP(record); SimpleApplicationOutOrInRecordP d = new SimpleApplicationOutOrInRecordP(record);
UserByPort userByPort = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userKey,token); UserByPort userByPort = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userKey, token);
d.setApplyRemark(d.getApplyRemark() == null ? "" : d.getApplyRemark()); d.setApplyRemark(d.getApplyRemark() == null ? "" : d.getApplyRemark());
d.setApplicantName(userByPort.getName()); d.setApplicantName(userByPort.getName());
result.add(d); result.add(d);
@ -4770,25 +4780,25 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @param list DepositoryRecord集合 * @param list DepositoryRecord集合
* @return 包装好的集合 * @return 包装好的集合
*/ */
private List<DepositoryRecordP> pack(List<DepositoryRecord> list,String userKey,String token) { private List<DepositoryRecordP> pack(List<DepositoryRecord> list, String userKey, String token) {
List<DepositoryRecordP> result = new ArrayList<>(list.size()); List<DepositoryRecordP> result = new ArrayList<>(list.size());
for (DepositoryRecord record : list) { for (DepositoryRecord record : list) {
result.add(singlePack(record, userKey,token)); result.add(singlePack(record, userKey, token));
} }
return result; return result;
} }
private DepositoryRecordP singlePack(DepositoryRecord record,String userKey,String token) { private DepositoryRecordP singlePack(DepositoryRecord record, String userKey, String token) {
DepositoryRecordP d = new DepositoryRecordP(record); DepositoryRecordP d = new DepositoryRecordP(record);
UserByPort getApplicantUser = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userKey,token); UserByPort getApplicantUser = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userKey, token);
d.setApplicantName(getApplicantUser.getName()); d.setApplicantName(getApplicantUser.getName());
d.setDepositoryName(depositoryMapper.findDepositoryNameById(record.getDepositoryId())); d.setDepositoryName(depositoryMapper.findDepositoryNameById(record.getDepositoryId()));
if (record.getReviewerId() != null) { if (record.getReviewerId() != null) {
UserByPort reviewerUser = LinkInterfaceUtil.FindUserById(record.getReviewerId(), userKey,token); UserByPort reviewerUser = LinkInterfaceUtil.FindUserById(record.getReviewerId(), userKey, token);
d.setReviewerName(reviewerUser.getName()); d.setReviewerName(reviewerUser.getName());
} }
if (record.getCheckerId() != null) { if (record.getCheckerId() != null) {
UserByPort checkerUser = LinkInterfaceUtil.FindUserById(record.getCheckerId(), userKey,token); UserByPort checkerUser = LinkInterfaceUtil.FindUserById(record.getCheckerId(), userKey, token);
d.setCheckerName(checkerUser.getName()); d.setCheckerName(checkerUser.getName());
} }
return d; return d;

116
src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java

@ -1917,9 +1917,13 @@ public class QyWxOperationService {
List<String> userIdList = new ArrayList<>(); List<String> userIdList = new ArrayList<>();
List<UserByPort> departmentHeadForUserToken = PublicConfig.findDepartmentHeadByUser(userToken.getMaindeparment(),userKey,token ); String[] departmentHeadS = mainRecord.getDepartmenthead().split(",");
for (UserByPort departmentHead : departmentHeadForUserToken for (String department:departmentHeadS
) { ) {
if("".equals(department)){
continue;
}
UserByPort departmentHead = LinkInterfaceUtil.FindUserById(ObjectFormatUtil.toInteger(department), userKey, token);
String departmentHeadWorkwechat = departmentHead.getWorkwechat(); String departmentHeadWorkwechat = departmentHead.getWorkwechat();
if (departmentHeadWorkwechat == null || "".equals(departmentHeadWorkwechat)) { if (departmentHeadWorkwechat == null || "".equals(departmentHeadWorkwechat)) {
departmentHeadWorkwechat = departmentHead.getWechat(); departmentHeadWorkwechat = departmentHead.getWechat();
@ -1927,6 +1931,7 @@ public class QyWxOperationService {
userIdList.add(departmentHeadWorkwechat); userIdList.add(departmentHeadWorkwechat);
} }
// 获取当前登录用户部门与企业微信部门对照 // 获取当前登录用户部门与企业微信部门对照
JSONObject userPortByQyWx = PublicConfig.getUserPortByQyWx(userToken.getMaindeparment()); JSONObject userPortByQyWx = PublicConfig.getUserPortByQyWx(userToken.getMaindeparment());
String portName = userPortByQyWx.getString("name"); String portName = userPortByQyWx.getString("name");
@ -2029,6 +2034,11 @@ public class QyWxOperationService {
// 定义仓库Id列表 // 定义仓库Id列表
List<Integer> depositoryIdList = new ArrayList<>(); List<Integer> depositoryIdList = new ArrayList<>();
List<Long> materialTypeIdList = new ArrayList<>();
// 设置标志位,用于标志是否全为办公用品库或消防用品库
boolean flag = true;
for (ApplicationOutRecordMin recordMin : minRecordList) { for (ApplicationOutRecordMin recordMin : minRecordList) {
// 获取明细信息 // 获取明细信息
@ -2040,10 +2050,21 @@ public class QyWxOperationService {
Depository depositoryById = depositoryMapper.findDepositoryById(depositoryId); Depository depositoryById = depositoryMapper.findDepositoryById(depositoryId);
if (!depositoryById.getDname().contains("前置仓")) {
// 如果不是前置仓下的仓库
flag = false;
}
if (!depositoryIdList.contains(depositoryId)) { if (!depositoryIdList.contains(depositoryId)) {
// 如果当前仓库列表中不存在该仓库id // 如果当前仓库列表中不存在该仓库id
depositoryIdList.add(depositoryId); depositoryIdList.add(depositoryId);
} }
Long materialTypeId = materialById.getMaterialTypeId();
if (!materialTypeIdList.contains(materialTypeId)) {
// 如果当前仓库列表中不存在该仓库id
materialTypeIdList.add(materialTypeId);
}
Map<String, Object> detail_list = new HashMap<>(); Map<String, Object> detail_list = new HashMap<>();
// 定义明细种的控件列表 // 定义明细种的控件列表
@ -2223,44 +2244,87 @@ public class QyWxOperationService {
String[] depositoryManagerS = mainRecord.getDepartmenthead().split(",");
List<String> depositoryManagerWorkWechats = new ArrayList<>();
for (String depositorymanager:depositoryManagerS
) {
if("".equals(depositorymanager)){
continue;
}
UserByPort depositoryManage = LinkInterfaceUtil.FindUserById(ObjectFormatUtil.toInteger(depositorymanager), userKey, token);
String departmentHeadWorkwechat = depositoryManage.getWorkwechat();
if (departmentHeadWorkwechat == null || "".equals(departmentHeadWorkwechat)) {
departmentHeadWorkwechat = depositoryManage.getWechat();
}
depositoryManagerWorkWechats.add(departmentHeadWorkwechat);
}
// 获取仓储中心负责人标签的用户userId
List<String> qyWxLabelUserList = QyWxConfig.getQyWxLabelUserList(userAgent);
// 用于设置仓储中心负责人流程 // 用于设置仓储中心负责人流程
Approval_template_approver approval_template_approver_Label = new Approval_template_approver(); Approval_template_approver approval_template_approver_Label = new Approval_template_approver();
approval_template_approver_Label.setAttr(1); approval_template_approver_Label.setAttr(1);
approval_template_approver_Label.setUserid(qyWxLabelUserList); approval_template_approver_Label.setUserid(depositoryManagerWorkWechats);
approval_template_approver_list.add(approval_template_approver_Label); approval_template_approver_list.add(approval_template_approver_Label);
for (Integer depositoryId : depositoryIdList
) { if(!flag){
// 获取当前仓库的管理员列表 for (Long mtId:materialTypeIdList
List<Integer> userIdByDid = roleMapper.findUserIdByDid(depositoryId);
// 获取当前管理员的企业微信userId
List<String> qywxUserIdList = new ArrayList<>();
for (Integer userId : userIdByDid
) { ) {
// 获取对应管理员信息 // 获取当前仓库的管理员列表
UserByPort userByPort = LinkInterfaceUtil.FindUserById(userId, userKey,token); List<Integer> userIdByDid = roleMapper.findUserIdByMtId(mtId);
String user = userByPort.getWorkwechat(); // 获取当前管理员的企业微信userId
if (user == null || "".equals(user)) { List<String> qywxUserIdList = new ArrayList<>();
user = userByPort.getWechat(); for (Integer userId : userIdByDid
) {
// 获取对应管理员信息
UserByPort userByPort = LinkInterfaceUtil.FindUserById(userId, userKey,token);
String user = userByPort.getWorkwechat();
if (user == null || "".equals(user)) {
user = userByPort.getWechat();
}
qywxUserIdList.add(user);
} }
qywxUserIdList.add(user); if (qywxUserIdList.size() > 0) {
} // 用于设置仓库管理员流程
if (qywxUserIdList.size() > 0) { Approval_template_approver approval_template_approver_depository_manager = new Approval_template_approver();
// 用于设置仓库管理员流程 approval_template_approver_depository_manager.setAttr(1);
Approval_template_approver approval_template_approver_depository_manager = new Approval_template_approver(); approval_template_approver_depository_manager.setUserid(qywxUserIdList);
approval_template_approver_depository_manager.setAttr(1);
approval_template_approver_depository_manager.setUserid(qywxUserIdList);
approval_template_approver_list.add(approval_template_approver_depository_manager); approval_template_approver_list.add(approval_template_approver_depository_manager);
}
} }
}
else{
for (Integer depositoryId : depositoryIdList
) {
// 获取当前仓库的管理员列表
List<Integer> userIdByDid = roleMapper.findUserIdByDid(depositoryId);
// 获取当前管理员的企业微信userId
List<String> qywxUserIdList = new ArrayList<>();
for (Integer userId : userIdByDid
) {
// 获取对应管理员信息
UserByPort userByPort = LinkInterfaceUtil.FindUserById(userId, userKey,token);
String user = userByPort.getWorkwechat();
if (user == null || "".equals(user)) {
user = userByPort.getWechat();
}
qywxUserIdList.add(user);
}
if (qywxUserIdList.size() > 0) {
// 用于设置仓库管理员流程
Approval_template_approver approval_template_approver_depository_manager = new Approval_template_approver();
approval_template_approver_depository_manager.setAttr(1);
approval_template_approver_depository_manager.setUserid(qywxUserIdList);
approval_template_approver_list.add(approval_template_approver_depository_manager);
}
}
} }

Loading…
Cancel
Save