zsw-farm
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

109 lines
4.0 KiB

package com.zsw.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.datasource.entities.MaterialExtend;
import com.zsw.erp.datasource.vo.MaterialExtendVo4List;
import com.zsw.erp.service.materialExtend.MaterialExtendService;
import com.zsw.base.R;
import com.zsw.erp.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = "/materialsExtend")
@Api(tags = {"商品价格扩展"})
public class MaterialExtendController {
private Logger logger = LoggerFactory.getLogger(MaterialExtendController.class);
@Resource
private MaterialExtendService materialExtendService;
@GetMapping(value = "/getDetailList")
@ApiOperation(value = "价格信息列表")
public R getDetailList(@RequestParam("materialId") Long materialId,
HttpServletRequest request)throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
List<MaterialExtendVo4List> dataList = new ArrayList<MaterialExtendVo4List>();
if(materialId!=0) {
dataList = materialExtendService.getDetailList(materialId);
}
JSONObject outer = new JSONObject();
outer.put("total", dataList.size());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (MaterialExtendVo4List md : dataList) {
JSONObject item = new JSONObject();
item.put("id", md.getId());
item.put("barCode", md.getBarCode());
item.put("commodityUnit", md.getCommodityUnit());
if(StringUtil.isNotEmpty(md.getSku())){
item.put("sku", md.getSku());
}
item.put("purchaseDecimal", md.getPurchaseDecimal());
item.put("commodityDecimal", md.getCommodityDecimal());
item.put("wholesaleDecimal", md.getWholesaleDecimal());
item.put("lowDecimal", md.getLowDecimal());
dataArray.add(item);
}
}
outer.put("rows", dataArray);
return R.success(outer);
}
/**
* 根据条码查询商品信息
* @param barCode
* @param request
* @return
* @throws Exception
*/
@GetMapping(value = "/getInfoByBarCode")
@ApiOperation(value = "根据条码查询商品信息")
public R getInfoByBarCode(@RequestParam("barCode") String barCode,
HttpServletRequest request)throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
MaterialExtend materialExtend = materialExtendService.getInfoByBarCode(barCode);
return R.success(materialExtend);
}
/**
* 校验条码是否存在
* @param id
* @param barCode
* @param request
* @return
* @throws Exception
*/
@GetMapping(value = "/checkIsBarCodeExist")
@ApiOperation(value = "校验条码是否存在")
public R checkIsBarCodeExist(@RequestParam("id") Long id,
@RequestParam("barCode") String barCode,
HttpServletRequest request)throws Exception {
Map<String, Object> map = new HashMap<>();
int exist = materialExtendService.checkIsBarCodeExist(id, barCode);
if(exist > 0) {
map.put("status", true);
} else {
map.put("status", false);
}
return R.success(map);
}
}