ErpCommonController.java
9.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package com.skua.modules.erp.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.query.QueryGenerator;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.equipment.service.IEquipmentSparepartService;
import com.skua.modules.erp.entity.ApproveRecord;
import com.skua.modules.erp.entity.PurchaseMaterial;
import com.skua.modules.erp.service.IDistributMaterialService;
import com.skua.modules.erp.service.IPurchaseMaterialService;
import com.skua.modules.erp.vo.MaterialSearchVO;
import com.skua.modules.erp.vo.PurchaseMaterialVO;
import com.skua.modules.quartz.util.BaseUtil;
import com.skua.modules.supplies.entity.EquipmentSparepartSupplies;
import com.skua.modules.supplies.entity.EquipmentSparepartType;
import com.skua.modules.supplies.service.IEquipmentSparepartSuppliesService;
import com.skua.modules.supplies.service.IEquipmentSparepartTypeService;
import com.skua.modules.system.entity.SysUser;
import com.skua.tool.dfs.MapDFS;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@Slf4j
@Api(tags="ert通用方法")
@RestController("erpCommonController")
@RequestMapping("/web/erp/common")
public class ErpCommonController {
@Autowired
private IEquipmentSparepartSuppliesService sparepartSuppliesService;//物料serivce
@Autowired
private IPurchaseMaterialService purchaseMaterialService;
@Autowired
private IEquipmentSparepartTypeService equipmentSparepartTypeService;
@AutoLog(value = "ERP-采购计划--物料列表")
@ApiOperation(value = "ERP-采购计划--物料列表", notes = "ERP-采购计划--物料列表")
@RequestMapping(value = "/sparepartList", method = RequestMethod.GET)
public Result<IPage<EquipmentSparepartSupplies>> sparepartList(MaterialSearchVO materialSearchVO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
Result<IPage<EquipmentSparepartSupplies>> result = new Result<IPage<EquipmentSparepartSupplies>>();
Page<EquipmentSparepartSupplies> page = new Page<EquipmentSparepartSupplies>(pageNo, pageSize);
Set<String> sparepartTypeSet = new HashSet<>();
String sparepartTypeStr = "";
if (StringUtils.isNotEmpty(materialSearchVO.getSparepartType())) {
// 查询子集
sparepartTypeSet = equipmentSparepartTypeService.getAllChildrenSparepartTypeIds( materialSearchVO.getSparepartType() );
if(sparepartTypeSet.size() > 0 ){
// 使用String.join()方法转换Set为字符串,以逗号分隔
sparepartTypeStr = String.join(",", sparepartTypeSet);
}
}
// String depId = BaseContextHandler.getRealDepartId();//临时参数
// String username = req.getParameter("username");
IPage<EquipmentSparepartSupplies> pageList = sparepartSuppliesService.queryPageByOut(page , materialSearchVO.getSparepartName() ,sparepartTypeStr ,materialSearchVO.getSparepartCode());
result.setSuccess(true);
result.setResult(pageList);
return result;
}
@AutoLog(value = "ERP-采购合同--物料清单")
@ApiOperation(value = "ERP-采购合同--物料清单", notes = "ERP-采购合同--物料清单")
@RequestMapping(value = "/purchaseMaterialList", method = RequestMethod.GET)
public Result<IPage<PurchaseMaterial>> purchaseMaterialList(
@RequestParam(name = "goodCode") String goodCode,
@RequestParam(name = "medicament") boolean medicament,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
Result<IPage<PurchaseMaterial>> result = new Result<IPage<PurchaseMaterial>>();
Page<PurchaseMaterial> page = new Page<PurchaseMaterial>(pageNo, pageSize);
String depId = BaseContextHandler.getRealDepartId();//临时参数
// String username = req.getParameter("username");
IPage<PurchaseMaterial> pageList = purchaseMaterialService.queryByPage(page,goodCode, depId);
result.setSuccess(true);
result.setResult(pageList);
return result;
}
@AutoLog(value = "ERP-采购合同--物料清单(药剂入库使用)")
@ApiOperation(value = "ERP-采购合同--物料清单药剂入库使用()", notes = "ERP-采购合同--物料清单(药剂入库使用)")
@RequestMapping(value = "/queryPurchaseMaterialListByIn", method = RequestMethod.GET)
public Result<IPage<PurchaseMaterialVO>> queryPurchaseMaterialListByIn(
MaterialSearchVO materialSearchVO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
Result<IPage<PurchaseMaterialVO>> result = new Result<IPage<PurchaseMaterialVO>>();
Page<PurchaseMaterialVO> page = new Page<PurchaseMaterialVO>(pageNo, pageSize);
//String departId = BaseContextHandler.getRealDepartId();//当前部门编号
// materialSearchVO.setDepartId( BaseContextHandler.getRealDepartId() );
//如果为管理员,则跳过权限
if (!"1".equals(BaseContextHandler.get("userType"))) {
if (StringUtils.isNotEmpty( BaseContextHandler.getDeparts())) {
materialSearchVO.setDepartId( BaseUtil.quoteEach(BaseContextHandler.getDeparts() ,",")) ;//非管理员,获取权限部门集合
}else{
materialSearchVO.setDepartId(BaseContextHandler.getRealDepartId() ) ;//非管理员,获取权限部门集合
}
}
String sparepartTypeStr = "";
if(StringUtils.isNotEmpty(materialSearchVO.getSparepartType())){
//查询子集合
Set<String> sparepartTypeSet = equipmentSparepartTypeService.getAllChildrenSparepartTypeIds(materialSearchVO.getSparepartType() );
if(sparepartTypeSet.size() > 0 ){
// 使用String.join()方法转换Set为字符串,以逗号分隔
sparepartTypeStr = String.join(",", sparepartTypeSet);
}
materialSearchVO.setSparepartType(sparepartTypeStr) ;
}else{
if(materialSearchVO.isMedicament()){ //查询药剂物料清单
EquipmentSparepartType equipmentSparepartType = new EquipmentSparepartType();
equipmentSparepartType.setMedicament( materialSearchVO.isMedicament() );
List<EquipmentSparepartType> sparepartTypeList = equipmentSparepartTypeService.querySparepartTypeList(equipmentSparepartType);
if(sparepartTypeList != null && !sparepartTypeList.isEmpty()){
for(EquipmentSparepartType sparepartType : sparepartTypeList){
if(sparepartTypeStr.length() > 0 ) sparepartTypeStr+=",";
sparepartTypeStr += "'"+sparepartType.getId()+"'";
}
}
materialSearchVO.setSparepartType(sparepartTypeStr) ;
}
}
IPage<PurchaseMaterialVO> pageList = purchaseMaterialService.queryPurchaseMaterialListByIn(page,materialSearchVO);
result.setSuccess(true);
result.setResult(pageList);
return result;
}
/* @AutoLog(value = "ERP-采购合同--物料清单")
@ApiOperation(value = "ERP-采购合同--物料清单", notes = "ERP-采购合同--物料清单")
@RequestMapping(value = "/distributMaterialList", method = RequestMethod.GET)
public Result<IPage<EquipmentSparepartSupplies>> distributMaterialList(
@RequestParam(name = "goodCode") String goodCode,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
Result<IPage<EquipmentSparepartSupplies>> result = new Result<IPage<EquipmentSparepartSupplies>>();
Page<EquipmentSparepartSupplies> page = new Page<EquipmentSparepartSupplies>(pageNo, pageSize);
String depId = BaseContextHandler.getRealDepartId();//临时参数
// String username = req.getParameter("username");
IPage<EquipmentSparepartSupplies> pageList = distributMaterialService.queryByPage(page,goodCode, depId);
result.setSuccess(true);
result.setResult(pageList);
return result;
}*/
}