Administrator
2023-04-15 4c64dca2491f0ae298ee160c1e8df22448a588ae
明晟webservice
已修改5个文件
218 ■■■■■ 文件已修改
JavaSource/com/mandi/common/Wxhtmethod.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/mapper/Fd_XSTDMXMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/util/Contants.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/util/Contants_production.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/webservice/service/impl/FdXSTDService.java 197 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/common/Wxhtmethod.java
@@ -113,7 +113,7 @@
         JsonObject jo=new JsonObject();
         CloseableHttpClient httpclient = HttpClients.createDefault();
         HttpPost hp=new HttpPost(url);
        RequestConfig config = RequestConfig.custom().setConnectTimeout(30000).setSocketTimeout(30000).build();
        RequestConfig config = RequestConfig.custom().setConnectTimeout(10000).setSocketTimeout(30000).build();
        hp.setConfig(config);
         String re=null;
         List<NameValuePair> fps=new ArrayList<NameValuePair>();
@@ -179,7 +179,7 @@
//             s.setContentEncoding("UTF-8");
//             hp.setEntity(s);
             HttpPost hp=new HttpPost(url);
             RequestConfig config = RequestConfig.custom().setConnectTimeout(30000).setSocketTimeout(30000).build();
             RequestConfig config = RequestConfig.custom().setConnectTimeout(10000).setSocketTimeout(30000).build();
             hp.setConfig(config);
             StringEntity se=new StringEntity(jsonStr, Charset.forName("utf-8"));
             se.setContentType("application/json");
@@ -281,7 +281,7 @@
    {
         CloseableHttpClient httpclient = HttpClients.createDefault();
         HttpPost hp=new HttpPost(url);
        RequestConfig config = RequestConfig.custom().setConnectTimeout(30000).setSocketTimeout(30000).build();
        RequestConfig config = RequestConfig.custom().setConnectTimeout(10000).setSocketTimeout(30000).build();
        hp.setConfig(config);
         String re=null;
         List<NameValuePair> fps=new ArrayList<NameValuePair>();
@@ -321,7 +321,7 @@
         CloseableHttpClient httpclient=nssl();
        // CloseableHttpClient httpclient = HttpClients.createDefault();
         HttpPost hp=new HttpPost(url);
        RequestConfig config = RequestConfig.custom().setConnectTimeout(30000).setSocketTimeout(30000).build();
        RequestConfig config = RequestConfig.custom().setConnectTimeout(10000).setSocketTimeout(30000).build();
        hp.setConfig(config);
         String re=null;
         List<NameValuePair> fps=new ArrayList<NameValuePair>();
@@ -361,7 +361,7 @@
    {
         CloseableHttpClient httpclient=nssl();
         HttpPost hp=new HttpPost(url);
        RequestConfig config = RequestConfig.custom().setConnectTimeout(30000).setSocketTimeout(30000).build();
        RequestConfig config = RequestConfig.custom().setConnectTimeout(10000).setSocketTimeout(30000).build();
        hp.setConfig(config);
         MultipartEntityBuilder me=MultipartEntityBuilder.create();
         me.addBinaryBody(upfilename, file);
@@ -397,7 +397,7 @@
    {
         CloseableHttpClient httpclient=nssl();
         HttpPost hp=new HttpPost(url);
        RequestConfig config = RequestConfig.custom().setConnectTimeout(30000).setSocketTimeout(30000).build();
        RequestConfig config = RequestConfig.custom().setConnectTimeout(10000).setSocketTimeout(30000).build();
        hp.setConfig(config);
         StringEntity se=new StringEntity(body, Charset.forName("utf-8"));
         hp.setEntity(se);
JavaSource/com/mandi/fendan/mapper/Fd_XSTDMXMapper.java
@@ -159,9 +159,9 @@
    @Select({"select  hw.name tdmx_hwmc,mx.* from fd_xstdmx mx " ,
            " left join nc_hw hw on mx.tdmx_hwbh=hw.pkid and hw.state=1 " ,
            " join fd_bsheet on bsNo=tdmx_fdywbh and status='在办' and sdepartNo=#{sdepartNo} "
            " join fd_bsheet on bsNo=tdmx_fdywbh and status='在办' where SdepartNo=#{sdepartNo} "
    })
    public List getHwList(String sdepartNo);
    public List<Map> getHwList(String sdepartNo);
}
JavaSource/com/mandi/fendan/util/Contants.java
@@ -39,7 +39,8 @@
    //分单系统推送一卡通测试地址
    public static String yktLocalAdd=  "http://10.1.1.9:8088";//一卡通外网测试地址
    public static String yktLocalAdd=  "http://127.0.0.1:8085"; // "http://10.1.1.9:8088";//一卡通外网测试地址
    public final static String msLedServiceAddr= "http://192.168.200.211:8077/APPService.asmx"; // 明晟ABC区LED
//    public static String yktLocalAdd="http://125.46.81.106:8088";//一卡通外网测试地址
    //分单回写nc系统测试地址NCfdhx_url
    public static String NCfdhx_url = "http://10.0.13.20:9088/api/Domain/mtcesb/servlet/PubAPIServlet";
JavaSource/com/mandi/fendan/util/Contants_production.java
@@ -44,6 +44,8 @@
//    public static String yktLocalAdd="http://125.46.81.106:8088";//一卡通外网测试地址
    // 正式
    public static String yktLocalAdd = "http://10.0.12.11:8080";
    public final static String msLedServiceAddr= "http://10.22.11.151:8080/APPService.asmx"; // 明晟ABC区LED webservice
    //分单回写nc系统测试地址
//    public static String NCfdhx_url = "http://10.0.13.20:9090/api/Domain/mtcesb/servlet/PubAPIServlet";
    // 正式
JavaSource/com/mandi/webservice/service/impl/FdXSTDService.java
@@ -1,60 +1,34 @@
package com.mandi.webservice.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.mandi.basicconfig.persist.*;
import com.mandi.fendan.util.ConvertTool;
import com.mandi.fendan.util.ThreadPoolUtil;
import com.mandi.servlet.file.impl.FileLoadImpl;
import javafx.concurrent.Task;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.mandi.basicconfig.mapper.FdRepertoryNexusMapper;
import com.mandi.basicconfig.mapper.NczsjMapper;
import com.mandi.basicconfig.persist.*;
import com.mandi.common.JSONobj;
import com.mandi.common.Wxhtmethod;
import com.mandi.common.ParamFileter.BigDecimalfiter;
import com.mandi.common.Wxhtmethod;
import com.mandi.dao.common.ObjectResult;
import com.mandi.dao.common.PageResult;
import com.mandi.fendan.mapper.BsheetEcgbMapper;
import com.mandi.fendan.mapper.BusinessMapper;
import com.mandi.fendan.mapper.Fd_BsheetMapper;
import com.mandi.fendan.mapper.Fd_CompanyMapper;
import com.mandi.fendan.mapper.Fd_GbxstdMapper;
import com.mandi.fendan.mapper.Fd_GbxstdmxMapper;
import com.mandi.fendan.mapper.Fd_VehicleMapper;
import com.mandi.fendan.mapper.Fd_XSTDMXMapper;
import com.mandi.fendan.mapper.Fd_XSTDMapper;
import com.mandi.fendan.mapper.Fd_YKTMapper;
import com.mandi.fendan.mapper.VehicleXSTDMapper;
import com.mandi.fendan.persist.BsheetEcgb;
import com.mandi.fendan.persist.Fd_Bsheet;
import com.mandi.fendan.persist.Fd_Company;
import com.mandi.fendan.persist.Fd_Gbxstd;
import com.mandi.fendan.persist.Fd_Gbxstdmx;
import com.mandi.fendan.persist.Fd_XSTD;
import com.mandi.fendan.persist.Fd_XSTDMX;
import com.mandi.fendan.persist.Vehicle_XSTD;
import com.mandi.fendan.mapper.*;
import com.mandi.fendan.persist.*;
import com.mandi.fendan.util.Contants;
import com.mandi.fendan.util.ConvertTool;
import com.mandi.fendan.util.ThreadPoolUtil;
import com.mandi.fendan.util.persist.Serviceenum;
import com.mandi.fendan.util.persist.WaitXSTDMX;
import com.mandi.fendan.util.persist.Yktbsitem;
import com.mandi.servlet.file.impl.FileLoadImpl;
import com.mandi.webservice.service.IFdXSTDService;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
@Service
public class FdXSTDService implements IFdXSTDService{
@@ -459,7 +433,7 @@
            // TODO: handle exception
        }
        String currPch="";// 当前批次号
        //第一次添加装卸记录发送装车信息
        int sfzc=this.fbper.getbsitembyNo(fdb.getBsNo());
        if(sfzc<=0) {
@@ -582,6 +556,7 @@
            remp.put("td_tdls",tdmx.getTdmx_tdls());
            remp.put("tdmx_tdfl",tdmx.getTdmx_tdfl());
            relist.add(remp);
            currPch  = tdmx.getTdmx_pch();
        }
        if(grossNum>0) {
@@ -607,7 +582,8 @@
         // 此处异步触发一下明晟发车
        if("06".equals(fdb.getSdepartNo())) {
            ThreadPoolUtil.getInstance().execute(()->sendToMsLed());
            final String cph = currPch;
            ThreadPoolUtil.getInstance().execute(()->sendToMsLed(cph));
        }
        prr.setCode(0);
        prr.setErrmsg("装车操作成功!");
@@ -615,7 +591,11 @@
        return prr;
    }
    public void sendToMsLed(){ // todo 明天需要测试一下
    /**
     *
     * @param currPch 当前批次号
     */
    public void sendToMsLed(String currPch){
        //A区  76-86 +  99-1
        //B区  14-33 +  99-2
        //C区  53-67 +  99-3
@@ -628,12 +608,21 @@
            }
            ywbhListMap.get(ywdw).add(map);
        }
        String str1 = "车号-A区-B区-C区" + "\r\n", str2="";
        String str1 = " 车号  A区  B区  C区" + "\r\n", str2="";
        //"(车牌号)\\-(A区已装车)/(A区总计)\\-(B区已装车)/(B区总计)\\-(C区已装车)/(C区总计)\\r\\n";
        String formatStr = "%s-%d/%d- %d/%d-%d/%d\r\n";
        String formatStr = "%s %s/%s %s/%s %s/%s\r\n";
        // 只有1个区
        String speakTxtFormatStr1 = "车号%s ,装货%d件已完成,请司机清点货物后尽快驶离装货区。";
        // 只有2个区
        String speakTxtFormatStr2 = "车号%s,%s区装货%d件已全部扫描完成,请司机清点货物后去%s区装货。";
        // 只有3个区
        String speakTxtFormatStr3 = "车号%s,%s区装货%d件已全部扫描完成,请司机清点货物后去%s区%s区装货。";
        Map speakParam = new HashMap(1);
        for (Map.Entry<String, List<Map>> entry : ywbhListMap.entrySet()) { // 遍历每个业务单的
            // 当前装车A、B、C区
            boolean currA = false,currB = false, currC = false;
            boolean hasZcwc = false; // 保证已经完成了
            String ywhb = entry.getKey();
            // String ywhb = entry.getKey();
            List<Map> vehicleIdTotalList = entry.getValue();
            Map<String, Integer> totalAbcMap = new HashMap(3); // 总计信息
            totalAbcMap.put("A", 0);
@@ -646,41 +635,135 @@
            String cph = ""; // 车牌号
            for (Map map : vehicleIdTotalList) {
                String hw = (String) map.get("tdmx_hwmc");
                if(!"".equals(cph))  cph = (String) map.get("tdmx_zccph");
                String pch = (String) map.get("tdmx_pch");
                if("".equals(cph))  cph = (String) map.get("tdmx_fdcph");
                Integer zcbz = (Integer) map.get("tdmx_zcbz");
                String hh = hw.replaceAll("\\-.*","");
                hh = hh.substring(hh.length()-2); // 取最后两位
                int num = Integer.parseInt(hh);
                if (num >= 76 && num <= 86 || hw.lastIndexOf("99-1") >= 0) { // A区
                    totalAbcMap.put("A", 1);
                    totalAbcMap.put("A",totalAbcMap.get("A") + 1);
                    if (zcbz != null && zcbz == 1) { // 装车完成
                        abcMap.put("A", abcMap.get("A") + 1);
                        hasZcwc = true;
                    }
                    if(pch.equals(currPch)) {
                        currA = true; currB = false;currC =false;
                    }
                } else if (num >= 14 && num <= 33 || hw.lastIndexOf("99-2") >= 0) { // B区
                    totalAbcMap.put("B", 1);
                    totalAbcMap.put("B", totalAbcMap.get("B") + 1);
                    if (zcbz != null && zcbz == 1) {
                        abcMap.put("B", abcMap.get("B") + 1);
                        hasZcwc = true;
                    }
                    if(pch.equals(currPch)) {
                        currA = false; currB = true;currC =false;
                    }
                } else if (num >= 53 && num <= 67 || hw.lastIndexOf("99-3") >= 0) { // C区
                    totalAbcMap.put("C", 1);
                    totalAbcMap.put("C", totalAbcMap.get("C") + 1);
                    if (zcbz != null && zcbz == 1) {
                        abcMap.put("C", abcMap.get("C") + 1);
                        hasZcwc = true;
                    }
                    if(pch.equals(currPch)) {
                        currA = false; currB = false; currC =true;
                    }
                }
            }
            if (!hasZcwc) continue;
            str2 += String.format(formatStr, cph, abcMap.get("A"), totalAbcMap.get("A"),
                    abcMap.get("B"), totalAbcMap.get("B"),
                    abcMap.get("C"), totalAbcMap.get("C"));
            if (!hasZcwc) continue; //没有装车完成的也跳过
            if (!(currA || currB || currC) && abcMap.get("A") + abcMap.get("B") + abcMap.get("C") ==
                    totalAbcMap.get("A") + totalAbcMap.get("B") + totalAbcMap.get("C")) { // 非当前车牌号,已经装车完成但是未出厂
                continue;
            }
            str2 += String.format(formatStr, cph, fillSpace(abcMap.get("A")), fillSpace(totalAbcMap.get("A")),
                    fillSpace(abcMap.get("B")), fillSpace(totalAbcMap.get("B")),
                    fillSpace(abcMap.get("C")), fillSpace(totalAbcMap.get("C")));
            // 开始准备语音
            int total = 0;
            if(currA && abcMap.get("A") == totalAbcMap.get("A")) { // 当前车在A区装车完成
                total = totalAbcMap.get("A");
            }
            if(currB && abcMap.get("B") == totalAbcMap.get("B")) {// 当前车在B区装车完成
                total = totalAbcMap.get("B");
            }
            if(currC && abcMap.get("C") == totalAbcMap.get("C")) {// 当前车在C区装车完成
                total = totalAbcMap.get("C");
            }
            if(total > 0) { // 播放语音,请离开区域
                speakParam.clear();
                String speakTxt=null ;
                if( (abcMap.get("A")>0  && totalAbcMap.get("B")==0 && totalAbcMap.get("C")==0) ||
                        (abcMap.get("B")>0  && totalAbcMap.get("A")==0 && totalAbcMap.get("C")==0)  ||
                        (abcMap.get("C")>0  && totalAbcMap.get("B")==0 && totalAbcMap.get("D")==0)
                ) { // 只有一个区域有货物
                    speakTxt= String.format(speakTxtFormatStr1, cph, total);
                }else  if(totalAbcMap.get("A")>0 && totalAbcMap.get("B")>0 &&
                        (totalAbcMap.get("C")==0 || totalAbcMap.get("C") == abcMap.get("C"))){ // AB都有货 C区已完或无货
                    if(totalAbcMap.get("C")>0 && abcMap.get("A")< totalAbcMap.get("A") && abcMap.get("B")< totalAbcMap.get("B")) { // C装完AB未装完
                        speakTxt= String.format(speakTxtFormatStr3, cph,"C", total,"A","B");
                    } else if(abcMap.get("A")== totalAbcMap.get("A") && abcMap.get("B")< totalAbcMap.get("B")) { //A完B未完
                        speakTxt = String.format(speakTxtFormatStr2, cph, "A", total, "B");
                    }else if(abcMap.get("B")== totalAbcMap.get("B") && abcMap.get("A")< totalAbcMap.get("A")) {//B完A未完
                        speakTxt = String.format(speakTxtFormatStr2, cph, "B", total, "A");
                    }else { // 全部装完
                        speakTxt= String.format(speakTxtFormatStr1, cph, total);
                    }
                }else if(totalAbcMap.get("C")>0 && totalAbcMap.get("B")>0 &&
                        (totalAbcMap.get("A")==0 || totalAbcMap.get("A") == abcMap.get("A")) ){ //BC有货 A区已完或无货
                    if(totalAbcMap.get("A")>0 && abcMap.get("C")< totalAbcMap.get("C") && abcMap.get("B")< totalAbcMap.get("B")) {  // A装完BC未装完
                        speakTxt= String.format(speakTxtFormatStr3, cph,"A", total,"B","C");
                    } else if(abcMap.get("C")== totalAbcMap.get("C") && abcMap.get("B")< totalAbcMap.get("B")) { // C完B未装完
                        speakTxt = String.format(speakTxtFormatStr2, cph, "C", total, "B");
                    }else if(abcMap.get("B")== totalAbcMap.get("B") && abcMap.get("C")< totalAbcMap.get("C")) {// B完C未装完
                        speakTxt = String.format(speakTxtFormatStr2, cph, "B", total, "C");
                    }else { // 全部装完
                        speakTxt= String.format(speakTxtFormatStr1, cph, total);
                    }
                }else  if (totalAbcMap.get("A")>0 && totalAbcMap.get("C")>0 &&
                        (totalAbcMap.get("B")==0 || totalAbcMap.get("B") == abcMap.get("B")) ) { //AC有货
                    if(totalAbcMap.get("B")>0 && abcMap.get("A")< totalAbcMap.get("A") && abcMap.get("C")< totalAbcMap.get("C")) {
                        speakTxt= String.format(speakTxtFormatStr3, cph,"B", total,"A","C");
                    } else if(abcMap.get("A")== totalAbcMap.get("A") && abcMap.get("C")< totalAbcMap.get("C")) { // A装完C未装完
                        speakTxt = String.format(speakTxtFormatStr2, cph, "A", total, "C");
                    }else if(abcMap.get("C")== totalAbcMap.get("C") && abcMap.get("A")< totalAbcMap.get("A")) {// C装完A未装完
                        speakTxt = String.format(speakTxtFormatStr2, cph, "C", total, "A");
                    }else { // 全部装完
                        speakTxt= String.format(speakTxtFormatStr1, cph, total);
                    }
                }else if(totalAbcMap.get("A")>0 && totalAbcMap.get("B")>0 && totalAbcMap.get("C")>0) { // 3区都有货物,且只有一个取装完了
                    if(abcMap.get("A")>0 && abcMap.get("B")<totalAbcMap.get("B") && abcMap.get("C")<totalAbcMap.get("C")) {
                        speakTxt= String.format(speakTxtFormatStr3, cph,"A", total,"B","C");
                    } else if(abcMap.get("B")>0 && abcMap.get("C")==0 && abcMap.get("A")==0) {
                        speakTxt= String.format(speakTxtFormatStr3, cph,"B", total,"A","C");
                    } else if(abcMap.get("C")>0 && abcMap.get("A")==0 && abcMap.get("B")==0) {
                        speakTxt= String.format(speakTxtFormatStr3, cph,"C", total,"A","B");
                    } else { // 全部装完
                        speakTxt= String.format(speakTxtFormatStr1, cph, total);
                    }
                } else {
                    speakTxt= String.format(speakTxtFormatStr1, cph, total);
                }
                speakParam.put("SpeakTxt", speakTxt);
                log.info("SpeakTxt:"+ speakTxt);
            }
            // 单辆车的单个业务单的信息结束
        }
        Map paramMap = new HashMap();
        paramMap.put("str1",str1);
        paramMap.put("str2",str2);
        Wxhtmethod.post("192.168.112.21/api/xxx",paramMap);
        paramMap.put("strTitle",str1);
        paramMap.put("strContent",str2);
        try {
          String re = Wxhtmethod.post(Contants.msLedServiceAddr + "/SendLED",paramMap);
          // 语音只播一条
          String re1 = Wxhtmethod.post(Contants.msLedServiceAddr + "/Speak",speakParam);
        }catch (Exception e){}
    }
    String fillSpace(int str){
        String s;
        if(str<10 && str>=0) s= "0" + str;
        else s=String.valueOf(str);
        return s;
    }
    @Override