|
|
@@ -9,9 +9,14 @@ import java.util.Map;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
-import com.uas.eis.entity.ActionConfig;
|
|
|
-import com.uas.eis.entity.ErrorMsg;
|
|
|
+import com.uas.eis.core.config.SpObserver;
|
|
|
+import com.uas.eis.dao.SqlRowList;
|
|
|
+import com.uas.eis.entity.*;
|
|
|
+import com.uas.eis.exception.ApiSystemException;
|
|
|
import com.uas.eis.exception.SystemException;
|
|
|
+import com.uas.eis.sdk.entity.ApiResult;
|
|
|
+import com.uas.eis.sdk.resp.ApiResponse;
|
|
|
+import com.uas.eis.utils.StringUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -20,9 +25,6 @@ import org.springframework.util.StringUtils;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.uas.eis.core.support.TokenHandler;
|
|
|
import com.uas.eis.dao.BaseDao;
|
|
|
-import com.uas.eis.entity.QueryArgs;
|
|
|
-import com.uas.eis.entity.QueryConfig;
|
|
|
-import com.uas.eis.entity.QueryConfigDetail;
|
|
|
import com.uas.eis.service.QueryService;
|
|
|
import com.uas.eis.utils.BaseUtil;
|
|
|
|
|
|
@@ -254,7 +256,71 @@ public class QueryServiceImpl implements QueryService {
|
|
|
public Object doAction(String code, String param) {
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResult<List<Map<String,Object>>> getMakeProcess(String accessKey, String requestId, String macode) {
|
|
|
+ String AE_MASTER = checkAccessKey(accessKey, requestId);
|
|
|
+ SpObserver.putSp(AE_MASTER);
|
|
|
+ //如果有传工单则,查询指定工单的,
|
|
|
+ if(StringUtil.hasText(macode)){
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select nvl(SP_MAKECODE,mpd_makecode) v_makecode ,nvl(SP_WCCODE,wc_code) v_wccode,nvl(V_INQTY,0)V_INQTY, " +
|
|
|
+ " nvl(mpd_inqty,0) v_planinqty,nvl(V_OKQTY,0)V_OKQTY,nvl(V_OUTQTY,0) V_OUTQTY,nvl(V_NGQTY,0) V_NGQTY, " +
|
|
|
+ " case when nvl(v_outqty,0)>0 then round(nvl(v_ngqty,0)*100/nvl(v_outqty,0),2) else 0 end v_ngrate, " +
|
|
|
+ " case when nvl(v_outqty,0)>0 then round(nvl(v_okqty,0)*100/nvl(v_outqty,0),2) else 0 end v_okrate " +
|
|
|
+ " from (select SP_WCCODE,SP_MAKECODE,sum(inqty) v_inqty ,sum(fokqty) v_okqty,sum(outqty) v_outqty,sum(snngqty) v_ngqty " +
|
|
|
+ " from(select SP_MAKECODE,SP_WCCODE,sp_sncode,max(case when sp_ifturnin<>0 and NVL(sp_ifrework,0)+NVL(sp_ifbackflow,0)=0 then 1 else 0 end)inqty " +
|
|
|
+ " ,max(case when NVL(sp_ifng,0)=0 and sp_ifturnout<>0 and NVL(sp_ifrework,0)+NVL(sp_ifbackflow,0)=0 then 1 else 0 end)fokqty " +
|
|
|
+ " ,max(case when sp_ifturnout<>0 and NVL(sp_ifrework,0)+NVL(sp_ifbackflow,0)=0 then 1 else 0 end)outqty " +
|
|
|
+ " ,max(case when NVL(sp_ifng,0)<>0 and sp_ifturnout<>0 and NVL(sp_ifrework,0)+NVL(sp_ifbackflow,0)=0 then 1 else 0 end)snngqty " +
|
|
|
+ " from steppassed where sp_makecode=? " +
|
|
|
+ " group by SP_WCCODE,sp_sncode,SP_MAKECODE) group by SP_MAKECODE,SP_WCCODE)a " +
|
|
|
+ " full join (select mpd_makecode,wc_code,sum(mpd_inqty) mpd_inqty from MakePlan left join MAKEPLANDETAIL on mpd_mpid=mp_id " +
|
|
|
+ " left join line on li_code=mpd_linecode left join workcenter on wc_code=li_wccode " +
|
|
|
+ " where trunc(mpd_plandate)<=trunc(sysdate) and mpd_makecode =? " +
|
|
|
+ " and mp_statuscode='AUDITED' and mp_kind='日计划' group by mpd_makecode,wc_code ) " +
|
|
|
+ " on SP_WCCODE=wc_code and SP_MAKECODE=mpd_makecode",macode,macode);
|
|
|
+ if(rs.hasNext()){
|
|
|
+ return ApiResponse.successRsp("0",requestId,rs.getResultList());
|
|
|
+ }
|
|
|
+ }else{ //如果没有传工单号,则查询当天生产计划所有的工单
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select nvl(SP_MAKECODE,mpd_makecode) v_makecode ,nvl(SP_WCCODE,wc_code) v_wccode,nvl(V_INQTY,0)V_INQTY, " +
|
|
|
+ " nvl(mpd_inqty,0) v_planinqty,nvl(V_OKQTY,0)V_OKQTY,nvl(V_OUTQTY,0) V_OUTQTY,nvl(V_NGQTY,0) V_NGQTY, " +
|
|
|
+ " case when nvl(v_outqty,0)>0 then round(nvl(v_ngqty,0)*100/nvl(v_outqty,0),2) else 0 end v_ngrate, " +
|
|
|
+ " case when nvl(v_outqty,0)>0 then round(nvl(v_okqty,0)*100/nvl(v_outqty,0),2) else 0 end v_okrate " +
|
|
|
+ " from (select SP_WCCODE,SP_MAKECODE,sum(inqty) v_inqty ,sum(fokqty) v_okqty,sum(outqty) v_outqty,sum(snngqty) v_ngqty " +
|
|
|
+ " from(select SP_MAKECODE,SP_WCCODE,sp_sncode,max(case when sp_ifturnin<>0 and NVL(sp_ifrework,0)+NVL(sp_ifbackflow,0)=0 then 1 else 0 end)inqty " +
|
|
|
+ " ,max(case when NVL(sp_ifng,0)=0 and sp_ifturnout<>0 and NVL(sp_ifrework,0)+NVL(sp_ifbackflow,0)=0 then 1 else 0 end)fokqty " +
|
|
|
+ " ,max(case when sp_ifturnout<>0 and NVL(sp_ifrework,0)+NVL(sp_ifbackflow,0)=0 then 1 else 0 end) outqty " +
|
|
|
+ " ,max(case when NVL(sp_ifng,0)<>0 and sp_ifturnout<>0 and NVL(sp_ifrework,0)+NVL(sp_ifbackflow,0)=0 then 1 else 0 end)snngqty " +
|
|
|
+ " from steppassed where sp_makecode in (select distinct mpd_makecode from MakePlan left join MAKEPLANDETAIL on mpd_mpid=mp_id " +
|
|
|
+ " where trunc(mpd_plandate)=trunc(sysdate) and mp_statuscode='AUDITED' and mp_kind='日计划' ) " +
|
|
|
+ " group by SP_WCCODE,sp_sncode,SP_MAKECODE) group by SP_MAKECODE,SP_WCCODE )a " +
|
|
|
+ " full join (select mpd_makecode,wc_code,sum(mpd_inqty) mpd_inqty from MakePlan left join MAKEPLANDETAIL on mpd_mpid=mp_id " +
|
|
|
+ " left join line on li_code=mpd_linecode left join workcenter on wc_code=li_wccode " +
|
|
|
+ " where trunc(mpd_plandate)<=trunc(sysdate) and mpd_makecode in (select distinct mpd_makecode from MakePlan left join MAKEPLANDETAIL on mpd_mpid=mp_id " +
|
|
|
+ " where trunc(mpd_plandate)=trunc(sysdate) and mp_statuscode='AUDITED' and mp_kind='日计划' ) " +
|
|
|
+ " and mp_statuscode='AUDITED' and mp_kind='日计划' group by mpd_makecode,wc_code ) " +
|
|
|
+ " on SP_WCCODE=wc_code and SP_MAKECODE=mpd_makecode");
|
|
|
+ if(rs.hasNext()){
|
|
|
+ return ApiResponse.successRsp("0",requestId,rs.getResultList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ApiResponse.successRsp("0",requestId,null);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String checkAccessKey(String accessKey,String requestId){
|
|
|
+ Object accessSecret_O = baseDao.getFieldDataByCondition("APIEMPLOYEE", "AE_SECRET", "AE_KEY='"+accessKey+"'");
|
|
|
+ Object AE_MASTER = baseDao.getFieldDataByCondition("APIEMPLOYEE", "AE_MASTER", "AE_KEY='"+accessKey+"'");
|
|
|
+ String accessSecret = accessSecret_O == null ? "" : accessSecret_O.toString();
|
|
|
+ // 检查KEY是否合理
|
|
|
+ if (org.apache.commons.lang.StringUtils.isEmpty(accessKey) || org.apache.commons.lang.StringUtils.isEmpty(accessSecret) || AE_MASTER== null || "".equals(AE_MASTER.toString())) {
|
|
|
+ ApiResult apiResult = new ApiResult();
|
|
|
+ apiResult.setCode(ErrorMessage.ACCESSKEY_ILLEGAL.getCode());
|
|
|
+ apiResult.setMessage(ErrorMessage.ACCESSKEY_ILLEGAL.getMessage());
|
|
|
+ apiResult.setRequestId(requestId);
|
|
|
+ throw new ApiSystemException(apiResult);
|
|
|
+ }
|
|
|
+ return AE_MASTER.toString();
|
|
|
+ }
|
|
|
+
|
|
|
}
|