|
|
@@ -1,5 +1,6 @@
|
|
|
package com.uas.eis.service.Impl;
|
|
|
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
@@ -7,7 +8,9 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.uas.eis.dao.BaseDao;
|
|
|
import com.uas.eis.dao.SqlRowList;
|
|
|
import com.uas.eis.dto.Key;
|
|
|
-import com.uas.eis.entity.*;
|
|
|
+import com.uas.eis.entity.Employee;
|
|
|
+import com.uas.eis.entity.VerifyApply;
|
|
|
+import com.uas.eis.entity.VerifyApplyDetail;
|
|
|
import com.uas.eis.sdk.entity.ApiResult;
|
|
|
import com.uas.eis.sdk.resp.ApiResponse;
|
|
|
import com.uas.eis.service.MESService;
|
|
|
@@ -664,7 +667,7 @@ public class MESServiceImpl implements MESService {
|
|
|
id = baseDao.getSeqId("PRODINOUT_SEQ");
|
|
|
code = baseDao.sGetMaxNumber(caller, 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_type,pi_mescode,pi_cardcode,pi_title,pi_custno) " +
|
|
|
- "values ("+id+",'"+code+"','"+piclass+"',to_date('"+jsonObject2.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPOST','未过账','"+map1.get("FNumber")+"','"+map1.get("FName")+"','"+map3.get("FNumber")+"','"+map3.get("FName")+"','AUDITED','已审核','"+map5.get("FName")+"',to_date('"+jsonObject2.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPRINT','未打印','"+map2.get("FName")+"','"+fSelBillNo+"','"+fCustCode+"','"+cuname+"','"+fCustNo+"')");
|
|
|
+ "values ("+id+",'"+code+"','"+piclass+"',to_date('"+jsonObject2.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPOST','未过账','"+map1.get("FNumber")+"','"+map1.get("FName")+"','"+map3.get("FNumber")+"','"+map3.get("FName")+"','ENTERING','在录入','"+map5.get("FName")+"',to_date('"+jsonObject2.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPRINT','未打印','"+map2.get("FName")+"','"+fSelBillNo+"','"+fCustCode+"','"+cuname+"','"+fCustNo+"')");
|
|
|
}
|
|
|
JSONArray array = data.get("detail");
|
|
|
int detno=1;
|
|
|
@@ -1695,6 +1698,45 @@ public class MESServiceImpl implements MESService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ApiResult<String> confirmMakeScrap(HttpServletRequest request) {
|
|
|
+ String requestId = request.getHeader("RequestId");
|
|
|
+ JSONObject data = getJsonData(request);
|
|
|
+ if (data != null) {
|
|
|
+ String apCode = null;
|
|
|
+ String msclass = "生产报废单";
|
|
|
+ Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_code=?", new BeanPropertyRowMapper<Employee>(Employee.class), "mes");
|
|
|
+ String msId = StringUtil.nvl(data.get("scrapid"), "");
|
|
|
+ baseDao.updateByCondition("MakeScrapdetail", "md_status=99", "md_msid=" + msId);
|
|
|
+ List<Object[]> objects = baseDao.getFieldsDatasByCondition("MakeScrapdetail left join make on ma_code=md_mmcode ", new String[]{
|
|
|
+ "ma_id", "md_mmdetno", "md_qty", "md_prodcode"}, " md_msid=" + msId);
|
|
|
+ for (Object[] object : objects) {
|
|
|
+ baseDao.updateByCondition("Makematerial ", "mm_scrapqty =nvl(mm_scrapqty,0)+" + object[2], "mm_detno=" + object[1]
|
|
|
+ + " and mm_maid=" + object[0]);
|
|
|
+ baseDao.updateByCondition("Makematerial ", "mm_repscrapqty =nvl(mm_repscrapqty,0)+" + object[2], "mm_detno=" + object[1]
|
|
|
+ + " and mm_maid=" + object[0] + " and mm_prodcode<>'" + object[3] + "'");
|
|
|
+ baseDao.updateByCondition("Makematerialreplace ", "mp_scrapqty =nvl(mp_scrapqty,0)+" + object[2], " mp_maid=" + object[0]
|
|
|
+ + " and mp_mmdetno=" + object[1] + " and mp_prodcode='" + object[3] + "'");
|
|
|
+ }
|
|
|
+ // 执行审核操作
|
|
|
+ baseDao.updateByCondition("MakeScrap", "ms_status='已确认',ms_statuscode='CONFIRMED'", "ms_id=" + msId);
|
|
|
+ // 记录操作
|
|
|
+ baseDao.execute("INSERT INTO MessageLog(ml_id,ml_date,ml_man,ml_content,ml_result,ml_search) VALUES (MessageLog_seq.nextval,sysdate,'mes','审核操作','审核成功','MakeScrap|ms_id=" + msId + "')");
|
|
|
+ //生成超损请购
|
|
|
+ int apId = baseDao.getSeqId("APPLICATION_SEQ");
|
|
|
+ apCode = baseDao.sGetMaxNumber("Application", 2);
|
|
|
+ Object dpcode = baseDao.getFieldDataByCondition("MakeScrapDetail", "min(md_department)", "md_msid=" + msId);
|
|
|
+ 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 " +
|
|
|
+ " select " + apId + ",'" + apCode + "','超损请购',sysdate,'ENTERING','在录入','" + employee.getEm_name() + "'," + employee.getEm_id() + ",'" + employee.getEm_name() + "'," + employee.getEm_id() + ",sysdate,'" + dpcode + "',dp_name,'" + msclass + "',ms_id,'UNPRINT','未打印','MES生产报废单确认生成',ms_code from MakeScrap,department where dp_code='" + dpcode + "' and ms_id=" + msId);
|
|
|
+ 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 + "',md_code,'MES生产报废单审核生成',md_mmcode,md_mmdetno,ma_salecode,ma_saledetno from MakeScrapdetail left join make on md_mmcode=ma_code where md_msid=" + msId);
|
|
|
+ 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, "请购单:" + apCode + ",请在ERP查看!");
|
|
|
+ }else {
|
|
|
+ return ApiResponse.failRsp("10074",requestId,"参数异常!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private Map<String, JSONArray> getData(HttpServletRequest request){
|
|
|
Map<String, JSONArray> map = new HashMap<>();
|
|
|
try {
|