Prechádzať zdrojové kódy

巡检修改

This reverts commit 73e5d58d078e7ba801b36335d47d53d90235a38a.
DGJ 1 rok pred
rodič
commit
f592cce3e1

+ 22 - 1
Assets/Game/ShowXunJian/ShowXunJian.prefab

@@ -3834,7 +3834,7 @@ MonoBehaviour:
   m_OnCullStateChanged:
     m_PersistentCalls:
       m_Calls: []
-  m_text: "\u5DE1\u68C0\u5C1A\u672A\u5B8C\u6210\uFF0C\u662F\u5426\u786E\u8BA4\u9000\u51FA\uFF1F"
+  m_text: "\u662F\u5426\u786E\u8BA4\u9000\u51FA\uFF1F"
   m_isRightToLeft: 0
   m_fontAsset: {fileID: 11400000, guid: 53b37c1f568195149b410dacded90c09, type: 2}
   m_sharedMaterial: {fileID: 1738077909898060448, guid: 53b37c1f568195149b410dacded90c09, type: 2}
@@ -12264,6 +12264,10 @@ MonoBehaviour:
   - {fileID: 1579895052500749792}
   normalBtn: {fileID: 5692948887516078235}
   WarningBtn: {fileID: 3454956826294898332}
+  normalBG1: {fileID: 8913329317618553722}
+  normalBG2: {fileID: 5534510805703273222}
+  warningBG1: {fileID: 612234819673247380}
+  WarningBG2: {fileID: 5696947006763345551}
   exception: {fileID: 9183237031783825460}
   lastBtn: {fileID: 367278282814544627}
   nextBtn: {fileID: 3873807730786844588}
@@ -15038,14 +15042,26 @@ PrefabInstance:
   m_Modification:
     m_TransformParent: {fileID: 4629186307896980025}
     m_Modifications:
+    - target: {fileID: 2244507811620856916, guid: 87071b209bf7fca41b94d3839f47ca29, type: 3}
+      propertyPath: m_RaycastTarget
+      value: 0
+      objectReference: {fileID: 0}
     - target: {fileID: 5190978295931163826, guid: 87071b209bf7fca41b94d3839f47ca29, type: 3}
       propertyPath: m_Group
       value: 
       objectReference: {fileID: 6056082980992642573}
+    - target: {fileID: 7286170989260178358, guid: 87071b209bf7fca41b94d3839f47ca29, type: 3}
+      propertyPath: m_RaycastTarget
+      value: 0
+      objectReference: {fileID: 0}
     - target: {fileID: 7350649361258748609, guid: 87071b209bf7fca41b94d3839f47ca29, type: 3}
       propertyPath: toggle
       value: 
       objectReference: {fileID: 7246798814736293977}
+    - target: {fileID: 7350649361258748609, guid: 87071b209bf7fca41b94d3839f47ca29, type: 3}
+      propertyPath: imageBG
+      value: 
+      objectReference: {fileID: 6369639987024589858}
     - target: {fileID: 7350649361258748609, guid: 87071b209bf7fca41b94d3839f47ca29, type: 3}
       propertyPath: numText
       value: 
@@ -15199,6 +15215,11 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 577315de11183c947bb2a68c0f3ad735, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+--- !u!1 &6369639987024589858 stripped
+GameObject:
+  m_CorrespondingSourceObject: {fileID: 8430249991365198025, guid: 87071b209bf7fca41b94d3839f47ca29, type: 3}
+  m_PrefabInstance: {fileID: 3214376483655611627}
+  m_PrefabAsset: {fileID: 0}
 --- !u!114 &7246798814736293977 stripped
 MonoBehaviour:
   m_CorrespondingSourceObject: {fileID: 5190978295931163826, guid: 87071b209bf7fca41b94d3839f47ca29, type: 3}

+ 17 - 8
Assets/Game/ShowXunJian/XJTaskItem.cs

@@ -12,7 +12,7 @@ public class XJTaskItem : MonoBehaviour
     public TMP_Text numText;
     public TMP_Text nameText;
     public GameObject errorObj;
-
+    public GameObject imageBG;
     public RoomItem itemData;
     public XunJianDetails xjDetails;
 
@@ -20,32 +20,35 @@ public class XJTaskItem : MonoBehaviour
     private void Start()
     {
         toggle.onValueChanged.AddListener((b) =>
-        {
-            if (b)
+        {  
+            if(b)
             {
                 XunJianInitialize.Instance.checkTaskItem = this;
                 // 把数据传递出去
                 xjDetails.InitData(itemData);
-                
             }
         });
+        numText.raycastTarget = false;
+        nameText.raycastTarget = false;
     }
-    public void InitData(RoomItem data , XunJianDetails xjDetails)
+    public void InitData(int num, RoomItem data , XunJianDetails xjDetails)
     {
         this.itemData = data;
         this.xjDetails = xjDetails;
 
-        numText.text = data.inspItemType;
+        numText.text = num.ToString();
         nameText.text = data.inspItemName;
 
         if(data.recd ==null)
         {
             // 未操作过的
             errorObj.SetActive(false);
+            imageBG.SetActive(false);
         }
         else
         {
             errorObj.SetActive(data.recd.recordStatus == "0");
+            imageBG.SetActive(true);
         } 
     }
 
@@ -53,6 +56,7 @@ public class XJTaskItem : MonoBehaviour
     {
         string url = JsonConvert.SerializeObject(imageUrl);
         Debug.Log("DGJ ===> SubmitData  " + url + state + memo);
+      //  Debug.Log("DGJ ===> SubmitData  " + JsonConvert.SerializeObject(itemData.recd.recordImgList) + itemData.recd.recordStatus + itemData.recd.recordMemo);
         if (itemData.recd == null)
         {
             itemData.recd = new Record();
@@ -66,14 +70,19 @@ public class XJTaskItem : MonoBehaviour
             itemData.recd.recordMemo = null;
             itemData.recd.recordStatus = null;
             itemData.recd.recordImg = null;
+            itemData.recd.recordImgList = null;
         }
 
-        if(url!= itemData.recd.recordImg||state!= itemData.recd.recordStatus||memo!= itemData.recd.recordMemo)
+        if(url != JsonConvert.SerializeObject(itemData.recd.recordImgList) ||state!= itemData.recd.recordStatus||memo!= itemData.recd.recordMemo)
         {
+
+
+            Debug.Log("DGJ ===> Record   ");
+
             itemData.recd.recordImg = url;
             itemData.recd.recordStatus = state;
             itemData.recd.recordMemo = memo;
-
+            itemData.recd.recordImgList = imageUrl;
             LangChaoJiekou.Instance.addRecord(itemData.recd, (b) => {
 
                 if (b)

+ 94 - 23
Assets/Game/ShowXunJian/XunJianDetails.cs

@@ -7,6 +7,7 @@ using UnityEngine.UI;
 using System.IO;
 using LitJson;
 using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 
 public class XunJianDetails : MonoBehaviour
 {
@@ -18,8 +19,16 @@ public class XunJianDetails : MonoBehaviour
     public Button normalBtn;
     public Button WarningBtn;
 
+    public Image normalBG1;
+    public Image normalBG2;
+
+    public Image warningBG1;
+    public Image WarningBG2;
+
+
     public XunJianException exception;
 
+    
 
     public Button lastBtn;
     public Button nextBtn;
@@ -64,6 +73,13 @@ public class XunJianDetails : MonoBehaviour
 
             recordStatus = "1";
             isUpdata = true;
+
+            normalBG1.gameObject.SetActive(true);
+            normalBG2.gameObject.SetActive(false);
+            warningBG1.gameObject.SetActive(false);
+            WarningBG2.gameObject.SetActive(true);
+
+            LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
         });
 
         WarningBtn.onClick.AddListener(() =>
@@ -73,6 +89,11 @@ public class XunJianDetails : MonoBehaviour
             recordStatus = "0";
             isUpdata = true;
 
+            normalBG1.gameObject.SetActive(false);
+            normalBG2.gameObject.SetActive(true);
+            warningBG1.gameObject.SetActive(true);
+            WarningBG2.gameObject.SetActive(false);
+
             LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
         });
 
@@ -80,7 +101,7 @@ public class XunJianDetails : MonoBehaviour
         {
             // 提交
             SubmitData();
-
+            XunJianInitialize.Instance.LastItem();
           
         });
 
@@ -89,7 +110,7 @@ public class XunJianDetails : MonoBehaviour
             // 提交
             SubmitData();
 
-            
+            XunJianInitialize.Instance.NextItem();
             
 
         });
@@ -119,64 +140,112 @@ public class XunJianDetails : MonoBehaviour
         if (data.recd != null) // 之前提交过
         {
             // 同步照片
-            if(!string.IsNullOrEmpty(data.recd.recordImg))
+            if (data.recd.recordImgList != null)
             {
                 // Json 转换
-                List<string> listurl = JsonConvert.DeserializeObject<List<string>>(data.recd.recordImg);
+                // List<string> listurl = data.recd.recordImgList;
+
 
-                if(listurl!=null)
-                for (int i = 0; i < listurl.Count; i++)
+                for (int i = 0; i < data.recd.recordImgList.Count; i++)
                 {
-                    if (listurl[i] != null)
+
+                    if (!string.IsNullOrEmpty(data.recd.recordImgList[i]))
                     {
+                        Debug.Log(" DGJ ===> recordImgList " + data.recd.recordImgList[i]);
                         JsonData data2 = new JsonData();
-                        data2["fileName"] = listurl[i];
-                        LangChaoJiekou.Instance.DownloadImage(LangChaoJiekou.file_download, data2.ToJson(), (texture,url) => {
+                        data2["fileName"] = data.recd.recordImgList[i];
+                        StartCoroutine(LangChaoJiekou.Instance.DownloadImage(LangChaoJiekou.file_download, data2.ToJson(), (texture, url) =>
+                        {
+
+                            Debug.Log("DGJ ===> DownLoadImage " + url);
+                            JObject obj = JObject.Parse(url);
+                            url = obj["fileName"].ToString();
 
                             if (texture != null)
                             {
-                                for (int i = 0; i < listurl.Count; i++)
+                               
+                                for (int i = 0; i < data.recd.recordImgList.Count; i++)
                                 {
-                                    if(listurl[i] == url)
+                                    Debug.Log("DGJ ===> DownLoadImage2  " + url + "    " + data.recd.recordImgList[i]);
+                                    if (data.recd.recordImgList[i] == url)
                                     {
+                                        Debug.Log("DGJ ===> DownLoadImage3  " + url);
                                         listImages[i].sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                                         break;
                                     }
                                 }
                             }
 
-                        });
+                        }));
                     }
                 }
-                
+
             }
 
+            switch (data.recd.recordStatus)
+            {
+                case "0":
+                    normalBG1.gameObject.SetActive(false);
+                    normalBG2.gameObject.SetActive(true);
+                    warningBG1.gameObject.SetActive(true);
+                    WarningBG2.gameObject.SetActive(false);
+                    break;
+                case "1":
+                    normalBG1.gameObject.SetActive(true);
+                    normalBG2.gameObject.SetActive(false);
+                    warningBG1.gameObject.SetActive(false);
+                    WarningBG2.gameObject.SetActive(true);
+                    break;
+                default:
+                    break;
+            }
             // 同步异常
-            exception.gameObject.SetActive(true);
+            exception.gameObject.SetActive(data.recd.recordStatus=="0");
+
+            //if (data.recd.recordImg != null)
+            //    listImageUrl = JsonConvert.DeserializeObject<List<string>>(data.recd.recordImg);
+            listImageUrl = new List<string>();
 
-            if (data.recd.recordImg != null)
-                listImageUrl = JsonConvert.DeserializeObject<List<string>>(data.recd.recordImg);
+            for (int i = 0; i < data.recd.recordImgList.Count; i++)
+            {
+                listImageUrl.Add(data.recd.recordImgList[i]);
+            }          
             recordStatus = data.recd.recordStatus;
             recordMemo = data.recd.recordMemo;
             exception.scInput.text = data.recd.recordMemo;
         }
-       
-      
+        else
+        {
+            normalBG1.gameObject.SetActive(true);
+            normalBG2.gameObject.SetActive(false);
+            warningBG1.gameObject.SetActive(true);
+            WarningBG2.gameObject.SetActive(false);
+
+            listImageUrl = new List<string>();
+            recordStatus = null;
+            recordMemo = null;
+            exception.scInput.text = null;
+        }
+
+        LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
     }
 
     private void InitUI()
     {
-        xjName.text = data.inspItemName;
+        xjName.text = data.inspItemDesc;
         for (int i = 0; i < listImages.Count; i++)
         {
             listImages[i].sprite = startImg;
         }
         exception.InitData(data);
         exception.gameObject.SetActive(false);
-       
+
+        lastBtn.gameObject.SetActive(true);
+        nextBtn.gameObject.SetActive(true);
+        completeBtn.gameObject.SetActive(false);
         // 如果是第一步 没有上一步按钮
-        
-        if(data == XunJianAllData.listRoomItem[0])
+
+        if (data == XunJianAllData.listRoomItem[0])
         {
             lastBtn.gameObject.SetActive(false);
         }
@@ -207,6 +276,8 @@ public class XunJianDetails : MonoBehaviour
     /// </summary>
     public void SubmitData()
     {
+
+        Debug.Log("DGJ ===> SubmitData  " + isUpdata);
         if (isUpdata)
         {
             isUpdata = false;
@@ -272,7 +343,7 @@ public class XunJianDetails : MonoBehaviour
         byte[] bytes = texture2D.EncodeToPNG();
         if (!Directory.Exists(Application.persistentDataPath + "/Image"))
             Directory.CreateDirectory(Application.persistentDataPath + "/Image");
-        string filename = Application.persistentDataPath + "/Image" + "/" +xjName.text+ showImage.name + ".png";
+        string filename = Application.persistentDataPath + "/Image" + "/" +data.inspItemName+ showImage.name + ".png";
         if (File.Exists(filename))
             File.Delete(filename);
        // Debug.LogError(filename);

+ 51 - 1
Assets/Game/ShowXunJian/XunJianInitialize.cs

@@ -48,7 +48,7 @@ public class XunJianInitialize :MonoSingleton<XunJianInitialize>
         {
             GameObject item = GameObject.Instantiate(tastItem.gameObject, tastItem.transform.parent);
             item.SetActive(true);
-            item.GetComponent<XJTaskItem>().InitData( XunJianAllData.listRoomItem[i] ,xjDetails);
+            item.GetComponent<XJTaskItem>().InitData(i+1, XunJianAllData.listRoomItem[i] ,xjDetails);
             listItem.Add(item.GetComponent<XJTaskItem>());
         }
 
@@ -83,6 +83,56 @@ public class XunJianInitialize :MonoSingleton<XunJianInitialize>
 
         endUI.SetActive(true);
     }
+
+    public void LastItem()
+    {
+        for (int i = 0; i < listItem.Count; i++)
+        {
+            if(checkTaskItem.itemData.inspItemId == listItem[i].itemData.inspItemId)
+            {
+                int num = i - 1;
+
+                if(num>=0)
+                {
+                    checkTaskItem = listItem[num];
+                    xjDetails.InitData(listItem[num].itemData);
+                }
+                else
+                {
+                    checkTaskItem = listItem[i];
+                    xjDetails.InitData(listItem[i].itemData);
+                }
+
+
+                break;
+            }
+        }
+    }
+
+    public void NextItem()
+    {
+        for (int i = 0; i < listItem.Count; i++)
+        {
+            if (checkTaskItem.itemData.inspItemId == listItem[i].itemData.inspItemId)
+            {
+                int num = i + 1;
+
+                if (num < listItem.Count)
+                {
+                    checkTaskItem = listItem[num];
+                    xjDetails.InitData(listItem[num].itemData);
+                }
+                else
+                {
+                    checkTaskItem = listItem[i];
+                    xjDetails.InitData(listItem[i].itemData);
+                }
+
+
+                break;
+            }
+        }
+    }
     public void back()
     {
         ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);

+ 33 - 31
Assets/LangChaoJiekou.cs

@@ -230,6 +230,7 @@ public class LangChaoJiekou : MonoSingleton<LangChaoJiekou>
         public string inspItemType;
         public List<RoomError> errorList;
         public string inspItemName;
+        public string inspItemDesc;
         public string createUser;
         public string createUserName;
         public string inspItemId;
@@ -250,12 +251,13 @@ public class LangChaoJiekou : MonoSingleton<LangChaoJiekou>
         public string recordImg; // 图片
         public string recordMemo; // 巡检备注
         public string recordStatus;// 1-正常 0-异常
+        public List<string> recordImgList;
     }
 
     public void Start()
     {
 
-        GotToLogin("lisongnan", "13579Wp!#%&(", (bool b) => {
+       GotToLogin("lisongnan", "13579Wp!#%&(", (bool b) => {
 
             if (b)
             {
@@ -263,41 +265,41 @@ public class LangChaoJiekou : MonoSingleton<LangChaoJiekou>
             }
 
         });
-        
+
         //测试接口
-        GotToLogin("lisongnan", "13579Wp!#%&(",(bool b)=> {
+        /*  GotToLogin("lisongnan", "13579Wp!#%&(",(bool b)=> {
 
-            if (b)
-            {
-                checkXunjian("机房A", (TaskItem item) => {
-                
-                    if(item!=null)
-                    {
-                        getXunJian(item, (List<RoomItem> list)=>{
+             if (b)
+             {
+                 checkXunjian("机房A", (TaskItem item) => {
 
-                            for (int i = 0; i < list.Count; i++)
-                            {
-                                Debug.Log("RoomItem===>"+JsonConvert.SerializeObject(list[i]));
-                            }
-                    
-                        });
-                    }
-                
-                });
-            }
-        
-        });
-        StartCoroutine(UploadFile("D:\\Screenshot_0_Btn.png", "http://36.133.197.238:10002" + file_upload, (string msg) => {
+                     if(item!=null)
+                     {
+                         getXunJian(item, (List<RoomItem> list)=>{
 
-            Debug.Log("UploadFile===>" + msg);
-            JsonData d2 = JsonMapper.ToObject(msg);
+                             for (int i = 0; i < list.Count; i++)
+                             {
+                                 Debug.Log("RoomItem===>"+JsonConvert.SerializeObject(list[i]));
+                             }
 
-            JsonData data = new JsonData();
-            data["fileName"] = d2["data"].ToString();
-            StartCoroutine(DownloadImage(file_download, data.ToJson(), (Texture2D msg) => {
-             //   img.texture = msg;
-            }));
-        }));
+                         });
+                     }
+
+                 });
+             }
+
+         });
+         StartCoroutine(UploadFile("D:\\Screenshot_0_Btn.png", "http://36.133.197.238:10002" + file_upload, (string msg) => {
+
+             Debug.Log("UploadFile===>" + msg);
+             JsonData d2 = JsonMapper.ToObject(msg);
+
+             JsonData data = new JsonData();
+             data["fileName"] = d2["data"].ToString();
+             StartCoroutine(DownloadImage(file_download, data.ToJson(), (Texture2D msg) => {
+              //   img.texture = msg;
+             }));
+         }));*/
     }
 
     public void initHead(string ContentType)