caolong hace 4 años
padre
commit
5a9e05a2e0

+ 298 - 51
src/main/java/com/yc/education/controller/PurchasingController.java

@@ -2,14 +2,12 @@ package com.yc.education.controller;
 
 import com.yc.education.mapper.TbSerializeMapper;
 import com.yc.education.model.*;
-import com.yc.education.service.IDemandOrderService;
-import com.yc.education.service.IDemandService;
-import com.yc.education.service.IProviderPurchaseLibraryService;
-import com.yc.education.service.IServiceCategoryService;
+import com.yc.education.service.*;
 import com.yc.education.util.*;
 import com.yc.education.vo.CarCommercialVo;
 import com.yc.education.vo.purchasingVo.ListBrandVo;
 import com.yc.education.vo.purchasingVo.PjVo;
+import com.yc.education.vo.purchasingVo.QualityVo;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
@@ -18,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.*;
+import java.lang.reflect.Array;
 import java.util.*;
 
 /**
@@ -50,6 +49,9 @@ public class PurchasingController extends BaseController {
     @Autowired
     private TbSerializeMapper tbSerializeMapper;
 
+    @Autowired
+    private IQualityService iQualityService;
+
     /**
      * 发布采购首页
      *
@@ -101,7 +103,6 @@ public class PurchasingController extends BaseController {
         return new ApiMessage<>(false, AppConst.FAIL_CODE, AppConst.FAIL_MSG);
     }
 
-
     /**
      * 通过图片识别的VIN码查询
      *
@@ -157,24 +158,24 @@ public class PurchasingController extends BaseController {
         try {
 
             TbSerialize serializeData = tbSerializeMapper.getOneByUKey("purchasingListBrand采购车型品牌");
-            if(serializeData != null){
+            if (serializeData != null) {
                 ListBrandVo vo = (ListBrandVo) CommonUtil.getSerialize(serializeData.getValue( ));
                 return new ApiMessage<>(true, AppConst.SUCCESS_CODE, AppConst.SUCCESS_GET_MSG, vo);
             }
 
             ListBrandVo vo = new ListBrandVo( );
-            List< ProviderPurchaseLibrary > firstLetter = iProviderPurchaseLibraryService.listFirstLetter();
+            List< ProviderPurchaseLibrary > firstLetter = iProviderPurchaseLibraryService.listFirstLetter( );
             List< ProviderPurchaseLibrary > brandList = iProviderPurchaseLibraryService.listBrand( );
             ArrayList< ListBrandVo.InnerListBrand > voList = new ArrayList<>( );
             for (ProviderPurchaseLibrary letter : firstLetter) {
                 ListBrandVo.InnerListBrand listBrandVo = vo.new InnerListBrand( );
-                listBrandVo.setFirstLetter(letter.getFirstLetter());
+                listBrandVo.setFirstLetter(letter.getFirstLetter( ));
                 ArrayList< ListBrandVo.InnerListCarType > list = new ArrayList<>( );
                 for (ProviderPurchaseLibrary brand : brandList) {
-                    if(letter.getFirstLetter().equals(brand.getFirstLetter())){
+                    if (letter.getFirstLetter( ).equals(brand.getFirstLetter( ))) {
                         ListBrandVo.InnerListCarType innerListCarType = vo.new InnerListCarType( );
                         innerListCarType.setPurchaseLibrary(brand);
-                        List< ProviderPurchaseLibrary > carTypeList = iProviderPurchaseLibraryService.listCarType(brand.getBrand());
+                        List< ProviderPurchaseLibrary > carTypeList = iProviderPurchaseLibraryService.listCarType(brand.getBrand( ));
                         innerListCarType.setList(carTypeList);
                         list.add(innerListCarType);
                     }
@@ -231,7 +232,6 @@ public class PurchasingController extends BaseController {
         return new ApiMessage<>(false, AppConst.FAIL_CODE, AppConst.FAIL_MSG);
     }
 
-
     /**
      * 按条件搜索车信息
      *
@@ -265,15 +265,101 @@ public class PurchasingController extends BaseController {
         return new ApiMessage<>(false, AppConst.FAIL_CODE, AppConst.FAIL_MSG);
     }
 
+    /**
+     * 回显 查看采购信息
+     *
+     * @param token
+     * @param category
+     * @param vin
+     * @param levelId
+     * @param saleName
+     * @return
+     */
+    @RequestMapping(value = "showDemand", method = {RequestMethod.GET, RequestMethod.POST}, produces = {"application/json;charset=UTF-8"})
+    public ApiMessage< Object > showDemand(String token, String category, String vin, String levelId, String saleName) {
+        if (StringUtils.isBlank(token)) return new ApiMessage<>(false, AppConst.FAIL_CODE, "token为空");
+        if (StringUtils.isBlank(category)) return new ApiMessage<>(false, AppConst.FAIL_CODE, "采购类型为空");
+        Map< String, Object > map = new HashMap<>( );
+        try {
+
+            List< Quality > qualities = iQualityService.listAllQualityInfo( );
+            List< QualityVo > qualityVos = new ArrayList<>( );
+            for (Quality quality : qualities) {
+                QualityVo vo = new QualityVo( );
+                vo.setName(quality.getQualityName( ));
+                vo.setId(quality.getId( ) + "");
+                qualityVos.add(vo);
+            }
+            map.put("demand", "");
+            map.put("demandOrder", "");
+            map.put("quality", qualityVos);
+            UserInfo userInfo = getUserInfo(token);
+            Demand demand = iDemandService.getOneByStatus(userInfo.getId( ), "0", category);
+            if (demand != null) {
+                map.put("demand", demand);
+                //给选中状态
+                if (StringUtils.isNotBlank(demand.getQuality( ))) {
+                    List< String > stringList = Arrays.asList(demand.getQuality( ).split(","));
+                    for (QualityVo qualityVo : qualityVos) {
+                        if (stringList.contains(qualityVo.getId( ))) {
+                            qualityVo.setActive("1");
+                        }
+                    }
+                    map.put("quality", qualityVos);
+                }
+
+
+                List< DemandOrder > demandOrderList = iDemandOrderService.listByDemandId(demand.getId( ));
+                if (CollectionUtils.isNotEmpty(demandOrderList)) {
+                    for (DemandOrder demandOrder : demandOrderList) {
+                        //填写 封面图 和 封面图数量
+                        if(StringUtils.isNotBlank(demandOrder.getImage())){
+                            List< String > strImg = Arrays.asList(demandOrder.getImage( ).split(","));
+                            demandOrder.setFaceImg(strImg.get(0)); //封面图 默认是第一张
+                            demandOrder.setImageAmount(strImg.size()); //一共几张图片
+                        }
+                    }
+                    map.put("demandOrder", demandOrderList);
+                }
+                return new ApiMessage<>(true, AppConst.SUCCESS_GET_MSG, AppConst.SUCCESS_GET_MSG, map);
+            } else {
+                Demand dmd = new Demand( );
+                dmd.setUserId(userInfo.getId( ));
+                dmd.setStatus("0");
+                dmd.setCategory(category);
+                if (StringUtils.isNotBlank(vin)) dmd.setVin(vin);
+                if (StringUtils.isNotBlank(levelId)) dmd.setLevelId(levelId);
+                if (StringUtils.isNotBlank(saleName)) dmd.setSaleName(saleName);
+                iDemandService.insertUseGeneratedKeys(dmd);
+                Demand d = iDemandService.getOneByStatus(userInfo.getId( ), "0", category);
+                if (d != null) {
+                    map.put("demand", d);
+                    List< DemandOrder > demandOrderList = iDemandOrderService.listByDemandId(d.getId( ));
+                    if (CollectionUtils.isNotEmpty(demandOrderList)) {
+                        map.put("demandOrder", demandOrderList);
+                    }
+                    return new ApiMessage<>(true, AppConst.SUCCESS_GET_MSG, AppConst.SUCCESS_GET_MSG, map);
+                } else {
+                    return new ApiMessage<>(false, AppConst.FAIL_CODE, "暂无数据", map);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace( );
+        }
+        return new ApiMessage<>(false, AppConst.FAIL_CODE, AppConst.FAIL_MSG, map);
+    }
+
     /**
      * 添加配件
      *
+     * @param token
      * @param category 1汽车配件2汽车改装3汽保设备与工具4商用车
      * @return
      */
     @RequestMapping(value = "listPj", method = {RequestMethod.GET, RequestMethod.POST}, produces = {"application/json;charset=UTF-8"})
-    public ApiMessage< Object > listPj(String category) {
-        if (StringUtils.isBlank(category)) category = "1";
+    public ApiMessage< Object > listPj(String token, String category) {
+        if (StringUtils.isBlank(token)) return new ApiMessage<>(false, AppConst.FAIL_CODE, "token为空");
+        if (StringUtils.isBlank(category)) return new ApiMessage<>(false, AppConst.FAIL_CODE, "采购类型为空");
         try {
             PjVo vo;
             List< ServiceCategory > serviceCategoryList = null;
@@ -302,6 +388,19 @@ public class PurchasingController extends BaseController {
                     list.add(inner);
                 }
                 vo.setList(list);
+
+                UserInfo userInfo = getUserInfo(token);
+                Demand demand = iDemandService.getOneByStatus(userInfo.getId( ), "0", category);
+                if (demand != null) {
+                    List< DemandOrder > demandOrderList = iDemandOrderService.listByDemandId(demand.getId( ));
+                    if (CollectionUtils.isNotEmpty(demandOrderList)) {
+                        List< String > objects = new ArrayList<>( );
+                        for (DemandOrder demandOrder : demandOrderList) {
+                            objects.add(demandOrder.getName( ));
+                        }
+                        vo.setChoose(objects);
+                    }
+                }
                 return new ApiMessage<>(true, AppConst.SUCCESS_CODE, AppConst.SUCCESS_GET_MSG, vo);
             } else {
                 return new ApiMessage<>(false, AppConst.FAIL_CODE, "暂无数据", "");
@@ -312,18 +411,164 @@ public class PurchasingController extends BaseController {
         return new ApiMessage<>(false, AppConst.FAIL_CODE, AppConst.FAIL_MSG);
     }
 
+    /**
+     * 点击'+-' 更新 采购单 数量
+     * @param id 主键id   不为空
+     * @param amount 数量 不为空
+     * @return
+     */
+    @RequestMapping(value = "demandOrderAmount", method = {RequestMethod.GET, RequestMethod.POST}, produces = {"application/json;charset=UTF-8"})
+    public ApiMessage< Object > demandOrderAmount(Long id, Integer amount) {
+        if(id == null) return new ApiMessage<>(false,AppConst.FAIL_CODE,"id为空");
+        if(amount == null) return new ApiMessage<>(false,AppConst.FAIL_CODE,"数量不为空");
+        if(amount <= 0) return new ApiMessage<>(false,AppConst.FAIL_CODE,"设置数量必须大于等于1");
+        try {
+            DemandOrder demandOrder = iDemandOrderService.getOneByKey(id);
+            demandOrder.setAmount(amount);
+            int row = iDemandOrderService.update(demandOrder);
+            if(row > 0){
+                return new ApiMessage<>(true,AppConst.SUCCESS_GET_MSG,AppConst.SUCCESS_UPDATE_MSG);
+            }else {
+                return new ApiMessage<>(false,AppConst.FAIL_CODE,"更新失败");
+            }
+        } catch (Exception e) {
+            log.error("点击'+-' 更新 采购单 数量 error",e);
+        }
+        return new ApiMessage<>(false, AppConst.FAIL_CODE, AppConst.FAIL_MSG);
+    }
+
+    /**
+     * 更新 质量信息
+     * @param id
+     * @param ids
+     * @return
+     */
+    @RequestMapping(value = "demandQuality", method = {RequestMethod.GET, RequestMethod.POST}, produces = {"application/json;charset=UTF-8"})
+    public ApiMessage< Object > demandQuality(Long id, String ids) {
+        if(id == null) return new ApiMessage<>(false,AppConst.FAIL_CODE,"id为空");
+        if(StringUtils.isBlank(ids)) return new ApiMessage<>(false,AppConst.FAIL_CODE,"数量不为空");
+        try {
+            Demand demand = iDemandService.getOneByKey(id);
+            demand.setQuality(ids);
+            int row = iDemandService.update(demand);
+            if(row > 0){
+                return new ApiMessage<>(true,AppConst.SUCCESS_GET_MSG,AppConst.SUCCESS_UPDATE_MSG);
+            }else {
+                return new ApiMessage<>(false,AppConst.FAIL_CODE,"更新失败");
+            }
+        } catch (Exception e) {
+            log.error(" 更新 质量信息  error",e);
+        }
+        return new ApiMessage<>(false, AppConst.FAIL_CODE, AppConst.FAIL_MSG);
+    }
+
+    /**
+     * 点击 采购列表 时 触发
+     * 添加  采购单
+     *
+     * @param token
+     * @param category
+     * @param name
+     * @return
+     */
+    @RequestMapping(value = "saveDemandOrder", method = {RequestMethod.GET, RequestMethod.POST}, produces = {"application/json;charset=UTF-8"})
+    public ApiMessage< Object > saveDemandOrder(String token, String category, String name) {
+        if (StringUtils.isBlank(token)) return new ApiMessage<>(false, AppConst.FAIL_CODE, "token为空");
+        if (StringUtils.isBlank(category)) return new ApiMessage<>(false, AppConst.FAIL_CODE, "采购类型为空");
+        if (StringUtils.isBlank(name)) return new ApiMessage<>(false, AppConst.FAIL_CODE, "请选择采购信息");
+        try {
+            List< String > nameList = Arrays.asList(name.split(","));
+            UserInfo userInfo = getUserInfo(token);
+            Demand demand = iDemandService.getOneByStatus(userInfo.getId( ), "0", category);
+            if (demand != null) {
+                List< DemandOrder > demandOrderList = iDemandOrderService.listByDemandId(demand.getId( ));
+                //如果等空 就添加操作  不等空就 判断哪个不存在   删除操作
+                if (CollectionUtils.isNotEmpty(demandOrderList)) {
+                    List< String > names = new ArrayList<>( );
+                    if (nameList.size( ) > demandOrderList.size( )) {
+                        List< String > strList = new ArrayList<>( );
+                        for (DemandOrder demandOrder : demandOrderList) {
+                            strList.add(demandOrder.getName( ));
+                        }
+                        for (String s : nameList) {
+                            if (strList.contains(s)) {
+                                continue;
+                            } else {
+                                names.add(s);
+                            }
+                        }
+                    } else {
+                        for (DemandOrder demandOrder : demandOrderList) {
+                            if (nameList.contains(demandOrder.getName( ))) {
+                                continue;
+                            } else {
+                                names.add(demandOrder.getName( ));
+                            }
+                        }
+                    }
+                    if (CollectionUtils.isNotEmpty(names)) {
+                        for (String nm : names) {
+                            DemandOrder demandOrder = iDemandOrderService.listByDemandIdName(demand.getId( ), nm);
+                            if (demandOrder != null) {
+                                iDemandOrderService.deleteByKey(demandOrder.getId( ));
+                            } else {
+                                DemandOrder ddOrder = new DemandOrder( );
+                                ddOrder.setDemandId(demand.getId( ));
+                                ddOrder.setAmount(1);
+                                ddOrder.setName(nm);
+                                ddOrder.setRemark("");
+                                iDemandOrderService.insert(ddOrder);
+                            }
+                        }
+                    }
+                } else {
+                    List< DemandOrder > dList = new ArrayList<>( );
+                    for (String s : nameList) {
+                        DemandOrder demandOrder = new DemandOrder( );
+                        demandOrder.setDemandId(demand.getId( ));
+                        demandOrder.setAmount(1);
+                        demandOrder.setName(s);
+                        demandOrder.setRemark("");
+                        dList.add(demandOrder);
+                    }
+                    iDemandOrderService.insertList(dList);
+                }
+                return new ApiMessage<>(true, AppConst.SUCCESS_GET_MSG, AppConst.SUCCESS_GET_MSG);
+            } else {
+                Demand demands = new Demand( );
+                demands.setUserId(userInfo.getId( ));
+                demands.setStatus("0");
+                demands.setCategory(category);
+                iDemandService.insertUseGeneratedKeys(demands);
+                List< DemandOrder > dList = new ArrayList<>( );
+                for (String s : nameList) {
+                    DemandOrder demandOrder = new DemandOrder( );
+                    demandOrder.setDemandId(demand.getId( ));
+                    demandOrder.setAmount(1);
+                    demandOrder.setName(s);
+                    demandOrder.setRemark("");
+                    dList.add(demandOrder);
+                }
+                iDemandOrderService.insertList(dList);
+                return new ApiMessage<>(true, AppConst.SUCCESS_GET_MSG, AppConst.SUCCESS_GET_MSG);
+            }
+        } catch (Exception e) {
+            e.printStackTrace( );
+        }
+        return new ApiMessage<>(false, AppConst.FAIL_CODE, AppConst.FAIL_MSG);
+    }
 
     /**
      * 图片上传
      *
-     * @param image 图片
+     * @param img 图片
      * @return
      */
     @RequestMapping(value = "imageUpload", method = {RequestMethod.GET, RequestMethod.POST}, produces = {"application/json;charset=UTF-8"})
-    public ApiMessage< Object > imageUpload(MultipartFile image) {
-        if (image == null) return new ApiMessage<>(false, AppConst.FAIL_CODE, "图片为空");
+    public ApiMessage< Object > imageUpload(MultipartFile img) {
+        if (img == null) return new ApiMessage<>(false, AppConst.FAIL_CODE, "图片为空");
         try {
-            String relativePath = FileUploadUtils.getRelativePath(image, CommonCons.DEMAND_PICTURE);
+            String relativePath = FileUploadUtils.getRelativePath(img, CommonCons.DEMAND_PICTURE);
             if (relativePath.length( ) > 0) {
                 return new ApiMessage<>(true, AppConst.SUCCESS_CODE, AppConst.PICTURE_UPLOAD_SUCCESS, relativePath);
             } else {
@@ -335,49 +580,44 @@ public class PurchasingController extends BaseController {
         return new ApiMessage<>(false, AppConst.FAIL_CODE, AppConst.FAIL_MSG);
     }
 
+    /**
+     * 回显 采购单
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "showPj", method = {RequestMethod.GET, RequestMethod.POST}, produces = {"application/json;charset=UTF-8"})
+    public ApiMessage< Object > showPj(Long id){
+        try {
+            DemandOrder oneByKey = iDemandOrderService.getOneByKey(id);
+            return new ApiMessage<>(true, AppConst.SUCCESS_CODE, AppConst.SUCCESS_GET_MSG, oneByKey);
+        } catch (Exception e) {
+            e.printStackTrace( );
+        }
+        return new ApiMessage<>(false, AppConst.FAIL_CODE, AppConst.FAIL_MSG);
+    }
 
     /**
      * 添加配件
-     *
      * @param token
-     * @param name
-     * @param image
+     * @param id
+     * @param img
      * @param remark
      * @return
      */
     @RequestMapping(value = "addPj", method = {RequestMethod.GET, RequestMethod.POST}, produces = {"application/json;charset=UTF-8"})
-    public ApiMessage< Object > addPj(String token, String name, String image, String remark) {
+    public ApiMessage< Object > addPj(String token,Long id, String img, String remark) {
         if (StringUtils.isBlank(token)) return new ApiMessage<>(false, AppConst.FAIL_CODE, "token为空");
-        if (StringUtils.isBlank(image)) return new ApiMessage<>(false, AppConst.FAIL_CODE, "图片为空");
+        if (StringUtils.isBlank(img)) return new ApiMessage<>(false, AppConst.FAIL_CODE, "图片为空");
         try {
             UserInfo userInfo = getUserInfo(token);
             if (userInfo == null) return new ApiMessage<>(false, AppConst.FAIL_CODE, "没有找到该用户信息");
 
-            int row;
-            Demand one = iDemandService.getOneByStatus(userInfo.getId( ), "0");
-            if (one != null) {
-                DemandOrder demandOrder = new DemandOrder( );
-                demandOrder.setRemandId(one.getId( ));
-                demandOrder.setAmount(1);
-                demandOrder.setImage(image);
-                demandOrder.setName(name);
-                demandOrder.setRemark(remark);
-                row = iDemandOrderService.insert(demandOrder);
-            } else {
-                Demand demand = new Demand( );
-                demand.setUserId(userInfo.getId( ));
-                demand.setStatus("0");
-                iDemandService.insertUseGeneratedKeys(demand);
-                DemandOrder demandOrder = new DemandOrder( );
-                demandOrder.setRemandId(demand.getId( ));
-                demandOrder.setAmount(1);
-                demandOrder.setImage(image);
-                demandOrder.setName(name);
-                demandOrder.setRemark(remark);
-                row = iDemandOrderService.insert(demandOrder);
-            }
+            DemandOrder demandOrder = iDemandOrderService.getOneByKey(id);
+            demandOrder.setRemark(remark);
+            demandOrder.setImage(img);
+            int row = iDemandOrderService.update(demandOrder);
             if (row > 0) {
-                return new ApiMessage<>(true, AppConst.SUCCESS_CODE, AppConst.SUCCESS_SAVE_MSG, row);
+                return new ApiMessage<>(true, AppConst.SUCCESS_CODE, AppConst.SUCCESS_UPDATE_MSG, row);
             } else {
                 return new ApiMessage<>(false, AppConst.FAIL_CODE, "保存失败", row);
             }
@@ -387,11 +627,19 @@ public class PurchasingController extends BaseController {
         return new ApiMessage<>(false, AppConst.FAIL_CODE, AppConst.FAIL_MSG);
     }
 
-
     /**
      * 发布采购  发布
      *
-     * @param demand
+     * @param demand token
+     *               userId 用户id
+     *               category 1汽车配件2用品改装3汽保设备与工具4商用车
+     *               levelId 力洋ID
+     *               saleName  销售版本
+     *               quality  品质 逗号隔开
+     *               isInvoice 是否开发票(0否1是)
+     *               brandName 品牌名称
+     *               status 是否发布(0否1是)
+     *               publishDate 发布时间
      * @return
      */
     @RequestMapping(value = "publish", method = {RequestMethod.GET, RequestMethod.POST}, produces = {"application/json;charset=UTF-8"})
@@ -400,10 +648,10 @@ public class PurchasingController extends BaseController {
         try {
             String token = demand.getToken( );
             UserInfo userInfo = getUserInfo(token);
-            Demand one = iDemandService.getOneByStatus(userInfo.getId( ), "0");
+            Demand one = iDemandService.getOneByStatus(userInfo.getId( ), "0", demand.getCategory( ));
             if (one != null) {
                 one.setStatus("1");
-                one.setPublishDate(new Date());
+                one.setPublishDate(new Date( ));
                 int row = iDemandService.update(one);
                 if (row > 0) {
                     return new ApiMessage<>(true, AppConst.SUCCESS_CODE, AppConst.SUCCESS_UPDATE_MSG, row);
@@ -420,5 +668,4 @@ public class PurchasingController extends BaseController {
     }
 
 
-
 }

+ 1 - 1
src/main/java/com/yc/education/mapper/DemandMapper.java

@@ -12,6 +12,6 @@ public interface DemandMapper extends MyMapper<Demand> {
      * @param status
      * @return
      */
-    Demand getOneByStatus(@Param("userId") Long userId,@Param("status") String status);
+    Demand getOneByStatus(@Param("userId") Long userId,@Param("status") String status,@Param("category") String category);
 
 }

+ 24 - 0
src/main/java/com/yc/education/mapper/DemandOrderMapper.java

@@ -2,7 +2,31 @@ package com.yc.education.mapper;
 
 import com.yc.education.model.DemandOrder;
 import com.yc.education.util.MyMapper;
+import org.apache.ibatis.annotations.Param;
 import tk.mybatis.mapper.common.Mapper;
 
+import java.util.List;
+
 public interface DemandOrderMapper extends MyMapper<DemandOrder> {
+
+    /**
+     * 根据采购 信息 查看采购单 信息
+     * @param demandId
+     * @return
+     */
+    List< DemandOrder> listByDemandId(@Param("demandId") Long demandId);
+
+    /**
+     * 删除多个
+     * @param ids
+     */
+    int deleteByKeys(@Param("list") List< Long> ids);
+
+    /**
+     * 根据 采购信息 id和 名称  是否存在采购单
+     * @param demandId
+     * @param name
+     * @return
+     */
+    DemandOrder listByDemandIdName(@Param("demandId") Long demandId,@Param("name") String name);
 }

+ 13 - 0
src/main/java/com/yc/education/model/Demand.java

@@ -26,6 +26,11 @@ public class Demand {
      */
     private String category;
 
+    /**
+     * vin
+     */
+    private String vin;
+
     /**
      * 力洋ID
      */
@@ -268,4 +273,12 @@ public class Demand {
     public void setPublishDate(Date publishDate) {
         this.publishDate = publishDate;
     }
+
+    public String getVin( ) {
+        return vin;
+    }
+
+    public void setVin(String vin) {
+        this.vin = vin;
+    }
 }

+ 36 - 8
src/main/java/com/yc/education/model/DemandOrder.java

@@ -14,8 +14,8 @@ public class DemandOrder {
     /**
      * 发布求购 订单id
      */
-    @Column(name = "remand_id")
-    private Long remandId;
+    @Column(name = "demand_id")
+    private Long demandId;
 
     /**
      * 类型名称
@@ -27,6 +27,18 @@ public class DemandOrder {
      */
     private String image;
 
+    /**
+     * 封面图
+     */
+    @Transient
+    private String faceImg;
+
+    /**
+     * 封面图 数量
+     */
+    @Transient
+    private Integer imageAmount = 0;
+
     /**
      * 个数
      */
@@ -58,19 +70,19 @@ public class DemandOrder {
     /**
      * 获取发布求购 订单id
      *
-     * @return remand_id - 发布求购 订单id
+     * @return demand_id - 发布求购 订单id
      */
-    public Long getRemandId() {
-        return remandId;
+    public Long getDemandId() {
+        return demandId;
     }
 
     /**
      * 设置发布求购 订单id
      *
-     * @param remandId 发布求购 订单id
+     * @param demandId 发布求购 订单id
      */
-    public void setRemandId(Long remandId) {
-        this.remandId = remandId;
+    public void setDemandId(Long demandId) {
+        this.demandId = demandId;
     }
 
     /**
@@ -144,4 +156,20 @@ public class DemandOrder {
     public void setRemark(String remark) {
         this.remark = remark;
     }
+
+    public String getFaceImg( ) {
+        return faceImg;
+    }
+
+    public void setFaceImg(String faceImg) {
+        this.faceImg = faceImg;
+    }
+
+    public Integer getImageAmount( ) {
+        return imageAmount;
+    }
+
+    public void setImageAmount(Integer imageAmount) {
+        this.imageAmount = imageAmount;
+    }
 }

+ 51 - 0
src/main/java/com/yc/education/service/IDemandOrderService.java

@@ -2,6 +2,8 @@ package com.yc.education.service;
 
 import com.yc.education.model.DemandOrder;
 
+import java.util.List;
+
 /**
  * @ProjectName: nvrnetwork
  * @Package: com.yc.education.service
@@ -18,4 +20,53 @@ public interface IDemandOrderService {
      * @return
      */
     int insert(DemandOrder demandOrder);
+
+    /**
+     * 根据 采购表 查看采购单信息
+     * @param demandId
+     * @return
+     */
+    List< DemandOrder> listByDemandId(Long demandId);
+
+    /**
+     * 添加集合
+     * @param dList
+     * @return
+     */
+    int insertList(List< DemandOrder> dList);
+
+    /**
+     * 根据id删除信息
+     * @param id
+     * @return
+     */
+    int deleteByKey(Long id);
+
+    /**
+     * 删除多个
+     * @param ids
+     */
+    int deleteByKeys(List< Long> ids);
+
+    /**
+     * 根据 采购信息 id和 名称  是否存在采购单
+     * @param demandId
+     * @param name
+     * @return
+     */
+    DemandOrder listByDemandIdName(Long demandId, String name);
+
+    /**
+     *
+     * @param id
+     * @return
+     */
+    DemandOrder getOneByKey(Long id);
+
+    /**
+     * 更新 采购单 信息
+     * @param demandOrder
+     * @return
+     */
+    int update(DemandOrder demandOrder);
 }

+ 9 - 1
src/main/java/com/yc/education/service/IDemandService.java

@@ -30,9 +30,10 @@ public interface IDemandService {
      * 查询该是否发布  默认否  只允许
      * @param userId
      * @param status
+     * @param category
      * @return
      */
-    Demand getOneByStatus(Long userId, String status);
+    Demand getOneByStatus(Long userId, String status,String category);
 
     /**
      * 修改
@@ -40,4 +41,11 @@ public interface IDemandService {
      * @return
      */
     int update(Demand demand);
+
+    /**
+     * 查询 采购信息
+     * @param id
+     * @return
+     */
+    Demand getOneByKey(Long id);
 }

+ 96 - 0
src/main/java/com/yc/education/service/impl/DemandOrderServiceImpl.java

@@ -7,6 +7,8 @@ import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @ProjectName: nvrnetwork
  * @Package: com.yc.education.service.impl
@@ -39,4 +41,98 @@ public class DemandOrderServiceImpl implements IDemandOrderService {
         }
         return 0;
     }
+
+    /**
+     * 根据 采购表 查看采购单信息
+     *
+     * @param demandId
+     * @return
+     */
+    @Override
+    public List< DemandOrder > listByDemandId(Long demandId) {
+        try {
+            return demandOrderMapper.listByDemandId(demandId);
+        } catch (Exception e) {
+            e.printStackTrace( );
+        }
+        return null;
+    }
+
+    /**
+     * 添加集合
+     *
+     * @param dList
+     * @return
+     */
+    @Override
+    public int insertList(List< DemandOrder > dList) {
+        try {
+            return demandOrderMapper.insertList(dList);
+        } catch (Exception e) {
+            e.printStackTrace( );
+        }
+        return 0;
+    }
+
+
+    @Override
+    public int deleteByKey(Long id) {
+        try {
+            return demandOrderMapper.deleteByPrimaryKey(id);
+        } catch (Exception e) {
+            e.printStackTrace( );
+        }
+        return 0;
+    }
+
+    /**
+     * 删除多个
+     * @param ids
+     */
+    @Override
+    public int deleteByKeys(List< Long > ids) {
+        try {
+            return demandOrderMapper.deleteByKeys(ids);
+        } catch (Exception e) {
+            e.printStackTrace( );
+        }
+        return 0;
+    }
+
+
+    /**
+     * 根据 采购信息 id和 名称  是否存在采购单
+     * @param demandId
+     * @param name
+     * @return
+     */
+    @Override
+    public DemandOrder listByDemandIdName(Long demandId, String name) {
+        try {
+            return demandOrderMapper.listByDemandIdName(demandId,name);
+        } catch (Exception e) {
+            e.printStackTrace( );
+        }
+        return null;
+    }
+
+    @Override
+    public DemandOrder getOneByKey(Long id) {
+        try {
+            return demandOrderMapper.selectByPrimaryKey(id);
+        } catch (Exception e) {
+            e.printStackTrace( );
+        }
+        return null;
+    }
+
+    @Override
+    public int update(DemandOrder demandOrder) {
+        try {
+            return demandOrderMapper.updateByPrimaryKeySelective(demandOrder);
+        } catch (Exception e) {
+            e.printStackTrace( );
+        }
+        return 0;
+    }
 }

+ 24 - 3
src/main/java/com/yc/education/service/impl/DemandServiceImpl.java

@@ -19,13 +19,14 @@ import org.springframework.stereotype.Service;
 @Service
 public class DemandServiceImpl implements IDemandService {
 
-    private Logger log = Logger.getLogger(DemandServiceImpl.class.getName());
+    private Logger log = Logger.getLogger(DemandServiceImpl.class.getName( ));
 
     @Autowired
     private DemandMapper demandMapper;
 
     /**
      * 保存
+     *
      * @param demand
      * @return
      */
@@ -41,6 +42,7 @@ public class DemandServiceImpl implements IDemandService {
 
     /**
      * 保存返回 主键id
+     *
      * @param demand
      * @return
      */
@@ -56,14 +58,16 @@ public class DemandServiceImpl implements IDemandService {
 
     /**
      * 查询该是否发布  默认否  只允许
+     *
      * @param userId
      * @param status
+     * @param category
      * @return
      */
     @Override
-    public Demand getOneByStatus(Long userId, String status) {
+    public Demand getOneByStatus(Long userId, String status, String category) {
         try {
-            return demandMapper.getOneByStatus(userId,status);
+            return demandMapper.getOneByStatus(userId, status, category);
         } catch (Exception e) {
             e.printStackTrace( );
         }
@@ -73,6 +77,7 @@ public class DemandServiceImpl implements IDemandService {
 
     /**
      * 修改
+     *
      * @param demand
      * @return
      */
@@ -85,4 +90,20 @@ public class DemandServiceImpl implements IDemandService {
         }
         return 0;
     }
+
+    /**
+     * 采购信息 id
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public Demand getOneByKey(Long id) {
+        try {
+            return demandMapper.selectByPrimaryKey(id);
+        } catch (Exception e) {
+            e.printStackTrace( );
+        }
+        return null;
+    }
 }

+ 10 - 0
src/main/java/com/yc/education/vo/purchasingVo/PjVo.java

@@ -13,6 +13,8 @@ import java.util.List;
  */
 public class PjVo {
 
+    private List choose;
+
     private List<InnerPj> list;
 
     public class InnerPj{
@@ -46,6 +48,14 @@ public class PjVo {
         }
     }
 
+    public List getChoose( ) {
+        return choose;
+    }
+
+    public void setChoose(List choose) {
+        this.choose = choose;
+    }
+
     public List< InnerPj > getList( ) {
         return list;
     }

+ 43 - 0
src/main/java/com/yc/education/vo/purchasingVo/QualityVo.java

@@ -0,0 +1,43 @@
+package com.yc.education.vo.purchasingVo;
+
+/**
+ * @ProjectName: nvrnetwork
+ * @Package: com.yc.education.vo.purchasingVo
+ * @ClassName: QualityVo
+ * @Author: Jzdsh
+ * @Description: 品质表 vo
+ * @Date: 2019/12/5 11:47
+ * @Version: 1.0
+ */
+public class QualityVo {
+
+    private String id;
+
+    private String active = "0";
+
+    private String name;
+
+    public String getId( ) {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getActive( ) {
+        return active;
+    }
+
+    public void setActive(String active) {
+        this.active = active;
+    }
+
+    public String getName( ) {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 4 - 0
src/main/resources/mapper/DemandMapper.xml

@@ -8,6 +8,7 @@
         <id column="id" property="id" jdbcType="BIGINT"/>
         <result column="user_id" property="userId" jdbcType="BIGINT"/>
         <result column="category" property="category" jdbcType="CHAR"/>
+        <result column="vin" property="vin" jdbcType="VARCHAR"/>
         <result column="level_id" property="levelId" jdbcType="VARCHAR"/>
         <result column="sale_name" property="saleName" jdbcType="VARCHAR"/>
         <result column="quality" property="quality" jdbcType="VARCHAR"/>
@@ -27,6 +28,9 @@
             <if test="status != null and status != ''">
                 and status = #{status}
             </if>
+            <if test="category != null and category != ''">
+                and category = #{category}
+            </if>
         </where>
         limit 0,1
     </select>

+ 19 - 1
src/main/resources/mapper/DemandOrderMapper.xml

@@ -6,10 +6,28 @@
       WARNING - @mbggenerated
     -->
     <id column="id" property="id" jdbcType="BIGINT" />
-    <result column="remand_id" property="remandId" jdbcType="BIGINT" />
+    <result column="demand_id" property="demandId" jdbcType="BIGINT" />
     <result column="name" property="name" jdbcType="VARCHAR" />
     <result column="image" property="image" jdbcType="VARCHAR" />
     <result column="amount" property="amount" jdbcType="INTEGER" />
     <result column="remark" property="remark" jdbcType="VARCHAR" />
   </resultMap>
+
+  <select id="listByDemandId" resultMap="BaseResultMap">
+    select * from demand_order where demand_id = #{demandId}
+  </select>
+
+  <!-- 批量更新方法,通过接收传进来的参数list进行循环着组装sql -->
+  <delete id="deleteByKeys" parameterType="java.util.List">
+    delete from demand_order
+    where id in
+    <foreach collection="list" open="(" separator="," close=")" item="id">
+      #{id}
+    </foreach>
+  </delete>
+
+  <select id="listByDemandIdName" resultMap="BaseResultMap">
+    select * from demand_order where demand_id = #{demandId} and name = #{name}
+  </select>
+
 </mapper>

+ 34 - 0
src/main/webapp/jk.txt

@@ -862,3 +862,37 @@ purchasing/listSaleName
      */
 purchasing/searchBrandCarTypeSaleName
 
+    /**
+     * 添加配件
+     *
+     * @param category 1汽车配件2汽车改装3汽保设备与工具4商用车
+     * @return
+     */
+purchasing/listPj
+
+    /**
+     * 图片上传
+     *
+     * @param image 图片
+     * @return
+     */
+purchasing/imageUpload
+
+    /**
+     * 添加配件
+     *
+     * @param token
+     * @param name
+     * @param image
+     * @param remark
+     * @return
+     */
+purchasing/addPj
+
+    /**
+     * 发布采购  发布
+     *
+     * @param demand
+     * @return
+     */
+purchasing/publish