Commit 073e364c sunke

手动入库

1 个父辈 02bfb2a9
package com.myproject.webapp.controller.storage;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.myproject.bean.CodeBean;
import com.myproject.bean.qisda.ResultBean;
import com.myproject.bean.update.Barcode;
import com.myproject.bean.update.DataLog;
import com.myproject.bean.update.Storage;
import com.myproject.bean.update.StoragePos;
import com.myproject.dao.mongo.IDataLogDao;
import com.myproject.exception.ValidateException;
import com.myproject.manager.IBarcodeManager;
import com.myproject.manager.IStoragePosManager;
import com.myproject.util.StorageConstants;
import com.myproject.webapp.controller.webService.DataCache;
import com.myproject.webapp.controller.webService.ITaskService;
import com.myproject.webapp.controller.webService.StorageDataController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* 挚锦料架
*/
@Controller
public class ManualInOutController extends BaseController {
@Autowired
private DataCache dataCache;
@Autowired
private ITaskService taskService;
@Autowired
protected IStoragePosManager storagePosManager;
@Autowired
protected IBarcodeManager barcodeManager;
@Autowired
private IDataLogDao dataLogDao;
@RequestMapping("/storage/manualInOut")
public String manualInOut(HttpServletRequest request){
return "storage/manualInOut";
}
@RequestMapping(value = "/service/store/manual/putIn")
@ResponseBody
public ResultBean menuPutIn(HttpServletRequest request) {
String codeStr = request.getParameter("code");
String posName = request.getParameter("pos");
log.info("手动入库["+codeStr+"]到["+posName+"]");
StoragePos pos = storagePosManager.getByPosName(posName);
if(pos != null){
try {
if(pos.getBarcode() != null){
return ResultBean.newErrorResult(-3,"库位["+posName+"]中已有物料["+pos.getBarcode().getBarcode()+"]");
}
Barcode barcode = dataCache.resolveOneValideBarcode("=7x8="+codeStr);
StoragePos inPos = storagePosManager.getByBarcode(barcode.getBarcode());
if(inPos != null){
return ResultBean.newErrorResult(-3,"条码["+barcode.getBarcode()+"]已在库位["+inPos.getPosName()+"]中");
}
String opUser = StorageDataController.getLoginUsername();
taskService.addTaskToFinished(pos,barcode, opUser + "-manual");
String nextPosName = getNextPosName(posName);
return ResultBean.newOkResult("入库到["+posName+"]成功",nextPosName);
} catch (ValidateException e) {
String msg = "条码["+ codeStr +"]解析失败:" + e.getMessage();
log.info(msg);
return ResultBean.newErrorResult(-1,msg);
}catch (Exception e){
log.error("手动入库出错:",e);
return ResultBean.newErrorResult(-2,"入库出错:"+e.getMessage());
}
}else{
return ResultBean.newErrorResult(-3,"未找到库位["+posName+"]");
}
}
/**
* 库位号格式:
例:05AA03040102
05:表示料仓编号,01-08
AA:存储机构A面或B面,AA或者BB
03:表示抽屉在第几行
04:表示抽屉在第几列
01:表示在抽屉中的第几行
02:表示在抽屉中的第几列
* @param posName
*/
private String getNextPosName(String posName){
int length = posName.length();
//格子的第几行
String latticeRow = posName.substring(length -4, length -2);
//格子的第几列
String latticeColumn = posName.substring(length -2);
int nextRow = Integer.valueOf(latticeRow);
int nextColumn = Integer.valueOf(latticeColumn) + 1;
if(nextColumn >20){
nextColumn = 1;
nextRow = nextRow + 1;
}
String nextPosName = posName.substring(0,length -4) + String.format("%02d", nextRow) + String.format("%02d", nextColumn);
StoragePos nextPos =storagePosManager.getByPosName(nextPosName);
if(nextPos != null){
return nextPos.getPosName();
}
return "";
}
}
......@@ -646,20 +646,20 @@ public class StorageDataController extends BaseController {
if(pos != null){
Storage storage = dataCache.getStorageById(pos.getStorageId());
if(!storage.isPackage()){
//不是包装仓,如果所在料仓有出库任务,暂停入库
Collection<DataLog> tasks = taskService.getQueueTasks();
for (DataLog task : tasks) {
if(task.isCheckOutTask() && task.getStorageId().equals(pos.getStorageId())){
errorMsg = "库位["+ pos.getPosName() + "]所在料仓有出库任务,暂停入库";
lineMsg = errorMsg;
resultMap.put("result","99");
resultMap.put("msg",errorMsg);
return resultMap;
}
}
}
// Storage storage = dataCache.getStorageById(pos.getStorageId());
// if(!storage.isPackage()){
// //不是包装仓,如果所在料仓有出库任务,暂停入库
// Collection<DataLog> tasks = taskService.getQueueTasks();
// for (DataLog task : tasks) {
// if(task.isCheckOutTask() && task.getStorageId().equals(pos.getStorageId())){
// errorMsg = "库位["+ pos.getPosName() + "]所在料仓有出库任务,暂停入库";
// lineMsg = errorMsg;
// resultMap.put("result","99");
// resultMap.put("msg",errorMsg);
// return resultMap;
// }
// }
// }
Storage theStorage = dataCache.getStorageById(pos.getStorageId());
......
<%@ page import="com.myproject.util.StorageConstants" %>
<%@ include file="/common/taglibs.jsp" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<style type="text/css">
.box{
margin-top: 10px;
}
.alert{
padding:8px;
}
.partnumber-box{
height: 100px;text-align: center;
padding-top:35px;
margin-bottom:10px;
font-size: 16px;
vertical-align: middle;
word-wrap:break-word ;
cursor: pointer;
}
.table-scrollable{
overflow-y: auto;
}
</style>
<link href="${ctx}/scripts/lobibox/css/lobibox.min.css?id=2" rel="stylesheet" type="text/css"/>
<div class="row" id="codeBox">
<div class="col-md-6 col-sm-6">
<input type="text" class="form-control" id="scan-code"/>
</div>
<div class="col-md-6 col-sm-6">
<div class="alert alert-success" id="msg">&nbsp;
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-sm-12">
<!-- BEGIN EXAMPLE TABLE PORTLET-->
<div class="portlet box blue">
<div class="portlet-title">
<div class="caption">
手动入库到 <input type="text" class="form-control" id="posName"/>
</div>
<div class="actions">
</div>
</div>
<div class="portlet-body">
<div class="table-scrollable" style="height:400px;">
<table class="table table-striped table-hover table-bordered no-footer" role="grid" aria-describedby="sample_editable_1_info">
<thead>
<tr role="row">
<th><fmt:message key="barcode.barcode"/></th>
<th><fmt:message key="barcode.partNumber"/></th>
<th><fmt:message key="checkOut.pos"/></th>
<th><fmt:message key="dataLog.type"/></th>
<th><fmt:message key="dataLog.status"/></th>
<th><fmt:message key="dataLog.date"/></th>
</tr>
</thead>
<tbody class="dataTable">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tbody>
</table>
</div>
</div>
</div>
<!-- END EXAMPLE TABLE PORTLET-->
</div>
</div>
<fmt:message key="op.1" var="op.1"/>
<fmt:message key="op.2" var="op.2"/>
<fmt:message key="inOutList.in" var="in_label"/>
<fmt:message key="inOutList.out" var="out_label"/>
<fmt:message key="op.status.wait" var="op_status_wait"/>
<fmt:message key="op.status.executing" var="op_status_executing"/>
<fmt:message key="op.status.pause" var="op_status_pause"/>
<fmt:message key="op.status.finished" var="op_status_finished"/>
<fmt:message key="op.status.cancel" var="op_status_cancel"/>
<fmt:message key="op.status.end" var="op_status_end"/>
<c:set var="scripts" scope="request">
<script type="text/javascript">
function showMsg(msg){
if(msg == ""){
$("#msg").attr("class","");
$("#msg").text("");
}else{
var error = true;
if(msg.indexOf("OK") == 0){
error = false;
msg = msg.substr(2);
}
if(msg.indexOf("0") == 0){
error = false;
msg = msg.substr(1);
}
if(msg.indexOf("x") == 0){
msg = msg.substr(1);
}
if(error){
$("#msg").attr("class","alert alert-danger");
}else{
$("#msg").attr("class","alert alert-success");
}
$("#msg").text(msg);
}
}
$("#scan-code").change(function () {
var codeValue = $(this).val();
$(this).val("");
showMsg("");
var posName = $("#posName").val();
$(this).attr("placeholder", codeValue);
$.post("${ctx}/service/store/manual/putIn", {pos: posName, code: codeValue}, function (data) {
if(data.code == 0){
$("#posName").val(data.data);
showMsg("OK"+data.msg);
}else{
showMsg(data.msg);
}
});
});
setInterval(function(){
//$("#scan-code").focus();
}, 1000);
function updateTasks(cid,seconds){
//任务列表
$.post("${ctx}/service/store/tasks", {cid: cid, seconds:seconds}, function (data) {
$(".dataTable").html("");
for(var item in data){
var taskId = data[item].id;
var partNumber = data[item].partNumber;
var barcode = data[item].barcode;
var posStr = data[item].posStr;
var typeStr = "${in_label}";
if(data[item].type == 2){//出库
typeStr = "${out_label}";
}
var statusStr = "";
if(data[item].cancel){
statusStr ="${op_status_cancel}";
} else if(data[item].executing){
statusStr ="${op_status_executing}";
}else if(data[item].finished){
statusStr ="${op_status_finished}";
}else if(data[item].wait){
statusStr ="${op_status_wait}";
}else if(data[item].end){
statusStr ="${op_status_end}";
}
var dateStr = data[item].updateDateStr;
var tdStr =
"<td>"+barcode+"</td>"+
"<td>"+partNumber+"</td>"+
"<td>"+posStr+"</td>"+
"<td>"+typeStr+"</td>"+
"<td><span class='label label-sm label-"+data[item].status.toLowerCase()+"'>"+statusStr+"</span></td>"+
"<td>"+dateStr+"</td>";
var trStr = "<tr>" + tdStr+ "</tr>";
$(".dataTable").append(trStr);
}
});
}
//updateTasks('${show}',-10*60);
setInterval(function(){
updateTasks('',-10*60);
}, 1000);
waitting = function(){
Metronic.blockUI({
iconOnly: true,
overlayColor: '#4b8df8'
});
window.setTimeout(function() {
Metronic.unblockUI();
}, 1500);
}
</script>
</c:set>
\ No newline at end of file
......@@ -25,6 +25,8 @@
<i class="fa fa-list-alt"></i><fmt:message key="storage.search.subtitle"/>
</div>
<div class="actions">
<a href="manualInOut.html" class="btn btn-default btn-sm">
<i class="fa fa-building"></i> <fmt:message key="手动入库"/> </a>
<a href="storagePosManage.html" class="btn btn-default btn-sm">
<i class="fa fa-building"></i> <fmt:message key="库位管理"/> </a>
<a href="storageUpdate.html" class="btn btn-default btn-sm">
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!