|
@@ -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 {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|