Commit 5beaa107 LN

合并工单功能

1 个父辈 a9f87048
......@@ -135,6 +135,17 @@ public class OutInfo extends BaseMongoBean {
@Transient
private Map<String, OutItem> outItemMap = new HashMap<>();
public Set<String> getMergehSerials() {
return mergehSerials;
}
public void setMergehSerials(Set<String> mergehSerials) {
this.mergehSerials = mergehSerials;
}
private Set<String> mergehSerials=new HashSet<>();
public String getAction() {
return action;
}
......@@ -387,6 +398,7 @@ public class OutInfo extends BaseMongoBean {
return sendStatus == StorageConstants.SEND_STATUS.SEND_LESS;
}
/**
* 是否是需要优先执行的
*/
......
......@@ -27,6 +27,7 @@ import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.management.remote.rmi._RMIConnection_Stub;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
......@@ -1100,12 +1101,16 @@ public class OutInfoCache {
return o1.getSlotlocation() - o2.getSlotlocation();
}
});
//合并出库的工单列表
List<OutInfo> mergeOutList= getMergeOutList(outInfo);
List<OutItem> currOutItems=new ArrayList<>();
Date itemUpdateTime = new Date();
for (OutItem outItem : itemList) {
outItem.setUpdateDate(itemUpdateTime);
List<DataLog> itemTasks = new ArrayList<>();
//合并工单已出的多余数量
Integer mergeOutQty=getMergeOutQty(mergeOutList,currOutItems,outItem);
//首盘料需求单
if(outItem.isFirstReelAction()){
itemTasks = checkOutFirst(outItem, outInfoExecuted);
......@@ -1116,9 +1121,9 @@ public class OutInfoCache {
}else if(outItem.isUrgentAction()){
itemTasks = checkOutUrgent(outItem);
}else if(outItem.isPnAction()){
itemTasks = checkOutPnItem(outItem);
itemTasks = checkOutPnItem(outItem,mergeOutQty);
}
currOutItems.add(outItem);
if(itemTasks != null && !itemTasks.isEmpty()){
for (DataLog itemTask : itemTasks) {
tasks.add(itemTask);
......@@ -1180,6 +1185,56 @@ public class OutInfoCache {
return ResultBean.newOkResult(msg,"ok");
}
private List<OutInfo> getMergeOutList(OutInfo excuteOut){
List<OutInfo> outInfos=new ArrayList<>();
if(excuteOut.getMergehSerials().size()>0){
for (String hs :
excuteOut.getMergehSerials()) {
if(hs.trim().equals(excuteOut.gethSerial())){
continue;
}
OutInfo outInfo=getOutInfoFromCache(hs);
if(outInfo==null){
outInfo=outInfoDao.findByHSerial(hs);
}
outInfos.add(outInfo);
}
}
return outInfos;
}
private Integer getMergeOutQty(List<OutInfo> mergeOutList, List<OutItem> currOutItems,OutItem currOutItem) {
Integer surplusQty = 0;
Integer outQty = 0;
Integer qty = 0;
for (OutInfo mergeOut : mergeOutList
) {
if (mergeOut.isNew()) {
continue;
}
List<OutItem> outItems = mergeOut.getOutItems();
for (OutItem outItem :
outItems) {
if (outItem.getPn().equals(currOutItem.getPn())) {
outQty += outItem.getOutQty();
qty += outItem.getQty();
}
}
}
for (OutItem outItem :
currOutItems) {
if (outItem.getPn().equals(currOutItem.getPn())) {
outQty += outItem.getOutQty();
qty += outItem.getQty();
}
}
int iSurplusQ = outQty - qty;
if (iSurplusQ > 0) {
outQty = iSurplusQ;
}
return outQty;
}
/**
* 对补料任务进行出库排序
......@@ -1216,15 +1271,24 @@ public class OutInfoCache {
}
private List<DataLog> checkOutPnItem(OutItem outItem){
private List<DataLog> checkOutPnItem(OutItem outItem,Integer mergeOutQty){
List<DataLog> tasks = new ArrayList<>();
//紧急料,直接出库
List<StoragePos> posList = storagePosDao.findBindList(outItem.gethSerial(),outItem.getId());
int outQty = outItem.getOutQty() + mergeOutQty;
for (StoragePos pos : posList) {
DataLog task = newTask(outItem, pos);
task = InquiryShelfBean.addUnlimitLoc(task, outItem);
task = dataLogDao.save(task);
tasks.add(task);
if(outQty > outItem.getQty()){
log.info("需求单["+outItem.gethSerial()+"]PN["+outItem.getPn()+"]已发数量"+outQty+"满足需求"+outItem.getQty()+",不需要出库");
}else{
DataLog task = newTask(outItem, pos);
task = InquiryShelfBean.addUnlimitLoc(task, outItem);
task = dataLogDao.save(task);
tasks.add(task);
outQty = outQty + pos.getBarcode().getAmount();
}
}
return tasks;
}
......
......@@ -23,6 +23,8 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -941,5 +943,65 @@ public class QisdaApiController extends BaseController {
}
}
@RequestMapping("/mergerOut")
@ResponseBody
public String mergerOut(HttpServletRequest request){
String param= request.getParameter("hSerials");
String[] hSerials =param.split(",");
String line="";
Set<String> hSerialsSet=new HashSet<>();
List<OutInfo> outInfos=new ArrayList<>();
for (String hSerial :hSerials
) {
hSerial=hSerial.trim();
if(hSerial.isEmpty()){
continue;
}
OutInfo outInfo = outInfoDao.findByHSerial(hSerial);
if(outInfo==null){
return ResultBean.newErrorResult(1001, "未找到需求单号["+hSerial+"]",false).getMsg();
}
if(StringUtils.isEmpty(outInfo.getLine())){
return ResultBean.newErrorResult(1001, "需求单号["+hSerial+"]未设置线别,无法合并出库",false).getMsg();
}
if(!outInfo.isNew()) {
String msg = "已开始发料";
if (outInfo.isClosed()) {
msg = "已关闭";
} else if (outInfo.isExecuting()) {
msg = "在执行中";
}
return ResultBean.newErrorResult(1001, "需求单号[" + hSerial + "]" + msg + ",无法合并出库", false).getMsg();
}
if(line.isEmpty()){
line=outInfo.getLine();
}else if(!line.equals(outInfo.getLine())){
return ResultBean.newErrorResult(1001, "线别不一致,无法合并出库",false).getMsg();
}
if(outInfo.getMergehSerials().size()>0){
String msg="";
for (String h :
outInfo.getMergehSerials()) {
if(h.equals(hSerial)){
continue;
}else{
msg+="\r\n"+h;
}
}
return ResultBean.newErrorResult(1001, "需求单["+hSerial+"]已与以下需求单设置合并出库:"+outInfo.getMergehSerials().toString(),false).getMsg();
}
hSerialsSet.add(hSerial);
outInfos.add(outInfo);
}
for (OutInfo outInfo:outInfos){
outInfo.setMergehSerials(hSerialsSet);
outInfo=outInfoDao.save(outInfo);
outInfoCache.addOutInfo(outInfo);
}
log.info("成功设置合并出库:"+param);
ResultBean resultBean = ResultBean.newOkResult("合并出库成功","");
return resultBean.getMsg();
}
}
......@@ -32,6 +32,11 @@
<div class="caption">
<i class="fa fa-list-alt"></i>
</div>
<div class="actions">
<a onclick="executeMergeOut()" class="btn btn-default btn-sm">
<i class="fa fa-sign-out"></i> <fmt:message key="合并出库"/> </a>
</div>
</div>
<div class="portlet-body">
<form id="searchCriteria" class="form-horizontal form-bordered" action="${ctx}/qisda/outInfoSearch.html" method="post">
......@@ -93,6 +98,11 @@
<c:if test="${outInfo.closed}">
<c:set var="closedClass" value="closed"/>
</c:if>
<display:column titleKey="选择" sortable="true" sortProperty="hSerial" media="html">
<c:if test="${empty outInfo.mergehSerials && not empty outInfo.line && (!outInfo.executing && !outInfo.sendEnd && !outInfo.closed) }">
<input type="checkbox" name="checkbox2" value="${outInfo.hSerial} "/>
</c:if>
</display:column>
<display:column titleKey="需求单号" sortable="true" sortProperty="hSerial" media="html">
<a href="#" onclick="showDetail('${outInfo.hSerial}')">${outInfo.hSerial}</a>
</display:column>
......@@ -139,7 +149,9 @@
<display:column titleKey="需求时间" sortable="true" sortProperty="taskNeedOutDate">
<fmt:formatDate value="${outInfo.taskNeedOutDate}" pattern="yyyy-MM-dd HH:mm"/>
</display:column>
<%-- <display:column titleKey="状态" sortable="true" sortProperty="sendStatus" class="${closedClass}">--%>
<%-- ${ outInfo.sendStatus }--%>
<%-- </display:column>--%>
<display:column titleKey="checkOut.operate" media="html" sortProperty="sendStatus" sortable="true">
<c:if test="${!outInfo.executing && stopJob}">
<c:if test="${(outInfo.urgentAction && outInfo.taskFinishNum != outInfo.taskNum) || (!outInfo.sendEnd && !outInfo.closed)}">
......@@ -148,11 +160,6 @@
</button>
</c:if>
</c:if>
<%--<c:if test="${!outInfo.sendEnd && !outInfo.closed && !outInfo.executing}">--%>
<%--<button class="btn yellow" id="btn${outInfo.hSerial}" onclick="executeOut('${outInfo.hSerial}')">--%>
<%--<i class="fa fa-sign-out"></i><fmt:message key="button.checkout"/>--%>
<%--</button>--%>
<%--</c:if>--%>
</display:column>
</display:table>
......@@ -171,6 +178,9 @@
<h4 class="modal-title" style="margin:10px;">
<span id="detailTitle">&nbsp</span>
</h4>
<h7 class="modal-title" style="margin:10px;">
<span id="detailMergeInfo">&nbsp</span>
</h7>
<input type="text" class="form-control filterInput" id="filterStr"/>
</div>
<div class="modal-body">
......@@ -267,10 +277,17 @@
showDetail = function(hSerial){
$(".filterInput").val("");
$("#detailTitle").html(hSerial);
$('#detailMergeInfo').html("");
$("#theItems").html("");
$.post("${ctx}/service/store/qisda/outDetail", {hSerial: hSerial}, function (outInfo) {
$("#detailTitle").html("需求单: "+ outInfo.hSerial + " 工单: " + outInfo.so + " ["+outInfo.action+"]");
if(outInfo.mergehSerials+""==""){
$('#detailMergeInfo').hidden=true;
}else{
$('#detailMergeInfo').hidden=false;
$('#detailMergeInfo').html(" 合并出库工单:"+outInfo.mergehSerials);
}
var data = outInfo.outItems;
var table = $('#itemsTable').DataTable();
table.clear();
......@@ -324,6 +341,29 @@
});
}
executeMergeOut=function(){
var hSerials="";
var msgH="";
var i=0;
$("input[name='checkbox2']:checked").each(function(){
// alert("checkbox2组选中项的值:"+$(this).val());//遍历选中项的值
hSerials+=$(this).val()+",";
msgH+="\r\n"+$(this).val();
i++;
});
if(i>=2){
if(confirm("合并出库后不能取消,确定设置如下需求单为合并出库?"+msgH.toString()+"")){
// var hSerials=$("input[name='checkbox2']:checked");
$.post("${ctx}/rest/api/dcs/mergerOut", {hSerials: hSerials}, function (data) {
alert(data);
});
}
}else{
alert("请选择至少两个需求单");
}
}
closeOut = function(hSerial){
Lobibox.confirm({
title: "确认",
......
......@@ -239,7 +239,7 @@
<div class="page-footer-inner">
2016&copy; <a href="">SMD BOX</a>
</div>
<span class="right" style="color: #a3a3a3;">Version: 1.6.2910</span>
<span class="right" style="color: #a3a3a3;">Version: 1.8.1110</span>
<div class="scroll-to-top">
<i class="icon-arrow-up"></i>
</div>
......
......@@ -24,6 +24,7 @@
<datasource-mapping>
<factory-entry name="ApplicationEntityManager" />
</datasource-mapping>
<naming-strategy-map />
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" />
</configuration>
</facet>
......@@ -31,7 +32,7 @@
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!