客户订单

pull/451/head
starrysky 2019-08-26 09:04:49 +08:00
parent a7e80e0ed7
commit 52ab50449d
12 changed files with 171 additions and 38 deletions

View File

@ -36,10 +36,10 @@ public class CreateMaterialInfoRequest implements Serializable {
private String measureUnitName; private String measureUnitName;
// 产品库存预警 // 产品库存预警
private List<MaterialInventoryWarning> materialInventoryWarningList; private List<MaterialInventoryWarning> materialInventoryWarning;
// 产品期初设置 // 产品期初设置
private List<MaterialInitialSetup> materialInitialSetupList; private List<MaterialInitialSetup> materialInitialSetup;
// 物料期初合计期初总价格 // 物料期初合计期初总价格
private Integer materialInitialSetupTotalPrice; private Integer materialInitialSetupTotalPrice;

View File

@ -38,9 +38,9 @@ public class CreateProductInfoRequest implements Serializable {
private Long unitPrice; private Long unitPrice;
// 产品库存预警 // 产品库存预警
private List<ProductInventoryWarning> productInventoryWarningList; private List<ProductInventoryWarning> productInventoryWarning;
// 产品期初设置 // 产品期初设置
private List<ProductInitialSetup> productInitialSetupList; private List<ProductInitialSetup> productInitialSetup;
} }

View File

@ -0,0 +1,58 @@
package me.zhengjie.modules.wms.bd.request;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import me.zhengjie.modules.wms.bd.domain.MaterialInfo;
import java.io.Serializable;
import java.util.List;
/**
* @author
* @date 2019-08-24
*/
@Data
public class UpdateMaterialInfoRequest implements Serializable {
private Long id;
// 所属物料分类主键
private Long materialCategoryId;
// 物料分类名称
private String materialCategoryName;
// 物料名称
private String name;
// 物料编码
private String materialCode;
// 物料规格
private String specifications;
// 所属计量单位主键
private Long measureUnitId;
// 所属计量单位名称
private String measureUnitName;
// 产品库存预警
private List<MaterialInventoryWarning> materialInventoryWarning;
// 产品期初设置
private List<MaterialInitialSetup> materialInitialSetup;
// 物料期初合计期初总价格
private Integer materialInitialSetupTotalPrice;
// 物料期初合计总数量
private String materialInitialSetupTotalNumber;
private Boolean status;
public void copy(MaterialInfo source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -40,9 +40,9 @@ public class UpdateProductInfoRequest implements Serializable {
private Long unitPrice; private Long unitPrice;
// 产品库存预警 // 产品库存预警
private List<ProductInventoryWarning> productInventoryWarningList; private List<ProductInventoryWarning> productInventoryWarning;
// 产品期初设置 // 产品期初设置
private List<ProductInitialSetup> productInitialSetupList; private List<ProductInitialSetup> productInitialSetup;
} }

View File

@ -3,6 +3,7 @@ package me.zhengjie.modules.wms.bd.rest;
import me.zhengjie.aop.log.Log; import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.wms.bd.domain.MaterialInfo; import me.zhengjie.modules.wms.bd.domain.MaterialInfo;
import me.zhengjie.modules.wms.bd.request.CreateMaterialInfoRequest; import me.zhengjie.modules.wms.bd.request.CreateMaterialInfoRequest;
import me.zhengjie.modules.wms.bd.request.UpdateMaterialInfoRequest;
import me.zhengjie.modules.wms.bd.service.MaterialInfoService; import me.zhengjie.modules.wms.bd.service.MaterialInfoService;
import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoQueryCriteria; import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -62,8 +63,8 @@ public class MaterialInfoController {
@Log("修改物料资料") @Log("修改物料资料")
@ApiOperation(value = "修改物料资料") @ApiOperation(value = "修改物料资料")
@PutMapping(value = "/materialInfo/update") @PutMapping(value = "/materialInfo/update")
public ResponseEntity update(@Validated @RequestBody MaterialInfo resources){ public ResponseEntity update(@RequestBody UpdateMaterialInfoRequest updateMaterialInfoRequest){
materialInfoService.update(resources); materialInfoService.update(updateMaterialInfoRequest);
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }

View File

@ -2,6 +2,7 @@ package me.zhengjie.modules.wms.bd.service;
import me.zhengjie.modules.wms.bd.domain.MaterialInfo; import me.zhengjie.modules.wms.bd.domain.MaterialInfo;
import me.zhengjie.modules.wms.bd.request.CreateMaterialInfoRequest; import me.zhengjie.modules.wms.bd.request.CreateMaterialInfoRequest;
import me.zhengjie.modules.wms.bd.request.UpdateMaterialInfoRequest;
import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoDTO; import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoDTO;
import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoDetailDTO; import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoDetailDTO;
import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoQueryCriteria; import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoQueryCriteria;
@ -52,10 +53,10 @@ public interface MaterialInfoService {
/** /**
* update * update
* @param resources * @param updateMaterialInfoRequest
*/ */
//@CacheEvict(allEntries = true) //@CacheEvict(allEntries = true)
void update(MaterialInfo resources); void update(UpdateMaterialInfoRequest updateMaterialInfoRequest);
/** /**
* delete * delete

View File

@ -24,6 +24,9 @@ public class MaterialInfoDTO implements Serializable {
// 物料名称 // 物料名称
private String name; private String name;
// 物料编码
private String materialCode;
// 物料规格 // 物料规格
private String specifications; private String specifications;
@ -33,14 +36,7 @@ public class MaterialInfoDTO implements Serializable {
// 所属计量单位名称 // 所属计量单位名称
private String measureUnitName; private String measureUnitName;
// 产品库存预警[{“sort”:””,”ware_house_code”:””,”ware_house_name”:””,”minimum_inventory”:””,”highest_inventory”:””}]
private String materialInventoryWarning;
// 产品期初设置[{“sort”:””,”ware_house_code”:””,”ware_house_name”:””,“initial_setup_numer”:””,“initial_setup_total_price”:””}]
private String materialInitialSetup;
// 物料期初合计期初总价格 // 物料期初合计期初总价格
private Long materialInitialSetupTotalPrice; private Long materialInitialSetupTotalPrice;
// 物料期初合计总数量 // 物料期初合计总数量

View File

@ -13,10 +13,10 @@ import java.util.List;
* @date 2019-08-03 * @date 2019-08-03
*/ */
@Data @Data
public class MaterialInfoDetailDTO extends ProductInfoDTO implements Serializable { public class MaterialInfoDetailDTO extends MaterialInfoDTO implements Serializable {
private List<MaterialInventoryWarning> materialInventoryWarningList; private List<MaterialInventoryWarning> materialInventoryWarning;
private List<MaterialInitialSetup> materialInitialSetupList; private List<MaterialInitialSetup> materialInitialSetup;
} }

View File

@ -19,7 +19,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -137,14 +140,14 @@ public class MaterialInfoServiceImpl implements MaterialInfoService {
String productInventoryWarningStr = materialInfo.getMaterialInventoryWarning(); String productInventoryWarningStr = materialInfo.getMaterialInventoryWarning();
if(StringUtils.hasLength(productInventoryWarningStr)){ if(StringUtils.hasLength(productInventoryWarningStr)){
List<MaterialInventoryWarning> materialInventoryWarningList = new Gson().fromJson(productInventoryWarningStr,new TypeToken<ArrayList<MaterialInventoryWarning>>() {}.getType()); List<MaterialInventoryWarning> materialInventoryWarningList = new Gson().fromJson(productInventoryWarningStr,new TypeToken<ArrayList<MaterialInventoryWarning>>() {}.getType());
materialInfoDetailDTO.setMaterialInventoryWarningList(materialInventoryWarningList); materialInfoDetailDTO.setMaterialInventoryWarning(materialInventoryWarningList);
} }
String materialInitialSetupStr = materialInfo.getMaterialInitialSetup(); String materialInitialSetupStr = materialInfo.getMaterialInitialSetup();
if(StringUtils.hasLength(materialInitialSetupStr)){ if(StringUtils.hasLength(materialInitialSetupStr)){
List<MaterialInitialSetup> materialInitialSetupList = new Gson().fromJson(materialInitialSetupStr,new TypeToken<ArrayList<MaterialInitialSetup>>() {}.getType()); List<MaterialInitialSetup> materialInitialSetupList = new Gson().fromJson(materialInitialSetupStr,new TypeToken<ArrayList<MaterialInitialSetup>>() {}.getType());
materialInfoDetailDTO.setMaterialInitialSetupList(materialInitialSetupList); materialInfoDetailDTO.setMaterialInitialSetup(materialInitialSetupList);
} }
} }
return materialInfoDetailDTO; return materialInfoDetailDTO;
@ -173,24 +176,22 @@ public class MaterialInfoServiceImpl implements MaterialInfoService {
throw new BadRequestException("物料类别不存在!"); throw new BadRequestException("物料类别不存在!");
} }
MaterialInfoDetailDTO materialInfoDetailDTO = new MaterialInfoDetailDTO(); MaterialInfoDetailDTO materialInfoDetailDTO = new MaterialInfoDetailDTO();
MaterialInfo materialInfo = new MaterialInfo(); MaterialInfo materialInfo = new MaterialInfo();
BeanUtils.copyProperties(createMaterialInfoRequest, materialInfo); BeanUtils.copyProperties(createMaterialInfoRequest, materialInfo);
materialInfo.setStatus(true); materialInfo.setStatus(true);
List<MaterialInventoryWarning> materialInventoryWarningList = createMaterialInfoRequest.getMaterialInventoryWarningList(); List<MaterialInventoryWarning> materialInventoryWarningList = createMaterialInfoRequest.getMaterialInventoryWarning();
if(!CollectionUtils.isEmpty(materialInventoryWarningList)){ if(!CollectionUtils.isEmpty(materialInventoryWarningList)){
String materialInventoryWarningStr = new Gson().toJson(materialInventoryWarningList); String materialInventoryWarningStr = new Gson().toJson(materialInventoryWarningList);
materialInfo.setMaterialInventoryWarning(materialInventoryWarningStr); materialInfo.setMaterialInventoryWarning(materialInventoryWarningStr);
materialInfoDetailDTO.setMaterialInventoryWarningList(materialInventoryWarningList); materialInfoDetailDTO.setMaterialInventoryWarning(materialInventoryWarningList);
} }
List<MaterialInitialSetup> materialInitialSetupList = createMaterialInfoRequest.getMaterialInitialSetupList(); List<MaterialInitialSetup> materialInitialSetupList = createMaterialInfoRequest.getMaterialInitialSetup();
if(!CollectionUtils.isEmpty(materialInitialSetupList)){ if(!CollectionUtils.isEmpty(materialInitialSetupList)){
String materialInitialSetupStr = new Gson().toJson(materialInitialSetupList); String materialInitialSetupStr = new Gson().toJson(materialInitialSetupList);
materialInfo.setMaterialInitialSetup(materialInitialSetupStr); materialInfo.setMaterialInitialSetup(materialInitialSetupStr);
materialInfoDetailDTO.setMaterialInitialSetupList(materialInitialSetupList); materialInfoDetailDTO.setMaterialInitialSetup(materialInitialSetupList);
} }
materialInfo.setMaterialCategoryName(materialCategory.getName()); materialInfo.setMaterialCategoryName(materialCategory.getName());
@ -204,11 +205,72 @@ public class MaterialInfoServiceImpl implements MaterialInfoService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void update(MaterialInfo resources) { public void update(UpdateMaterialInfoRequest updateMaterialInfoRequest) {
Optional<MaterialInfo> optionalBdMaterialInfo = materialInfoRepository.findById(resources.getId()); Long materialInfoId = updateMaterialInfoRequest.getId();
ValidationUtil.isNull(optionalBdMaterialInfo, "MaterialInfo", "id", resources.getId()); if(null == materialInfoId){
MaterialInfo materialInfo = optionalBdMaterialInfo.get(); throw new BadRequestException("物料主键不能为空!");
materialInfo.copy(resources); }
Long materialCategoryId = updateMaterialInfoRequest.getMaterialCategoryId();
if(null == materialCategoryId){
throw new BadRequestException("物料类别主键不能为空!");
}
Optional<MaterialCategory> materialCategoryOptional = materialCategoryRepository.findById(materialCategoryId);
MaterialCategory materialCategory = materialCategoryOptional.get();
if(null == materialCategory){
throw new BadRequestException("物料类别不存在!");
}
Long measureUnitId = updateMaterialInfoRequest.getMeasureUnitId();
if(null == measureUnitId){
throw new BadRequestException("计量单位主键不能为空!");
}
Optional<MeasureUnit> measureUnitOptional = measureUnitRepository.findById(measureUnitId);
MeasureUnit measureUnit = measureUnitOptional.get();
if(null== measureUnit){
throw new BadRequestException("计量单位不存在!");
}
// 物料资料-物料仓库预警修改目标
List<MaterialInventoryWarning> materialInventoryWarningTarget = updateMaterialInfoRequest.getMaterialInventoryWarning();
// 物料资料-供应商联系方式修改目标
List<MaterialInitialSetup> materialInitialSetupTarget = updateMaterialInfoRequest.getMaterialInitialSetup();
MaterialInfo materialInfo = materialInfoRepository.findByIdAndStatusTrue(materialInfoId);
if(null == materialInfo){
throw new BadRequestException("物料资料不存在");
}
Timestamp createTime = materialInfo.getCreateTime();
// 将需要修改的值复制到数据库对象中
BeanUtils.copyProperties(updateMaterialInfoRequest, materialInfo);
// 判断提前获取的供应商联系地址和联系方式是否是空
if(CollectionUtils.isEmpty(materialInventoryWarningTarget)){
materialInfo.setMaterialInventoryWarning(null);
}else{
String materialInventoryWarningStr = new Gson().toJson(materialInventoryWarningTarget);
materialInfo.setMaterialInventoryWarning(materialInventoryWarningStr);
}
if(CollectionUtils.isEmpty(materialInitialSetupTarget)){
materialInfo.setMaterialInitialSetup(null);
}else{
String materialInitialSetupStr = new Gson().toJson(materialInitialSetupTarget);
materialInfo.setMaterialInventoryWarning(materialInitialSetupStr);
}
materialInfo.setCreateTime(createTime);
materialInfo.setStatus(true);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
materialInfo.setUpdateTime(Timestamp.valueOf(sdf.format(new Date())));
materialInfo.setMaterialCategoryName(materialCategory.getName());
materialInfo.setMeasureUnitName(materialCategory.getName());
// 修改物料资料
materialInfoRepository.save(materialInfo); materialInfoRepository.save(materialInfo);
} }

View File

@ -157,13 +157,13 @@ public class ProductInfoServiceImpl implements ProductInfoService {
ProductInfo productInfo = new ProductInfo(); ProductInfo productInfo = new ProductInfo();
BeanUtils.copyProperties(createProductInfoRequest, productInfo); BeanUtils.copyProperties(createProductInfoRequest, productInfo);
productInfo.setStatus(true); productInfo.setStatus(true);
List<ProductInventoryWarning> productInventoryWarningList = createProductInfoRequest.getProductInventoryWarningList(); List<ProductInventoryWarning> productInventoryWarningList = createProductInfoRequest.getProductInventoryWarning();
if(!CollectionUtils.isEmpty(productInventoryWarningList)){ if(!CollectionUtils.isEmpty(productInventoryWarningList)){
String productInventoryWarningStr = new Gson().toJson(productInventoryWarningList); String productInventoryWarningStr = new Gson().toJson(productInventoryWarningList);
productInfo.setProductInventoryWarning(productInventoryWarningStr); productInfo.setProductInventoryWarning(productInventoryWarningStr);
productInfoDetailDTO.setProductInventoryWarningList(productInventoryWarningList); productInfoDetailDTO.setProductInventoryWarningList(productInventoryWarningList);
} }
List<ProductInitialSetup> productInitialSetupList = createProductInfoRequest.getProductInitialSetupList(); List<ProductInitialSetup> productInitialSetupList = createProductInfoRequest.getProductInitialSetup();
if(!CollectionUtils.isEmpty(productInitialSetupList)){ if(!CollectionUtils.isEmpty(productInitialSetupList)){
String productInitialSetupStr = new Gson().toJson(productInitialSetupList); String productInitialSetupStr = new Gson().toJson(productInitialSetupList);
productInfo.setProductInitialSetup(productInitialSetupStr); productInfo.setProductInitialSetup(productInitialSetupStr);
@ -211,9 +211,9 @@ public class ProductInfoServiceImpl implements ProductInfoService {
// 产品资料-仓库预警修改目标 // 产品资料-仓库预警修改目标
List<ProductInventoryWarning> productInventoryWarningListTarget = updateProductInfoRequest.getProductInventoryWarningList(); List<ProductInventoryWarning> productInventoryWarningListTarget = updateProductInfoRequest.getProductInventoryWarning();
// 产品资料-期初设置修改目标 // 产品资料-期初设置修改目标
List<ProductInitialSetup> productInitialSetupListTarget = updateProductInfoRequest.getProductInitialSetupList(); List<ProductInitialSetup> productInitialSetupListTarget = updateProductInfoRequest.getProductInitialSetup();
ProductInfo productInfo = productInfoRepository.findByIdAndStatusTrue(productInfoId); ProductInfo productInfo = productInfoRepository.findByIdAndStatusTrue(productInfoId);

View File

@ -69,4 +69,10 @@ public class CustomerOrderController {
String supplierCode = "DD"+ LocalDateTime.now().format(fmt); String supplierCode = "DD"+ LocalDateTime.now().format(fmt);
return new ResponseEntity(supplierCode,HttpStatus.OK); return new ResponseEntity(supplierCode,HttpStatus.OK);
} }
@Log("查看客户订单详情")
@GetMapping(value = "/customerOrder/{id}")
public ResponseEntity getCustomerOrderInfo(@PathVariable Long id){
return new ResponseEntity(customerOrderService.findById(id), HttpStatus.OK);
}
} }

View File

@ -69,7 +69,16 @@ public class CustomerOrderServiceImpl implements CustomerOrderService {
public CustomerOrderDTO findById(Long id) { public CustomerOrderDTO findById(Long id) {
Optional<CustomerOrder> sCustomerOrder = customerOrderRepository.findById(id); Optional<CustomerOrder> sCustomerOrder = customerOrderRepository.findById(id);
ValidationUtil.isNull(sCustomerOrder,"SCustomerOrder","id",id); ValidationUtil.isNull(sCustomerOrder,"SCustomerOrder","id",id);
return customerOrderMapper.toDto(sCustomerOrder.get()); CustomerOrder customerOrder = sCustomerOrder.get();
if(null == customerOrder){
throw new BadRequestException("客户订单不存在!");
}
CustomerOrderDTO customerOrderDTO = customerOrderMapper.toDto(customerOrder);
List<CustomerOrderProduct> customerOrderProductList = customerOrderProductRepository.findByCustomerOrderIdAndStatusTrue(customerOrder.getId());
List<CustomerOrderProductDTO> customerOrderProductDTOList = customerOrderProductMapper.toDto(customerOrderProductList);
customerOrderDTO.setCustomerOrderProductList(customerOrderProductDTOList);
return customerOrderDTO;
} }
@Override @Override