|
|
@@ -444,6 +444,14 @@ public class MESServiceImpl implements MESService {
|
|
|
Object co = baseDao.getFieldDataByCondition("MakeScrap", "ms_code", "ms_class='" + msclass + "' and ms_mescode='" + fSelBillNo + "'");
|
|
|
return ApiResponse.failRsp("10024",requestId,"MES单号:"+fSelBillNo+"已存在,请在ERP查看"+msclass+",单据编号:"+co);
|
|
|
}
|
|
|
+ //临时逻辑 工单结案直接返回成功
|
|
|
+ if (baseDao.isDBSetting("MakeScrap","overSuccess")) {
|
|
|
+ int condition = baseDao.getCountByCondition("make", "ma_statuscode='FINISH' and ma_code='" + prodNo + "'");
|
|
|
+ if (condition > 0) {
|
|
|
+ return ApiResponse.successRsp("0", requestId, "工单【" + prodNo + "】已结案,请在ERP查看!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
id = baseDao.getSeqId("MAKESCRAP_SEQ");
|
|
|
code = baseDao.sGetMaxNumber(caller, 2);
|
|
|
String fdateTime = StringUtil.nvl(jsonObject.get("FdateTime"), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
@@ -476,10 +484,19 @@ public class MESServiceImpl implements MESService {
|
|
|
if ("".equals(itemNo)){
|
|
|
return ApiResponse.failRsp("10024",requestId,"物料不能为空!");
|
|
|
}
|
|
|
- String qty = StringUtil.nvl(object.get("qty"), "");
|
|
|
- if ("".equals(qty)){
|
|
|
+ double qty = Double.parseDouble(StringUtil.nvl(object.get("qty"), "0"));
|
|
|
+ if (qty==0){
|
|
|
return ApiResponse.failRsp("10025",requestId,"报废数量不能为空!");
|
|
|
}
|
|
|
+ //临时逻辑 重新计算报废数量
|
|
|
+ int coun = baseDao.getCountByCondition("make", "ma_code='" + prodNo + "' and to_char(ma_date,'yyyyMM')<'202212'");
|
|
|
+ if (baseDao.isDBSetting("MakeScrap","overQtySuccess")&&coun>0) {
|
|
|
+ qty = Double.parseDouble(StringUtil.nvl(baseDao.getFieldDataByCondition("makematerial left join make on mm_maid=ma_id", "nvl(mm_havegetqty,0)-nvl(mm_returnmqty,0)+nvl(mm_addqty,0)+nvl(mm_scrapqty,0)-nvl(mm_oneuseqty,0)*nvl(ma_madeqty,0)", "mm_id=" + lineId), "0"));
|
|
|
+ /*if (mmqty < qty) {
|
|
|
+ qty = mmqty;
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+
|
|
|
String reason = StringUtil.nvl(object.get("reason"), "");
|
|
|
if ("".equals(reason)){
|
|
|
return ApiResponse.failRsp("10026",requestId,"报废原因不能为空!");
|
|
|
@@ -495,9 +512,14 @@ public class MESServiceImpl implements MESService {
|
|
|
|
|
|
String allScrapQty = StringUtil.nvl(object.get("AllScrapQty"), "0");
|
|
|
String remark = StringUtil.nvl(object.get("remark"), "");
|
|
|
- sqls.add("insert into MakeScrapdetail (md_id,md_msid,md_detno,md_mmid,md_mmcode,md_mmdetno,md_prodcode,md_qty,md_reason,md_department,md_departmentname,md_allscrapqty,md_remark) values " +
|
|
|
- "(MAKESCRAPDETAIL_SEQ.nextval,"+id+","+detno+","+lineId+",'"+prodNo+"',"+mmdetno+",'"+itemNo+ "',"+qty+",'"+reason+"','"+fDeptID+"','"+fDept+"',"+allScrapQty+",'"+remark+"')");
|
|
|
- detno++;
|
|
|
+ if (qty>0) {
|
|
|
+ sqls.add("insert into MakeScrapdetail (md_id,md_msid,md_detno,md_mmid,md_mmcode,md_mmdetno,md_prodcode,md_qty,md_reason,md_department,md_departmentname,md_allscrapqty,md_remark,md_status,md_code) values " +
|
|
|
+ "(MAKESCRAPDETAIL_SEQ.nextval," + id + "," + detno + "," + lineId + ",'" + prodNo + "'," + mmdetno + ",'" + itemNo + "'," + qty + ",'" + reason + "','" + fDeptID + "','" + fDept + "'," + allScrapQty + ",'" + remark + "',0,'"+code+"')");
|
|
|
+ detno++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (detno==1) {
|
|
|
+ return ApiResponse.failRsp("10030",requestId,"没有可报废的用料!");
|
|
|
}
|
|
|
baseDao.execute(sqls);
|
|
|
Object[] status = baseDao.getFieldsDataByCondition("MakeScrap", new String[] { "ms_statuscode", "ms_indate","ms_date" }, "ms_id=" + id);
|
|
|
@@ -511,7 +533,7 @@ public class MESServiceImpl implements MESService {
|
|
|
if (s!=null||s1!=null||s2!=null||s3!=null||s4!=null){
|
|
|
baseDao.deleteById("MakeScrapdetail","md_msid",id);
|
|
|
baseDao.deleteById("MakeScrap","ms_id",id);
|
|
|
- return ApiResponse.failRsp("10029",requestId,s+s1+s2+s3+s4);
|
|
|
+ return ApiResponse.failRsp("10029",requestId,(s==null?"":s)+(s1==null?"":s1)+(s2==null?"":s2)+(s3==null?"":s3)+(s4==null?"":s4));
|
|
|
}
|
|
|
baseDao.updateByCondition("MakeScrapdetail", "md_status=99", "md_msid=" + id);
|
|
|
List<Object[]> objects = baseDao.getFieldsDatasByCondition("MakeScrapdetail left join make on ma_code=md_mmcode ", new String[] {
|
|
|
@@ -531,10 +553,10 @@ public class MESServiceImpl implements MESService {
|
|
|
//生成超损请购
|
|
|
int apId = baseDao.getSeqId("APPLICATION_SEQ");
|
|
|
String apCode = baseDao.sGetMaxNumber("Application", 2);
|
|
|
- baseDao.execute("insert into Application (ap_id,ap_code,ap_kind,ap_date,ap_statuscode,ap_status,ap_pleamanname,ap_pleamanid,ap_recorder,ap_recorderid,ap_recorddate,ap_departcode,ap_departname,ap_source,ap_sourceid,ap_printstatuscode,ap_printstatus,ap_remark) values " +
|
|
|
- "("+apId+",'"+apCode+"','超损请购',sysdate,'ENTERING','在录入','"+employee.getEm_name()+"',"+employee.getEm_id()+",'"+employee.getEm_name()+"',"+employee.getEm_id()+",sysdate,'"+fDeptID+"','"+fDept+"','"+msclass+"',"+id+",'UNPRINT','未打印','MES生产报废单审核生成')");
|
|
|
- baseDao.execute("insert into applicationdetail (ad_id,ad_apid,ad_code,ad_detno,ad_prodcode,ad_qty,ad_use,ad_statuscode,ad_status,ad_source,ad_sourcecode,ad_remark) " +
|
|
|
- "select APPLICATIONDETAIL_SEQ.nextval,"+apId+",'"+apCode+"',md_detno,md_prodcode,md_qty,md_reason,'ENTERING','在录入','"+msclass+"','"+code+"','MES生产报废单审核生成' from MakeScrapdetail where md_msid=" + id);
|
|
|
+ baseDao.execute("insert into Application (ap_id,ap_code,ap_kind,ap_date,ap_statuscode,ap_status,ap_pleamanname,ap_pleamanid,ap_recorder,ap_recorderid,ap_recorddate,ap_departcode,ap_departname,ap_source,ap_sourceid,ap_printstatuscode,ap_printstatus,ap_remark,ap_bfcode_user) values " +
|
|
|
+ "("+apId+",'"+apCode+"','超损请购',sysdate,'ENTERING','在录入','"+employee.getEm_name()+"',"+employee.getEm_id()+",'"+employee.getEm_name()+"',"+employee.getEm_id()+",sysdate,'"+fDeptID+"','"+fDept+"','"+msclass+"',"+id+",'UNPRINT','未打印','MES生产报废单审核生成','"+code+"')");
|
|
|
+ baseDao.execute("insert into applicationdetail (ad_id,ad_apid,ad_code,ad_detno,ad_prodcode,ad_qty,ad_use,ad_statuscode,ad_status,ad_source,ad_sourcecode,ad_remark,ad_zzcode_user,ad_zzxh_user,ad_sacode,ad_sadetno) " +
|
|
|
+ "select APPLICATIONDETAIL_SEQ.nextval,"+apId+",'"+apCode+"',md_detno,md_prodcode,md_qty,md_reason,'ENTERING','在录入','"+msclass+"','"+code+"','MES生产报废单审核生成',md_mmcode,md_mmdetno,ma_salecode,ma_saledetno from MakeScrapdetail left join make on md_mmcode=ma_code where md_msid=" + id);
|
|
|
baseDao.execute("update applicationdetail set ad_kcqty=(select ad_qty/(case when nvl(pr_purcrate,0)=0 then 1 else pr_purcrate end) from product where pr_code=ad_prodcode) where ad_apid="+apId);
|
|
|
return ApiResponse.successRsp("0",requestId,msclass+":"+code+",请在ERP查看!");
|
|
|
}
|
|
|
@@ -583,7 +605,7 @@ public class MESServiceImpl implements MESService {
|
|
|
// 账期和工单状态检查
|
|
|
String s1 = ScrapCheckAll(msId, caller);
|
|
|
if (s!=null||s1!=null){
|
|
|
- return ApiResponse.failRsp("10029",requestId,s+s1);
|
|
|
+ return ApiResponse.failRsp("10029",requestId,(s==null?"":s)+(s1==null?"":s1));
|
|
|
}
|
|
|
baseDao.deleteByCondition("applicationdetail","ad_apid in (select ap_id from application where ap_source='" + msclass + "' and ap_sourceid=" + msId+")");
|
|
|
baseDao.deleteByCondition("Application","ap_source='" + msclass + "' and ap_sourceid=" + msId);
|
|
|
@@ -702,8 +724,11 @@ public class MESServiceImpl implements MESService {
|
|
|
JSONArray array = data.get("detail");
|
|
|
if(array!=null&&array.size()>0){
|
|
|
String macode = StringUtil.valueOf(JSON.parseObject(StringUtil.nvl(array.get(0), "{}")).get("FICMOBillNo"));
|
|
|
- Object[] data1 = baseDao.getFieldsDataByCondition("Make", "ma_tasktype,ma_id", "ma_code in ('" + macode + "')");
|
|
|
+ Object[] data1 = baseDao.getFieldsDataByCondition("Make", "ma_tasktype,ma_id,ma_status", "ma_code in ('" + macode + "')");
|
|
|
if (data1!=null&&data1.length>0) {
|
|
|
+ if ("已结案".equals(StringUtil.nvl(data1[2], ""))){
|
|
|
+ return ApiResponse.failRsp("10045", requestId, "工单:"+macode+"在ERP已结案,不允许领料!");
|
|
|
+ }
|
|
|
ma_tasktype = StringUtil.nvl(data1[0], "");
|
|
|
maid = Integer.parseInt(StringUtil.nvl(data1[1], "0"));
|
|
|
}else {
|
|
|
@@ -787,7 +812,7 @@ public class MESServiceImpl implements MESService {
|
|
|
int lineId = Integer.parseInt(StringUtil.nvl(object.get("lineId"), "0"));
|
|
|
int count4 = baseDao.getCount("select count(1) from MakeMaterial where mm_id in (" + lineId + ")");
|
|
|
if (count4<=0){
|
|
|
- return ApiResponse.failRsp("10046",requestId,"工单BOM在ERP没有不存在,明细ID:"+lineId+",请联系管理员!");
|
|
|
+ return ApiResponse.failRsp("10046",requestId,"工单BOM在ERP中不存在,物料编号:"+itemNo+",请联系管理员!");
|
|
|
}
|
|
|
Object[] data1 = baseDao.getFieldsDataByCondition("MakeMaterial", "mm_detno,mm_maid","mm_id in (" + lineId + ")");
|
|
|
maid = Integer.parseInt(StringUtil.nvl(data1[1], "0"));
|
|
|
@@ -839,7 +864,7 @@ public class MESServiceImpl implements MESService {
|
|
|
return ApiResponse.successRsp("0",requestId,bcpiclass+":"+bccode+ ",请在ERP查看并过账!");
|
|
|
}
|
|
|
String s = postProdInOut(bcpiid, bccaller, employee);
|
|
|
- logger.info("S=="+s);
|
|
|
+ logger.info("旧拨出单过账信息:"+s);
|
|
|
if (s!=null){
|
|
|
return ApiResponse.successRsp("0",requestId,bcpiclass+":"+bccode+",过账失败,请在ERP重新过账!");
|
|
|
}else {
|
|
|
@@ -850,12 +875,12 @@ public class MESServiceImpl implements MESService {
|
|
|
return ApiResponse.successRsp("0",requestId,llpiclass+":"+llcode+","+bcpiclass+":"+bccode+ ",请在ERP查看并手工过账!");
|
|
|
}
|
|
|
String s = postProdInOut(bcpiid, bccaller, employee);
|
|
|
- logger.info("S=="+s);
|
|
|
+ logger.info("旧拨出单过账信息:"+s);
|
|
|
if (s!=null){
|
|
|
return ApiResponse.successRsp("0",requestId,bcpiclass+":"+bccode+",过账失败,请在ERP重新过账!");
|
|
|
}
|
|
|
String s1 = postProdInOut(llpiid, llcaller, employee);
|
|
|
- logger.info("S1==" + s1);
|
|
|
+ logger.info("旧生产领料单过账信息:"+s1);
|
|
|
refreshTurnQty(maid,0);
|
|
|
setBackQty(String.valueOf(maid),0);
|
|
|
if (s1 != null) {
|
|
|
@@ -1416,12 +1441,15 @@ public class MESServiceImpl implements MESService {
|
|
|
JSONArray detail = data.get("detail");
|
|
|
if(detail!=null&&detail.size()>0){
|
|
|
String macode = StringUtil.valueOf(JSON.parseObject(StringUtil.nvl(detail.get(0), "{}")).get("FICMOBillNo"));
|
|
|
- Object[] data1 = baseDao.getFieldsDataByCondition("Make", "ma_tasktype,ma_id", "ma_code in ('" + macode + "')");
|
|
|
+ Object[] data1 = baseDao.getFieldsDataByCondition("Make", "ma_tasktype,ma_id,ma_status", "ma_code in ('" + macode + "')");
|
|
|
if (data1!=null&&data1.length>0) {
|
|
|
+ if ("已结案".equals(StringUtil.nvl(data1[2], ""))){
|
|
|
+ return ApiResponse.failRsp("10041", requestId, "工单:"+macode+"在ERP已结案,不允许领料!");
|
|
|
+ }
|
|
|
ma_tasktype = StringUtil.nvl(data1[0], "");
|
|
|
maid = Integer.parseInt(StringUtil.nvl(data1[1], "0"));
|
|
|
}else {
|
|
|
- return ApiResponse.failRsp("10041", requestId, "工单在ERP不存在,请核对!");
|
|
|
+ return ApiResponse.failRsp("10042", requestId, "工单在ERP不存在,请核对!");
|
|
|
}
|
|
|
}
|
|
|
JSONArray main = data.get("main");
|
|
|
@@ -1453,28 +1481,28 @@ public class MESServiceImpl implements MESService {
|
|
|
Map<Object, Object> map = JSONUtil.toMap(StringUtil.valueOf(object.get("FItemID")));
|
|
|
String itemNo = StringUtil.nvl(map.get("FNumber"), "");
|
|
|
if ("".equals(itemNo)){
|
|
|
- return ApiResponse.failRsp("10042",requestId,"物料不能为空!");
|
|
|
+ return ApiResponse.failRsp("10043",requestId,"物料不能为空!");
|
|
|
}
|
|
|
String fAuxQty = StringUtil.nvl(object.get("FAuxQty"), "0");
|
|
|
if ("0".equals(fAuxQty)){
|
|
|
- return ApiResponse.failRsp("10043",requestId,"实发数量不能为空!");
|
|
|
+ return ApiResponse.failRsp("10044",requestId,"实发数量不能为空!");
|
|
|
}
|
|
|
Double qty = Double.parseDouble(fAuxQty);
|
|
|
Map<Object, Object> map1 = JSONUtil.toMap(StringUtil.valueOf(object.get("FSCStockID2")));
|
|
|
String whcode = StringUtil.nvl(map1.get("FNumber"), "");
|
|
|
if ("".equals(whcode)){
|
|
|
- return ApiResponse.failRsp("10043",requestId,"发料仓库不能为空!");
|
|
|
+ return ApiResponse.failRsp("10045",requestId,"发料仓库不能为空!");
|
|
|
}
|
|
|
int count = baseDao.getCount("select count(1) from customtabledetail left join customtable on cd_ctid=ct_id where ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whcode + "'");
|
|
|
if (count<=0){
|
|
|
- return ApiResponse.failRsp("10044",requestId,"MES仓库编号在ERP没有对应关系,请联系管理员新增!");
|
|
|
+ return ApiResponse.failRsp("10046",requestId,"MES仓库编号在ERP没有对应关系,请联系管理员新增!");
|
|
|
}
|
|
|
warehouses = baseDao.getFieldsDataByCondition("customtabledetail left join customtable on 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='" + whcode + "'");
|
|
|
String ficmoBillNo = StringUtil.nvl(object.get("FICMOBillNo"), "");
|
|
|
int lineId = Integer.parseInt(StringUtil.nvl(object.get("lineId"), "0"));
|
|
|
int count4 = baseDao.getCount("select count(1) from MakeMaterial where mm_id in (" + lineId + ")");
|
|
|
if (count4<=0){
|
|
|
- return ApiResponse.failRsp("10046",requestId,"工单BOM在ERP没有不存在,明细ID:"+lineId+",请联系管理员!");
|
|
|
+ return ApiResponse.failRsp("10047",requestId,"工单BOM在ERP中不存在,物料编号:"+itemNo+",请联系管理员!");
|
|
|
}
|
|
|
Object[] data1 = baseDao.getFieldsDataByCondition("MakeMaterial", "mm_detno,mm_maid","mm_id in (" + lineId + ")");
|
|
|
maid = Integer.parseInt(StringUtil.nvl(data1[1], "0"));
|
|
|
@@ -1497,6 +1525,7 @@ public class MESServiceImpl implements MESService {
|
|
|
Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_code=?",
|
|
|
new BeanPropertyRowMapper<Employee>(Employee.class), "mes");
|
|
|
String s = postProdInOut(llpiid, llcaller, employee);
|
|
|
+ logger.info("新生产领料单过账信息:"+s);
|
|
|
if (s!=null){
|
|
|
return ApiResponse.successRsp("0", requestId, llpiclass + ":" + llcode + ",过账失败,请在ERP重新过账!");
|
|
|
}
|
|
|
@@ -1606,7 +1635,7 @@ public class MESServiceImpl implements MESService {
|
|
|
return ApiResponse.successRsp("0",requestId,tlpiclass+":"+tlcode+",请在ERP查看并手工过账!");
|
|
|
}
|
|
|
String s = postProdInOut(tlid, tlcaller, employee);
|
|
|
- logger.info("s=="+s);
|
|
|
+ logger.info("新生产退料单过账信息:"+s);
|
|
|
if (s!=null) {
|
|
|
return ApiResponse.successRsp("0", requestId, tlpiclass + ":" + tlcode + ",过账失败,请在ERP重新过账!");
|
|
|
}
|