|
@@ -43,16 +43,16 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void add(UmsCompanyDto dto) {
|
|
|
UmsCompanyInfo ums = new UmsCompanyInfo();
|
|
|
- BeanUtil.copyProperties(dto,ums);
|
|
|
+ BeanUtil.copyProperties(dto, ums);
|
|
|
ums.setCreateTime(new Date());
|
|
|
int i = umsCompanyInfoMapper.insertSelective(ums);
|
|
|
List<UmsCompanyFile> files = dto.getFiles();
|
|
|
List<UmsCompanyShop> shops = dto.getShops();
|
|
|
|
|
|
- List<UmsCompanyFile> filesAdd = dto.getFiles();
|
|
|
- List<UmsCompanyShop> shopsAdd = dto.getShops();
|
|
|
- if (shops != null && shops.size()>0){
|
|
|
- for (UmsCompanyShop shop:shops) {
|
|
|
+ List<UmsCompanyFile> filesAdd = new ArrayList<>();
|
|
|
+ List<UmsCompanyShop> shopsAdd = new ArrayList<>();
|
|
|
+ if (shops != null && shops.size() > 0) {
|
|
|
+ for (UmsCompanyShop shop : shops) {
|
|
|
shop.setShopStatus(0);
|
|
|
shop.setCreateTime(new Date());
|
|
|
shop.setCreateId(dto.getCreateId());
|
|
@@ -61,13 +61,13 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
}
|
|
|
umsCompanyShopDao.addUmsCompanyShopList(shopsAdd);
|
|
|
}
|
|
|
- if (files != null && files.size()>0){
|
|
|
- for (UmsCompanyFile file:files) {
|
|
|
+ if (files != null && files.size() > 0) {
|
|
|
+ for (UmsCompanyFile file : files) {
|
|
|
file.setFileStatus(0);
|
|
|
file.setCreateTime(new Date());
|
|
|
file.setCreateId(dto.getCreateId());
|
|
|
file.setCompId(ums.getId());
|
|
|
- files.add(file);
|
|
|
+ filesAdd.add(file);
|
|
|
}
|
|
|
umsCompanyShopDao.insertFile(filesAdd);
|
|
|
}
|
|
@@ -75,62 +75,110 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
|
|
|
@Override
|
|
|
public void update(UmsCompanyDto dto) {
|
|
|
- UmsCompanyInfo umsCompanyInfo = new UmsCompanyInfo();
|
|
|
- BeanUtil.copyProperties(dto, umsCompanyInfo);
|
|
|
- umsCompanyInfoMapper.updateByPrimaryKeySelective(umsCompanyInfo);
|
|
|
+ UmsCompanyInfo ums = new UmsCompanyInfo();
|
|
|
+ BeanUtil.copyProperties(dto, ums);
|
|
|
+
|
|
|
+ List<UmsCompanyFile> files = dto.getFiles();
|
|
|
+ List<UmsCompanyShop> shops = dto.getShops();
|
|
|
|
|
|
+ List<UmsCompanyFile> filesAdd = new ArrayList<>();
|
|
|
+ List<UmsCompanyShop> shopsAdd = new ArrayList<>();
|
|
|
+ Long id = ums.getId();
|
|
|
+ if (shops != null && shops.size() > 0) {
|
|
|
+ for (UmsCompanyShop shop : shops) {
|
|
|
+ shop.setShopStatus(0);
|
|
|
+ shop.setCreateTime(new Date());
|
|
|
+ shop.setCreateId(dto.getCreateId());
|
|
|
+ shop.setCompId(ums.getId());
|
|
|
+ shopsAdd.add(shop);
|
|
|
+ }
|
|
|
+ deleteCompanyShop(id);
|
|
|
+ umsCompanyShopDao.addUmsCompanyShopList(shopsAdd);
|
|
|
+ }
|
|
|
+ if (files != null && files.size() > 0) {
|
|
|
+ for (UmsCompanyFile file : files) {
|
|
|
+ file.setFileStatus(0);
|
|
|
+ file.setCreateTime(new Date());
|
|
|
+ file.setCreateId(dto.getCreateId());
|
|
|
+ file.setCompId(ums.getId());
|
|
|
+ filesAdd.add(file);
|
|
|
+ }
|
|
|
+ deleteCompanyFile(id);
|
|
|
+ umsCompanyShopDao.insertFile(filesAdd);
|
|
|
+ }
|
|
|
+ umsCompanyInfoMapper.updateByPrimaryKeySelective(ums);
|
|
|
}
|
|
|
+
|
|
|
@Autowired
|
|
|
private UmsCompanyInfoDao umsCompanyInfoDao;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void delete(Long id) {
|
|
|
long i = umsCompanyInfoDao.deleteCheck(id);
|
|
|
- if(i>0){
|
|
|
+ if (i > 0) {
|
|
|
throw new GlobalException("该供应商的数据被用户~生产地~商品所引用无法删除!");
|
|
|
}
|
|
|
UmsCompanyInfo info = new UmsCompanyInfo();
|
|
|
info.setCompStatus(2);
|
|
|
info.setId(id);
|
|
|
+
|
|
|
umsCompanyInfoMapper.updateByPrimaryKeySelective(info);
|
|
|
+
|
|
|
+ deleteCompanyShop(id);
|
|
|
+ deleteCompanyFile(id);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deleteCompanyShop(Long compId){
|
|
|
+ UmsCompanyShopExample example=new UmsCompanyShopExample();
|
|
|
+ UmsCompanyShopExample.Criteria criteria = example.createCriteria();
|
|
|
+ criteria.andCompIdEqualTo(compId);
|
|
|
+ umsCompanyShopMapper.deleteByExample(example);
|
|
|
}
|
|
|
|
|
|
+ private void deleteCompanyFile(Long compId){
|
|
|
+ UmsCompanyFileExample example=new UmsCompanyFileExample();
|
|
|
+ UmsCompanyFileExample.Criteria criteria = example.createCriteria();
|
|
|
+ criteria.andCompIdEqualTo(compId);
|
|
|
+ umsCompanyFileMapper.deleteByExample(example);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String importExcel(List<UmsCompanyInfoExcel> infoExcels) {
|
|
|
- if (infoExcels == null || infoExcels.size()<1){
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- List<UmsCompanyShop> listShops = new ArrayList<>();
|
|
|
- infoExcels.stream().forEach(item->{
|
|
|
- UmsCompanyInfo umsCompanyInfo = new UmsCompanyInfo();
|
|
|
- BeanUtil.copyProperties(item,umsCompanyInfo);
|
|
|
- umsCompanyInfo.setCreateTime(new Date());
|
|
|
- umsCompanyInfo.setCompStatus(0);
|
|
|
- try {
|
|
|
- int i = umsCompanyInfoMapper.insertSelective(umsCompanyInfo);
|
|
|
-
|
|
|
- item.setId(umsCompanyInfo.getId());
|
|
|
- List<UmsCompanyShop> shops = getShopsFromUmsCompanyInfoExcel(item);
|
|
|
- listShops.addAll(shops);
|
|
|
- }catch (Exception e){
|
|
|
- log.info("添加数据失败");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ if (infoExcels == null || infoExcels.size() < 1) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
- if (listShops != null &&listShops.size()>0){
|
|
|
- int i = umsCompanyShopDao.addUmsCompanyShopList(listShops);
|
|
|
- }
|
|
|
- return null;
|
|
|
+ List<UmsCompanyShop> listShops = new ArrayList<>();
|
|
|
+ infoExcels.stream().forEach(item -> {
|
|
|
+ UmsCompanyInfo umsCompanyInfo = new UmsCompanyInfo();
|
|
|
+ BeanUtil.copyProperties(item, umsCompanyInfo);
|
|
|
+ umsCompanyInfo.setCreateTime(new Date());
|
|
|
+ umsCompanyInfo.setCompStatus(0);
|
|
|
+ try {
|
|
|
+ int i = umsCompanyInfoMapper.insertSelective(umsCompanyInfo);
|
|
|
+
|
|
|
+ item.setId(umsCompanyInfo.getId());
|
|
|
+ List<UmsCompanyShop> shops = getShopsFromUmsCompanyInfoExcel(item);
|
|
|
+ listShops.addAll(shops);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("添加数据失败");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (listShops != null && listShops.size() > 0) {
|
|
|
+ int i = umsCompanyShopDao.addUmsCompanyShopList(listShops);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String,Object> getCompanyInfoList(int pageSize, int pageNo) {
|
|
|
- Map<String,Object> hasp=new HashMap<>();
|
|
|
- PageHelper.startPage(pageNo,pageSize);
|
|
|
+ public Map<String, Object> getCompanyInfoList(int pageSize, int pageNo) {
|
|
|
+ Map<String, Object> hasp = new HashMap<>();
|
|
|
+ PageHelper.startPage(pageNo, pageSize);
|
|
|
UmsCompanyInfoExample example = new UmsCompanyInfoExample();
|
|
|
UmsCompanyInfoExample.Criteria criteria = example.createCriteria();
|
|
|
criteria.andCompStatusEqualTo(0);
|
|
@@ -139,16 +187,15 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
CommonPage<UmsCompanyInfo> umsCompanyInfoCommonPage = CommonPage.restPage(companyInfos);
|
|
|
List<UmsCompanyInfo> list = umsCompanyInfoCommonPage.getList();
|
|
|
List<UmsCompanyDto> dtos = new ArrayList<>();
|
|
|
- list.stream().forEach(comp->{
|
|
|
- UmsCompanyDto dto= new UmsCompanyDto();
|
|
|
- BeanUtil.copyProperties(comp,dto);
|
|
|
+ list.stream().forEach(comp -> {
|
|
|
+ UmsCompanyDto dto = new UmsCompanyDto();
|
|
|
+ BeanUtil.copyProperties(comp, dto);
|
|
|
dto.setFiles(getCompanyFile(comp.getId()));
|
|
|
dto.setShops(getCompanyShop(comp.getId()));
|
|
|
dtos.add(dto);
|
|
|
- dtos.add(dto);
|
|
|
});
|
|
|
- hasp.put("total",umsCompanyInfoCommonPage.getTotal());
|
|
|
- hasp.put("list",dtos);
|
|
|
+ hasp.put("total", umsCompanyInfoCommonPage.getTotal());
|
|
|
+ hasp.put("list", dtos);
|
|
|
return hasp;
|
|
|
}
|
|
|
|
|
@@ -156,14 +203,13 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
public UmsCompanyDto getDetailCompany(Long companyId) {
|
|
|
UmsCompanyInfo umsCompanyInfo = umsCompanyInfoMapper.selectByPrimaryKey(companyId);
|
|
|
UmsCompanyDto ums = new UmsCompanyDto();
|
|
|
- BeanUtil.copyProperties(umsCompanyInfo,ums);
|
|
|
+ BeanUtil.copyProperties(umsCompanyInfo, ums);
|
|
|
ums.setFiles(getCompanyFile(companyId));
|
|
|
ums.setShops(getCompanyShop(companyId));
|
|
|
-
|
|
|
return ums;
|
|
|
}
|
|
|
|
|
|
- public List<UmsCompanyShop> getShopsFromUmsCompanyInfoExcel(UmsCompanyInfoExcel ums){
|
|
|
+ public List<UmsCompanyShop> getShopsFromUmsCompanyInfoExcel(UmsCompanyInfoExcel ums) {
|
|
|
List<UmsCompanyShop> shops = new ArrayList<>();
|
|
|
UmsCompanyShop shop = new UmsCompanyShop();
|
|
|
|
|
@@ -171,33 +217,37 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
shop.setCreateId((long) 1);
|
|
|
shop.setCreateTime(new Date());
|
|
|
shop.setShopStatus(0);
|
|
|
- if (!StringUtils.isEmpty(ums.getTbUrl())){
|
|
|
+ if (!StringUtils.isEmpty(ums.getTbUrl())) {
|
|
|
UmsCompanyShop tbShop = new UmsCompanyShop();
|
|
|
- BeanUtil.copyProperties(shop,tbShop);
|
|
|
+ BeanUtil.copyProperties(shop, tbShop);
|
|
|
tbShop.setShopType("taobao");
|
|
|
tbShop.setShopUrl(ums.getTbUrl());
|
|
|
+ tbShop.setShopImg("http://fqn.hongweisoft.com/jingdong.jpg");
|
|
|
shops.add(tbShop);
|
|
|
|
|
|
}
|
|
|
- if (!StringUtils.isEmpty(ums.getJdUrl())){
|
|
|
+ if (!StringUtils.isEmpty(ums.getJdUrl())) {
|
|
|
UmsCompanyShop jdShop = new UmsCompanyShop();
|
|
|
- BeanUtil.copyProperties(shop,jdShop);
|
|
|
+ BeanUtil.copyProperties(shop, jdShop);
|
|
|
jdShop.setShopType("jd");
|
|
|
jdShop.setShopUrl(ums.getJdUrl());
|
|
|
+ jdShop.setShopImg("http://fqn.hongweisoft.com/taobao.jpg");
|
|
|
shops.add(jdShop);
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isEmpty(ums.getOwnUrl())){
|
|
|
+ if (!StringUtils.isEmpty(ums.getOwnUrl())) {
|
|
|
UmsCompanyShop ownShop = new UmsCompanyShop();
|
|
|
- BeanUtil.copyProperties(shop,ownShop);
|
|
|
+ BeanUtil.copyProperties(shop, ownShop);
|
|
|
ownShop.setShopType("own");
|
|
|
ownShop.setShopUrl(ums.getOwnUrl());
|
|
|
+ ownShop.setShopImg("http://bpic.588ku.com/element_pic/20/06/30/65ed28bc8f14415778c878ecca4bacc8.jpg");
|
|
|
shops.add(ownShop);
|
|
|
}
|
|
|
return shops;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
- public List<UmsCompanyFile> getCompanyFile(Long compId){
|
|
|
+ public List<UmsCompanyFile> getCompanyFile(Long compId) {
|
|
|
UmsCompanyFileExample example = new UmsCompanyFileExample();
|
|
|
UmsCompanyFileExample.Criteria criteria = example.createCriteria();
|
|
|
criteria.andCompIdEqualTo(compId);
|
|
@@ -205,7 +255,8 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
List<UmsCompanyFile> files = umsCompanyFileMapper.selectByExample(example);
|
|
|
return files;
|
|
|
}
|
|
|
- public List<UmsCompanyShop> getCompanyShop(Long compId){
|
|
|
+
|
|
|
+ public List<UmsCompanyShop> getCompanyShop(Long compId) {
|
|
|
UmsCompanyShopExample example = new UmsCompanyShopExample();
|
|
|
UmsCompanyShopExample.Criteria criteria = example.createCriteria();
|
|
|
criteria.andCompIdEqualTo(compId);
|
|
@@ -216,7 +267,7 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
|
|
|
@Override
|
|
|
public void updateCompanyFile(UmsCompanyFile umsCompanyFile) {
|
|
|
- if (StringUtils.isEmpty(umsCompanyFile.getId())){
|
|
|
+ if (StringUtils.isEmpty(umsCompanyFile.getId())) {
|
|
|
throw new GlobalException("缺失修改主体!");
|
|
|
}
|
|
|
umsCompanyFile.setUpdateTime(new Date());
|
|
@@ -225,8 +276,8 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
|
|
|
@Override
|
|
|
public void deleteCompanyFile(Long shopId, Long userId) {
|
|
|
- if (shopId == null){
|
|
|
- throw new GlobalException("缺失删除主体!");
|
|
|
+ if (shopId == null) {
|
|
|
+ throw new GlobalException("缺失删除主体!");
|
|
|
}
|
|
|
UmsCompanyFile umsCompanyFile = new UmsCompanyFile();
|
|
|
umsCompanyFile.setId(shopId);
|
|
@@ -238,7 +289,7 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
|
|
|
@Override
|
|
|
public void updateCompanyShop(UmsCompanyShop umsCompanyShop) {
|
|
|
- if (StringUtils.isEmpty(umsCompanyShop.getId())){
|
|
|
+ if (StringUtils.isEmpty(umsCompanyShop.getId())) {
|
|
|
throw new GlobalException("缺失修改主体!");
|
|
|
}
|
|
|
umsCompanyShop.setUpdateTime(new Date());
|
|
@@ -247,8 +298,8 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
|
|
|
@Override
|
|
|
public void deleteCompanyShop(Long shopId, Long userId) {
|
|
|
- if (shopId == null){
|
|
|
- throw new GlobalException("缺失删除主体");
|
|
|
+ if (shopId == null) {
|
|
|
+ throw new GlobalException("缺失删除主体");
|
|
|
}
|
|
|
|
|
|
UmsCompanyShop umsCompanyShop = new UmsCompanyShop();
|
|
@@ -267,7 +318,7 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
file.setFileStatus(2);
|
|
|
file.setUpdateId(userId);
|
|
|
file.setUpdateTime(new Date());
|
|
|
- umsCompanyFileMapper.updateByExample(file,fileExampleW);
|
|
|
+ umsCompanyFileMapper.updateByExample(file, fileExampleW);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -278,19 +329,19 @@ public class UmsCompanyInfoServiceImpl implements UmsCompanyService {
|
|
|
UmsCompanyShopExample shopExample = new UmsCompanyShopExample();
|
|
|
UmsCompanyShopExample.Criteria criteria = shopExample.createCriteria();
|
|
|
criteria.andCompIdEqualTo(compId);
|
|
|
- umsCompanyShopMapper.updateByExample(shop,shopExample);
|
|
|
+ umsCompanyShopMapper.updateByExample(shop, shopExample);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<UmsCompanyInfo> searchCompanyInfo(String key,int pageNo,int pageSize,Long compId) {
|
|
|
- PageHelper.startPage(pageNo,pageSize);
|
|
|
+ public List<UmsCompanyInfo> searchCompanyInfo(String key, int pageNo, int pageSize, Long compId) {
|
|
|
+ PageHelper.startPage(pageNo, pageSize);
|
|
|
UmsCompanyInfoExample umsCompanyInfoExample = new UmsCompanyInfoExample();
|
|
|
UmsCompanyInfoExample.Criteria criteria = umsCompanyInfoExample.createCriteria();
|
|
|
- if (compId != null){
|
|
|
+ if (compId != null) {
|
|
|
criteria.andIdEqualTo(compId);
|
|
|
- }else {
|
|
|
- if (StringUtils.isEmpty(key)){
|
|
|
- criteria.andCompNameLike("%"+key+"%");
|
|
|
+ } else {
|
|
|
+ if (StringUtils.isEmpty(key)) {
|
|
|
+ criteria.andCompNameLike("%" + key + "%");
|
|
|
}
|
|
|
}
|
|
|
|