|
|
|
@ -17,6 +17,7 @@ import org.apache.http.protocol.HTTP; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.io.IOException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
@ -94,22 +95,23 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取之前仓库的库存值 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static Map<String,Object> getBeforeInventoryByDName(DepositoryService depositoryService,DepositoryRecordService depositoryRecordService){ |
|
|
|
public static Map<String, Object> getBeforeInventoryByDName(DepositoryService depositoryService, DepositoryRecordService depositoryRecordService, UserByPort user) { |
|
|
|
List<Double> result = new ArrayList<>(); |
|
|
|
List<Long> days = getLastTimeInterval(); |
|
|
|
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(); |
|
|
|
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(user); |
|
|
|
Iterator it = depositoryAllNameAndId.keySet().iterator(); |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
// 获取本周仓库库存
|
|
|
|
Map<String, Object> thisWeekInventoryByDName = getThisWeekInventoryByDName(depositoryService, depositoryRecordService); |
|
|
|
while (it.hasNext()){ |
|
|
|
Map<String, Object> thisWeekInventoryByDName = getThisWeekInventoryByDName(depositoryService, depositoryRecordService, user); |
|
|
|
while (it.hasNext()) { |
|
|
|
int i; |
|
|
|
Object key = it.next(); |
|
|
|
Double thisDayInventory = 0.0; |
|
|
|
// 本周周一的总量
|
|
|
|
thisDayInventory = ((List<Double>)thisWeekInventoryByDName.get(key.toString())).get(0); |
|
|
|
thisDayInventory = ((List<Double>) thisWeekInventoryByDName.get(key.toString())).get(0); |
|
|
|
result.add(thisDayInventory); |
|
|
|
int j = 0; |
|
|
|
for (i = days.size() - 1; i > 0; i--) { |
|
|
|
@ -132,24 +134,25 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取本周库存容量 |
|
|
|
* |
|
|
|
* @param depositoryService |
|
|
|
* @param depositoryRecordService |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static Map<String,Object> getThisWeekInventoryByDName(DepositoryService depositoryService,DepositoryRecordService depositoryRecordService){ |
|
|
|
public static Map<String, Object> getThisWeekInventoryByDName(DepositoryService depositoryService, DepositoryRecordService depositoryRecordService, UserByPort user) { |
|
|
|
Calendar instance = Calendar.getInstance(); |
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
int weekDay = instance.get(Calendar.DAY_OF_WEEK); |
|
|
|
weekDay = weekDay - 1; |
|
|
|
// 获取所有仓库名称
|
|
|
|
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(); |
|
|
|
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(user); |
|
|
|
Iterator it = depositoryAllNameAndId.keySet().iterator(); |
|
|
|
//result用来接收每个仓库每天的库存
|
|
|
|
List<Double> result = new ArrayList<>(); |
|
|
|
// map用来存储仓库与库存的映射
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
// 只获取当天
|
|
|
|
if(weekDay == 1){ |
|
|
|
if (weekDay == 1) { |
|
|
|
while (it.hasNext()) { |
|
|
|
int i; |
|
|
|
Object key = it.next(); |
|
|
|
@ -158,7 +161,7 @@ public class DepositoryController { |
|
|
|
map.put(key.toString(), ((ArrayList<Double>) result).clone()); |
|
|
|
result.clear(); |
|
|
|
} |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
int now = instance.get(Calendar.DAY_OF_WEEK) - 1; |
|
|
|
List<Long> days = new ArrayList<>(); |
|
|
|
days.add(DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime()))); |
|
|
|
@ -166,30 +169,30 @@ public class DepositoryController { |
|
|
|
while (now - 1 > 0) { |
|
|
|
now--; |
|
|
|
instance.add(Calendar.DATE, -1); |
|
|
|
long format =DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime())); |
|
|
|
long format = DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime())); |
|
|
|
days.add(format); |
|
|
|
} |
|
|
|
while (it.hasNext()) { |
|
|
|
int i; |
|
|
|
Object key = it.next(); |
|
|
|
int j =0; |
|
|
|
int j = 0; |
|
|
|
// 获取今天容量
|
|
|
|
Double toDayInventoryByDName = depositoryService.getToDayInventoryByDName(key.toString()); |
|
|
|
result.add(toDayInventoryByDName); |
|
|
|
// 判断当天是否有出入口记录
|
|
|
|
Calendar IsInOut = Calendar.getInstance(); |
|
|
|
Long start = DateUtil.DateTimeByMonthToTimeStamp(formatter.format(IsInOut.getTime())); |
|
|
|
IsInOut.add(Calendar.DATE,1); |
|
|
|
IsInOut.add(Calendar.DATE, 1); |
|
|
|
Long end = DateUtil.DateTimeByMonthToTimeStamp(formatter.format(IsInOut.getTime())); |
|
|
|
Double inCount = depositoryRecordService.findApplicationInRecordByDate(end, start, null); |
|
|
|
Double OutCount = depositoryRecordService.findApplicationOutRecordByDate(end, start, null); |
|
|
|
if(inCount >0 || OutCount > 0){ |
|
|
|
if (inCount > 0 || OutCount > 0) { |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
for (i = 0;i<days.size() - 1;i++) { |
|
|
|
for (i = 0; i < days.size() - 1; i++) { |
|
|
|
// 获取本周周一日期
|
|
|
|
String mondayOnThisWeek = DateUtil.getMondayOnThisWeek(); |
|
|
|
if(mondayOnThisWeek.equals(DateUtil.TimeStampToDateTime(days.get(i)))){ |
|
|
|
if (mondayOnThisWeek.equals(DateUtil.TimeStampToDateTime(days.get(i)))) { |
|
|
|
break; |
|
|
|
} |
|
|
|
// 当前日期额度
|
|
|
|
@ -197,7 +200,7 @@ public class DepositoryController { |
|
|
|
// 获取当前仓库
|
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 如果今天有出入库记录
|
|
|
|
if(flag){ |
|
|
|
if (flag) { |
|
|
|
Double inRecordByDate = depositoryRecordService.findApplicationInRecordByDate(end, start, val); |
|
|
|
Double OutRecordByDate = depositoryRecordService.findApplicationOutRecordByDate(end, start, val); |
|
|
|
aDouble = aDouble - inRecordByDate + OutRecordByDate; |
|
|
|
@ -237,11 +240,12 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取之前各月的库存容量 |
|
|
|
* |
|
|
|
* @param depositoryService |
|
|
|
* @param depositoryRecordService |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static List<Object> getBeforeInventoryByMonth(DepositoryService depositoryService,DepositoryRecordService depositoryRecordService){ |
|
|
|
public static List<Object> getBeforeInventoryByMonth(DepositoryService depositoryService, DepositoryRecordService depositoryRecordService) { |
|
|
|
List<Depository> depositoryAll = depositoryService.findDepositoryAll(); |
|
|
|
Map<String, Object> previousMonth = getPreviousMonth(); |
|
|
|
List<Object> months = (List<Object>) previousMonth.get("months"); |
|
|
|
@ -266,13 +270,13 @@ public class DepositoryController { |
|
|
|
// 获取每月入库总额
|
|
|
|
parmIn.put("type", 1); |
|
|
|
parmIn.put("state", "已入库"); |
|
|
|
parmIn.put("depository_id",depositoryAll.get(j).getId()); |
|
|
|
parmIn.put("depository_id", depositoryAll.get(j).getId()); |
|
|
|
parmIn.put("start", months.get(num + 1)); |
|
|
|
parmIn.put("end", months.get(num)); |
|
|
|
// 获取每月出库总额
|
|
|
|
parmOut.put("type", 2); |
|
|
|
parmOut.put("state", "已出库"); |
|
|
|
parmOut.put("depository_id",depositoryAll.get(j).getId()); |
|
|
|
parmOut.put("depository_id", depositoryAll.get(j).getId()); |
|
|
|
parmOut.put("start", months.get(num + 1)); |
|
|
|
parmOut.put("end", months.get(num)); |
|
|
|
// 获取月份中入库物料的总额
|
|
|
|
@ -306,11 +310,12 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取之前个月的库存给地图数据 |
|
|
|
* |
|
|
|
* @param depositoryService |
|
|
|
* @param depositoryRecordService |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static Map<String,Object> getBeforeInventoryOnMap(DepositoryService depositoryService,DepositoryRecordService depositoryRecordService){ |
|
|
|
public static Map<String, Object> getBeforeInventoryOnMap(DepositoryService depositoryService, DepositoryRecordService depositoryRecordService) { |
|
|
|
// 中国地图数据
|
|
|
|
// ['product', '3月', '4月', '5月', '6月', '7月', '8月'],
|
|
|
|
// ['电子产品类', 41.1, 30.4, 65.1, 53.3, 83.8, 98.7],
|
|
|
|
@ -341,13 +346,13 @@ public class DepositoryController { |
|
|
|
Map<String, Object> parmOut = new HashMap<>(); |
|
|
|
parmIn.put("type", 1); |
|
|
|
parmIn.put("state", "已入库"); |
|
|
|
parmIn.put("depository_id",depositoryAll.get(i).getId()); |
|
|
|
parmIn.put("depository_id", depositoryAll.get(i).getId()); |
|
|
|
parmIn.put("start", months.get(j + 1)); |
|
|
|
parmIn.put("end", months.get(j)); |
|
|
|
parmIn.put("dname", depositoryAll.get(i).getDname()); |
|
|
|
parmOut.put("type",2); |
|
|
|
parmOut.put("type", 2); |
|
|
|
parmOut.put("state", "已出库"); |
|
|
|
parmOut.put("depository_id",depositoryAll.get(i).getId()); |
|
|
|
parmOut.put("depository_id", depositoryAll.get(i).getId()); |
|
|
|
parmOut.put("start", months.get(j + 1)); |
|
|
|
parmOut.put("end", months.get(j)); |
|
|
|
parmOut.put("dname", depositoryAll.get(i).getDname()); |
|
|
|
@ -362,7 +367,7 @@ public class DepositoryController { |
|
|
|
} |
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
|
result.add(productData.get(0)); |
|
|
|
for (int j = productData.size() - 2; j > 0;j--) { |
|
|
|
for (int j = productData.size() - 2; j > 0; j--) { |
|
|
|
result.add(productData.get(j)); |
|
|
|
} |
|
|
|
mapDataList.add(result); |
|
|
|
@ -392,13 +397,14 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据父级编号获取所有仓库 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@GetMapping("/allWarehouseByParent") |
|
|
|
public RestResponse findDepositoryByNoParent(@RequestParam Map<String, Object> map){ |
|
|
|
public RestResponse findDepositoryByNoParent(@RequestParam Map<String, Object> map) { |
|
|
|
if ("".equals(map.get("parentId")) || map.get("parentId") == null) { |
|
|
|
map.put("parentId",0); |
|
|
|
map.put("parentId", 0); |
|
|
|
} |
|
|
|
List<Depository> list = depositoryService.findDepositoryRecordPByCondition(map); |
|
|
|
// 获取所有行政单位
|
|
|
|
@ -407,71 +413,73 @@ public class DepositoryController { |
|
|
|
Integer total = (Integer) administration.get("total"); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
for (int j = 0; j < administrationPList.size(); j++) { |
|
|
|
if(list.get(i).getCid().compareTo(administrationPList.get(j).getId()) == 0){ |
|
|
|
if (list.get(i).getCid().compareTo(administrationPList.get(j).getId()) == 0) { |
|
|
|
list.get(i).setCname(administrationPList.get(j).getName()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return new RestResponse(list,depositoryService.findCountByCondition(map),200); |
|
|
|
return new RestResponse(list, depositoryService.findCountByCondition(map), 200); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取当前行政组织 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static Map<String, Object> findAdministration(){ |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
String url = PortConfig.external_url +"/org/govlist"; |
|
|
|
public static Map<String, Object> findAdministration() { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
String url = PortConfig.external_url + "/org/govlist"; |
|
|
|
String superior = "313"; |
|
|
|
map.put("superior",superior); |
|
|
|
map.put("state",1); |
|
|
|
map.put("superior", superior); |
|
|
|
map.put("state", 1); |
|
|
|
String jsonString = JSONObject.toJSONString(map); |
|
|
|
JSONObject paramObject = JSONObject.parseObject(jsonString); |
|
|
|
String post = null; |
|
|
|
try { |
|
|
|
post = HttpUtils.send(url,paramObject, HTTP.UTF_8); |
|
|
|
post = HttpUtils.send(url, paramObject, HTTP.UTF_8); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(post); |
|
|
|
JSONObject data = (JSONObject) jsonObject.get("data"); |
|
|
|
JSONArray list = (JSONArray) data.get("list"); |
|
|
|
if(list == null){ |
|
|
|
if (list == null) { |
|
|
|
list = new JSONArray(); |
|
|
|
} |
|
|
|
Integer total = ObjectFormatUtil.toInteger(data.get("total")); |
|
|
|
Map<String,Object> result = new HashMap(); |
|
|
|
Map<String, Object> result = new HashMap(); |
|
|
|
List<AdministrationP> administrationPList = new ArrayList<>(); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
Administration administration = JSONObject.toJavaObject((JSONObject)list.get(i), Administration.class); |
|
|
|
Administration administration = JSONObject.toJavaObject((JSONObject) list.get(i), Administration.class); |
|
|
|
AdministrationP administrationP = new AdministrationP(administration); |
|
|
|
administrationPList.add(administrationP); |
|
|
|
} |
|
|
|
result.put("administrationPList",administrationPList); |
|
|
|
result.put("total",total); |
|
|
|
result.put("administrationPList", administrationPList); |
|
|
|
result.put("total", total); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 彻底删除仓库记录(硬删除) |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("/realDeleteDepository") |
|
|
|
public RestResponse realDeleteDepository(@RequestBody Map<String,Object> map){ |
|
|
|
if (map.containsKey("id")){ |
|
|
|
Integer id= ObjectFormatUtil.toInteger(map.get("id")); |
|
|
|
public RestResponse realDeleteDepository(@RequestBody Map<String, Object> map) { |
|
|
|
if (map.containsKey("id")) { |
|
|
|
Integer id = ObjectFormatUtil.toInteger(map.get("id")); |
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
RealDeleteSonDepository(id.toString()); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
return CrudUtil.deleteHandle(depositoryService.deleteDepositoryRecordById(id),1); |
|
|
|
}else if (map.containsKey("ids")){ |
|
|
|
List<Integer> ids=(List<Integer>) map.get("ids"); |
|
|
|
return CrudUtil.deleteHandle(depositoryService.deleteDepositoryRecordById(id), 1); |
|
|
|
} else if (map.containsKey("ids")) { |
|
|
|
List<Integer> ids = (List<Integer>) map.get("ids"); |
|
|
|
for (int j = 0; j < ids.size(); j++) { |
|
|
|
String id = ids.get(j).toString(); |
|
|
|
new Thread(new Runnable() { |
|
|
|
@ -481,19 +489,20 @@ public class DepositoryController { |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} |
|
|
|
return CrudUtil.deleteHandle(depositoryService.deleteDepositoryRecordByIds(ids),ids.size()); |
|
|
|
}else { |
|
|
|
return CrudUtil.deleteHandle(depositoryService.deleteDepositoryRecordByIds(ids), ids.size()); |
|
|
|
} else { |
|
|
|
throw new MyException("所需请求参数缺失!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除所有子仓库信息(硬删除) |
|
|
|
* |
|
|
|
* @param parentId |
|
|
|
*/ |
|
|
|
public void RealDeleteSonDepository(String parentId){ |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
param.put("parentId",parentId); |
|
|
|
public void RealDeleteSonDepository(String parentId) { |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("parentId", parentId); |
|
|
|
// 获取当前仓库所有子仓库
|
|
|
|
List<Depository> depositoryRecordPByCondition = depositoryService.findDepositoryRecordPByCondition(param); |
|
|
|
for (int i = 0; i < depositoryRecordPByCondition.size(); i++) { |
|
|
|
@ -528,7 +537,7 @@ public class DepositoryController { |
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
UpdateSonState(id.toString(),3,true); |
|
|
|
UpdateSonState(id.toString(), 3, true); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
return CrudUtil.deleteHandle(depositoryService.changeStateToDeletedById(id), 1); |
|
|
|
@ -540,7 +549,7 @@ public class DepositoryController { |
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
UpdateSonState(id,3,true); |
|
|
|
UpdateSonState(id, 3, true); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} |
|
|
|
@ -568,28 +577,29 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改仓库状态 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("/EditDepositoryState") |
|
|
|
public RestResponse EditDepositoryState(@RequestBody Map<String,Object> map){ |
|
|
|
public RestResponse EditDepositoryState(@RequestBody Map<String, Object> map) { |
|
|
|
if (map.containsKey("state")) { |
|
|
|
map.put("state", 1); |
|
|
|
} else { |
|
|
|
map.put("state", 2); |
|
|
|
} |
|
|
|
int state = ((int)map.get("state")); |
|
|
|
int state = ((int) map.get("state")); |
|
|
|
String id = (String) map.get("id"); |
|
|
|
if(state == 2){ |
|
|
|
if(map.containsKey("envelop")){ |
|
|
|
if (state == 2) { |
|
|
|
if (map.containsKey("envelop")) { |
|
|
|
// 封库
|
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
UpdateSonState(id,state,true); |
|
|
|
UpdateSonState(id, state, true); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
// 禁用仓库
|
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
@ -598,11 +608,11 @@ public class DepositoryController { |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} |
|
|
|
}else if(state == 1){ // 如果是启用仓库,则只启用当前仓库下的物品
|
|
|
|
} else if (state == 1) { // 如果是启用仓库,则只启用当前仓库下的物品
|
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
UpdateSonMaterialState(id,state); |
|
|
|
UpdateSonMaterialState(id, state); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} |
|
|
|
@ -611,49 +621,259 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改所有子仓库状态 |
|
|
|
* |
|
|
|
* @param parentId |
|
|
|
*/ |
|
|
|
public void UpdateSonState(String parentId,Integer state,boolean envelop){ |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
param.put("parentId",parentId); |
|
|
|
public void UpdateSonState(String parentId, Integer state, boolean envelop) { |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("parentId", parentId); |
|
|
|
// 获取当前仓库所有子仓库
|
|
|
|
List<Depository> depositoryRecordPByCondition = depositoryService.findDepositoryRecordPByCondition(param); |
|
|
|
if(envelop){ |
|
|
|
if (envelop) { |
|
|
|
// 将当前仓库下的产品状态改为禁用
|
|
|
|
UpdateSonMaterialState(parentId,state); |
|
|
|
UpdateSonMaterialState(parentId, state); |
|
|
|
} |
|
|
|
for (int i = 0; i < depositoryRecordPByCondition.size(); i++) { |
|
|
|
Depository depository = depositoryRecordPByCondition.get(i); |
|
|
|
int depositoryId = depository.getId(); |
|
|
|
Map<String,Object> newMap = new HashMap<>(); |
|
|
|
newMap.put("parentId",depositoryId); |
|
|
|
UpdateSonState(String.valueOf(depositoryId),state,envelop); |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
map.put("id",depositoryId); |
|
|
|
map.put("state",state); |
|
|
|
Map<String, Object> newMap = new HashMap<>(); |
|
|
|
newMap.put("parentId", depositoryId); |
|
|
|
UpdateSonState(String.valueOf(depositoryId), state, envelop); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("id", depositoryId); |
|
|
|
map.put("state", state); |
|
|
|
depositoryService.updateStateByParam(map); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改当前仓库下的物料状态 |
|
|
|
* |
|
|
|
* @param parentId |
|
|
|
* @param state |
|
|
|
*/ |
|
|
|
public void UpdateSonMaterialState(String parentId,Integer state){ |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
param.put("depositoryId",parentId); |
|
|
|
public void UpdateSonMaterialState(String parentId, Integer state) { |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("depositoryId", parentId); |
|
|
|
List<MaterialP> materialPByCondition = materialService.findMaterialPByCondition(param); |
|
|
|
for (int i = 0; i < materialPByCondition.size(); i++) { |
|
|
|
MaterialP materialP = materialPByCondition.get(i); |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
map.put("id",materialP.getId()); |
|
|
|
map.put("state",state); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("id", materialP.getId()); |
|
|
|
map.put("state", state); |
|
|
|
materialService.updateStateByParam(map); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 获取各类别库存容量
|
|
|
|
@RequestMapping(value = "/layui/echart_back_invetory", method = RequestMethod.GET) |
|
|
|
@ResponseBody |
|
|
|
public Map<String, Object> echart_back_MaterialTypeInvetory(@RequestParam Map<String, Object> map, HttpServletRequest request) { |
|
|
|
String typeName = (String) map.get("typeName"); |
|
|
|
String type = (String) map.get("type"); |
|
|
|
// 获取本月及之前月份各种类别入/出库总量
|
|
|
|
List<MaterialType> materialTypeAll = materialTypeService.findMaterialTypeNoParent(); |
|
|
|
Map<String, Object> previousMonth = getPreviousMonth(); |
|
|
|
List<Object> months = (List<Object>) previousMonth.get("months"); |
|
|
|
List<Object> sourceList = (List<Object>) previousMonth.get("sourceList"); |
|
|
|
for (int num = 0; num < months.size() - 1; num++) { |
|
|
|
for (int j = 0; j < materialTypeAll.size(); j++) { |
|
|
|
Map<String, Object> parm = new HashMap<>(); |
|
|
|
parm.put("type", Integer.parseInt(type)); |
|
|
|
if (Integer.parseInt(type) == 1) { |
|
|
|
parm.put("state", "已入库"); |
|
|
|
} else if (Integer.parseInt(type) == 2) { |
|
|
|
parm.put("state", "已出库"); |
|
|
|
} |
|
|
|
parm.put("start", months.get(num + 1)); |
|
|
|
parm.put("end", months.get(num)); |
|
|
|
parm.put("tname", materialTypeAll.get(j).getTname()); |
|
|
|
//根据条件获取月份中物料的总额
|
|
|
|
Double materialCountByMonth = depositoryRecordService.findMaterialCountByMonth(parm); |
|
|
|
// 测试
|
|
|
|
Double materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth1(parm); |
|
|
|
((Map<String, Object>) sourceList.get(num)).put(materialTypeAll.get(j).getTname(), materialCountByMonth1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取上周 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/layui/echart_back_lastWeek", method = RequestMethod.GET) |
|
|
|
@ResponseBody |
|
|
|
public Map<String, Object> echart_back_lastWeek(@RequestParam("type") String type, HttpServletRequest request) { |
|
|
|
|
|
|
|
// 获取当前登录用户
|
|
|
|
UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); |
|
|
|
|
|
|
|
List<String> show_weekday = new ArrayList<String>(); |
|
|
|
show_weekday.add("周一"); |
|
|
|
show_weekday.add("周二"); |
|
|
|
show_weekday.add("周三"); |
|
|
|
show_weekday.add("周四"); |
|
|
|
show_weekday.add("周五"); |
|
|
|
show_weekday.add("周六"); |
|
|
|
show_weekday.add("周日"); |
|
|
|
|
|
|
|
// 获取各仓库名称以及id
|
|
|
|
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(userByPort); |
|
|
|
|
|
|
|
Iterator it = depositoryAllNameAndId.keySet().iterator(); |
|
|
|
|
|
|
|
// 仓库名称列表
|
|
|
|
List<String> depositoryName = new ArrayList<>(); |
|
|
|
|
|
|
|
// 各仓库对应入库数目
|
|
|
|
Map<String, Double> yesterdayData = new HashMap<>(); |
|
|
|
// 获取昨天数据标志位
|
|
|
|
boolean flag = true; |
|
|
|
|
|
|
|
// 每天各仓库入库数目
|
|
|
|
Map<String, Object> show_data = new HashMap<>(); |
|
|
|
List<Long> days = getLastTimeInterval(); |
|
|
|
List<Double> drCountbyDrName = new ArrayList<>(); |
|
|
|
while (it.hasNext()) { |
|
|
|
int i; |
|
|
|
Object key = it.next(); |
|
|
|
for (i = days.size() - 1; i > 0; i--) { |
|
|
|
// 遍历 Map并计算各仓库的入库数
|
|
|
|
if (i == days.size() - 1) { |
|
|
|
depositoryName.add(key.toString()); |
|
|
|
} |
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 获取一段时间内的库存额度
|
|
|
|
// 测试
|
|
|
|
Double depositoryRecordByDateAndType1 = depositoryRecordService.findApplicationRecordByDate(days.get(i), days.get(i - 1), Integer.parseInt(type), val); |
|
|
|
drCountbyDrName.add(depositoryRecordByDateAndType1); |
|
|
|
if (i == 2 && flag) { |
|
|
|
yesterdayData.put(key.toString(), depositoryRecordByDateAndType1); |
|
|
|
} |
|
|
|
} |
|
|
|
Collections.reverse(drCountbyDrName); |
|
|
|
show_data.put(key.toString(), ((ArrayList<Double>) drCountbyDrName).clone()); |
|
|
|
drCountbyDrName.clear(); |
|
|
|
} |
|
|
|
|
|
|
|
Map<String,Object> depository_data = new HashMap<>(); |
|
|
|
depository_data.put("data", show_data); |
|
|
|
return depository_data; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取本周 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/layui/echart_back_thisWeek", method = RequestMethod.GET) |
|
|
|
@ResponseBody |
|
|
|
public Map<String, Object> echart_back_thisWeek(@RequestParam("type") String type, HttpServletRequest request) { |
|
|
|
|
|
|
|
// 获取当前登录用户
|
|
|
|
UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); |
|
|
|
|
|
|
|
// 设置展示天数
|
|
|
|
List<String> show_weekday = new ArrayList<String>(); |
|
|
|
show_weekday.add("周一"); |
|
|
|
show_weekday.add("周二"); |
|
|
|
show_weekday.add("周三"); |
|
|
|
show_weekday.add("周四"); |
|
|
|
show_weekday.add("周五"); |
|
|
|
show_weekday.add("周六"); |
|
|
|
show_weekday.add("周日"); |
|
|
|
|
|
|
|
// 获取各仓库名称以及id
|
|
|
|
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(userByPort); |
|
|
|
|
|
|
|
Iterator it = depositoryAllNameAndId.keySet().iterator(); |
|
|
|
// 仓库名称列表
|
|
|
|
List<String> depositoryName = new ArrayList<>(); |
|
|
|
// 各仓库对应入库数目
|
|
|
|
Map<String, Double> yesterdayData = new HashMap<>(); |
|
|
|
// 每天各仓库入库数目
|
|
|
|
Map<String, Object> show_data = new HashMap<>(); |
|
|
|
// 各仓库当前库存数目
|
|
|
|
Map<String, Object> todayInventory = new HashMap<>(); |
|
|
|
//获取获取系统的当前日历对象
|
|
|
|
Calendar instance = Calendar.getInstance(); |
|
|
|
// 获取昨天数据标志位
|
|
|
|
boolean flag = true; |
|
|
|
// 获取今天是周几
|
|
|
|
int weekDay = instance.get(Calendar.DAY_OF_WEEK); |
|
|
|
weekDay = weekDay - 1; // 具体周几
|
|
|
|
// 获取日期
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
if (weekDay == 1) { |
|
|
|
//只获取今天
|
|
|
|
Long now = DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime())); |
|
|
|
instance.add(Calendar.DATE, 1); |
|
|
|
Long tomorrow = DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime())); |
|
|
|
instance.add(Calendar.DATE, -2); |
|
|
|
String yesterday = formatter.format(instance.getTime()); |
|
|
|
while (it.hasNext()) { |
|
|
|
// 遍历 Map并计算各仓库的入库数
|
|
|
|
Object key = it.next(); |
|
|
|
depositoryName.add(key.toString()); |
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 获取一段时间内的库存额度
|
|
|
|
Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(tomorrow, now, Integer.parseInt(type), val); |
|
|
|
Double toDayInventoryByDName = depositoryService.getToDayInventoryByDName(key.toString()); |
|
|
|
todayInventory.put(key.toString(), toDayInventoryByDName); |
|
|
|
yesterdayData.put(key.toString(), depositoryRecordByDate1); |
|
|
|
List<Double> drCountbyDrName = new ArrayList<>(); |
|
|
|
drCountbyDrName.add(depositoryRecordByDate1); |
|
|
|
show_data.put(key.toString(), ((ArrayList<Double>) drCountbyDrName).clone()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
int now = instance.get(Calendar.DAY_OF_WEEK) - 1; |
|
|
|
List<Long> days = new ArrayList<>(); // 周一至今的每天
|
|
|
|
instance.add(Calendar.DATE, 1); |
|
|
|
days.add(DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime()))); |
|
|
|
instance.add(Calendar.DATE, -1); |
|
|
|
days.add(DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime()))); |
|
|
|
while (now - 1 > 0) { |
|
|
|
now--; |
|
|
|
instance.add(Calendar.DATE, -1); |
|
|
|
Long format = DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime())); |
|
|
|
days.add(format); |
|
|
|
} |
|
|
|
List<Double> drCountbyDrName = new ArrayList<>(); |
|
|
|
while (it.hasNext()) { |
|
|
|
int i; |
|
|
|
Object key = it.next(); |
|
|
|
Double toDayInventoryByDName = depositoryService.getToDayInventoryByDName(key.toString()); |
|
|
|
todayInventory.put(key.toString(), toDayInventoryByDName); |
|
|
|
for (i = days.size() - 1; i > 0; i--) { |
|
|
|
// 遍历 Map并计算各仓库的入库数
|
|
|
|
if (i == days.size() - 1) { |
|
|
|
depositoryName.add(key.toString()); |
|
|
|
} |
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 获取一段时间内的库存额度
|
|
|
|
|
|
|
|
Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i - 1), days.get(i), Integer.parseInt(type), val); |
|
|
|
drCountbyDrName.add(depositoryRecordByDate1); |
|
|
|
if (i == 2 && flag) { |
|
|
|
yesterdayData.put(key.toString(), depositoryRecordByDate1); |
|
|
|
} |
|
|
|
} |
|
|
|
show_data.put(key.toString(), ((ArrayList<Double>) drCountbyDrName).clone()); |
|
|
|
drCountbyDrName.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Map<String,Object> depository_data = new HashMap<>(); |
|
|
|
depository_data.put("data", show_data); |
|
|
|
return depository_data; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 动态绘制图像 |
|
|
|
@ -662,7 +882,10 @@ public class DepositoryController { |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/layui/echart_back", method = RequestMethod.GET) |
|
|
|
@ResponseBody |
|
|
|
public Map<String, Object> learnLayuiAndEchart_back(@RequestParam("type") String type, @RequestParam(value = "last", required = false) String last) { |
|
|
|
public Map<String, Object> learnLayuiAndEchart_back(@RequestParam("type") String type, @RequestParam(value = "last", required = false) String last, HttpServletRequest request) { |
|
|
|
// 获取当前登录用户
|
|
|
|
UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); |
|
|
|
|
|
|
|
// 设置展示天数
|
|
|
|
List<String> show_weekday = new ArrayList<String>(); |
|
|
|
show_weekday.add("周一"); |
|
|
|
@ -674,7 +897,8 @@ public class DepositoryController { |
|
|
|
show_weekday.add("周日"); |
|
|
|
|
|
|
|
// 获取各仓库名称以及id
|
|
|
|
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(); |
|
|
|
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(userByPort); |
|
|
|
|
|
|
|
Iterator it = depositoryAllNameAndId.keySet().iterator(); |
|
|
|
// 仓库名称列表
|
|
|
|
List<String> depositoryName = new ArrayList<>(); |
|
|
|
@ -683,7 +907,7 @@ public class DepositoryController { |
|
|
|
// 每天各仓库入库数目
|
|
|
|
Map<String, Object> show_data = new HashMap<>(); |
|
|
|
// 各仓库当前库存数目
|
|
|
|
Map<String,Object> todayInventory = new HashMap<>(); |
|
|
|
Map<String, Object> todayInventory = new HashMap<>(); |
|
|
|
//获取获取系统的当前日历对象
|
|
|
|
Calendar instance = Calendar.getInstance(); |
|
|
|
// 获取昨天数据标志位
|
|
|
|
@ -719,8 +943,7 @@ public class DepositoryController { |
|
|
|
show_data.put(key.toString(), ((ArrayList<Double>) drCountbyDrName).clone()); |
|
|
|
drCountbyDrName.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
if (weekDay == 1) { |
|
|
|
//只获取今天
|
|
|
|
Long now = DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime())); |
|
|
|
@ -734,9 +957,9 @@ public class DepositoryController { |
|
|
|
depositoryName.add(key.toString()); |
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 获取一段时间内的库存额度
|
|
|
|
Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(tomorrow,now , Integer.parseInt(type), val); |
|
|
|
Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(tomorrow, now, Integer.parseInt(type), val); |
|
|
|
Double toDayInventoryByDName = depositoryService.getToDayInventoryByDName(key.toString()); |
|
|
|
todayInventory.put(key.toString(),toDayInventoryByDName); |
|
|
|
todayInventory.put(key.toString(), toDayInventoryByDName); |
|
|
|
yesterdayData.put(key.toString(), depositoryRecordByDate1); |
|
|
|
List<Double> drCountbyDrName = new ArrayList<>(); |
|
|
|
drCountbyDrName.add(depositoryRecordByDate1); |
|
|
|
@ -744,7 +967,7 @@ public class DepositoryController { |
|
|
|
} |
|
|
|
} else { |
|
|
|
int now = instance.get(Calendar.DAY_OF_WEEK) - 1; |
|
|
|
List<Long> days = new ArrayList<>(); |
|
|
|
List<Long> days = new ArrayList<>(); // 周一至今的每天
|
|
|
|
instance.add(Calendar.DATE, 1); |
|
|
|
days.add(DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime()))); |
|
|
|
instance.add(Calendar.DATE, -1); |
|
|
|
@ -760,7 +983,7 @@ public class DepositoryController { |
|
|
|
int i; |
|
|
|
Object key = it.next(); |
|
|
|
Double toDayInventoryByDName = depositoryService.getToDayInventoryByDName(key.toString()); |
|
|
|
todayInventory.put(key.toString(),toDayInventoryByDName); |
|
|
|
todayInventory.put(key.toString(), toDayInventoryByDName); |
|
|
|
for (i = days.size() - 1; i > 0; i--) { |
|
|
|
// 遍历 Map并计算各仓库的入库数
|
|
|
|
if (i == days.size() - 1) { |
|
|
|
@ -768,7 +991,7 @@ public class DepositoryController { |
|
|
|
} |
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 获取一段时间内的库存额度
|
|
|
|
// 测试
|
|
|
|
|
|
|
|
Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i - 1), days.get(i), Integer.parseInt(type), val); |
|
|
|
drCountbyDrName.add(depositoryRecordByDate1); |
|
|
|
if (i == 2 && flag) { |
|
|
|
@ -780,8 +1003,9 @@ public class DepositoryController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 获取本月及之前月份各种类入/出库总量
|
|
|
|
List<MaterialType> materialTypeAll = materialTypeService.findMaterialTypeAll(); |
|
|
|
|
|
|
|
// 获取本月及之前月份各种类别入/出库总量
|
|
|
|
List<MaterialType> materialTypeAll = materialTypeService.findMaterialTypeNoParent(); |
|
|
|
Map<String, Object> previousMonth = getPreviousMonth(); |
|
|
|
List<Object> months = (List<Object>) previousMonth.get("months"); |
|
|
|
List<Object> sourceList = (List<Object>) previousMonth.get("sourceList"); |
|
|
|
@ -857,13 +1081,13 @@ public class DepositoryController { |
|
|
|
depository_data.put("week", show_weekday); |
|
|
|
depository_data.put("data", show_data); |
|
|
|
depository_data.put("yesterdayData", yesterdayData); |
|
|
|
depository_data.put("todayInventory",todayInventory); |
|
|
|
depository_data.put("todayInventory", todayInventory); |
|
|
|
depository_data.put("sourceList", sourceList); |
|
|
|
depository_data.put("mapData", mapData); |
|
|
|
depository_data.put("sourceListByMonth",getBeforeInventoryByMonth(depositoryService,depositoryRecordService)); |
|
|
|
depository_data.put("BeforeInventory",getBeforeInventoryByDName(depositoryService,depositoryRecordService)); |
|
|
|
depository_data.put("ThisWeekInventory",getThisWeekInventoryByDName(depositoryService,depositoryRecordService)); |
|
|
|
depository_data.put("MapInventory",getBeforeInventoryOnMap(depositoryService,depositoryRecordService)); |
|
|
|
depository_data.put("sourceListByMonth", getBeforeInventoryByMonth(depositoryService, depositoryRecordService)); |
|
|
|
depository_data.put("BeforeInventory", getBeforeInventoryByDName(depositoryService, depositoryRecordService, userByPort)); |
|
|
|
depository_data.put("ThisWeekInventory", getThisWeekInventoryByDName(depositoryService, depositoryRecordService, userByPort)); |
|
|
|
depository_data.put("MapInventory", getBeforeInventoryOnMap(depositoryService, depositoryRecordService)); |
|
|
|
// 封装 最终数据
|
|
|
|
Map<String, Object> data = new LinkedHashMap<String, Object>(); |
|
|
|
data.put("depository_data", depository_data); |
|
|
|
@ -879,61 +1103,64 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据物料编号查询所在仓库 |
|
|
|
* |
|
|
|
* @param mid |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@GetMapping("/find_depository") |
|
|
|
public RestResponse FindDepositoryByMid(@RequestParam("mid") String mid){ |
|
|
|
public RestResponse FindDepositoryByMid(@RequestParam("mid") String mid) { |
|
|
|
Material materialById = materialService.findMaterialById(Integer.parseInt(mid)); |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("depositoryId", materialById.getDepositoryId()); |
|
|
|
List<Depository> depositoryId = depositoryService.findDepositoryRecordPByCondition(param); |
|
|
|
return new RestResponse(depositoryId.get(0),1, 200); |
|
|
|
return new RestResponse(depositoryId.get(0), 1, 200); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据物料名称查询所在仓库 |
|
|
|
* |
|
|
|
* @param mname |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@GetMapping("/findDepositoryByMname") |
|
|
|
public RestResponse FindDepositoryByMname(@RequestParam("mname") String mname){ |
|
|
|
public RestResponse FindDepositoryByMname(@RequestParam("mname") String mname) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查找仓库内是否有物品 |
|
|
|
* |
|
|
|
* @param depositoryId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@GetMapping("/findMaterialByDepository") |
|
|
|
public RestResponse FindMaterialByDepository(@RequestParam("depositoryId") String depositoryId){ |
|
|
|
public RestResponse FindMaterialByDepository(@RequestParam("depositoryId") String depositoryId) { |
|
|
|
Boolean allSonDepository = findAllSonDepository(depositoryId); |
|
|
|
return new RestResponse(allSonDepository); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询该仓库是否有其他关联信息 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("/findRelevancyByDepository") |
|
|
|
public RestResponse FindRelevancyByDepository(@RequestBody Map<String, Object> map){ |
|
|
|
public RestResponse FindRelevancyByDepository(@RequestBody Map<String, Object> map) { |
|
|
|
Boolean allSonDepositoryOfRelevancy = false; |
|
|
|
if(map.containsKey("id")){ |
|
|
|
if (map.containsKey("id")) { |
|
|
|
Integer depositoryId = (Integer) map.get("id"); |
|
|
|
allSonDepositoryOfRelevancy = findAllSonDepositoryOfRelevancy(depositoryId.toString()); |
|
|
|
}else if(map.containsKey("ids")){ |
|
|
|
} else if (map.containsKey("ids")) { |
|
|
|
List<Integer> ids = (List<Integer>) map.get("ids"); |
|
|
|
for (int i = 0; i < ids.size(); i++) { |
|
|
|
allSonDepositoryOfRelevancy |= findAllSonDepositoryOfRelevancy(ids.get(i).toString()); |
|
|
|
if(allSonDepositoryOfRelevancy){ |
|
|
|
if (allSonDepositoryOfRelevancy) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
throw new MyException("所需请求参数缺失!"); |
|
|
|
} |
|
|
|
return new RestResponse(allSonDepositoryOfRelevancy); |
|
|
|
@ -941,22 +1168,23 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据父级编号查询所有仓库物品 |
|
|
|
* |
|
|
|
* @param parentid |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Boolean findAllSonDepository(String parentid){ |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
param.put("parentId",parentid); |
|
|
|
param.put("state",1); |
|
|
|
public Boolean findAllSonDepository(String parentid) { |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("parentId", parentid); |
|
|
|
param.put("state", 1); |
|
|
|
boolean materialByDepository = findMaterialByDepository(parentid); |
|
|
|
if(materialByDepository){ |
|
|
|
if (materialByDepository) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
List<Depository> depositoryRecordPByCondition = depositoryService.findDepositoryRecordPByCondition(param); |
|
|
|
for (int i = 0; i < depositoryRecordPByCondition.size(); i++) { |
|
|
|
if(!findMaterialByDepository(depositoryRecordPByCondition.get(i).getId().toString())){ |
|
|
|
if (!findMaterialByDepository(depositoryRecordPByCondition.get(i).getId().toString())) { |
|
|
|
findAllSonDepository(depositoryRecordPByCondition.get(i).getId().toString()); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -965,24 +1193,25 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据父级编号查询所有关联信息 |
|
|
|
* |
|
|
|
* @param parentid |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Boolean findAllSonDepositoryOfRelevancy(String parentid) { |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
param.put("parentId",parentid); |
|
|
|
param.put("state",1); |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("parentId", parentid); |
|
|
|
param.put("state", 1); |
|
|
|
boolean materialByDepository = findMaterialByDepository(parentid); |
|
|
|
Boolean depositoryRecord = findDepositoryRecord(parentid); |
|
|
|
if(materialByDepository || depositoryRecord){ |
|
|
|
if (materialByDepository || depositoryRecord) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
List<Depository> depositoryRecordPByCondition = depositoryService.findDepositoryRecordPByCondition(param); |
|
|
|
for (int i = 0; i < depositoryRecordPByCondition.size(); i++) { |
|
|
|
String depositoryId = depositoryRecordPByCondition.get(i).getId().toString(); |
|
|
|
if(!findMaterialByDepository(depositoryId) && !findDepositoryRecord(depositoryId)){ |
|
|
|
if (!findMaterialByDepository(depositoryId) && !findDepositoryRecord(depositoryId)) { |
|
|
|
findAllSonDepositoryOfRelevancy(depositoryRecordPByCondition.get(i).getId().toString()); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -991,15 +1220,16 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据仓库编号判断该仓库是否有物品 |
|
|
|
* |
|
|
|
* @param parentId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public boolean findMaterialByDepository(String parentId){ |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
param.put("state",1); |
|
|
|
param.put("depositoryId",parentId); |
|
|
|
public boolean findMaterialByDepository(String parentId) { |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("state", 1); |
|
|
|
param.put("depositoryId", parentId); |
|
|
|
List<MaterialP> materialPByCondition = materialService.findMaterialPByCondition(param); |
|
|
|
if(materialPByCondition.size() > 0){ |
|
|
|
if (materialPByCondition.size() > 0) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
@ -1007,14 +1237,15 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据仓库编号查询与其有关的订单信息 |
|
|
|
* |
|
|
|
* @param depositoryId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Boolean findDepositoryRecord(String depositoryId){ |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
param.put("depositoryId",depositoryId); |
|
|
|
public Boolean findDepositoryRecord(String depositoryId) { |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("depositoryId", depositoryId); |
|
|
|
List<DepositoryRecordP> recordPByCondition = depositoryRecordService.findDepositoryRecordPByCondition(param); |
|
|
|
if(recordPByCondition.size() > 0){ |
|
|
|
if (recordPByCondition.size() > 0) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
@ -1022,19 +1253,20 @@ public class DepositoryController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询当前仓库子仓库 |
|
|
|
* |
|
|
|
* @param parentId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@GetMapping("/findDepositoryByParent") |
|
|
|
public RestResponse FindDepositoryByParentId(@RequestParam("parentId") String parentId){ |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
param.put("parentId",parentId); |
|
|
|
public RestResponse FindDepositoryByParentId(@RequestParam("parentId") String parentId) { |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("parentId", parentId); |
|
|
|
List<Depository> depositoryRecordPByCondition = depositoryService.findDepositoryRecordPByCondition(param); |
|
|
|
return new RestResponse(depositoryRecordPByCondition, depositoryService.findCountByCondition(param), 200); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/findManagerByDid") |
|
|
|
public RestResponse FindManagerByDid(@RequestParam("did") Integer did){ |
|
|
|
public RestResponse FindManagerByDid(@RequestParam("did") Integer did) { |
|
|
|
List<Integer> userIdByDid = roleService.findUserIdByDid(did); |
|
|
|
List<UserByPort> userByPortList = new ArrayList<>(); |
|
|
|
for (int i = 0; i < userIdByDid.size(); i++) { |
|
|
|
@ -1046,19 +1278,19 @@ public class DepositoryController { |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/findPostByCompany") |
|
|
|
public RestResponse findPostByCompany(@RequestParam("company") String company){ |
|
|
|
public RestResponse findPostByCompany(@RequestParam("company") String company) { |
|
|
|
List<AdministrationP> administrationPList = PageController.findCompanyBySuperior(company); |
|
|
|
int size = administrationPList.size(); |
|
|
|
return new RestResponse(administrationPList,size, 200); |
|
|
|
return new RestResponse(administrationPList, size, 200); |
|
|
|
} |
|
|
|
|
|
|
|
// 构造树选择框
|
|
|
|
@GetMapping("/treeMenus") |
|
|
|
public RestResponse InitTreeMenus(@RequestParam(value = "adminorg",required = false) Integer adminorg){ |
|
|
|
public RestResponse InitTreeMenus(@RequestParam(value = "adminorg", required = false) Integer adminorg) { |
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
if(Integer.compare(0,adminorg) == 0){ |
|
|
|
if (Integer.compare(0, adminorg) == 0) { |
|
|
|
list = depositoryService.InitTreeMenus(); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
list = depositoryService.InitTreeMenus(adminorg.toString()); |
|
|
|
} |
|
|
|
return new RestResponse(list); |
|
|
|
@ -1066,7 +1298,7 @@ public class DepositoryController { |
|
|
|
|
|
|
|
// 根据id获取仓库信息
|
|
|
|
@GetMapping("/findDepositoryByDid") |
|
|
|
public RestResponse findDepositoryByDid(@RequestParam(value = "depositoryId")Integer depositoryId){ |
|
|
|
public RestResponse findDepositoryByDid(@RequestParam(value = "depositoryId") Integer depositoryId) { |
|
|
|
Depository depositoryRecordById = depositoryService.findDepositoryRecordById(depositoryId); |
|
|
|
return new RestResponse(depositoryRecordById); |
|
|
|
} |
|
|
|
|