优化
This commit is contained in:
@@ -10,6 +10,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.utils.SecurityUtils;
|
||||
import org.nl.wms.pcs.Enum.ProcStatusEnum;
|
||||
import org.nl.wms.pcs.Enum.ReceiveStatusEnum;
|
||||
import org.nl.wms.st.core.service.StorPublicService;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -225,6 +227,10 @@ public class InbillServiceImpl {
|
||||
WQLObject dtl_table = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl");
|
||||
WQLObject dis_table = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
||||
WQLObject bucket_table = WQLObject.getWQLObject("md_pb_bucketrecord");
|
||||
WQLObject reMstTab = WQLObject.getWQLObject("PCS_RC_ReceiveMst"); //到货通知单主表
|
||||
WQLObject reDtlTab = WQLObject.getWQLObject("PCS_RC_ReceiveDtl"); //到货通知单明细表
|
||||
WQLObject procTab = WQLObject.getWQLObject("PCS_IF_PurchaseOrderProc"); //采购订单接口处理表
|
||||
WQLObject dtlTab = WQLObject.getWQLObject("QL_TEST_InspectionSheetDtl"); //质检单明细表
|
||||
String iostorinv_id = from.getString("iostorinv_id");
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
@@ -280,11 +286,81 @@ public class InbillServiceImpl {
|
||||
bucket_table.update(bucket_map, "storagevehicle_code = '" + dis_row.getString("storagevehicle_code") + "' AND status = '02'");
|
||||
|
||||
//如果单据为原辅料入库,且为寄样合格,回写到货通知单
|
||||
|
||||
}
|
||||
mst_jo.put("bill_status", "99");
|
||||
mst_jo.put("confirm_optid", currentUserId);
|
||||
mst_jo.put("confirm_optname", nickName);
|
||||
mst_jo.put("confirm_time", now);
|
||||
if("000101".equals(bill_type)){
|
||||
//查询
|
||||
dtl_rows = dtl_table.query("iostorinv_id = '" + iostorinv_id + "' AND bill_status = '99'").getResultJSONArray(0);
|
||||
|
||||
for(int i=0; i<dtl_rows.size();i++){
|
||||
boolean flag = false;
|
||||
JSONObject jo = dtl_rows.getJSONObject(i);
|
||||
String quality_scode = jo.getString("quality_scode");
|
||||
if("01".equals(quality_scode)){//合格
|
||||
flag = true;
|
||||
}else if("00".equals(quality_scode)){//待检品
|
||||
String material_id = jo.getString("material_id");
|
||||
String pcsn = jo.getString("pcsn");
|
||||
JSONObject dtl = dtlTab.query("bill_status='99' and material_id='"+material_id+"' and pcsn='"+pcsn+"' and result='01'").uniqueResult(0);
|
||||
if(dtl!=null){
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(flag){
|
||||
JSONObject jsonReDtl = reDtlTab.query("receivedtl_id = '" + jo.getString("source_billdtl_id") + "'").uniqueResult(0);
|
||||
if(jsonReDtl!=null){
|
||||
// 如果是合格或者是放行就存入 入库数
|
||||
jsonReDtl.put("instor_qty", jo.getDoubleValue("real_qty")+jsonReDtl.getDouble("instor_qty"));
|
||||
//判断到货明细表中的数量与到货入库数是否相等,相同就完成,不相等就到货中
|
||||
if (jsonReDtl.getDoubleValue("receive_qty") <= jsonReDtl.getDoubleValue("instor_qty")) {
|
||||
jsonReDtl.put("status", ReceiveStatusEnum.AFFIRM.getCode());
|
||||
} else {
|
||||
jsonReDtl.put("status", ReceiveStatusEnum.ARRIVAL_NOTICE.getCode());
|
||||
}
|
||||
reDtlTab.update(jsonReDtl);
|
||||
}
|
||||
|
||||
/*
|
||||
* 判断到货明细单中的状态是否完成,全部完成则更新到货通知单主表完成
|
||||
*/
|
||||
JSONArray reDtlArr = reDtlTab.query("receive_id = '" + jsonReDtl.getString("receive_id") + "'").getResultJSONArray(0);
|
||||
int flag2 = 0;
|
||||
for (int j = 0; j < reDtlArr.size(); j++) {
|
||||
JSONObject json1 = reDtlArr.getJSONObject(j);
|
||||
if (StrUtil.equals(json1.getString("status"), ReceiveStatusEnum.AFFIRM.getCode())) {
|
||||
flag2 = flag2 + 1;
|
||||
}
|
||||
}
|
||||
JSONObject jsonReMst = reMstTab.query("receive_id = '" + jsonReDtl.getString("receive_id") + "'").uniqueResult(0);
|
||||
if (reDtlArr.size() == flag2) {
|
||||
jsonReMst.put("status", ReceiveStatusEnum.AFFIRM.getCode());
|
||||
jsonReMst.put("confirm_optid", currentUserId);
|
||||
jsonReMst.put("confirm_optname", nickName);
|
||||
jsonReMst.put("confirm_time", now);
|
||||
reMstTab.update(jsonReMst);
|
||||
}
|
||||
/*
|
||||
* 如果到货单主表状态为确认,则需要更新采购订单接口处理表
|
||||
*/
|
||||
if (StrUtil.equals(jsonReMst.getString("status"), ReceiveStatusEnum.AFFIRM.getCode())) {
|
||||
JSONObject jsonProc = procTab.query("id = '" + jsonReDtl.getString("source_billdtl_id") + "'").uniqueResult(0);
|
||||
// 到货数量 = 订单数量,为完成,否则为采购中
|
||||
if ((jsonReDtl.getDoubleValue("instor_qty") >= jsonProc.getDoubleValue("qty")) && (StrUtil.equals(jsonReDtl.getString("status"), "99"))) {
|
||||
jsonProc.put("proc_status", ProcStatusEnum.FULFILL.getCode());
|
||||
} else {
|
||||
jsonProc.put("proc_status", ProcStatusEnum.BUYING_CENTER.getCode());
|
||||
}
|
||||
procTab.update(jsonProc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//更新主表状态为99
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInv").update(mst_jo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user