package com.fzzy.sys.controller.grain;
|
|
import com.fzzy.igds.constant.Constant;
|
import com.fzzy.igds.constant.DepotType;
|
import com.fzzy.igds.data.*;
|
import com.fzzy.igds.domain.Depot;
|
import com.fzzy.igds.request.ExeBaseRequest;
|
import com.fzzy.igds.response.GrainResponse;
|
import com.fzzy.igds.utils.ContextUtil;
|
import com.fzzy.sys.manager.common.CommonManager;
|
import com.fzzy.sys.manager.grain.GrainManager;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.utils.StringUtils;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.ModelMap;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import javax.annotation.Resource;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @Description 粮情控制器
|
* @Author CZT
|
* @Date 2025/12/9 9:04
|
*/
|
@Slf4j
|
@Controller
|
@RequestMapping("grain")
|
public class GrainController {
|
|
private static final String prefix = "grain";
|
|
@Resource
|
private CommonManager commonManager;
|
@Resource
|
private GrainManager grainManager;
|
|
/**
|
* 页面控制--根据仓库类型调整不同页面
|
*
|
* @param depotId
|
* @param deptId
|
* @return
|
*/
|
@RequestMapping("/gateway")
|
public String gateway(
|
@RequestParam(value = "depotId", required = true) String depotId,
|
@RequestParam(value = "deptId", required = false) String deptId,
|
ModelMap view) {
|
|
SysUser user = ContextUtil.getLoginUser();
|
view.put(Constant.MODEL_KEY_LOGIN_USER, user);
|
|
if(StringUtils.isBlank(deptId)){
|
deptId = ContextUtil.subDeptId(user);
|
}
|
view.put("deptId", deptId);
|
|
// 仓库列表做下拉框使用
|
List<Depot> listDepot = commonManager.listDepotByDeptId(deptId);
|
view.put(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
|
|
String depotType = commonManager.getDepotTypeById(depotId);
|
view.put("depotType", depotType);
|
view.put("depotId", depotId);
|
|
//页面,默认平房仓
|
String viewUrl = prefix + "grain-check1";
|
if (depotType.equals(DepotType.TYPE_01.getCode()) || depotType.equals(DepotType.TYPE_05.getCode())) {
|
viewUrl = prefix + "/grain-check1";
|
}
|
if (DepotType.TYPE_02.getCode().equals(depotType) || DepotType.TYPE_04.getCode().equals(depotType)) {
|
viewUrl = prefix + "/grain-check4";
|
}
|
if (DepotType.TYPE_03.getCode().equals(depotType)) {
|
viewUrl = prefix + "/grain-check3";
|
}
|
|
return viewUrl;
|
}
|
|
/**
|
* 页面控制--粮情检测页面 - 平房仓
|
*
|
* @param depotId
|
* @return
|
*/
|
@RequestMapping("/view-check1")
|
public String viewCheck(
|
@RequestParam(value = "depotId", required = false) String depotId,
|
@RequestParam(value = "deptId", required = false) String deptId,
|
ModelMap view) {
|
|
SysUser user = ContextUtil.getLoginUser();
|
view.put(Constant.MODEL_KEY_LOGIN_USER, user);
|
|
// 获取当前用户所在的分库名称
|
if(StringUtils.isBlank(deptId)){
|
deptId = ContextUtil.subDeptId(user);
|
}
|
view.put("deptId", deptId);
|
|
// 获取当前部门,所有仓库列表
|
List<Depot> listDepot = commonManager.listDepotByDeptId(deptId);
|
view.put(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
|
|
view.put("depotType", DepotType.TYPE_01.getCode());
|
view.put("depotId", depotId);
|
|
return prefix + "/grain-check1";
|
}
|
|
/**
|
* 页面控制--粮情检测页面 - 筒仓、浅圆仓
|
*
|
* @param depotId
|
* @param deptId
|
* @return
|
*/
|
@RequestMapping("/view-check4")
|
public String viewCheck4(
|
@RequestParam(value = "depotId", required = false) String depotId,
|
@RequestParam(value = "deptId", required = false) String deptId,
|
ModelMap view) {
|
|
SysUser user = ContextUtil.getLoginUser();
|
view.put(Constant.MODEL_KEY_LOGIN_USER, user);
|
|
// 获取当前用户所在的分库名称
|
if(StringUtils.isBlank(deptId)){
|
deptId = ContextUtil.subDeptId(user);
|
}
|
view.put("deptId", deptId);
|
|
// 获取当前部门,所有仓库列表
|
List<Depot> listDepot = commonManager.listDepotByDeptId(deptId);
|
view.put(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
|
|
view.put("depotType", DepotType.TYPE_04.getCode());
|
view.put("depotId", depotId);
|
|
return prefix + "/grain-check4";
|
}
|
|
/**
|
* 获取执行命令记录
|
*
|
* @param depotId
|
* @param deptId
|
* @return
|
*/
|
@RequestMapping("/order-list")
|
public String orderList(
|
@RequestParam(value = "depotId", required = false) String depotId,
|
@RequestParam(value = "deptId", required = false) String deptId,
|
ModelMap view) {
|
|
SysUser user = ContextUtil.getLoginUser();
|
view.put(Constant.MODEL_KEY_LOGIN_USER, user);
|
|
// 获取当前用户所在的分库名称
|
if (org.apache.commons.lang3.StringUtils.isEmpty(deptId)) {
|
deptId = ContextUtil.subDeptId(user);
|
}
|
view.put("deptId", deptId);
|
|
view.put("bizType", "grain");
|
view.put("depotId", depotId);
|
|
return prefix + "/order-list";
|
}
|
|
/**
|
* 粮情页面 - 根据条件获取集合,默认查询当天的数据
|
*
|
* @param param
|
* @return
|
*/
|
@RequestMapping("/query-list-data")
|
@ResponseBody
|
public PageResponse<List<GrainData>> queryListGrainData(@RequestBody GrainParam param) {
|
if (null == param.getCheckMonth()) {
|
param.setLimit(5);
|
} else {
|
param.setLimit(80);
|
}
|
return grainManager.queryListGrainData(param);
|
}
|
|
/**
|
* 粮情检测-单仓检测
|
*
|
* @param param
|
* @return
|
*/
|
@RequestMapping("/check-single")
|
@ResponseBody
|
public GrainResponse checkSingle(@RequestBody GrainParam param) {
|
return grainManager.checkSingle(param);
|
}
|
|
/**
|
* 粮情检测-批量检测
|
*
|
* @param param
|
* @return
|
*/
|
@RequestMapping("/check-batch")
|
@ResponseBody
|
public GrainResponse checkBatch(@RequestBody GrainParam param) {
|
return grainManager.checkBatch(param);
|
}
|
|
/**
|
* 根据当前仓库获取检测记录,默认10条,如果检测当前月,默认显示80条
|
*
|
* @param param
|
* @return
|
*/
|
@RequestMapping("/page-list")
|
@ResponseBody
|
public PageResponse<List<GrainData>> pageList(@RequestBody GrainParam param) {
|
if (null == param.getCheckMonth()) {
|
param.setLimit(10);
|
} else {
|
param.setLimit(80);
|
}
|
return grainManager.pageListGrainData(param);
|
}
|
|
|
/**
|
* 根据参数获取打印的模板
|
*
|
* @param param
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/build-print-model")
|
public PageResponse<PrintModeData> buildPrintModel(
|
@RequestBody GrainParam param) {
|
return grainManager.buildPrintModel(param);
|
}
|
|
/**
|
* 根据参数获取打印的模板-ALL
|
*
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/build-print-model-all")
|
public PageResponse<Map<String, PrintModeData>> buildPrintModelAll(
|
@RequestBody GrainParam param) {
|
param.setCompanyId(ContextUtil.getCompanyId());
|
return grainManager.buildPrintModelAll(param);
|
}
|
|
|
/**
|
* 粮情检测-批量导出EXCEL
|
*
|
* @param param 包括检测时间和需要导出的IDS
|
* @return
|
*/
|
@RequestMapping("/export-batch")
|
@ResponseBody
|
public GrainResponse exportBatch(@RequestBody GrainParam param) {
|
return grainManager.exportBatch(param);
|
}
|
|
|
|
/**
|
* 根据参数获取打印的模板-ALL
|
*
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/query-order-list")
|
public LayPage<List<ExeBaseRequest>> queryOrderList(@RequestParam(value = "depotId", required = false) String depotId,
|
@RequestParam(value = "deptId", required = false) String deptId) {
|
// 获取当前用户所在的分库名称
|
if(StringUtils.isBlank(deptId)){
|
deptId = ContextUtil.subDeptId(null);
|
}
|
|
List<ExeBaseRequest> result = grainManager.orderList(deptId);
|
|
return new LayPage(result);
|
}
|
|
|
/**
|
* 清除执行日志
|
*
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/clean-order-list")
|
public PageResponse<String> cleanOrderList(@RequestBody IgdsBaseParam param) {
|
|
if (StringUtils.isEmpty(param.getCompanyId())) {
|
param.setCompanyId(ContextUtil.getCompanyId());
|
}
|
if (StringUtils.isEmpty(param.getDeptId())) {
|
param.setDeptId(ContextUtil.subDeptId(null));
|
}
|
|
return grainManager.cleanOrderList(param);
|
}
|
}
|