|
|
@@ -742,21 +742,64 @@ public class MESServiceImpl implements MESService {
|
|
|
int tlid=0;
|
|
|
String tlcode = "";
|
|
|
String macode="";
|
|
|
- String ma_tasktype=null;
|
|
|
+ String ma_tasktype="制程不良";
|
|
|
+ //良品退仓、来料不良、制程不良
|
|
|
+ String taskType=null;
|
|
|
int maid=0;
|
|
|
String tlpiclass = "生产退料单", tlcaller = "ProdInOut!Make!Return", bcpiclass = "拨出单", bccaller = "ProdInOut!AppropriationOut";
|
|
|
List<String> sqls = new ArrayList<>();
|
|
|
int frob=99;
|
|
|
JSONArray array = data.get("detail");
|
|
|
- if(array!=null&&array.size()>0){
|
|
|
+ Object[] warehouses=null;
|
|
|
+ Object[] warehouses2=null;
|
|
|
+ if(array!=null&&array.size()>0) {
|
|
|
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 + "')");
|
|
|
- if (data1!=null&&data1.length>0) {
|
|
|
+ if (data1 != null && data1.length > 0) {
|
|
|
ma_tasktype = StringUtil.nvl(data1[0], "");
|
|
|
maid = Integer.parseInt(StringUtil.nvl(data1[1], "0"));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return ApiResponse.failRsp("10057", requestId, "工单在ERP不存在,请核对!");
|
|
|
}
|
|
|
+ for (int i = 0; i <array.size(); i++) {
|
|
|
+ JSONObject object = JSON.parseObject(StringUtil.nvl(array.get(i), "{}"));
|
|
|
+ Object lineId = object.get("lineId");
|
|
|
+ //线边仓
|
|
|
+ Map<Object, Object> map1 = JSONUtil.toMap(StringUtil.valueOf(object.get("FSCStockID1")));
|
|
|
+ String whcode = StringUtil.nvl(map1.get("FNumber"), "");
|
|
|
+ if ("".equals(whcode)) {
|
|
|
+ return ApiResponse.failRsp("10053", 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("10054", requestId, "MES仓库编号在ERP没有对应关系,请联系管理员新增!");
|
|
|
+ }
|
|
|
+ //大仓
|
|
|
+ Map<Object, Object> map2 = JSONUtil.toMap(StringUtil.nvl(object.get("FSCStockID2"), "{}"));
|
|
|
+ String whcode2 = StringUtil.nvl(map2.get("FNumber"), "");
|
|
|
+ if ("".equals(whcode2)) {
|
|
|
+ return ApiResponse.failRsp("10055", requestId, "物料退回仓库不能为空!");
|
|
|
+ }
|
|
|
+ int count2 = 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='" + whcode2 + "'");
|
|
|
+ if (count2 <= 0) {
|
|
|
+ return ApiResponse.failRsp("10056", requestId, "MES仓库编号在ERP没有对应关系,请联系管理员新增!");
|
|
|
+ }
|
|
|
+ warehouses2 = 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='" + whcode2 + "'");
|
|
|
+ //获取领料单拨出仓库
|
|
|
+ int mmdetno = Integer.parseInt(StringUtil.nvl(baseDao.getFieldDataByCondition("make","mm_detno","mm_id in (" + lineId + ")"), "0"));
|
|
|
+ Object data2 = baseDao.getFieldDataByCondition("prodiodetail", "min(pd_batchcode)","pd_piclass='生产领料单' and pd_ordercode='" + macode + "' and pd_orderdetno=" + mmdetno);
|
|
|
+ Object pdwhcode = baseDao.getFieldDataByCondition("prodiodetail", "pd_whcode","pd_piclass='拨出单' and pd_batchcode='" + data2 + "'");
|
|
|
+ int nocost = Integer.parseInt(StringUtil.nvl(baseDao.getFieldDataByCondition("Warehouse", "nvl(wh_nocost,0)", "wh_code='" + pdwhcode + "'"), "0"));
|
|
|
+ int nocost1 = Integer.parseInt(StringUtil.nvl(baseDao.getFieldDataByCondition("Warehouse", "nvl(wh_nocost,0)", "wh_code='" + warehouses2[0] + "'"), "0"));
|
|
|
+ if (nocost != nocost1) {
|
|
|
+ if (nocost == -1) {
|
|
|
+ return ApiResponse.failRsp("10058", requestId, "工单BOM领料仓是零值仓,不允许退有值仓!");
|
|
|
+ }
|
|
|
+ if (nocost == 0) {
|
|
|
+ return ApiResponse.failRsp("10059", requestId, "工单BOM领料仓是有值仓,不允许退零值仓!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
for (int i = 0; i <jsonArray.size() ; i++) {
|
|
|
Object obj = jsonArray.get(i);
|
|
|
@@ -767,6 +810,7 @@ public class MESServiceImpl implements MESService {
|
|
|
Map<Object, Object> map4 = JSONUtil.toMap(StringUtil.nvl(jsonObject2.get("FSManagerID"),"{}"));
|
|
|
Map<Object, Object> map5 = JSONUtil.toMap(StringUtil.nvl(jsonObject2.get("FBillerID"),"{}"));
|
|
|
frob = Integer.parseInt(StringUtil.nvl(jsonObject2.get("FROB"), "99"));
|
|
|
+ taskType = StringUtil.nvl(jsonObject2.get("TaskType"), "");
|
|
|
if ("OS".equals(ma_tasktype)) {
|
|
|
tlpiclass = "委外退料单";
|
|
|
tlcaller = "ProdInOut!OutsideReturn";
|
|
|
@@ -780,17 +824,15 @@ public class MESServiceImpl implements MESService {
|
|
|
if (result1!=null){
|
|
|
return result1;
|
|
|
}
|
|
|
- if (frob==0){
|
|
|
+ if (frob==0||"制程不良".equals(taskType)){
|
|
|
tlid = baseDao.getSeqId("PRODINOUT_SEQ");
|
|
|
tlcode = baseDao.sGetMaxNumber(tlcaller, 2);
|
|
|
- sqls.add("INSERT INTO ProdInOut(pi_id, pi_inoutno, pi_date, pi_class,pi_invostatus,pi_invostatuscode,pi_recordman, pi_recorddate, pi_statuscode,pi_status,pi_updatedate,pi_updateman,pi_printstatuscode,pi_printstatus,pi_departmentcode,pi_departmentname,pi_emcode,pi_emname,pi_mescode) VALUES ("+tlid+",'"+tlcode+"',to_date('"+jsonObject2.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'"+tlpiclass+"','在录入','ENTERING','"+map5.get("FName")+"',to_date('"+jsonObject2.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPOST','未过账',sysdate,'"+map5.get("FName")+"','UNPRINT','未打印','"+map1.get("FNumber")+"','"+map1.get("FName")+"','"+map4.get("FNumber")+"','"+map4.get("FName")+"','"+fSelBillNo+"')");
|
|
|
+ sqls.add("INSERT INTO ProdInOut(pi_id, pi_inoutno, pi_date, pi_class,pi_invostatus,pi_invostatuscode,pi_recordman, pi_recorddate, pi_statuscode,pi_status,pi_updatedate,pi_updateman,pi_printstatuscode,pi_printstatus,pi_departmentcode,pi_departmentname,pi_emcode,pi_emname,pi_mescode) VALUES ("+tlid+",'"+tlcode+"',to_date('"+jsonObject2.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'"+tlpiclass+"','已审核','AUDITED','"+map5.get("FName")+"',to_date('"+jsonObject2.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPOST','未过账',sysdate,'"+map5.get("FName")+"','UNPRINT','未打印','"+map1.get("FNumber")+"','"+map1.get("FName")+"','"+map4.get("FNumber")+"','"+map4.get("FName")+"','"+fSelBillNo+"')");
|
|
|
}
|
|
|
id = baseDao.getSeqId("PRODINOUT_SEQ");
|
|
|
code = baseDao.sGetMaxNumber(bccaller, 2);
|
|
|
- sqls.add("insert into prodinout (pi_id,pi_inoutno,pi_class,pi_date,pi_statuscode,pi_status,pi_departmentcode,pi_departmentname,pi_emcode,pi_emname,pi_invostatuscode,pi_invostatus,pi_recordman,pi_recorddate,pi_printstatuscode,pi_printstatus,pi_inoutman,pi_type,pi_mescode) values ("+id+",'"+code+"','"+bcpiclass+"',to_date('"+jsonObject2.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPOST','未过账','"+map1.get("FNumber")+"','"+map1.get("FName")+"','"+map4.get("FNumber")+"','"+map4.get("FName")+"','ENTERING','在录入','"+map5.get("FName")+"',to_date('"+jsonObject2.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPRINT','未打印','"+map3.get("FName")+"','库存转移','"+fSelBillNo+"')");
|
|
|
+ sqls.add("insert into prodinout (pi_id,pi_inoutno,pi_class,pi_date,pi_statuscode,pi_status,pi_departmentcode,pi_departmentname,pi_emcode,pi_emname,pi_invostatuscode,pi_invostatus,pi_recordman,pi_recorddate,pi_printstatuscode,pi_printstatus,pi_inoutman,pi_type,pi_mescode) values ("+id+",'"+code+"','"+bcpiclass+"',to_date('"+jsonObject2.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPOST','未过账','"+map1.get("FNumber")+"','"+map1.get("FName")+"','"+map4.get("FNumber")+"','"+map4.get("FName")+"','AUDITED','已审核','"+map5.get("FName")+"',to_date('"+jsonObject2.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPRINT','未打印','"+map3.get("FName")+"','库存转移','"+fSelBillNo+"')");
|
|
|
}
|
|
|
- Object[] warehouses=null;
|
|
|
- Object[] warehouses2=null;
|
|
|
int detno=1;
|
|
|
int det=1;
|
|
|
for (int i = 0; i <array.size(); i++) {
|
|
|
@@ -805,39 +847,22 @@ public class MESServiceImpl implements MESService {
|
|
|
return ApiResponse.failRsp("10052",requestId,"实发数量不能为空!");
|
|
|
}
|
|
|
String fnote = StringUtil.nvl(object.get("Fnote"), "");
|
|
|
+ Object lineId = object.get("lineId");
|
|
|
Map<Object, Object> map1 = JSONUtil.toMap(StringUtil.valueOf(object.get("FSCStockID1")));
|
|
|
String whcode = StringUtil.nvl(map1.get("FNumber"), "");
|
|
|
- String whname = StringUtil.nvl(map1.get("FName"), "");
|
|
|
- if ("".equals(whcode)){
|
|
|
- return ApiResponse.failRsp("10053",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("10054",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 + "'");
|
|
|
Map<Object, Object> map2 = JSONUtil.toMap(StringUtil.nvl(object.get("FSCStockID2"), "{}"));
|
|
|
String whcode2 = StringUtil.nvl(map2.get("FNumber"), "");
|
|
|
- String whname2 = StringUtil.nvl(map2.get("FName"), "");
|
|
|
- if ("".equals(whcode2)){
|
|
|
- return ApiResponse.failRsp("10055",requestId,"物料退回仓库不能为空!");
|
|
|
- }
|
|
|
- int count2 = 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='" + whcode2 + "'");
|
|
|
- if (count2<=0){
|
|
|
- return ApiResponse.failRsp("10056",requestId,"MES仓库编号在ERP没有对应关系,请联系管理员新增!");
|
|
|
- }
|
|
|
warehouses2 = 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='" + whcode2 + "'");
|
|
|
-
|
|
|
String ficmoBillNo = StringUtil.nvl(object.get("FICMOBillNo"), "");
|
|
|
String fBatchNo = StringUtil.nvl(object.get("FBatchNo"), "");
|
|
|
- Object lineId = object.get("lineId");
|
|
|
int count1 = baseDao.getCount("select count(1) from MakeMaterial where mm_id in (" + lineId + ")");
|
|
|
if (count1<=0){
|
|
|
return ApiResponse.failRsp("10075",requestId,"工单BOM不存在或ID不一致,请联系管理员处理!");
|
|
|
}
|
|
|
Object[] objs = baseDao.getFieldsDataByCondition("Make left join MakeMaterial on ma_id=mm_maid", new String[] { "mm_id", "mm_code","mm_detno", "mm_mdcode", "mm_prodcode", "mm_wccode"}, "mm_id in (" + lineId+")");
|
|
|
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,"+id+",'"+code+"','"+bcpiclass+"',"+detno+",'"+itemNo+"',"+qty+",'"+warehouses[0]+"','"+warehouses[1]+"','"+warehouses2[0]+"','"+warehouses2[1]+"','"+ficmoBillNo+"',"+objs[2]+")");
|
|
|
- if (frob==0) {
|
|
|
+ if (frob==0||"制程不良".equals(taskType)) {
|
|
|
Object prid = baseDao.getFieldDataByCondition("Product", "pr_id", "pr_code='" + itemNo + "'");
|
|
|
Double remain = baseDao.getSummaryByField("batch", "ba_remain", "ba_prodcode='" + itemNo + "' and ba_macode='" + macode + "' and ba_whcode='" + warehouses[0] + "'");
|
|
|
/*Object[] data1 = baseDao.getFieldsDataByCondition("MakeMaterial left join Make on ma_id=mm_maid",
|
|
|
@@ -1060,6 +1085,37 @@ public class MESServiceImpl implements MESService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ApiResult<String> prodInOutMakeGive(HttpServletRequest request) {
|
|
|
+ String requestId = request.getHeader("RequestId");
|
|
|
+ Map<String, JSONArray> data = getData(request);
|
|
|
+ JSONArray jsonArray = data.get("main");
|
|
|
+ String piCaller="ProdInOut!Make!Give";
|
|
|
+ String piClass="生产补料单";
|
|
|
+ Object piid=null;
|
|
|
+ String inoutno="";
|
|
|
+ for (int i = 0; i <jsonArray.size() ; i++) {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(StringUtil.nvl(jsonArray.get(i), ""));
|
|
|
+ inoutno = StringUtil.nvl(jsonObject.get("FSelBillNo"), "");
|
|
|
+ if ("".equals(inoutno)){
|
|
|
+ return ApiResponse.failRsp("10019",requestId,"生产补料单号不能为空!");
|
|
|
+ }
|
|
|
+ int count = baseDao.getCount("select count(1) from prodinout where pi_inoutno='" + inoutno + "' and pi_invostatuscode='AUDITED' and pi_statuscode='UNPOST' and pi_class='生产补料单'");
|
|
|
+ if (count>0) {
|
|
|
+ Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_code=?", new BeanPropertyRowMapper<Employee>(Employee.class), "mes");
|
|
|
+ piid = baseDao.getFieldDataByCondition("prodinout", "pi_id", "pi_inoutno='" + inoutno + "'");
|
|
|
+ String s = postProdInOut(Integer.parseInt(StringUtil.nvl(piid,"0")), piCaller, employee);
|
|
|
+ logger.info("s==" + s);
|
|
|
+ if (s != null) {
|
|
|
+ return ApiResponse.successRsp("108", requestId, piClass+":" + inoutno + ",过账失败,请在ERP重新过账!");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return ApiResponse.successRsp("107", requestId, piClass+":" + inoutno + ",不存在或未审核,或已过帐!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ApiResponse.successRsp("0",requestId,piClass+":"+inoutno+"自动过账,请在ERP查看!");
|
|
|
+ }
|
|
|
+
|
|
|
private Map<String, JSONArray> getData(HttpServletRequest request){
|
|
|
Map<String, JSONArray> map = new HashMap<>();
|
|
|
try {
|