|
@@ -0,0 +1,158 @@
|
|
|
+package com.huimv.manage.eartag.controller;
|
|
|
+
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.huimv.manage.eartag.dao.entity.EtEarmarkEntity;
|
|
|
+import com.huimv.manage.eartag.dao.entity.EtPackageEntity;
|
|
|
+import com.huimv.manage.eartag.dao.repo.EarmarkRepo;
|
|
|
+import com.huimv.manage.eartag.dao.repo.PackageRepo;
|
|
|
+import com.huimv.manage.util.Const;
|
|
|
+import com.huimv.manage.util.Result;
|
|
|
+import com.huimv.manage.webservice.Soap;
|
|
|
+import com.huimv.manage.webservice.task.ProduceMissionTask;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import lombok.val;
|
|
|
+import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@CrossOrigin
|
|
|
+@RestController
|
|
|
+@Slf4j
|
|
|
+@RequestMapping(value = "/eartag/earmark")
|
|
|
+public class FaHuoController {
|
|
|
+
|
|
|
+
|
|
|
+ @Value("${webservice.url}")
|
|
|
+ private String webServiceUrl;
|
|
|
+ @Value("${webservice.producerId}")
|
|
|
+ private String producerId;
|
|
|
+ @Autowired
|
|
|
+ private Soap soap;
|
|
|
+ @Autowired
|
|
|
+ private ProduceMissionTask produceMissionTask;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private EarmarkRepo earmarkRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PackageRepo packageRepo;
|
|
|
+
|
|
|
+
|
|
|
+ // 根据任务号 8.上传批次,耳标生产数据
|
|
|
+ @RequestMapping(value = "/UploadDataToWebService", method = RequestMethod.GET)
|
|
|
+ public Result UploadDataToWebService( @RequestParam(value = "ApplyID") String ApplyID,
|
|
|
+ @RequestParam(value = "ProduceDate") String ProduceDate,
|
|
|
+ @RequestParam(value = "ProduceLineID") Integer ProduceLineID) throws UnsupportedEncodingException {
|
|
|
+ log.info("producerId>>" + producerId);
|
|
|
+ log.info("webServiceUrl>>" + webServiceUrl);
|
|
|
+
|
|
|
+// List<EtEarmarkEntity> etEarmarkEntities = earmarkRepo.listEarmarkByApply(ApplyID);
|
|
|
+ List<EtPackageEntity> etPackageEntities = packageRepo.listByApply(ApplyID);
|
|
|
+ for (EtPackageEntity etPackageEntity : etPackageEntities) {
|
|
|
+ Integer packageId = etPackageEntity.getPackageId();
|
|
|
+ List<String> list = earmarkRepo.listEarmarkByPackageId(packageId);
|
|
|
+ String s = soap.callSoap(produceMissionTask.UploadDataToWebService(ApplyID, packageId, ProduceDate, ProduceLineID, list), webServiceUrl);
|
|
|
+ System.out.println(s);
|
|
|
+ //TODO 修改状态已生产
|
|
|
+// System.out.println("耳标号--->" +list.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /* Integer count = 0;
|
|
|
+ for (EtEarmarkEntity etEarmarkEntity : etEarmarkEntities) {
|
|
|
+ String EarMarkID = etEarmarkEntity.getEarmarkId();
|
|
|
+ String PackageID = etEarmarkEntity.getPackageId();
|
|
|
+ if ("0".equals(PackageID)){
|
|
|
+ return new Result(10001,"未绑定批次",false);
|
|
|
+ }
|
|
|
+
|
|
|
+ String s = soap.callSoap(produceMissionTask.UploadDataToWebService(ApplyID, PackageID, ProduceDate, ProduceLineID, EarMarkID), webServiceUrl);
|
|
|
+// JSONArray objects = produceMissionTask.parseReturnUploadDataXML(s);
|
|
|
+ System.out.println(s);
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ System.out.println(count);*/
|
|
|
+ // 上报
|
|
|
+// String stateBln = produceMissionTask.parseReturnSetMissionHasDownStateXML();
|
|
|
+ //更新数据库
|
|
|
+
|
|
|
+ return null;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传装箱信息数据
|
|
|
+ @RequestMapping(value = "/getNewTask", method = RequestMethod.GET)
|
|
|
+ public Result getNewTask( @RequestParam(value = "BoxCode") String BoxCode,
|
|
|
+ @RequestParam(value = "EarMarkAmount") Integer EarMarkAmount,
|
|
|
+ @RequestParam(value = "PackageAmount") Integer PackageAmount,
|
|
|
+ @RequestParam(value = "ProducerCode") String ProducerCode,
|
|
|
+ @RequestParam(value = "BoxTime") String BoxTime,
|
|
|
+ @RequestParam(value = "ApplyID") Integer ApplyID,
|
|
|
+ @RequestParam(value = "FHXX") String FHXX) throws UnsupportedEncodingException {
|
|
|
+ log.info("producerId>>" + producerId);
|
|
|
+ log.info("webServiceUrl>>" + webServiceUrl);
|
|
|
+ List<EtPackageEntity> etPackageEntities = packageRepo.listByApply(ApplyID+"");
|
|
|
+
|
|
|
+// DateTime date = new DateTime(BoxTime);
|
|
|
+ String s = soap.callSoap(produceMissionTask.AddEarMarkBoxData(BoxCode, EarMarkAmount, PackageAmount, ProducerCode, BoxTime, ApplyID, FHXX,etPackageEntities), webServiceUrl);
|
|
|
+ // 上报
|
|
|
+// String stateBln = produceMissionTask.parseReturnSetMissionHasDownStateXML();
|
|
|
+ //更新数据库
|
|
|
+ System.out.println(s);
|
|
|
+ return null;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //10.上传箱发货信息
|
|
|
+ @RequestMapping(value = "/AddShipEarMarkBoxData", method = RequestMethod.GET)
|
|
|
+ public Result AddShipEarMarkBoxData( @RequestParam(value = "BoxCode") String BoxCode,
|
|
|
+ @RequestParam(value = "ShipTime") String ShipTime) throws UnsupportedEncodingException {
|
|
|
+ log.info("producerId>>" + producerId);
|
|
|
+ log.info("webServiceUrl>>" + webServiceUrl);
|
|
|
+ // 上报
|
|
|
+ String stateBln = produceMissionTask.parseReturnSetMissionHasDownStateXML(soap.callSoap(produceMissionTask.AddShipEarMarkBoxData(BoxCode,ShipTime), webServiceUrl));
|
|
|
+ System.out.println(stateBln);
|
|
|
+ //TODO 更新数据库 更新箱信息数据
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //获取厂商id
|
|
|
+ @RequestMapping(value = "/GetProducerCodeByID", method = RequestMethod.GET)
|
|
|
+ public Result GetProducerCodeByID() throws UnsupportedEncodingException {
|
|
|
+ log.info("producerId>>" + producerId);
|
|
|
+ log.info("webServiceUrl>>" + webServiceUrl);
|
|
|
+ String stateBln = produceMissionTask.parseReturnSetMissionHasDownStateXML(soap.callSoap(produceMissionTask.GetProducerCodeByID(producerId), webServiceUrl));
|
|
|
+ /*<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetProducerCodeByIDResponse xmlns="http://tempuri.org/">
|
|
|
+ <GetProducerCodeByIDResult>82</GetProducerCodeByIDResult></GetProducerCodeByIDResponse></soap:Body></soap:Envelope>*/
|
|
|
+ //82
|
|
|
+ System.out.println(stateBln);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //任务发货
|
|
|
+ @RequestMapping(value = "/UpdateMissionStatus", method = RequestMethod.GET)
|
|
|
+ public Result UpdateMissionStatus() throws UnsupportedEncodingException {
|
|
|
+ log.info("producerId>>" + producerId);
|
|
|
+ log.info("webServiceUrl>>" + webServiceUrl);
|
|
|
+ //<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><UpdateMissionStatusResponse xmlns="http://tempuri.org/">
|
|
|
+ // <UpdateMissionStatusResult>true</UpdateMissionStatusResult></UpdateMissionStatusResponse></soap:Body></soap:Envelope>
|
|
|
+ String stateBln = produceMissionTask.parseReturnSetMissionHasDownStateXML(soap.callSoap(produceMissionTask.UpdateMissionStatus(producerId), webServiceUrl));
|
|
|
+
|
|
|
+ System.out.println(stateBln);
|
|
|
+
|
|
|
+ //TODO 更新数据库
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|