|
@ -5,12 +5,15 @@ import cn.hutool.core.bean.BeanUtil; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
|
import com.wh.feign.enterpriseinformation.WhEnterpriseInformationFeign; |
|
|
|
|
|
import com.wh.feign.enterpriseinformation.WhEnterpriseInformationVo; |
|
|
import com.wh.mapper.purchasenew.PurchasenewMapper; |
|
|
import com.wh.mapper.purchasenew.PurchasenewMapper; |
|
|
import com.wh.pojo.purchasenew.*; |
|
|
import com.wh.pojo.purchasenew.*; |
|
|
import com.wh.pojo.purchasenewproduct.PurchasenewProduct; |
|
|
import com.wh.pojo.purchasenewproduct.PurchasenewProduct; |
|
|
import com.wh.pojo.purchasenewproduct.PurchasenewProductDto; |
|
|
import com.wh.pojo.purchasenewproduct.PurchasenewProductDto; |
|
|
import com.wh.pojo.purchasenewproduct.PurchasenewProductVo; |
|
|
import com.wh.pojo.purchasenewproduct.PurchasenewProductVo; |
|
|
import com.wh.service.api.instorehouse.InStorehouseMainService; |
|
|
import com.wh.service.api.instorehouse.InStorehouseMainService; |
|
|
|
|
|
import com.wh.service.api.prodstock.ProdStockService; |
|
|
import com.wh.service.purchasenewproduct.PurchasenewProductService; |
|
|
import com.wh.service.purchasenewproduct.PurchasenewProductService; |
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
@ -31,7 +34,11 @@ public class PurchasenewService extends MybatisBaseService<PurchasenewMapper, Pu |
|
|
@Autowired |
|
|
@Autowired |
|
|
private PurchasenewProductService purchasenewProductService; |
|
|
private PurchasenewProductService purchasenewProductService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
|
|
|
private ProdStockService prodStockService; |
|
|
|
|
|
@Autowired |
|
|
private InStorehouseMainService inStorehouseMainService; |
|
|
private InStorehouseMainService inStorehouseMainService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private WhEnterpriseInformationFeign whEnterpriseInformationFeign; |
|
|
private QueryWrapper<Purchasenew> createQueryWrapper(PurchasenewQuery query) { |
|
|
private QueryWrapper<Purchasenew> createQueryWrapper(PurchasenewQuery query) { |
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
@ -65,6 +72,16 @@ public class PurchasenewService extends MybatisBaseService<PurchasenewMapper, Pu |
|
|
@Transactional |
|
|
@Transactional |
|
|
public ResultBean saveOrUpdateDto(PurchasenewDto dto){ |
|
|
public ResultBean saveOrUpdateDto(PurchasenewDto dto){ |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
|
|
String custId = dto.getCustId(); |
|
|
|
|
|
ResultBean<List<WhEnterpriseInformationVo>> listResultBean = whEnterpriseInformationFeign.EnterpriseList(); |
|
|
|
|
|
List<WhEnterpriseInformationVo> data = listResultBean.getData(); |
|
|
|
|
|
data.forEach(d->{ |
|
|
|
|
|
String enterpriseName = d.getEnterpriseName(); |
|
|
|
|
|
String sid = d.getSid(); |
|
|
|
|
|
if(sid.equals(custId)){ |
|
|
|
|
|
dto.setCustName(enterpriseName); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
String dtoSid = dto.getSid(); |
|
|
String dtoSid = dto.getSid(); |
|
|
List<PurchasenewProductDto> products = dto.getProducts(); |
|
|
List<PurchasenewProductDto> products = dto.getProducts(); |
|
|
if(products.size()==0){ |
|
|
if(products.size()==0){ |
|
@ -116,8 +133,8 @@ public class PurchasenewService extends MybatisBaseService<PurchasenewMapper, Pu |
|
|
return rb.setMsg("主键信息不能为空"); |
|
|
return rb.setMsg("主键信息不能为空"); |
|
|
} |
|
|
} |
|
|
Purchasenew entity = fetchBySid(dtoSid); |
|
|
Purchasenew entity = fetchBySid(dtoSid); |
|
|
String status = entity.getStatus(); |
|
|
int state = entity.getState(); |
|
|
if("2".equals(status)){ |
|
|
if(2==state){ |
|
|
return rb.setMsg("采购订单已经入库不允许修改"); |
|
|
return rb.setMsg("采购订单已经入库不允许修改"); |
|
|
} |
|
|
} |
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
@ -125,6 +142,7 @@ public class PurchasenewService extends MybatisBaseService<PurchasenewMapper, Pu |
|
|
//dto.setSid(entity.getSid());
|
|
|
//dto.setSid(entity.getSid());
|
|
|
purchasenewProductService.deleteByPurchaseSid(dtoSid); |
|
|
purchasenewProductService.deleteByPurchaseSid(dtoSid); |
|
|
addPurchasenewProduct(dto, rb, entity); |
|
|
addPurchasenewProduct(dto, rb, entity); |
|
|
|
|
|
// TODO 当系统调试通后需要做修改 不能再 执行下一行代码了
|
|
|
return inStorehouseMainService.saveOrUpdateByPurchaseSid(dto,entity.getSid()); |
|
|
return inStorehouseMainService.saveOrUpdateByPurchaseSid(dto,entity.getSid()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -135,6 +153,8 @@ public class PurchasenewService extends MybatisBaseService<PurchasenewMapper, Pu |
|
|
PurchasenewProduct pp=new PurchasenewProduct(); |
|
|
PurchasenewProduct pp=new PurchasenewProduct(); |
|
|
BeanUtil.copyProperties(p,pp,"id","sid"); |
|
|
BeanUtil.copyProperties(p,pp,"id","sid"); |
|
|
pp.setMainSid(entity.getSid()); |
|
|
pp.setMainSid(entity.getSid()); |
|
|
|
|
|
pp.setStoreHouseName(dto.getStorehouseName()); |
|
|
|
|
|
pp.setStoreHouseSid(dto.getStorehouseId()); |
|
|
l.add(pp); |
|
|
l.add(pp); |
|
|
}); |
|
|
}); |
|
|
boolean b = purchasenewProductService.saveBatch(l); |
|
|
boolean b = purchasenewProductService.saveBatch(l); |
|
@ -158,11 +178,16 @@ public class PurchasenewService extends MybatisBaseService<PurchasenewMapper, Pu |
|
|
@Transactional |
|
|
@Transactional |
|
|
public int delByPurchasenewSids(String[] sids) { |
|
|
public int delByPurchasenewSids(String[] sids) { |
|
|
for (String sid : sids) { |
|
|
for (String sid : sids) { |
|
|
|
|
|
Purchasenew entity = fetchBySid(sid); |
|
|
|
|
|
int state = entity.getState(); |
|
|
|
|
|
if(2==state){ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
Map<String,Object> params=new HashMap<>(); |
|
|
Map<String,Object> params=new HashMap<>(); |
|
|
params.put("sid",sid); |
|
|
params.put("sid",sid); |
|
|
baseMapper.deleteByMap(params); |
|
|
baseMapper.deleteByMap(params); |
|
|
purchasenewProductService.deleteByPurchaseSid(sid); |
|
|
purchasenewProductService.deleteByPurchaseSid(sid); |
|
|
inStorehouseMainService.deleteByPurchaseSid(sid); |
|
|
// inStorehouseMainService.deleteByPurchaseSid(sid);
|
|
|
} |
|
|
} |
|
|
return sids.length; |
|
|
return sids.length; |
|
|
} |
|
|
} |
|
|