Browse Source

问题修改

xiaochen 3 years ago
parent
commit
c635068c14

+ 54 - 3
src/main/java/com/model/controller/ClientController.java

@@ -5,9 +5,7 @@ import com.model.result.CommRes;
 import com.model.service.ClientService;
 import com.model.util.PassToken;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * @program: model
@@ -33,4 +31,57 @@ public class ClientController {
     private CommRes getClient(Client client){
         return clientService.getClient(client);
     }
+
+    /**
+    * @Description: 添加客户信息
+    * @Param: client
+    * @return: CommRes
+    * @Author: XiaoChen
+    * @Date: 2023/4/24
+    */
+    @PostMapping("addClient")
+    @PassToken
+    private CommRes addClient(@RequestBody Client client){
+        return clientService.addClient(client);
+    }
+
+    /**
+    * @Description: 删除客户信息
+    * @Param: client
+    * @return:
+    * @Author: XiaoChen
+    * @Date: 2023/4/24
+    */
+    @DeleteMapping("delClient")
+    @PassToken
+    private CommRes delClient(@RequestBody Client client){
+        return clientService.delClient(client);
+    }
+
+    /**
+    * @Description: 修改客户信息
+    * @Param:
+    * @return:
+    * @Author: XiaoChen
+    * @Date: 2023/4/24
+    */
+    @PutMapping("updClient")
+    @PassToken
+    private CommRes updClient(@RequestBody Client client){
+        return clientService.updClient(client);
+    }
+    
+    /** 
+    * @Description: 查询客户表列表
+    * @Param:   client
+    * @return:   CommRes
+    * @Author: XiaoChen
+    * @Date: 2023/4/24
+    */
+    @GetMapping("getClientList")
+    @PassToken
+    private CommRes getClientList(Client client){
+        return clientService.getClientList(client);
+    }
+
 }

+ 26 - 0
src/main/java/com/model/controller/DispatchController.java

@@ -59,4 +59,30 @@ public class DispatchController {
         return dispatchService.getDispatchList(dispatch);
     }
 
+    /**
+     * @Description: 更改异常状态
+     * @Param: id
+     * @return: CommRes
+     * @Author: XiaoChen
+     * @Date: 2023/4/24
+     */
+    @PutMapping("updAnomaly")
+    @PassToken
+    private CommRes updAnomaly(String id){
+        return dispatchService.updAnomaly(id);
+    }
+
+    /**
+     * @Description: 更改预计到达时间
+     * @Param: id
+     * @return: CommRes
+     * @Author: XiaoChen
+     * @Date: 2023/4/24
+     */
+    @PutMapping("updArrivalTime")
+    @PassToken
+    private CommRes updArrivalTime(@RequestBody Dispatch dispatch){
+        return dispatchService.updArrivalTime(dispatch);
+    }
+
 }

+ 12 - 0
src/main/java/com/model/entity/Client.java

@@ -27,4 +27,16 @@ public class Client implements Serializable {
      * 天数
      */
     private String days;
+    /**
+     * 客户名称
+     */
+    private String name;
+    /**
+     * 页数
+     */
+    private int page;
+    /**
+     * 条数
+     */
+    private int limit;
 }

+ 4 - 0
src/main/java/com/model/entity/User.java

@@ -33,4 +33,8 @@ public class User implements Serializable {
      * token
      */
     private String token;
+    /**
+     * 权限
+     */
+    private String power;
 }

+ 6 - 0
src/main/java/com/model/mapper/ClientMapper.java

@@ -18,4 +18,10 @@ public interface ClientMapper {
     void addClient(Client client);
 
     void updClient(Client client);
+
+    void delClient(Client client);
+
+    List<Client> getClientList(Client client);
+
+    Client getClients(Client client);
 }

+ 6 - 0
src/main/java/com/model/mapper/DispatchMapper.java

@@ -21,4 +21,10 @@ public interface DispatchMapper {
     List<Dispatch> getDispatchList(Dispatch dispatch);
 
     List<DispatchSublist> getDispatchLists(Dispatch dispatch1);
+
+    void updAnomaly(@Param("id") String id);
+
+    Dispatch getDispatchs(Dispatch dispatch);
+
+    void updArrivalTime(Dispatch dispatch);
 }

+ 7 - 0
src/main/java/com/model/service/ClientService.java

@@ -6,4 +6,11 @@ import com.model.result.CommRes;
 public interface ClientService {
     CommRes getClient(Client client);
 
+    CommRes addClient(Client client);
+
+    CommRes delClient(Client client);
+
+    CommRes updClient(Client client);
+
+    CommRes getClientList(Client client);
 }

+ 4 - 0
src/main/java/com/model/service/DispatchService.java

@@ -12,4 +12,8 @@ public interface DispatchService {
     CommRes updDispatch(Dispatch dispatch);
 
     CommRes getDispatchList(Dispatch dispatch);
+
+    CommRes updAnomaly(String id);
+
+    CommRes updArrivalTime(Dispatch dispatch);
 }

+ 85 - 0
src/main/java/com/model/service/impl/ClientServiceImpl.java

@@ -1,6 +1,9 @@
 package com.model.service.impl;
 
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.model.entity.Client;
+import com.model.entity.Dispatch;
 import com.model.mapper.ClientMapper;
 import com.model.result.CommRes;
 import com.model.service.ClientService;
@@ -40,4 +43,86 @@ public class ClientServiceImpl implements ClientService {
         }
         return CommRes.success(clients);
     }
+
+    /**
+     * @Description: 添加客户信息
+     * @Param: Client
+     * @return: CommRes
+     * @Author: XiaoChen
+     * @Date: 2023/4/24
+     */
+    @Override
+    public CommRes addClient(Client client) {
+        try {
+            Client client1 =  clientMapper.getClient(client);
+            if (client1 != null){
+                return CommRes.fail("客户已存在");
+            }
+            clientMapper.addClient(client);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return CommRes.success(null);
+    }
+
+    /**
+     * @Description: 删除客户信息
+     * @Param:
+     * @return:
+     * @Author: XiaoChen
+     * @Date: 2023/4/24
+     */
+    @Override
+    public CommRes delClient(Client client) {
+        try {
+            Client client1 = clientMapper.getClients(client);
+            if (client1 == null){
+                return CommRes.fail("未找到该客户信息");
+            }
+            clientMapper.delClient(client);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return CommRes.success(null);
+    }
+
+    /**
+     * @Description: 修改客户信息
+     * @Param: client
+     * @return: CommRes
+     * @Author: XiaoChen
+     * @Date: 2023/4/24
+     */
+    @Override
+    public CommRes updClient(Client client) {
+        try {
+            Client client1 = clientMapper.getClient(client);
+            if (client1 == null){
+                return CommRes.fail("未找到该客户信息");
+            }
+            clientMapper.updClient(client);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return CommRes.success(null);
+    }
+
+    /**
+     * @Description: 查询客户表列表
+     * @Param:   client
+     * @return:   CommRes
+     * @Author: XiaoChen
+     * @Date: 2023/4/24
+     */
+    @Override
+    public CommRes getClientList(Client client) {
+        PageInfo<Client> pageInfo = null ;
+        try {
+            PageHelper.startPage(client.getPage(),client.getLimit());
+            pageInfo = new PageInfo<>(clientMapper.getClientList(client));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return CommRes.success(pageInfo);
+    }
 }

+ 39 - 0
src/main/java/com/model/service/impl/DispatchServiceImpl.java

@@ -90,6 +90,7 @@ public class DispatchServiceImpl implements DispatchService {
 //                    //修改
 //                    clientMapper.updClient(client);
 //                }
+
                 return CommRes.success(null);
             }else {
                 return CommRes.fail("未查询到发货单信息");
@@ -123,4 +124,42 @@ public class DispatchServiceImpl implements DispatchService {
         return CommRes.success(pageInfo);
     }
 
+    /**
+     * @Description: 更改异常状态
+     * @Param: id
+     * @return: CommRes
+     * @Author: XiaoChen
+     * @Date: 2023/4/24
+     */
+    @Override
+    public CommRes updAnomaly(String id) {
+        try {
+            dispatchMapper.updAnomaly(id);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return CommRes.success(null);
+    }
+
+    /**
+     * @Description: 更改预计到达时间
+     * @Param: id
+     * @return: CommRes
+     * @Author: XiaoChen
+     * @Date: 2023/4/24
+     */
+    @Override
+    public CommRes updArrivalTime(Dispatch dispatch) {
+        try {
+            Dispatch dispatch1 = dispatchMapper.getDispatchs(dispatch);
+            if (dispatch1 != null && dispatch1.getStates().equals("1")){
+                return CommRes.fail("已收货,不能修改");
+            }
+            dispatchMapper.updArrivalTime(dispatch);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return CommRes.success(null);
+    }
+
 }

+ 31 - 2
src/main/resources/mapper/ClientMapper.xml

@@ -4,13 +4,16 @@
 <mapper namespace="com.model.mapper.ClientMapper">
     <!--添加-->
     <insert id="addClient">
-        insert into sg_client(code,days) values(#{code},#{days})
+        insert into sg_client(code,days,name) values(#{code},#{days},#{name})
     </insert>
     <!--修改-->
     <update id="updClient">
         update sg_client set days = #{days} where code = #{code}
     </update>
-
+    <!--删除-->
+    <delete id="delClient">
+        delete from sg_client  where id = #{id}
+    </delete>
     <!--根据客户编号查询天数-->
     <select id="getClient" resultType="com.model.entity.Client">
         select
@@ -19,4 +22,30 @@
            days
         from sg_client where code = #{code}
     </select>
+    <!--查询客户表列表-->
+    <select id="getClientList" resultType="com.model.entity.Client">
+        select
+            a.id,
+            a.code,
+            a.days,
+            a.name
+        from sg_client a
+        <trim prefix="WHERE" prefixOverrides="and |or">
+            <if test="code != null and code != ''">
+                and a.code = #{code}
+            </if>
+            <if test="name != null and name != ''">
+                and a.name like CONCAT(CONCAT('%', #{name}), '%')
+            </if>
+        </trim>
+        order by a.id desc
+    </select>
+    <!--查询是否重复-->
+    <select id="getClients" resultType="com.model.entity.Client">
+        select
+            id,
+            code,
+            days
+        from sg_client where id = #{id}
+    </select>
 </mapper>

+ 27 - 0
src/main/resources/mapper/DispatchMapper.xml

@@ -21,6 +21,14 @@
         update sg_dispatch set anomaly = #{anomaly} , note = #{note} , imgs = #{imgs} ,final_time = now() ,states = '1'
         where truck_no = #{truckNo} and customer = #{customer}
     </update>
+    <!--修改异常状态-->
+    <update id="updAnomaly">
+        update sg_dispatch set anomaly = '0' , note = '' where id = #{id}
+    </update>
+    <!--修改预计到达时间-->
+    <update id="updArrivalTime">
+        update sg_dispatch set arrival_time = #{arrivalTime} where id = #{id}
+    </update>
     <!--查询是否有重复数据-->
     <select id="getDispatch" resultType="com.model.entity.Dispatch">
         select id,
@@ -78,6 +86,9 @@
             <if test="states != null and states != ''">
                 and a.states = #{states}
             </if>
+            <if test="arrivalTime != null and arrivalTime != ''">
+                and a.arrival_time = #{arrivalTime}
+            </if>
         </trim>
         order by a.id desc
     </select>
@@ -91,4 +102,20 @@
             uuid
         from sg_dispatch_z where uuid = #{uuid}
     </select>
+    <!--查询是否已收货-->
+    <select id="getDispatchs" resultType="com.model.entity.Dispatch">
+        select id,
+               truck_no,
+               customer,
+               scrq,
+               arrival_time,
+               anomaly,
+               note,
+               imgs,
+               final_time,
+               uuid,
+               states
+        from sg_dispatch where id = #{id}
+    </select>
+
 </mapper>

+ 2 - 1
src/main/resources/mapper/UserMapper.xml

@@ -17,7 +17,8 @@
         select
              id,
              user_name,
-             password
+             password,
+             power
         from sg_user
         where user_name = #{userName} and password = #{password}
     </select>