Commit cd20bcd6 authored by 3533457856@qq.com's avatar 3533457856@qq.com

发货单

新增/编辑/详情接口 更新发货单状态接口
parent 14605fd5
...@@ -35,6 +35,15 @@ public class PreparationMoneyEnum { ...@@ -35,6 +35,15 @@ public class PreparationMoneyEnum {
* 编码 * 编码
*/ */
private String describe; private String describe;
public static String getName(String code) {
for(DOCUMENT_STATE type: DOCUMENT_STATE.values()) {
if (type.getCode().equals(code)) {
return type.getName();
}
}
return null;
}
} }
/** /**
...@@ -59,6 +68,15 @@ public class PreparationMoneyEnum { ...@@ -59,6 +68,15 @@ public class PreparationMoneyEnum {
* 编码 * 编码
*/ */
private String describe; private String describe;
public static String getName(String code) {
for(SHIPMENT_STATUS type: SHIPMENT_STATUS.values()) {
if (type.getCode().equals(code)) {
return type.getName();
}
}
return null;
}
} }
/** /**
* 到货状态 * 到货状态
...@@ -82,6 +100,15 @@ public class PreparationMoneyEnum { ...@@ -82,6 +100,15 @@ public class PreparationMoneyEnum {
* 编码 * 编码
*/ */
private String describe; private String describe;
public static String getName(String code) {
for(RECEIVING_STATUS type: RECEIVING_STATUS.values()) {
if (type.getCode().equals(code)) {
return type.getName();
}
}
return null;
}
} }
/** /**
* 业主类型 * 业主类型
...@@ -90,9 +117,8 @@ public class PreparationMoneyEnum { ...@@ -90,9 +117,8 @@ public class PreparationMoneyEnum {
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
enum OWNER_TYPE { enum OWNER_TYPE {
document_state("未完成", "0", "未完成"),// 订单状态0未完成1已完成2作废 非居民("非居民", "0", "非居民"),
shipment_status("已完成", "1", "0"),//发货状态 0 未发货1已发货 居民("居民", "1", "居民");//到货状态0未到货1已到货
receiving_status("作废", "2", "1");//到货状态0未到货1已到货
/** /**
* 名称,描述 * 名称,描述
*/ */
......
...@@ -132,6 +132,6 @@ public class DocumentBomController extends BaseController { ...@@ -132,6 +132,6 @@ public class DocumentBomController extends BaseController {
Page<DocumentBomDto> page = new Page<DocumentBomDto>(); Page<DocumentBomDto> page = new Page<DocumentBomDto>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
return ResponseHelper.buildResponse(documentBomServiceImpl.listByPreparationMoneyId(page, preparationMoneyId)); return ResponseHelper.buildResponse(documentBomServiceImpl.queryForDocumentBomPage(page, preparationMoneyId));
} }
} }
...@@ -146,14 +146,6 @@ public class PreparationMoneyController extends BaseController { ...@@ -146,14 +146,6 @@ public class PreparationMoneyController extends BaseController {
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/getShippingPricev")
@ApiOperation(httpMethod = "POST", value = "发货价格数据查询-for test", notes = "发货价格数据查询2")
public ResponseModel<Double> getShippingPricev(@RequestBody List<PeasantHouseholdDto> dtos) {
List<Long> powerHouseholdIds = dtos.stream().map(PeasantHouseholdDto::getSequenceNbr).collect(Collectors.toList());
return ResponseHelper.buildResponse(preparationMoneyServiceImpl.caculateShippingPriceByPowerHouseHoldIds(powerHouseholdIds).getInventoryPrice());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/detail") @GetMapping(value = "/detail")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个发货单详情", notes = "根据sequenceNbr查询单个发货单详情") @ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个发货单详情", notes = "根据sequenceNbr查询单个发货单详情")
public ResponseModel<PreparationMoneyDto> getObject(@RequestParam Long sequenceNbr) { public ResponseModel<PreparationMoneyDto> getObject(@RequestParam Long sequenceNbr) {
......
...@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.DocumentBom; ...@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.DocumentBom;
import com.yeejoin.amos.boot.module.hygf.api.mapper.DocumentBomMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.DocumentBomMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IDocumentBomService; import com.yeejoin.amos.boot.module.hygf.api.service.IDocumentBomService;
import com.yeejoin.amos.boot.module.hygf.api.dto.DocumentBomDto; import com.yeejoin.amos.boot.module.hygf.api.dto.DocumentBomDto;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
...@@ -53,10 +54,29 @@ public class DocumentBomServiceImpl extends BaseService<DocumentBomDto,DocumentB ...@@ -53,10 +54,29 @@ public class DocumentBomServiceImpl extends BaseService<DocumentBomDto,DocumentB
return this.queryForList("" , false); return this.queryForList("" , false);
} }
public Page<DocumentBomDto> listByPreparationMoneyId(Page<DocumentBomDto> page, Long preparationMoneyId) { /**
* 分页查询 By preparationMoneyId
*/
public Page<DocumentBomDto> queryForDocumentBomPage(Page<DocumentBomDto> page, Long preparationMoneyId) {
return this.queryForPage(page, null, false, preparationMoneyId); return this.queryForPage(page, null, false, preparationMoneyId);
} }
/**
* 查询 By preparationMoneyId
*/
public List<DocumentBomDto> listByPreparationMoneyId(Long preparationMoneyId) {
return this.queryForList(null, false, preparationMoneyId);
}
/**
* 根据发货电站组装BOM清单数据
*
*
* @param powerHouseholdIds powerHouseholdIds
* @return {@link List< DocumentBom>}
* @author Provence
* @throws
*/
public List<DocumentBom> assembleDocumentBom(List<Long> powerHouseholdIds) { public List<DocumentBom> assembleDocumentBom(List<Long> powerHouseholdIds) {
// hygf_design_information // hygf_design_information
List<DesignInformation> designInformations = designInformationService.query().in("peasant_household_id", powerHouseholdIds).list(); List<DesignInformation> designInformations = designInformationService.query().in("peasant_household_id", powerHouseholdIds).list();
...@@ -109,13 +129,25 @@ public class DocumentBomServiceImpl extends BaseService<DocumentBomDto,DocumentB ...@@ -109,13 +129,25 @@ public class DocumentBomServiceImpl extends BaseService<DocumentBomDto,DocumentB
List<DocumentBom> documentBoms = new ArrayList<>(); List<DocumentBom> documentBoms = new ArrayList<>();
JSONArray jsonArray = JSONArray.parseArray(objects.toString()); JSONArray jsonArray = JSONArray.parseArray(objects.toString());
for (int i = 0; i < jsonArray.size(); i++) { for (int i = 0; i < jsonArray.size(); i++) {
DocumentBom documentBom = new DocumentBom();
JSONObject json = jsonArray.getJSONObject(i); JSONObject json = jsonArray.getJSONObject(i);
Integer demandNumber = json.getInteger("pzsl");//配置数量 documentBoms.add(parseDocumentBom(json));
}
return documentBoms;
}
private DocumentBom parseDocumentBom(JSONObject json) {
DocumentBom documentBom = new DocumentBom();
String materialNum = json.getString("wlbm");//物料编码 String materialNum = json.getString("wlbm");//物料编码
String materialName = json.getString("wlmc");//物料名称 String materialName = json.getString("wlmc");//物料名称
Double power = Double.valueOf(Optional.ofNullable(json.getString("gl")).orElse("0").replace("W", ""));// 去掉功率的单位 Integer demandNumber = json.getInteger("pzsl");//配置数量
Double price = json.getDouble("price");//价格 Double price = json.getDouble("price");//价格
if (StringUtils.isAnyBlank(materialNum, materialName)) {
throw new RuntimeException("物料编码和物料名称不能为空");
}
if (null == demandNumber || null == price) {
throw new RuntimeException("价格和配置数量不能为空");
}
Double power = Double.valueOf(Optional.ofNullable(json.getString("gl")).orElse("0").replace("W", ""));// 去掉功率的单位
documentBom.setMaterialNum(materialNum);//物料编码 documentBom.setMaterialNum(materialNum);//物料编码
documentBom.setMaterialName(materialName);//物料名称 documentBom.setMaterialName(materialName);//物料名称
documentBom.setUnitPrice(price); documentBom.setUnitPrice(price);
...@@ -125,8 +157,6 @@ public class DocumentBomServiceImpl extends BaseService<DocumentBomDto,DocumentB ...@@ -125,8 +157,6 @@ public class DocumentBomServiceImpl extends BaseService<DocumentBomDto,DocumentB
类型和分组目前没有该字段 类型和分组目前没有该字段
documentBom.setMaterialType(materialType); documentBom.setMaterialType(materialType);
documentBom.setMaterialGroup();*/ documentBom.setMaterialGroup();*/
documentBoms.add(documentBom); return documentBom;
}
return documentBoms;
} }
} }
\ No newline at end of file
...@@ -30,6 +30,7 @@ import java.math.BigDecimal; ...@@ -30,6 +30,7 @@ import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -139,32 +140,32 @@ public class PreparationMoneyServiceImpl extends BaseService<PreparationMoneyDto ...@@ -139,32 +140,32 @@ public class PreparationMoneyServiceImpl extends BaseService<PreparationMoneyDto
isUpdate = true; isUpdate = true;
} }
// BOM 清单 后台查询数据库整合数据 // BOM 清单 后台查询数据库整合数据
List<PeasantHouseholdDto> powerStations = Optional.ofNullable(model.getPowerStations()).orElseGet(ArrayList::new); List<PeasantHouseholdDto> powerStations = model.getPowerStations();
List<Long> powerHouseholdIds = powerStations.stream().map(PeasantHouseholdDto::getSequenceNbr).collect(Collectors.toList()); List<Long> powerHouseholdIds = powerStations.stream().map(PeasantHouseholdDto::getSequenceNbr).collect(Collectors.toList());
// 后台组装BOM清单
List<DocumentBom> documentBoms = documentBomService.assembleDocumentBom(powerHouseholdIds); List<DocumentBom> documentBoms = documentBomService.assembleDocumentBom(powerHouseholdIds);
if (CollectionUtils.isEmpty(documentBoms)) { if (CollectionUtils.isEmpty(documentBoms)) {
// throw new BaseException("BOM清单为空", "400", "BOM清单为空");// 这里阻塞前端接口 // throw new BaseException("BOM清单为空", "400", "BOM清单为空");// 这里阻塞前端接口
// 根据发货电站信息无法组装成BOM清单 // 根据发货电站信息无法组装成BOM清单
throw new RuntimeException("BOM清单为空"); throw new RuntimeException("BOM清单为空");
} }
// 根据BOM清单计算当前发货单的价格
PreparationMoneyDto pmd = caculateShippingPrice(documentBoms); PreparationMoneyDto pmd = caculateShippingPrice(documentBoms);
model.setInventoryPrice(pmd.getInventoryPrice());//清单价格 model.setInventoryPrice(pmd.getInventoryPrice());//清单价格
model.setDiscount(pmd.getDiscount());//折扣 model.setDiscount(pmd.getDiscount());//折扣
model.setPromotion(pmd.getPromotion());//促销 model.setPromotion(pmd.getPromotion());//促销
model.setTotalPrice(pmd.getTotalPrice()); model.setTotalPrice(pmd.getTotalPrice());//总价
// 前端传值改动太大, 从数据库获取dealerName // 前端传值改动太大, 从数据库获取dealerName
LambdaQueryWrapper<UnitInfo> unitInfoque = new LambdaQueryWrapper<>(); String dealerName = Optional.ofNullable(unitInfoService.query().eq("amos_company_seq", model.getDealerId()).one()).map(UnitInfo::getName).orElse(null);
unitInfoque.eq(UnitInfo::getAmosCompanySeq, model.getDealerId());
String dealerName = Optional.ofNullable(unitInfoService.query().getBaseMapper().selectOne(unitInfoque)).map(UnitInfo::getName).orElse(null);
model.setDealerName(dealerName); model.setDealerName(dealerName);
// model.setContractPrice(pmd.getContractPrice());//合同价格 // model.setContractPrice(pmd.getContractPrice());//合同价格
PreparationMoney entity = new PreparationMoney() ;
if (!isUpdate) { if (!isUpdate) {
// 初始化状态 // 初始化状态
model.setReceivingStatus(PreparationMoneyEnum.RECEIVING_STATUS.未到货.getName()); model.setReceivingStatus(PreparationMoneyEnum.RECEIVING_STATUS.未到货.getName());
model.setShipmentStatus(PreparationMoneyEnum.SHIPMENT_STATUS.未发货.getName()); model.setShipmentStatus(PreparationMoneyEnum.SHIPMENT_STATUS.未发货.getName());
model.setDocumentState(PreparationMoneyEnum.DOCUMENT_STATE.未完成.getName()); model.setDocumentState(PreparationMoneyEnum.DOCUMENT_STATE.未完成.getName());
} }
PreparationMoney entity = new PreparationMoney();
BeanUtils.copyProperties(model, entity); BeanUtils.copyProperties(model, entity);
this.saveOrUpdate(entity); this.saveOrUpdate(entity);
documentBoms.stream().forEach(d -> d.setPreparationMoneyId(entity.getSequenceNbr())); documentBoms.stream().forEach(d -> d.setPreparationMoneyId(entity.getSequenceNbr()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment