Commit 76f82f5d by 高晓磊

同步销售记录

parent f5988d6d
......@@ -11,6 +11,10 @@ public interface NeedPlanConstant {
*/
String NEED_PLAN_ENTITY = "com.xyst.dinas.sales.datamodel.NeedPlan";
/**
* 子表实体名
*/
String NEED_PLAN_DETAIL_ENTITY = "com.xyst.dinas.sales.datamodel.NeedPlanAssociatedNeedPlanDetail";
/**
* 需用计划量
*/
String needPlanAmount = "needPlanAmount";
......
......@@ -30,5 +30,5 @@ public interface NeedPlanDao {
List<KObject> getByCarAndPlanningCycle(String carNum, KObject planningCycleObj);
KObject queryDetailById(UUID fromString);
}
......@@ -44,6 +44,13 @@ public class SalesPlanDao {
return (KObject) template.get(SalesPlanConstant.ENTITY, id);
}
public KObject loadDetail(UUID sealDetailId) {
return (KObject) template.get(SalesPlanConstant.ENTITY_DETAIL, sealDetailId);
}
public KObject loadTempDetail(UUID sealDetailId) {
return (KObject) template.get(SalesPlanConstant.ENTITY_TEMP_DETAIL, sealDetailId);
}
public UUID create(KObject kObject) {
return (UUID) template.save(kObject.getType().getName(), kObject);
}
......@@ -356,5 +363,33 @@ public class SalesPlanDao {
detachedCriteria.add(Restrictions.like("carNumber", "%"+carNum+"%"));
return (List<KObject>) template.findByCriteria(detachedCriteria);
}
public void updateSalesPlanTempAmount(String salePlanTempId, BigDecimal dealamount) {
KObject o =(KObject) template.get(SalesPlanConstant.ENTITY_TEMP_DETAIL, UUID.fromString(salePlanTempId));
if(o==null||o.isNull()||o.isEmpty()){
return;
}
BigDecimal actualSaleAmount = o.getBigDecimal("actualSaleAmount");
if(actualSaleAmount==null){
actualSaleAmount=BigDecimal.ZERO;
}
o.set("actualSaleAmount",actualSaleAmount.add(dealamount));
template.update(o);
}
public void updateSalesPlanDetailAmount(String salePlanDetailId, Double dealAmount) {
KObject o =(KObject) template.get(SalesPlanConstant.ENTITY_DETAIL, UUID.fromString(salePlanDetailId));
if(o==null||o.isNull()||o.isEmpty()){
return;
}
BigDecimal actualSaleAmount = o.getBigDecimal("actualSaleAmount");
if(actualSaleAmount==null){
actualSaleAmount=BigDecimal.ZERO;
}
o.set("actualSaleAmount",actualSaleAmount.add(BigDecimal.valueOf(dealAmount)));
template.update(o);
}
}
......@@ -8,6 +8,7 @@ import com.beecode.amino.core.Amino;
import com.beecode.bcp.type.KClass;
import com.xyst.dinas.biz.dao.DinasTypeDao;
import com.xyst.dinas.biz.enumeration.SubmitStateEnum;
import com.xyst.dinas.sales.constant.SalesPlanConstant;
import com.xyst.dinas.sales.enumeration.TransportModeEnum;
import org.hibernate.HibernateException;
import org.hibernate.Session;
......@@ -170,4 +171,9 @@ public class NeedPlanDaoImpl implements NeedPlanDao, NeedPlanConstant {
return (List<KObject>)template.findByCriteria(detachedCriteria);
}
@Override
public KObject queryDetailById(UUID fromString) {
return (KObject) template.get(NEED_PLAN_DETAIL_ENTITY, fromString);
}
}
......@@ -45,8 +45,6 @@ public class NeedPlanServiceImpl implements NeedPlanService {
if (needPlanDetailsList.size() > 0) {
kObject = needPlanDetailsList.stream().filter(detail -> detail.get("dinasType").getUuid("id").equals(dinasTypeId)).findAny().orElse(null);
}
Map<String, Object> map = new HashMap<>();
map.put("needPlanAmount", kObject);
return kObject;
}
......
......@@ -613,7 +613,7 @@ public class SalesPlanServiceImpl implements SalesPlanService {
//需用计划id
stringObjectHashMap.put("needPlanId", saleTempDetail.getUuid("id"));
//需用计划砂石id
stringObjectHashMap.put("needDinasTypeId", saleTempDetail.getUuid("id"));
stringObjectHashMap.put("needPlanDetailId", saleTempDetail.getUuid("id"));
//本周期已拉取量
stringObjectHashMap.put("effectiveSale", saleTempDetail.getBigDecimal("actualSaleAmount"));
//本周期分配量
......@@ -674,7 +674,7 @@ public class SalesPlanServiceImpl implements SalesPlanService {
//需用计划id
stringObjectHashMap.put("needPlanId", plan.getUuid("id"));
//需用计划砂石id
stringObjectHashMap.put("needDinasTypeId", needPlanDetail.getUuid("id"));
stringObjectHashMap.put("needPlanDetailId", needPlanDetail.getUuid("id"));
//本周期已拉取量
stringObjectHashMap.put("effectiveSale", needPlanDetail.getBigDecimal("effectiveSale"));
//本周期分配量
......
......@@ -14,9 +14,9 @@ public interface SalesRecordService {
* 主要用于外部接口调用
* @param salesRecordList 销售台账List
* @param station
* @return 返回存储状态 failure/失败 success/成功
* @return
*/
String saveSalesRecordService(List<SalesRecordInfo> salesRecordList, KObject station);
String saveSalesRecordService(SalesRecordInfo salesRecordList, KObject station);
HashMap<String,Object> qualityReportExcelImport(MultipartFile file);
}
......@@ -87,6 +87,44 @@
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>javax.persistence.Column</m:type>
<m:properties>
<m:property>
<m:key>name</m:key>
<m:value>gross_weight_time</m:value>
</m:property>
</m:properties>
</m:annotation>
</m:annotations>
<m:id>ca273c9d-0981-4f6d-94b4-4a3b76742a1e</m:id>
<m:name>grossWeightTime</m:name>
<m:title>毛重时间</m:title>
<m:type>datetime</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>javax.persistence.Column</m:type>
<m:properties>
<m:property>
<m:key>name</m:key>
<m:value>tare_weight_time</m:value>
</m:property>
</m:properties>
</m:annotation>
</m:annotations>
<m:id>ca273c9d-0981-4f6d-94b4-4a3b76742a1e</m:id>
<m:name>tareWeightTime</m:name>
<m:title>皮重时间</m:title>
<m:type>datetime</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>javax.persistence.ManyToOne</m:type>
</m:annotation>
<m:annotation>
......@@ -379,6 +417,52 @@
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>20</m:value>
</m:annotation>
<m:annotation>
<m:type>javax.persistence.Column</m:type>
<m:properties>
<m:property>
<m:key>name</m:key>
<m:value>gross_weight_person</m:value>
</m:property>
</m:properties>
</m:annotation>
</m:annotations>
<m:id>9ed97388-563a-4634-a555-b56bb1664dd0</m:id>
<m:name>grossWeightPerson</m:name>
<m:title>毛重司磅员</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>20</m:value>
</m:annotation>
<m:annotation>
<m:type>javax.persistence.Column</m:type>
<m:properties>
<m:property>
<m:key>name</m:key>
<m:value>tare_weight_person</m:value>
</m:property>
</m:properties>
</m:annotation>
</m:annotations>
<m:id>9ed97388-563a-4634-a555-b56bb1664dd0</m:id>
<m:name>tareWeightPerson</m:name>
<m:title>皮重司磅员</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.Numeric</m:type>
<m:properties>
<m:property>
......
......@@ -9,6 +9,8 @@ import com.xyst.dinas.price.enumeration.PriceAdjustmentAdjustmentStatusEnum;
import com.xyst.dinas.sales.constant.SalesPlanConstant;
import com.xyst.dinas.sales.constant.SalesRecordConstant;
import com.xyst.dinas.sales.dao.InventoryDao;
import com.xyst.dinas.sales.dao.NeedPlanDao;
import com.xyst.dinas.sales.dao.SalesPlanDao;
import com.xyst.dinas.transport.constant.VehicleDriverUserConstant;
import com.xyst.dinas.transport.constant.VehicleDispatchConstant;
import com.xyst.dinas.transport.dao.VehicleDispatchDao;
......@@ -35,13 +37,16 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
private VehicleDispatchDao vehicleDispatchDao;
@Autowired
private DinasTypeDao dinasTypeDao;
@Autowired
private DriverUserDao driverUserDao;
@Autowired
private VehicleDriverUserDao vehicleDriverUserDao;
@Autowired
private InventoryDao inventoryDao;
@Autowired
private SalesPlanDao salesPlanDao;
@Autowired
private NeedPlanDao needPlanDao;
@Override
public UUID create(KObject kobject) {
......@@ -178,7 +183,8 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
KObject project = dispatch.get("project");
KObject dinasType = dispatch.get("dinasType");
KObject contract = dispatch.get("contract");
UUID sealDetailId = dispatch.getUuid("sealDetailId");
int dispatchType = dispatch.getInt("dispatchType");
Map<String, Object> stringObjectHashMap = new HashMap<String, Object>();
//车牌号
stringObjectHashMap.put("carNum", carNum);
......@@ -192,7 +198,7 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
stringObjectHashMap.put("projectCode", project.getString("projectNum"));
//项目id
stringObjectHashMap.put("projectId", project.getUuid("id"));
//项目id
//合同id
stringObjectHashMap.put("contractId", contract.getUuid("id"));
//砂石类型名称
stringObjectHashMap.put("dinasTypeName", dinasType.getString("dinasTypeName"));
......@@ -200,14 +206,37 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
stringObjectHashMap.put("dinasTypeId", dinasType.getUuid("id"));
//本次需用量
stringObjectHashMap.put("needPlanAmount", dispatch.getBigDecimal("planAmount"));
//需用计划id
stringObjectHashMap.put("needPlanId", dispatch.getUuid("id"));
//需用计划砂石id
stringObjectHashMap.put("needDinasTypeId", dispatch.getUuid("id"));
//本周期已拉取量
stringObjectHashMap.put("effectiveSale", dispatch.getBigDecimal("actualTransportation"));
//本周期分配量
stringObjectHashMap.put("planAmount", dispatch.getBigDecimal("planAmount"));
if(dispatchType==DispatchTypeEnum.SALE_TEMP_PLAN.getValue()){
KObject salePlanTemp = salesPlanDao.loadTempDetail(sealDetailId);
//临时销售计划没有需用计划,这里值仅做填充
//需用计划id
stringObjectHashMap.put("needPlanId", salePlanTemp.get("master").getUuid("id"));
//需用计划砂石id
stringObjectHashMap.put("needPlanDetailId", salePlanTemp.getUuid("id"));
//销售计划id
stringObjectHashMap.put("salePlanId", salePlanTemp.get("master").getUuid("id"));
//销售计划砂石id
stringObjectHashMap.put("salePlanDetailId", salePlanTemp.getUuid("id"));
}else {
KObject kObject = needPlanDao.queryNeedPlanAmountByCycleId(project.getUuid("id"), planningCycle.getUuid("id"));
List<KObject> needPlanDetail = kObject.get("NeedPlanDetail").toList();
Optional<KObject> first = needPlanDetail.stream().filter(a -> a.get("dinasType").getUuid("id").toString().equals(dinasType.getUuid("id").toString())).findFirst();
stringObjectHashMap.put("needPlanId", kObject.getUuid("id"));
first.ifPresent(a->{
//需用计划砂石id
stringObjectHashMap.put("needPlanDetailId", a.getUuid("id"));
});
KObject salePlanDetail = salesPlanDao.loadDetail(sealDetailId);
//需用计划id
stringObjectHashMap.put("salePlanId", salePlanDetail.get("master").getUuid("id"));
//需用计划砂石id
stringObjectHashMap.put("salePlanDetailId", salePlanDetail.getUuid("id"));
}
//获取砂石今日库存
//库存id
KObject inventory = inventoryDao.getItemByStationIdAndDinasTypeId(station.getUuid("id"), dinasType.getUuid("id"));
......@@ -221,13 +250,20 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
stringObjectHashMap.put("price", price);
//销售类型
stringObjectHashMap.put("planAmount", dispatch.getBigDecimal("planAmount"));
stringObjectHashMap.put("saleType", dispatch.getInt("dispatchType"));
stringObjectHashMap.put("saleType", dispatchType);
//运输类型
stringObjectHashMap.put("transportType", 1);
if(amount.compareTo(new BigDecimal("0"))<1){
stringObjectHashMap.put("canSale", false);
stringObjectHashMap.put("canSaleTitle", "今日已售罄");
if(amount.compareTo(BigDecimal.ZERO)<1){
stringObjectHashMap.put("canSale",false);
stringObjectHashMap.put("canSaleTitle","今日已售罄");
}else if(price.compareTo(BigDecimal.ZERO)<1){
stringObjectHashMap.put("canSale",false);
stringObjectHashMap.put("canSaleTitle","砂石价格未维护,请联系场站人员维护");
}else{
stringObjectHashMap.put("canSale",true);
}
maps.add(stringObjectHashMap);
}
return maps;
......
......@@ -52,7 +52,7 @@ public class WeighbridgeSyncController {
* @return
*/
@PostMapping(value = "/weighbridgeSync/saveSalesRecord", consumes = "application/json")
public Object saveSalesRecord(@RequestParam String weighbridgeCode,@RequestBody List<SalesRecordInfo> salesRecordList) {
public Object saveSalesRecord(@RequestParam String weighbridgeCode,@RequestBody SalesRecordInfo salesRecordList) {
//根据地磅id查询场站
if(StringUtils.isBlank(weighbridgeCode)){
return ResponseObj.error(500,"地磅唯一编码不能为空");
......@@ -61,10 +61,10 @@ public class WeighbridgeSyncController {
if(station==null){
return ResponseObj.error(500,"没有查询到地磅匹配的场站");
}
if (salesRecordList.isEmpty()) {
if (salesRecordList==null) {
return ResponseObj.error("传递的销售台账数据条数为0!请确认!");
} else {
return salesRecordService.saveSalesRecordService(salesRecordList,station);
return ResponseObj.success("新增成功",salesRecordService.saveSalesRecordService(salesRecordList,station));
}
}
......@@ -124,7 +124,7 @@ public class WeighbridgeSyncController {
}
/**
* 根据车牌号和地磅唯一编码获取本场站下本车辆今日销售计划和临时销售计划
* 查询全部售卖的砂石类型和价格
* @param
* @return
*/
......
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