|
|
@@ -265,18 +265,31 @@ public class MESServiceImpl implements MESService {
|
|
|
location = baseDao.getFieldDataByCondition("ProductLocation", "pl_name", "pl_id=" + fDCSPID);
|
|
|
}
|
|
|
String fSourceBillNo = StringUtil.nvl(jsonObject3.get("FSourceBillNo"), "");
|
|
|
+ int ma_id = Integer.parseInt(StringUtil.nvl(baseDao.getFieldDataByCondition("make", "ma_id",
|
|
|
+ "ma_code='" + fSourceBillNo + "'"), "0"));
|
|
|
String fICMOBillNo = StringUtil.nvl(jsonObject3.get("FICMOBillNo"), "");
|
|
|
String fEntrySelfA0248 = StringUtil.nvl(jsonObject3.get("FEntrySelfA0248"), "");
|
|
|
String fEntrySelfA0245 = StringUtil.nvl(jsonObject3.get("FEntrySelfA0245"), "");
|
|
|
String fEntrySelfA0246 = StringUtil.nvl(jsonObject3.get("FEntrySelfA0246"), "");
|
|
|
+ String fEntrySelfA0247 = StringUtil.nvl(jsonObject3.get("FEntrySelfA0247"), "");
|
|
|
+ String fEntrySelfA0242 = StringUtil.nvl(jsonObject3.get("FEntrySelfA0242"), "");
|
|
|
sqls.add("insert into prodiodetail (pd_id,pd_piid,pd_inoutno,pd_piclass,pd_pdno,pd_ordercode,pd_prodcode," +
|
|
|
"pd_batchcode,pd_inqty,pd_nxlh,pd_purcrate,pd_notinqty,pd_orderprice,pd_ordertotal,pd_price," +
|
|
|
"pd_total,pd_whcode,pd_whname,pd_remark,pd_prodmadedate,pd_replydate,pd_location,pd_macode,pd_xb," +
|
|
|
- "pd_bz) values (PRODIODETAIL_SEQ.nextval,"+id+",'"+code+"','完工入库单',"+detno+",'"+fSourceBillNo+
|
|
|
+ "pd_bz,pd_dbds,pd_zds) values (PRODIODETAIL_SEQ.nextval,"+id+",'"+code+"','完工入库单',"+detno+",'"+fSourceBillNo+
|
|
|
"','"+map11.get("FNumber")+"','"+fBatchNo+"',"+fauxqty+",'"+fSecUnitID+"',"+fSecCoefficient+","+fSecQty+","+fAuxPlanPrice+","+fPlanAmount+","+fauxprice+"," +
|
|
|
""+famount+",'"+warehouses[0]+"','"+warehouses[1]+"','"+fnote+"',to_date('"+fEntrySelfA0248+ "'," +
|
|
|
- "'yyyy-MM-dd HH24:mi:ss'),to_date('"+fPeriodDate+"','yyyy-MM-dd HH24:mi:ss'),'"+location+"','"+fICMOBillNo+"','"+fEntrySelfA0246+"','"+fEntrySelfA0245+"')");
|
|
|
+ "'yyyy-MM-dd HH24:mi:ss'),to_date('"+fPeriodDate+"','yyyy-MM-dd HH24:mi:ss'),'"+location+"','"+fICMOBillNo+"','"+fEntrySelfA0246+"','"+fEntrySelfA0245+"',"+fEntrySelfA0247+","+fEntrySelfA0242+")");
|
|
|
detno++;
|
|
|
+ //更新已转完工数
|
|
|
+ sqls.add("update make set ma_tomadeqty=nvl((select sum(pd_inqty)-sum(case when pd_status=99 then pd_outqty else 0 end) from prodiodetail where pd_ordercode=ma_code and pd_piclass in('完工入库单','委外验收单','委外验退单')),0) where ma_id=" + ma_id);
|
|
|
+ sqls.add("update make set ma_tomadeqty=ma_madeqty where ma_id=" + ma_id + " and nvl(ma_madeqty,0)>nvl(ma_tomadeqty,0)");
|
|
|
+ //更新最大套料数
|
|
|
+ sqls.add("update make set ma_canmadeqty=nvl((select min(case when NVL(mm_havegetqty,0)-NVL(mm_scrapqty,0)>=mm_qty then ma_qty else floor(( nvl(mm_havegetqty, 0)-nvl(mm_scrapqty,0))*1.0/mm_oneuseqty )end) from makematerial where mm_maid=ma_id and nvl(mm_materialstatus,' ')=' ' and mm_oneuseqty>0 and mm_oneuseqty*ma_qty<=mm_qty+0.1 ),0) where ma_id in ("+ ma_id + ") ");
|
|
|
+ sqls.add("update make set ma_canmadeqty=ma_qty where ma_id in (" + ma_id
|
|
|
+ + ") and ma_id not in (select ma_id from make left join makematerial on ma_id=mm_maid where ma_id in (" + ma_id
|
|
|
+ + ") and nvl(mm_materialstatus,' ')=' ' and mm_oneuseqty>0 and mm_oneuseqty*ma_qty<=mm_qty+0.1)");
|
|
|
+ sqls.add("update make set ma_canmadeqty=0 where ma_id in (" + ma_id + ") and NVL(ma_canmadeqty,0)<=0");
|
|
|
}
|
|
|
baseDao.execute(sqls);
|
|
|
Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_code=?",
|
|
|
@@ -500,6 +513,7 @@ public class MESServiceImpl implements MESService {
|
|
|
Object[] warehouses2=null;
|
|
|
int detno=1;
|
|
|
int det=1;
|
|
|
+ int maid=0;
|
|
|
for (int i = 0; i <array.size(); i++) {
|
|
|
JSONObject object = JSON.parseObject(StringUtil.nvl(array.get(i), "{}"));
|
|
|
Map<Object, Object> map = JSONUtil.toMap(StringUtil.valueOf(object.get("FItemID")));
|
|
|
@@ -541,13 +555,15 @@ public class MESServiceImpl implements MESService {
|
|
|
"cd_ctid=ct_id left join Warehouse on cd_varchar50_3=wh_code", "cd_varchar50_3,wh_description",
|
|
|
"ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whcode2 + "'");
|
|
|
|
|
|
- Object lineId = object.get("lineId");
|
|
|
- Object mmdetno = baseDao.getFieldDataByCondition("MakeMaterial", "mm_detno", "mm_id in (" + lineId+")");
|
|
|
+ int lineId = Integer.parseInt(StringUtil.nvl(object.get("lineId"), "0"));
|
|
|
+ Object[] data1 = baseDao.getFieldsDataByCondition("MakeMaterial", "mm_detno,mm_maid",
|
|
|
+ "mm_id in (" + lineId + ")");
|
|
|
+ maid = Integer.parseInt(StringUtil.nvl(data1[1], "0"));
|
|
|
if(bccode!=null) {
|
|
|
sqls.add("insert into prodiodetail (pd_id,pd_piid,pd_inoutno,pd_piclass,pd_pdno,pd_prodcode," +
|
|
|
"pd_outqty,pd_whcode,pd_whname,pd_inwhcode,pd_inwhname,pd_macode,pd_madetno) " +
|
|
|
"values (PRODIODETAIL_SEQ.nextval," + bcpiid + ",'" + bccode + "','"+bcpiclass+"'," + detno + ",'" + itemNo +
|
|
|
- "'," + qty + ",'" + warehouses2[0] + "','" + warehouses2[1] + "','" + warehouses[0] + "','" + warehouses[1] + "','"+ficmoBillNo+"',"+mmdetno+")");
|
|
|
+ "'," + qty + ",'" + warehouses2[0] + "','" + warehouses2[1] + "','" + warehouses[0] + "','" + warehouses[1] + "','"+ficmoBillNo+"',"+data1[0]+")");
|
|
|
detno++;
|
|
|
}
|
|
|
int count1 = baseDao.getCount("select count(1) from MakeMaterial where mm_prodcode='" + itemNo + "' and mm_id in (" + lineId + ")");
|
|
|
@@ -576,7 +592,7 @@ public class MESServiceImpl implements MESService {
|
|
|
sqls.add("insert into prodiodetail (pd_id,pd_piid,pd_inoutno,pd_piclass,pd_pdno,pd_prodcode," +
|
|
|
"pd_outqty,pd_whcode,pd_whname,pd_ordercode,pd_orderdetno,pd_macode,pd_madetno) " +
|
|
|
"values (PRODIODETAIL_SEQ.nextval," + llpiid + ",'" + llcode + "','" + llpiclass + "'," + det + ",'" + itemNo +
|
|
|
- "'," + qty + ",'" + warehouses[0] + "','" + warehouses[1] + "','" + ficmoBillNo + "'," + mmdetno + ",'" + ficmoBillNo + "'," + mmdetno + ")");
|
|
|
+ "'," + qty + ",'" + warehouses[0] + "','" + warehouses[1] + "','" + ficmoBillNo + "'," + data1[0] + ",'" + ficmoBillNo + "'," + data1[0] + ")");
|
|
|
det++;
|
|
|
}
|
|
|
}
|
|
|
@@ -587,6 +603,8 @@ public class MESServiceImpl implements MESService {
|
|
|
sqls.add("update prodinout set pi_purpose='"+warehouses[0]+"',pi_purposename='"+warehouses[1]+"' where pi_id="+bcpiid);
|
|
|
}
|
|
|
baseDao.execute(sqls);
|
|
|
+ refreshTurnQty(maid,0);
|
|
|
+ setBackQty(String.valueOf(maid),0);
|
|
|
int count = baseDao.getCount("select count(1) from prodiodetail where pd_piid=" + llpiid);
|
|
|
if (count<=0){
|
|
|
baseDao.deleteById("prodinout","pi_id",llpiid);
|
|
|
@@ -3039,4 +3057,87 @@ public class MESServiceImpl implements MESService {
|
|
|
+ ids + ") and nvl(ma_turnstatuscode,' ')<>'TURNGET' and not exists(select 1 from makematerial where mm_maid=ma_id "
|
|
|
+ "and nvl(MM_QTY,0)-NVL(mm_havegetqty,0)-NVL(mm_totaluseqty,0)-NVL(mm_turnaddqty,0)>0 and NVL(mm_materialstatus,' ')=' ')");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private void refreshTurnQty(Integer ma_id, Integer mm_id) {
|
|
|
+ if (mm_id != null && mm_id > 0) {
|
|
|
+ // 已转领料数
|
|
|
+ baseDao.execute("update MakeMaterial set mm_totaluseqty=(select sum(nvl(pd_outqty,0)) from prodiodetail,prodinout where pd_piid=pi_id and pd_status=0 and pd_ordercode=mm_code and pd_orderdetno=mm_detno and pd_piclass in ('生产领料单', '委外领料单')) WHERE mm_maid="
|
|
|
+ + ma_id + " and mm_id=" + mm_id);
|
|
|
+ // 转补料数
|
|
|
+ baseDao.execute("update MakeMaterial set mm_turnaddqty=(select sum(nvl(pd_outqty,0)) from prodiodetail,prodinout "
|
|
|
+ + "where pd_piid=pi_id and pi_statuscode<>'DELETE' and pd_status=0 and pd_ordercode=mm_code and pd_orderdetno=mm_detno and pd_piclass in ('生产补料单', '委外补料单')) where mm_maid ="
|
|
|
+ + ma_id + " and mm_id=" + mm_id);
|
|
|
+ // 更新替代已转数
|
|
|
+ baseDao.execute("update makematerialreplace set mp_repqty=(select NVL(sum(nvl(pd_outqty,0)),0) from prodiodetail,prodinout "
|
|
|
+ + "where pd_piid=pi_id and pd_status=0 and pd_prodcode=mp_prodcode and pd_ordercode=mp_mmcode and "
|
|
|
+ + "pd_orderdetno=mp_mmdetno and pd_piclass in ('生产领料单', '委外领料单')) where mp_maid=" + ma_id + " and mp_mmid=" + mm_id);
|
|
|
+ baseDao.execute("update makematerialreplace set mp_repqty=0 where mp_maid=" + ma_id + " AND MP_REPQTY<0");
|
|
|
+ // 更新替代总已转数
|
|
|
+ baseDao.execute("update MakeMaterial set mm_repqty=NVL((select sum(NVL(mp_repqty,0)) from MakeMaterialreplace where mp_mmid=mm_id),0) where mm_maid="
|
|
|
+ + ma_id + " and mm_id=" + mm_id);
|
|
|
+ // 更新替代总已领数
|
|
|
+ baseDao.execute("update MakeMaterial set mm_haverepqty=NVL((select sum(NVL(mp_haverepqty,0)) from MakeMaterialreplace where mp_mmid=mm_id),0) where mm_maid="
|
|
|
+ + ma_id + " and mm_id=" + mm_id);
|
|
|
+ } else {
|
|
|
+ // 已转领料数
|
|
|
+ baseDao.execute("update MakeMaterial set mm_totaluseqty=(select sum(nvl(pd_outqty,0)) from prodiodetail,prodinout "
|
|
|
+ + "where pd_piid=pi_id and pd_status=0 and pd_ordercode=mm_code and pd_orderdetno=mm_detno and pd_piclass in ('生产领料单', '委外领料单')) WHERE mm_maid="
|
|
|
+ + ma_id);
|
|
|
+ // 转补料数
|
|
|
+ baseDao.execute("update MakeMaterial set mm_turnaddqty=(select sum(nvl(pd_outqty,0)) from prodiodetail,prodinout "
|
|
|
+ + "where pd_piid=pi_id and pi_statuscode<>'DELETE' and pd_status=0 and pd_ordercode=mm_code and pd_orderdetno=mm_detno and pd_piclass in ('生产补料单', '委外补料单')) where mm_maid ="
|
|
|
+ + ma_id);
|
|
|
+ // 更新替代已转数
|
|
|
+ baseDao.execute("update makematerialreplace set mp_repqty=(select NVL(sum(nvl(pd_outqty,0)),0) from prodiodetail,prodinout "
|
|
|
+ + "where pd_piid=pi_id and pd_status=0 and pd_prodcode=mp_prodcode and pd_ordercode=mp_mmcode and "
|
|
|
+ + "pd_orderdetno=mp_mmdetno and pd_piclass in ('生产领料单', '委外领料单')) where mp_maid=" + ma_id);
|
|
|
+ baseDao.execute("update makematerialreplace set mp_repqty=0 where mp_maid=" + ma_id + " AND MP_REPQTY<0");
|
|
|
+ // 更新替代总已转数
|
|
|
+ baseDao.execute("update MakeMaterial set mm_repqty=NVL((select sum(NVL(mp_repqty,0)) from MakeMaterialreplace where mp_mmid=mm_id),0) where mm_maid="
|
|
|
+ + ma_id);
|
|
|
+ // 更新替代总已领数
|
|
|
+ baseDao.execute("update MakeMaterial set mm_haverepqty=NVL((select sum(NVL(mp_haverepqty,0)) from MakeMaterialreplace where mp_mmid=mm_id),0) where mm_maid="
|
|
|
+ + ma_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setBackQty(String maidstr, Integer mm_id) {
|
|
|
+ if (mm_id != null && mm_id > 0) {
|
|
|
+ baseDao.getJdbcTemplate()
|
|
|
+ .execute(
|
|
|
+ "update makematerial set mm_backqty=(select sum(pd_inqty) from prodiodetail where pd_piclass in ('生产退料单','委外退料单') and pd_ordercode=mm_code and pd_orderdetno=mm_detno and pd_status=0) WHERE mm_maid in ("
|
|
|
+ + maidstr + ") and mm_id=" + mm_id);
|
|
|
+ baseDao.getJdbcTemplate()
|
|
|
+ .execute(
|
|
|
+ "update MakeMaterialreplace set mp_backqty=(select sum(pd_inqty) from prodiodetail where pd_piclass in ('生产退料单','委外退料单') and pd_ordercode=mp_mmcode and pd_orderdetno=mp_mmdetno and pd_prodcode=mp_prodcode and pd_status=0) WHERE mp_maid in ("
|
|
|
+ + maidstr + ") and mp_mmid=" + mm_id);
|
|
|
+ baseDao.getJdbcTemplate()
|
|
|
+ .execute(
|
|
|
+ "update makematerial set mm_turnscrapqty=(select sum(md_qty) from makescrapdetail,makescrap where ms_id=md_msid and ms_statuscode<>'AUDITED' and md_mmcode=mm_code and md_mmdetno=mm_detno ) WHERE mm_maid in ("
|
|
|
+ + maidstr + ") and mm_id=" + mm_id);
|
|
|
+ baseDao.getJdbcTemplate()
|
|
|
+ .execute(
|
|
|
+ "update MakeMaterialreplace set mp_turnscrapqty=(select sum(md_qty) from makescrapdetail,makescrap where ms_id=md_msid and ms_statuscode<>'AUDITED' and md_mmcode=mp_mmcode and md_mmdetno=mp_mmdetno ) WHERE mp_maid in ("
|
|
|
+ + maidstr + ") and mp_mmid=" + mm_id);
|
|
|
+ } else {
|
|
|
+ baseDao.getJdbcTemplate()
|
|
|
+ .execute(
|
|
|
+ "update makematerial set mm_backqty=(select sum(pd_inqty) from prodiodetail where pd_piclass in ('生产退料单','委外退料单') and pd_ordercode=mm_code and pd_orderdetno=mm_detno and pd_status=0) WHERE mm_maid in ("
|
|
|
+ + maidstr + ")");
|
|
|
+ baseDao.getJdbcTemplate()
|
|
|
+ .execute(
|
|
|
+ "update MakeMaterialreplace set mp_backqty=(select sum(pd_inqty) from prodiodetail where pd_piclass in ('生产退料单','委外退料单') and pd_ordercode=mp_mmcode and pd_orderdetno=mp_mmdetno and pd_prodcode=mp_prodcode and pd_status=0) WHERE mp_maid in ("
|
|
|
+ + maidstr + ")");
|
|
|
+ baseDao.getJdbcTemplate()
|
|
|
+ .execute(
|
|
|
+ "update makematerial set mm_turnscrapqty=(select sum(md_qty) from makescrapdetail,makescrap where ms_id=md_msid and ms_statuscode<>'AUDITED' and md_mmcode=mm_code and md_mmdetno=mm_detno ) WHERE mm_maid in ("
|
|
|
+ + maidstr + ")");
|
|
|
+ baseDao.getJdbcTemplate()
|
|
|
+ .execute(
|
|
|
+ "update MakeMaterialreplace set mp_turnscrapqty=(select sum(md_qty) from makescrapdetail,makescrap where ms_id=md_msid and ms_statuscode<>'AUDITED' and md_mmcode=mp_mmcode and md_mmdetno=mp_mmdetno ) WHERE mp_maid in ("
|
|
|
+ + maidstr + ")");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|