|
|
@ -1,5 +1,6 @@ |
|
|
package com.dreamchaser.depository_manage.controller; |
|
|
package com.dreamchaser.depository_manage.controller; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.dreamchaser.depository_manage.entity.*; |
|
|
import com.dreamchaser.depository_manage.entity.*; |
|
|
import com.dreamchaser.depository_manage.exception.MyException; |
|
|
import com.dreamchaser.depository_manage.exception.MyException; |
|
|
import com.dreamchaser.depository_manage.pojo.GroupInfoP; |
|
|
import com.dreamchaser.depository_manage.pojo.GroupInfoP; |
|
|
@ -8,10 +9,13 @@ import com.dreamchaser.depository_manage.pojo.StatusInfo; |
|
|
import com.dreamchaser.depository_manage.service.DepositoryService; |
|
|
import com.dreamchaser.depository_manage.service.DepositoryService; |
|
|
import com.dreamchaser.depository_manage.service.GroupService; |
|
|
import com.dreamchaser.depository_manage.service.GroupService; |
|
|
import com.dreamchaser.depository_manage.service.MaterialService; |
|
|
import com.dreamchaser.depository_manage.service.MaterialService; |
|
|
import com.dreamchaser.depository_manage.utils.CrudUtil; |
|
|
import com.dreamchaser.depository_manage.service.impl.QyWxOperationService; |
|
|
import com.dreamchaser.depository_manage.utils.DateUtil; |
|
|
import com.dreamchaser.depository_manage.utils.*; |
|
|
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|
|
import com.sun.org.apache.xpath.internal.operations.Bool; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
@ -19,6 +23,8 @@ import java.sql.Time; |
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("/group") |
|
|
@RequestMapping("/group") |
|
|
@ -33,6 +39,12 @@ public class GroupController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
MaterialService materialService; |
|
|
MaterialService materialService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private QyWxOperationService qyWxOperationService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private RedisTemplate<String, String> redisTemplateForHash; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于添加一条套餐记录 |
|
|
* 用于添加一条套餐记录 |
|
|
@ -62,7 +74,7 @@ public class GroupController { |
|
|
// 获取套餐编码
|
|
|
// 获取套餐编码
|
|
|
Group groupByCode = groupService.findGroupByCode(code); |
|
|
Group groupByCode = groupService.findGroupByCode(code); |
|
|
|
|
|
|
|
|
if(groupByCode != null) { |
|
|
if (groupByCode != null) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> paramForGetGroup = new HashMap<>(); |
|
|
Map<String, Object> paramForGetGroup = new HashMap<>(); |
|
|
@ -98,10 +110,10 @@ public class GroupController { |
|
|
if (flag) { |
|
|
if (flag) { |
|
|
return new RestResponse(groupByGid); |
|
|
return new RestResponse(groupByGid); |
|
|
} else { |
|
|
} else { |
|
|
return new RestResponse(null,666,new StatusInfo("不能出库","当前套餐中有物料库存不足")); |
|
|
return new RestResponse(null, 666, new StatusInfo("不能出库", "当前套餐中有物料库存不足")); |
|
|
} |
|
|
} |
|
|
}else{ |
|
|
} else { |
|
|
return new RestResponse(null,666,new StatusInfo("失败","暂无该套餐,请确认是否正确")); |
|
|
return new RestResponse(null, 666, new StatusInfo("失败", "暂无该套餐,请确认是否正确")); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -149,29 +161,30 @@ public class GroupController { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据套餐名称获取套餐 |
|
|
* 根据套餐名称获取套餐 |
|
|
|
|
|
* |
|
|
* @param map 套餐名称 |
|
|
* @param map 套餐名称 |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("/findGroupByGname") |
|
|
@PostMapping("/findGroupByGname") |
|
|
public RestResponse findGroupByGname(@RequestBody Map<String,Object> map){ |
|
|
public RestResponse findGroupByGname(@RequestBody Map<String, Object> map) { |
|
|
if(map.containsKey("gname")){ |
|
|
if (map.containsKey("gname")) { |
|
|
List<Group> groupOnlyByCondition = groupService.findGroupOnlyByCondition(map); |
|
|
List<Group> groupOnlyByCondition = groupService.findGroupOnlyByCondition(map); |
|
|
int size = groupOnlyByCondition.size(); |
|
|
int size = groupOnlyByCondition.size(); |
|
|
if(size > 1){ |
|
|
if (size > 1) { |
|
|
// 如果当前名称的套餐大于1个
|
|
|
// 如果当前名称的套餐大于1个
|
|
|
|
|
|
|
|
|
return new RestResponse("",-1,444); |
|
|
return new RestResponse("", -1, 444); |
|
|
}else if(size == 1){ |
|
|
} else if (size == 1) { |
|
|
// 如果刚好只有一个
|
|
|
// 如果刚好只有一个
|
|
|
// 获取当前套餐的所有物料数据
|
|
|
// 获取当前套餐的所有物料数据
|
|
|
List<GroupInfo> groupByGid = groupService.findGroupByCondition(map); |
|
|
List<GroupInfo> groupByGid = groupService.findGroupByCondition(map); |
|
|
return new RestResponse(groupByGid,groupByGid.size(),200); |
|
|
return new RestResponse(groupByGid, groupByGid.size(), 200); |
|
|
|
|
|
|
|
|
}else{ |
|
|
} else { |
|
|
// 如果没有
|
|
|
// 如果没有
|
|
|
return new RestResponse("",0,666); |
|
|
return new RestResponse("", 0, 666); |
|
|
} |
|
|
} |
|
|
}else{ |
|
|
} else { |
|
|
throw new MyException("缺少必要参数"); |
|
|
throw new MyException("缺少必要参数"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -250,15 +263,16 @@ public class GroupController { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于修改套餐信息 |
|
|
* 用于修改套餐信息 |
|
|
|
|
|
* |
|
|
* @param map 修改条件 |
|
|
* @param map 修改条件 |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("/editGroupInfo") |
|
|
@PostMapping("/editGroupInfo") |
|
|
public RestResponse editGroupInfo(@RequestBody Map<String,Object> map){ |
|
|
public RestResponse editGroupInfo(@RequestBody Map<String, Object> map) { |
|
|
if(map.containsKey("id")){ |
|
|
if (map.containsKey("id")) { |
|
|
Integer integer = groupService.updateGroupInfo(map); |
|
|
Integer integer = groupService.updateGroupInfo(map); |
|
|
return CrudUtil.putHandle(1,integer); |
|
|
return CrudUtil.putHandle(1, integer); |
|
|
}else{ |
|
|
} else { |
|
|
throw new MyException("缺少必要参数"); |
|
|
throw new MyException("缺少必要参数"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -309,7 +323,7 @@ public class GroupController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@PostMapping("/findGroupInfoByGid") |
|
|
@PostMapping("/findGroupInfoByGid") |
|
|
public RestResponse findGroupInfoByGid(@RequestBody Map<String,Object> map,HttpServletRequest request){ |
|
|
public RestResponse findGroupInfoByGid(@RequestBody Map<String, Object> map, HttpServletRequest request) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|
|
@ -346,18 +360,132 @@ public class GroupController { |
|
|
if (flag) { |
|
|
if (flag) { |
|
|
return new RestResponse(groupByGid); |
|
|
return new RestResponse(groupByGid); |
|
|
} else { |
|
|
} else { |
|
|
return new RestResponse(null,666,new StatusInfo("不能出库","当前套餐中有物料库存不足")); |
|
|
return new RestResponse(null, 666, new StatusInfo("不能出库", "当前套餐中有物料库存不足")); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/treeMenus") |
|
|
@PostMapping("/treeMenus") |
|
|
public RestResponse treeMenus(@RequestBody Map<String,Object> map){ |
|
|
public RestResponse treeMenus(@RequestBody Map<String, Object> map) { |
|
|
String gname = ""; |
|
|
String gname = ""; |
|
|
if(map.containsKey("gname")){ |
|
|
if (map.containsKey("gname")) { |
|
|
gname = (String) map.get("gname"); |
|
|
gname = (String) map.get("gname"); |
|
|
} |
|
|
} |
|
|
List<Object> list = groupService.InitTreeMenus(gname); |
|
|
List<Object> list = groupService.InitTreeMenus(gname); |
|
|
return new RestResponse(list); |
|
|
return new RestResponse(list); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/applicationOutForGroup") |
|
|
|
|
|
public RestResponse applicationOutForGroup(@RequestBody Map<String, Object> map, HttpServletRequest request) { |
|
|
|
|
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|
|
|
|
|
String header = request.getHeader("user-agent"); |
|
|
|
|
|
String crypt = Md5.crypt(header); |
|
|
|
|
|
map.put("applicantId", userToken.getId()); |
|
|
|
|
|
// 获取当前部门负责人
|
|
|
|
|
|
List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken); |
|
|
|
|
|
// 部门负责人id
|
|
|
|
|
|
StringBuilder departmentHeadId = new StringBuilder(); |
|
|
|
|
|
// 部门负责人企业微信user
|
|
|
|
|
|
StringBuilder departMentHeadQyWxName = new StringBuilder(); |
|
|
|
|
|
// for (int i = 0; i < departmentHeadByUsers.size(); i++) {
|
|
|
|
|
|
// departmentHeadId.append(departmentHeadByUsers.get(i).getId()).append(",");
|
|
|
|
|
|
// departMentHeadQyWxName.append(departmentHeadByUsers.get(i).getWorkwechat()+",");
|
|
|
|
|
|
// }
|
|
|
|
|
|
departmentHeadId.append("78").append(","); |
|
|
|
|
|
departMentHeadQyWxName.append("PangFuZhen").append(","); |
|
|
|
|
|
map.put("departmenthead", departmentHeadId.toString()); |
|
|
|
|
|
// 获取当前提交数
|
|
|
|
|
|
List<Integer> params = (List<Integer>) map.get("params"); |
|
|
|
|
|
// 执行结果
|
|
|
|
|
|
Integer integer = 0; |
|
|
|
|
|
// 实际结果
|
|
|
|
|
|
Integer result = 0; |
|
|
|
|
|
Integer gid = ObjectFormatUtil.toInteger(map.get("gid")); |
|
|
|
|
|
List<GroupInfo> groupInfoByGid = groupService.findGroupInfoByGid(gid); |
|
|
|
|
|
if(groupInfoByGid != null) { |
|
|
|
|
|
result = groupInfoByGid.size(); |
|
|
|
|
|
} |
|
|
|
|
|
if (params.size() < 1 && map.size() > 3) { |
|
|
|
|
|
try { |
|
|
|
|
|
integer += groupService.insertApplicationOutRecord(map, userToken); // 插入主订单
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
return new RestResponse("", 666, new StatusInfo("出库失败", e.getMessage())); |
|
|
|
|
|
} |
|
|
|
|
|
Object id = map.get("id"); // 获取主订单编号
|
|
|
|
|
|
|
|
|
|
|
|
// 开启一个线程开启审批
|
|
|
|
|
|
new Thread(new Runnable() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void run() { |
|
|
|
|
|
JSONObject jsonObject = qyWxOperationService.sendOutApprovalTemplate(crypt, userToken, ObjectFormatUtil.toInteger(id)); |
|
|
|
|
|
String sp_no = jsonObject.getString("sp_no"); |
|
|
|
|
|
Map<String, Object> QyWxApprovalMap = new HashMap<>(); |
|
|
|
|
|
QyWxApprovalMap.put("sp_no", sp_no); |
|
|
|
|
|
QyWxApprovalMap.put("mainId", id.toString()); |
|
|
|
|
|
redisTemplateForHash.opsForHash().putAll(sp_no, QyWxApprovalMap); |
|
|
|
|
|
// 设置过期为7天
|
|
|
|
|
|
redisTemplateForHash.expire(sp_no, 7, TimeUnit.DAYS); |
|
|
|
|
|
} |
|
|
|
|
|
}).start(); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if (integer != 0 && params.size() < 1) { |
|
|
|
|
|
return CrudUtil.postHandle(integer, result); |
|
|
|
|
|
} else if (integer != 0 && params.size() > 1) { |
|
|
|
|
|
return CrudUtil.postHandle(integer, result); |
|
|
|
|
|
} else { |
|
|
|
|
|
return new RestResponse("", 666, new StatusInfo("出库失败", "请联系管理员进行操作")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 用于判断当前套餐的数量是否合法 |
|
|
|
|
|
* @param map 套餐相关信息 |
|
|
|
|
|
* @param request |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
@PostMapping("/groupQuantityIsTrue") |
|
|
|
|
|
public RestResponse groupQuantityIsTrue(@RequestBody Map<String,Object> map,HttpServletRequest request){ |
|
|
|
|
|
if(map.containsKey("gid")){ |
|
|
|
|
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|
|
|
|
|
// 获取当前部门所拥有的仓库
|
|
|
|
|
|
List<Depository> depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userToken.getMaindeparment().toString()); |
|
|
|
|
|
// 获取套餐id
|
|
|
|
|
|
Integer gid = ObjectFormatUtil.toInteger(map.get("gid")); |
|
|
|
|
|
// 获取套餐数量
|
|
|
|
|
|
Integer quantity = ObjectFormatUtil.toInteger(map.get("quantity")); |
|
|
|
|
|
List<GroupInfo> groupInfoByGid = groupService.findGroupInfoByGid(gid); |
|
|
|
|
|
// 用于标志该数量是否合法
|
|
|
|
|
|
boolean flag = true; |
|
|
|
|
|
for (int i = 0; i < groupInfoByGid.size(); i++) { |
|
|
|
|
|
// 获取具体信息
|
|
|
|
|
|
GroupInfo groupInfo = groupInfoByGid.get(i); |
|
|
|
|
|
// 获取本次要出库的实际的数量
|
|
|
|
|
|
Integer totalQuantity = groupInfo.getQuantity() * quantity; |
|
|
|
|
|
// 用于标志是否可以满足库存要求
|
|
|
|
|
|
boolean flagForInventory = false; |
|
|
|
|
|
// 获取该物料在各仓库的库存
|
|
|
|
|
|
List<Integer> inventoryByMidAndDepository = materialService.findInventoryByMidAndDepository(groupInfo.getMid(), depositoryByAdminorg); |
|
|
|
|
|
for (int j = 0; j < inventoryByMidAndDepository.size(); j++) { |
|
|
|
|
|
Integer integer = inventoryByMidAndDepository.get(j); |
|
|
|
|
|
if(integer > totalQuantity){ |
|
|
|
|
|
flagForInventory = true; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(!flagForInventory){ |
|
|
|
|
|
// 如果概述了不合法
|
|
|
|
|
|
flag = false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return new RestResponse(flag); |
|
|
|
|
|
}else{ |
|
|
|
|
|
throw new MyException("缺少必要参数"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|