|
@@ -0,0 +1,342 @@
|
|
|
|
|
+package com.ktg.mes.rms.controller;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+
|
|
|
|
|
+import com.github.pagehelper.util.StringUtil;
|
|
|
|
|
+import com.ktg.common.constant.UserConstants;
|
|
|
|
|
+import com.ktg.mes.rms.service.IEmcsTaskInstockService;
|
|
|
|
|
+import com.ktg.mes.rms.domain.ClientRequest;
|
|
|
|
|
+import com.ktg.mes.rms.domain.RmsTaskInstock;
|
|
|
|
|
+import com.ktg.mes.rms.domain.RmsTaskInstockStat;
|
|
|
|
|
+import com.ktg.mes.rms.domain.RmsTaskStockResult;
|
|
|
|
|
+import com.ktg.mes.wm.domain.WmRmsBox;
|
|
|
|
|
+import com.ktg.mes.wm.service.IWmRmsBoxService;
|
|
|
|
|
+import com.ktg.system.service.ISysConfigService;
|
|
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+import com.ktg.common.annotation.Log;
|
|
|
|
|
+import com.ktg.common.core.controller.BaseController;
|
|
|
|
|
+import com.ktg.common.core.domain.AjaxResult;
|
|
|
|
|
+import com.ktg.common.enums.BusinessType;
|
|
|
|
|
+import com.ktg.mes.rms.service.IRmsTaskInstockService;
|
|
|
|
|
+import com.ktg.common.utils.poi.ExcelUtil;
|
|
|
|
|
+import com.ktg.common.core.page.TableDataInfo;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 扫码入库Controller
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author wangm
|
|
|
|
|
+ * @date 2024-07-24
|
|
|
|
|
+ */
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/mes/md/instock")
|
|
|
|
|
+public class RmsTaskInstockController extends BaseController
|
|
|
|
|
+{
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IRmsTaskInstockService rmsTaskInstockService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IEmcsTaskInstockService emcsTaskInstockService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IWmRmsBoxService wmRmsBoxService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ISysConfigService sysConfigService;
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询扫码入库列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('md:instock:list')")
|
|
|
|
|
+ @GetMapping("/list")
|
|
|
|
|
+ public TableDataInfo list(RmsTaskInstock rmsTaskInstock)
|
|
|
|
|
+ {
|
|
|
|
|
+ startPage();
|
|
|
|
|
+ List<RmsTaskInstock> list = rmsTaskInstockService.selectRmsTaskInstockList(rmsTaskInstock);
|
|
|
|
|
+ return getDataTable(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询扫码入库列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('md:instock:list')")
|
|
|
|
|
+ @GetMapping("/listSelf")
|
|
|
|
|
+ public TableDataInfo listSelf(RmsTaskInstock rmsTaskInstock)
|
|
|
|
|
+ {
|
|
|
|
|
+ startPage();
|
|
|
|
|
+ List<RmsTaskInstock> list = rmsTaskInstockService.selectRmsTaskInstockListSelf(rmsTaskInstock);
|
|
|
|
|
+ return getDataTable(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 导出扫码入库列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('md:instock:export')")
|
|
|
|
|
+ @Log(title = "扫码入库", businessType = BusinessType.EXPORT)
|
|
|
|
|
+ @PostMapping("/export")
|
|
|
|
|
+ public void export(HttpServletResponse response, RmsTaskInstock rmsTaskInstock)
|
|
|
|
|
+ {
|
|
|
|
|
+ List<RmsTaskInstock> list = rmsTaskInstockService.selectRmsTaskInstockList(rmsTaskInstock);
|
|
|
|
|
+ ExcelUtil<RmsTaskInstock> util = new ExcelUtil<RmsTaskInstock>(RmsTaskInstock.class);
|
|
|
|
|
+ util.exportExcel(response, list, "扫码入库数据");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取扫码入库详细信息
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('md:instock:query')")
|
|
|
|
|
+ @GetMapping(value = "/{instockId}")
|
|
|
|
|
+ public AjaxResult getInfo(@PathVariable("instockId") Long instockId)
|
|
|
|
|
+ {
|
|
|
|
|
+ return AjaxResult.success(rmsTaskInstockService.selectRmsTaskInstockByInstockId(instockId));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增扫码入库
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('md:instock:add')")
|
|
|
|
|
+ @Log(title = "扫码入库", businessType = BusinessType.INSERT)
|
|
|
|
|
+ @PostMapping
|
|
|
|
|
+ public AjaxResult add(@RequestBody RmsTaskInstock rmsTaskInstock)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(UserConstants.NOT_UNIQUE.equals(rmsTaskInstockService.checkErpInstockCodeUnique(rmsTaskInstock))){
|
|
|
|
|
+ return AjaxResult.error("新增入库"+rmsTaskInstock.getErpInstockCode()+"失败,入库单编码已存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ rmsTaskInstock.setCreateBy(getUsername());
|
|
|
|
|
+ rmsTaskInstock.setStatus("0");
|
|
|
|
|
+ rmsTaskInstock.setFromType(3);
|
|
|
|
|
+ rmsTaskInstock.setIsErp(3);
|
|
|
|
|
+ return toAjax(rmsTaskInstockService.insertRmsTaskInstock(rmsTaskInstock));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改扫码入库
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('md:instock:edit')")
|
|
|
|
|
+ @Log(title = "扫码入库", businessType = BusinessType.UPDATE)
|
|
|
|
|
+ @PutMapping
|
|
|
|
|
+ public AjaxResult edit(@RequestBody RmsTaskInstock rmsTaskInstock)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(UserConstants.NOT_UNIQUE.equals(rmsTaskInstockService.checkErpInstockCodeUnique(rmsTaskInstock))){
|
|
|
|
|
+ return AjaxResult.error("修改入库"+rmsTaskInstock.getErpInstockCode()+"失败,入库单编码已存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ rmsTaskInstock.setUpdateBy(getUsername());
|
|
|
|
|
+ return toAjax(rmsTaskInstockService.updateRmsTaskInstockAndLine(rmsTaskInstock));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除扫码入库
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('md:instock:remove')")
|
|
|
|
|
+ @Log(title = "扫码入库", businessType = BusinessType.DELETE)
|
|
|
|
|
+ @DeleteMapping("/{instockIds}")
|
|
|
|
|
+ public AjaxResult remove(@PathVariable Long[] instockIds)
|
|
|
|
|
+ {
|
|
|
|
|
+ return toAjax(rmsTaskInstockService.deleteRmsTaskInstockByInstockIds(instockIds));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 手动入库
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('md:instock:add')")
|
|
|
|
|
+ @Log(title = "手动入库", businessType = BusinessType.UPDATE)
|
|
|
|
|
+ @PostMapping("/manualInstock")
|
|
|
|
|
+ public AjaxResult manualInstock(@RequestBody RmsTaskInstock rmsTaskInstock)
|
|
|
|
|
+ {
|
|
|
|
|
+ rmsTaskInstock.setUpdateBy(getUsername());
|
|
|
|
|
+ return toAjax(rmsTaskInstockService.manualInstock(rmsTaskInstock));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 入库
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('md:instock:edit')")
|
|
|
|
|
+ @Log(title = "自动入库", businessType = BusinessType.OTHER)
|
|
|
|
|
+ @PostMapping("/autoIn")
|
|
|
|
|
+ public AjaxResult autoIn(@RequestBody RmsTaskInstock rmsTaskInstock)
|
|
|
|
|
+ {
|
|
|
|
|
+ try{
|
|
|
|
|
+ if(rmsTaskInstock.getInstockId()==null) {
|
|
|
|
|
+ rmsTaskInstock.setCreateBy(getUsername());
|
|
|
|
|
+ }else{
|
|
|
|
|
+ rmsTaskInstock.setUpdateBy(getUsername());
|
|
|
|
|
+ }
|
|
|
|
|
+ rmsTaskInstock.setFromType(0);
|
|
|
|
|
+ rmsTaskInstock.setIsErp(0);
|
|
|
|
|
+ rmsTaskInstockService.autoInStock(rmsTaskInstock);
|
|
|
|
|
+ }catch (Exception ex){
|
|
|
|
|
+ return AjaxResult.error(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return AjaxResult.success("入库单创建成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 库位手动入库
|
|
|
|
|
+ */
|
|
|
|
|
+ @Log(title = "终端入库", businessType = BusinessType.OTHER)
|
|
|
|
|
+ @PostMapping("/clientIn")
|
|
|
|
|
+ public AjaxResult clientIn(@RequestBody ClientRequest clientRequest)
|
|
|
|
|
+ {
|
|
|
|
|
+ try{
|
|
|
|
|
+ String ipAddress = getLoginUser().getIpaddr();
|
|
|
|
|
+ clientRequest.setIp(ipAddress);
|
|
|
|
|
+ clientRequest.setDeviceCode(getDeviceCode());
|
|
|
|
|
+ String rmsAreaSize = sysConfigService.selectConfigByKey(UserConstants.rmsAreaSize);
|
|
|
|
|
+ if("1".equals(rmsAreaSize)){
|
|
|
|
|
+ //尺寸验证打开,默认为单物料出库 20250722
|
|
|
|
|
+ clientRequest.setFromType(4);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(clientRequest.getFromType() == 2){
|
|
|
|
|
+ WmRmsBox rmsBox = wmRmsBoxService.selectWmRmsBoxByBoxCode(clientRequest.getBoxCode());
|
|
|
|
|
+ if(StringUtil.isEmpty(rmsBox.getItemOutCode())
|
|
|
|
|
+ && !rmsBox.getWmRmsBoxItemList().isEmpty()){
|
|
|
|
|
+ throw new Exception("当前料框没有出库单,不能再入库");
|
|
|
|
|
+ }
|
|
|
|
|
+ boolean isEmpty = wmRmsBoxService.clearBoxEmpty(rmsBox, clientRequest.getOperator());
|
|
|
|
|
+ if(isEmpty){
|
|
|
|
|
+ return AjaxResult.success("空料框结单完成");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(clientRequest.getFromType() == 4){
|
|
|
|
|
+ if(StringUtil.isEmpty(clientRequest.getItemCode())){
|
|
|
|
|
+ return AjaxResult.error("物料编码不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ rmsTaskInstockService.handInStock(clientRequest, getUsername());
|
|
|
|
|
+ }catch (Exception ex){
|
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
|
+ return AjaxResult.error(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return AjaxResult.success("入库请求成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询入库单信息
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping(value = "/getInstockByCode")
|
|
|
|
|
+ public AjaxResult getInstockByCode(RmsTaskInstock rmsTaskInstock)
|
|
|
|
|
+ {
|
|
|
|
|
+ rmsTaskInstock = rmsTaskInstockService.getInstockByCode(rmsTaskInstock);
|
|
|
|
|
+ return AjaxResult.success(rmsTaskInstock);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * AGV终端任务
|
|
|
|
|
+ */
|
|
|
|
|
+ @Log(title = "AGV终端任务", businessType = BusinessType.OTHER)
|
|
|
|
|
+ @PostMapping("/requestAgv")
|
|
|
|
|
+ public AjaxResult requestAgv(@RequestBody ClientRequest clientRequest)
|
|
|
|
|
+ {
|
|
|
|
|
+ try{
|
|
|
|
|
+ if(clientRequest.getFromType() == null){
|
|
|
|
|
+ return AjaxResult.error("入库类型不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+// String ipAddress = getLoginUser().getIpaddr();
|
|
|
|
|
+// rmsTaskInstockService.sendAgvTask(clientRequest, ipAddress);
|
|
|
|
|
+ }catch (Exception ex){
|
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
|
+ return AjaxResult.error(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return AjaxResult.success("AGV请求已发送");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Log(title = "基础修改", businessType = BusinessType.UPDATE)
|
|
|
|
|
+ @PostMapping("/updateRmsTaskInstock")
|
|
|
|
|
+ public AjaxResult updateRmsTaskInstock(@RequestBody RmsTaskInstock rmsTaskInstock)
|
|
|
|
|
+ {
|
|
|
|
|
+ rmsTaskInstock.setUpdateBy(getUsername());
|
|
|
|
|
+ return toAjax(rmsTaskInstockService.updateRmsTaskInstock(rmsTaskInstock));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping(value = "/selectErpStockInOrder")
|
|
|
|
|
+ public AjaxResult selectErpStockInOrder(RmsTaskInstock rmsTaskInstock) throws Exception
|
|
|
|
|
+ {
|
|
|
|
|
+ rmsTaskInstock.setCreateBy(getUsername());
|
|
|
|
|
+ RmsTaskInstock rmsTaskInstockSearch;
|
|
|
|
|
+ String erpSysOpen = sysConfigService.selectConfigByKey(UserConstants.erpSysOpen);
|
|
|
|
|
+ if(erpSysOpen.contains("3")){
|
|
|
|
|
+ // EMCS 入库单同步
|
|
|
|
|
+ rmsTaskInstockSearch = emcsTaskInstockService.selectErpStockInOrder(rmsTaskInstock);
|
|
|
|
|
+ }else if(erpSysOpen.contains("1")){
|
|
|
|
|
+ rmsTaskInstockSearch = rmsTaskInstockService.selectErpStockInOrder(rmsTaskInstock);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ throw new Exception("没有配置关联的ERP系统");
|
|
|
|
|
+ }
|
|
|
|
|
+ return AjaxResult.success(rmsTaskInstockSearch);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Log(title = "分拣修改入库单")
|
|
|
|
|
+ @PostMapping("/updateInstockForFj")
|
|
|
|
|
+ public AjaxResult updateInstockForFj(@RequestBody RmsTaskInstock rmsTaskInstock) throws Exception
|
|
|
|
|
+ {
|
|
|
|
|
+ if(UserConstants.NOT_UNIQUE.equals(rmsTaskInstockService.checkErpInstockCodeUnique(rmsTaskInstock))){
|
|
|
|
|
+ return AjaxResult.error("修改入库"+rmsTaskInstock.getErpInstockCode()+"失败,入库单编码已存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ rmsTaskInstock.setUpdateBy(getUsername());
|
|
|
|
|
+ int result = rmsTaskInstockService.updateRmsTaskInstockAndLineForFj(rmsTaskInstock);
|
|
|
|
|
+ return toAjax(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/listStock")
|
|
|
|
|
+ public TableDataInfo list(RmsTaskStockResult rmsTaskStockResult)
|
|
|
|
|
+ {
|
|
|
|
|
+ startPage();
|
|
|
|
|
+ List<RmsTaskStockResult> list = rmsTaskInstockService.selectRmsStockList(rmsTaskStockResult);
|
|
|
|
|
+ return getDataTable(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Log(title = "入库单同步ERP")
|
|
|
|
|
+ @PostMapping("/syncErpForInstock")
|
|
|
|
|
+ public AjaxResult syncErpForInstock(@RequestBody RmsTaskInstock rmsTaskInstock) throws Exception
|
|
|
|
|
+ {
|
|
|
|
|
+ rmsTaskInstock.setUpdateBy(getUsername());
|
|
|
|
|
+ String erpSysOpen = sysConfigService.selectConfigByKey(UserConstants.erpSysOpen);
|
|
|
|
|
+ int result = 0;
|
|
|
|
|
+ if(erpSysOpen.contains("3")){
|
|
|
|
|
+ //EMCS手动同步
|
|
|
|
|
+ result = emcsTaskInstockService.syncErpForInstock(rmsTaskInstock);
|
|
|
|
|
+ }else if(erpSysOpen.contains("1")){
|
|
|
|
|
+ result = rmsTaskInstockService.syncErpForInstock(rmsTaskInstock);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ throw new Exception("没有配置关联的ERP系统");
|
|
|
|
|
+ }
|
|
|
|
|
+ return toAjax(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Log(title = "入库统计分页")
|
|
|
|
|
+ @GetMapping("/listInStat")
|
|
|
|
|
+ public TableDataInfo listInStat(RmsTaskInstock rmsTaskInstock)
|
|
|
|
|
+ {
|
|
|
|
|
+ startPage();
|
|
|
|
|
+ List<RmsTaskInstock> rmsTaskInstocks = rmsTaskInstockService.selectRmsTaskInstockListSelf(rmsTaskInstock);
|
|
|
|
|
+ TableDataInfo dataTable = getDataTable(rmsTaskInstocks);
|
|
|
|
|
+ List<RmsTaskInstockStat> list = rmsTaskInstockService.convertRmsTaskInstockStatList(rmsTaskInstocks);
|
|
|
|
|
+ TableDataInfo dataTableConvert = getDataTable(list);
|
|
|
|
|
+ dataTableConvert.setTotal(dataTable.getTotal());
|
|
|
|
|
+ return dataTableConvert;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping(value = "/selectErpStockInOrderList")
|
|
|
|
|
+ public AjaxResult selectErpStockInOrderList(RmsTaskInstock rmsTaskInstock) throws Exception
|
|
|
|
|
+ {
|
|
|
|
|
+ String erpSysOpen = sysConfigService.selectConfigByKey(UserConstants.erpSysOpen);
|
|
|
|
|
+ List<RmsTaskInstock> list = new ArrayList<>();
|
|
|
|
|
+ if(erpSysOpen.contains("3")){
|
|
|
|
|
+ //EMCS采购单号获取多个入入库单
|
|
|
|
|
+ list = emcsTaskInstockService.selectErpStockInOrderList(rmsTaskInstock);
|
|
|
|
|
+ }else if(erpSysOpen.contains("1")){
|
|
|
|
|
+ list = rmsTaskInstockService.selectErpStockInOrderList(rmsTaskInstock);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ throw new Exception("没有配置关联的ERP系统");
|
|
|
|
|
+ }
|
|
|
|
|
+ return AjaxResult.success(list);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|