|
|
@ -35,13 +35,6 @@ import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import com.yxt.supervise.portal.api.brandinfo.BrandInfoVo; |
|
|
|
import com.yxt.supervise.portal.api.dictcommon.DictCommonDetailsVo; |
|
|
|
import com.yxt.supervise.portal.api.restrictedbrand.RestrictedBrand; |
|
|
|
import com.yxt.supervise.portal.api.restrictedcategory.*; |
|
|
|
import com.yxt.supervise.portal.biz.brandinfo.BrandInfoService; |
|
|
|
import com.yxt.supervise.portal.biz.dictcommon.DictCommonService; |
|
|
|
import com.yxt.supervise.portal.biz.restrictedbrand.RestrictedBrandService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell; |
|
|
@ -75,149 +68,149 @@ import java.util.Map; |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class RestrictedCategoryService extends MybatisBaseService<RestrictedCategoryMapper, RestrictedCategory> { |
|
|
|
@Resource |
|
|
|
private DictCommonService dictCommonService; |
|
|
|
@Resource |
|
|
|
private BrandInfoService brandInfoService; |
|
|
|
@Resource |
|
|
|
private RestrictedBrandService restrictedBrandService; |
|
|
|
private QueryWrapper<RestrictedCategory> createQueryWrapper(RestrictedCategoryQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<RestrictedCategory> qw = new QueryWrapper<>(); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<RestrictedCategoryVo> listPageVo(PagerQuery<RestrictedCategoryQuery> pq) { |
|
|
|
RestrictedCategoryQuery query = pq.getParams(); |
|
|
|
QueryWrapper<RestrictedCategory> qw = createQueryWrapper(query); |
|
|
|
IPage<RestrictedCategory> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<RestrictedCategoryVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<RestrictedCategoryVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(RestrictedCategoryDto dto){ |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
this.insertByDto(dto); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(RestrictedCategoryDto dto){ |
|
|
|
RestrictedCategory entity = new RestrictedCategory(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(RestrictedCategoryDto dto){ |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
RestrictedCategory entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public RestrictedCategoryDetailsVo fetchDetailsVoBySid(String sid){ |
|
|
|
RestrictedCategory entity = fetchBySid(sid); |
|
|
|
RestrictedCategoryDetailsVo vo = new RestrictedCategoryDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
public void readBrandPeriodSorXls1(InputStream is, String sid) { |
|
|
|
HSSFWorkbook hssfWorkbook = null; |
|
|
|
try { |
|
|
|
hssfWorkbook = new HSSFWorkbook(is); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
|
|
|
|
List<String> lisss=new ArrayList<>(); |
|
|
|
List<String> lisss2=new ArrayList<>(); |
|
|
|
HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(0); |
|
|
|
|
|
|
|
// 循环行Row
|
|
|
|
for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) { |
|
|
|
RestrictedCategory pr=new RestrictedCategory(); |
|
|
|
HSSFRow hssfRow = hssfSheet.getRow(rowNum); |
|
|
|
int i = 0; |
|
|
|
try{ |
|
|
|
if(rowNum>=1){ |
|
|
|
for ( ; i < hssfRow.getLastCellNum(); i++) { |
|
|
|
HSSFCell brandIdHSSFCell = hssfRow.getCell(i); |
|
|
|
if(brandIdHSSFCell!=null){ |
|
|
|
if (i == 1) {//编码
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
pr.setCategorys(value); |
|
|
|
} |
|
|
|
} |
|
|
|
/*if (i == 2) {//名称
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
pr.setBrands(value); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
}else{ |
|
|
|
System.err.println("rowNum="+rowNum+",i="+i+",value=null"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}catch(Exception e){ |
|
|
|
e.printStackTrace(); |
|
|
|
System.err.println("i="+i+",value=null"); |
|
|
|
} |
|
|
|
|
|
|
|
lisss.add(rowNum+""); |
|
|
|
baseMapper.insert(pr); |
|
|
|
log.info("productInformation:{}", JSONObject.toJSONString(pr)); |
|
|
|
} |
|
|
|
String x = JSON.toJSONString(lisss); |
|
|
|
System.out.println(x); |
|
|
|
String x1 = JSON.toJSONString(lisss2); |
|
|
|
System.out.println(x1); |
|
|
|
//return message;
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 商品限制判断 |
|
|
|
* @param categoryKey 品类键值 |
|
|
|
* @param brandCode 品牌代码 |
|
|
|
* @return ResultBean<ActivityCreateStepVo> |
|
|
|
* 2022/4/28 聂金毅 修改 |
|
|
|
*/ |
|
|
|
public Map<String,String> limitJudgement(String categoryKey, String brandCode) { |
|
|
|
Map<String,String> result=new HashMap<>(); |
|
|
|
RestrictedCategory r=baseMapper.selectByCategorys(categoryKey); |
|
|
|
result.put("success","1"); |
|
|
|
String msg=""; |
|
|
|
if(r==null ){ |
|
|
|
result.put("success","0"); |
|
|
|
DictCommonDetailsVo category = dictCommonService.fetchByKeyAndType(categoryKey, "category"); |
|
|
|
if(category==null){ |
|
|
|
msg=msg+categoryKey+"商品品类不存在;"; |
|
|
|
}else{ |
|
|
|
msg=msg+category.getDictValue()+"["+categoryKey+"]"+"不符合监管品类;"; |
|
|
|
} |
|
|
|
} |
|
|
|
RestrictedBrand r1=restrictedBrandService.selectByBrands(brandCode); |
|
|
|
if(r1==null ){ |
|
|
|
result.put("success","0"); |
|
|
|
BrandInfoVo brandInfoVo = brandInfoService.selectByCode(brandCode); |
|
|
|
if(brandInfoVo==null){ |
|
|
|
msg=msg+categoryKey+"商品品牌不存在;"; |
|
|
|
}else{ |
|
|
|
msg=msg+brandInfoVo.getName()+"["+brandCode+"]"+"不符合监管品牌;"; |
|
|
|
} |
|
|
|
} |
|
|
|
result.put("msg",msg); |
|
|
|
return result; |
|
|
|
} |
|
|
|
// @Resource
|
|
|
|
// private DictCommonService dictCommonService;
|
|
|
|
// @Resource
|
|
|
|
// private BrandInfoService brandInfoService;
|
|
|
|
// @Resource
|
|
|
|
// private RestrictedBrandService restrictedBrandService;
|
|
|
|
// private QueryWrapper<RestrictedCategory> createQueryWrapper(RestrictedCategoryQuery query) {
|
|
|
|
// // todo: 这里根据具体业务调整查询条件
|
|
|
|
// // 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
// QueryWrapper<RestrictedCategory> qw = new QueryWrapper<>();
|
|
|
|
// return qw;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// public PagerVo<RestrictedCategoryVo> listPageVo(PagerQuery<RestrictedCategoryQuery> pq) {
|
|
|
|
// RestrictedCategoryQuery query = pq.getParams();
|
|
|
|
// QueryWrapper<RestrictedCategory> qw = createQueryWrapper(query);
|
|
|
|
// IPage<RestrictedCategory> page = PagerUtil.queryToPage(pq);
|
|
|
|
// IPage<RestrictedCategoryVo> pagging = baseMapper.selectPageVo(page, qw);
|
|
|
|
// PagerVo<RestrictedCategoryVo> p = PagerUtil.pageToVo(pagging, null);
|
|
|
|
// return p;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// public void saveOrUpdateDto(RestrictedCategoryDto dto){
|
|
|
|
// String dtoSid = dto.getSid();
|
|
|
|
// if (StringUtils.isBlank(dtoSid)) {
|
|
|
|
// this.insertByDto(dto);
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// this.updateByDto(dto);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// public void insertByDto(RestrictedCategoryDto dto){
|
|
|
|
// RestrictedCategory entity = new RestrictedCategory();
|
|
|
|
// BeanUtil.copyProperties(dto, entity, "id", "sid");
|
|
|
|
// baseMapper.insert(entity);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// public void updateByDto(RestrictedCategoryDto dto){
|
|
|
|
// String dtoSid = dto.getSid();
|
|
|
|
// if (StringUtils.isBlank(dtoSid)) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// RestrictedCategory entity = fetchBySid(dtoSid);
|
|
|
|
// BeanUtil.copyProperties(dto, entity, "id", "sid");
|
|
|
|
// baseMapper.updateById(entity);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// public RestrictedCategoryDetailsVo fetchDetailsVoBySid(String sid){
|
|
|
|
// RestrictedCategory entity = fetchBySid(sid);
|
|
|
|
// RestrictedCategoryDetailsVo vo = new RestrictedCategoryDetailsVo();
|
|
|
|
// BeanUtil.copyProperties(entity, vo);
|
|
|
|
// return vo;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// public void readBrandPeriodSorXls1(InputStream is, String sid) {
|
|
|
|
// HSSFWorkbook hssfWorkbook = null;
|
|
|
|
// try {
|
|
|
|
// hssfWorkbook = new HSSFWorkbook(is);
|
|
|
|
// } catch (IOException e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// List<String> lisss=new ArrayList<>();
|
|
|
|
// List<String> lisss2=new ArrayList<>();
|
|
|
|
// HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(0);
|
|
|
|
//
|
|
|
|
// // 循环行Row
|
|
|
|
// for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
|
|
|
|
// RestrictedCategory pr=new RestrictedCategory();
|
|
|
|
// HSSFRow hssfRow = hssfSheet.getRow(rowNum);
|
|
|
|
// int i = 0;
|
|
|
|
// try{
|
|
|
|
// if(rowNum>=1){
|
|
|
|
// for ( ; i < hssfRow.getLastCellNum(); i++) {
|
|
|
|
// HSSFCell brandIdHSSFCell = hssfRow.getCell(i);
|
|
|
|
// if(brandIdHSSFCell!=null){
|
|
|
|
// if (i == 1) {//编码
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
|
|
|
|
// String value = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// pr.setCategorys(value);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// /*if (i == 2) {//名称
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
|
|
|
|
// String value = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// pr.setBrands(value);
|
|
|
|
// }
|
|
|
|
// }*/
|
|
|
|
// }else{
|
|
|
|
// System.err.println("rowNum="+rowNum+",i="+i+",value=null");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }catch(Exception e){
|
|
|
|
// e.printStackTrace();
|
|
|
|
// System.err.println("i="+i+",value=null");
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// lisss.add(rowNum+"");
|
|
|
|
// baseMapper.insert(pr);
|
|
|
|
// log.info("productInformation:{}", JSONObject.toJSONString(pr));
|
|
|
|
// }
|
|
|
|
// String x = JSON.toJSONString(lisss);
|
|
|
|
// System.out.println(x);
|
|
|
|
// String x1 = JSON.toJSONString(lisss2);
|
|
|
|
// System.out.println(x1);
|
|
|
|
// //return message;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// * 商品限制判断
|
|
|
|
// * @param categoryKey 品类键值
|
|
|
|
// * @param brandCode 品牌代码
|
|
|
|
// * @return ResultBean<ActivityCreateStepVo>
|
|
|
|
// * 2022/4/28 聂金毅 修改
|
|
|
|
// */
|
|
|
|
// public Map<String,String> limitJudgement(String categoryKey, String brandCode) {
|
|
|
|
// Map<String,String> result=new HashMap<>();
|
|
|
|
// RestrictedCategory r=baseMapper.selectByCategorys(categoryKey);
|
|
|
|
// result.put("success","1");
|
|
|
|
// String msg="";
|
|
|
|
// if(r==null ){
|
|
|
|
// result.put("success","0");
|
|
|
|
// DictCommonDetailsVo category = dictCommonService.fetchByKeyAndType(categoryKey, "category");
|
|
|
|
// if(category==null){
|
|
|
|
// msg=msg+categoryKey+"商品品类不存在;";
|
|
|
|
// }else{
|
|
|
|
// msg=msg+category.getDictValue()+"["+categoryKey+"]"+"不符合监管品类;";
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// RestrictedBrand r1=restrictedBrandService.selectByBrands(brandCode);
|
|
|
|
// if(r1==null ){
|
|
|
|
// result.put("success","0");
|
|
|
|
// BrandInfoVo brandInfoVo = brandInfoService.selectByCode(brandCode);
|
|
|
|
// if(brandInfoVo==null){
|
|
|
|
// msg=msg+categoryKey+"商品品牌不存在;";
|
|
|
|
// }else{
|
|
|
|
// msg=msg+brandInfoVo.getName()+"["+brandCode+"]"+"不符合监管品牌;";
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// result.put("msg",msg);
|
|
|
|
// return result;
|
|
|
|
// }
|
|
|
|
} |