Commit 77729e2c by 高晓磊

同步地磅接口提交

parent 42ead20f
...@@ -499,6 +499,7 @@ public class SecurityConfig { ...@@ -499,6 +499,7 @@ public class SecurityConfig {
.antMatchers("/workflow/api/**").permitAll() .antMatchers("/workflow/api/**").permitAll()
.antMatchers("/dnaserver/**").permitAll() .antMatchers("/dnaserver/**").permitAll()
.antMatchers("/dinasBiz/organization/queryOrganizationByUserName").permitAll() .antMatchers("/dinasBiz/organization/queryOrganizationByUserName").permitAll()
.antMatchers("/weighbridgeSync/**").permitAll()
.anyRequest().authenticated();//listAll,modifySelfPassword,loadAuctionByAsset临时开放 .anyRequest().authenticated();//listAll,modifySelfPassword,loadAuctionByAsset临时开放
http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint); http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint);
InzWebAuthenticationFilter filter = new InzWebAuthenticationFilter(); InzWebAuthenticationFilter filter = new InzWebAuthenticationFilter();
......
package com.beecode.inz.common.util;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Decoder;
import java.io.*;
public class BASE64DecodedMultipartFile implements MultipartFile {
private final byte[] imgContent;
private final String header;
public BASE64DecodedMultipartFile(byte[] imgContent, String header) {
this.imgContent = imgContent;
this.header = header.split(";")[0];
}
@Override
public String getName() {
return System.currentTimeMillis() + Math.random() + "." + header.split("/")[1];
}
@Override
public String getOriginalFilename() {
return System.currentTimeMillis() + (int) Math.random() * 10000 + "." + header.split("/")[1];
}
@Override
public String getContentType() {
return header.split(":")[1];
}
@Override
public boolean isEmpty() {
return imgContent == null || imgContent.length == 0;
}
@Override
public long getSize() {
return imgContent.length;
}
@Override
public byte[] getBytes() throws IOException {
return imgContent;
}
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(imgContent);
}
@Override
public void transferTo(File dest) throws IOException, IllegalStateException {
new FileOutputStream(dest).write(imgContent);
}
public static MultipartFile base64ToMultipart(String base64) {
try {
String[] baseStrs = base64.split(",");
BASE64Decoder decoder = new BASE64Decoder();
byte[] b = new byte[0];
b = decoder.decodeBuffer(baseStrs[1]);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {
b[i] += 256;
}
}
return new BASE64DecodedMultipartFile(b, baseStrs[0]);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}
\ No newline at end of file
...@@ -33,4 +33,6 @@ public interface RetailInfoDao extends BaseDao { ...@@ -33,4 +33,6 @@ public interface RetailInfoDao extends BaseDao {
BigDecimal selectBuyAmountByIdCard(String idCard, UUID fromString); BigDecimal selectBuyAmountByIdCard(String idCard, UUID fromString);
KObject insertNoInfo(String name, KObject station, KObject organization); KObject insertNoInfo(String name, KObject station, KObject organization);
KObject createOrGet(String retailName, String retailIdNum, KObject station);
} }
...@@ -32,4 +32,6 @@ public interface StationDao extends BaseDao { ...@@ -32,4 +32,6 @@ public interface StationDao extends BaseDao {
List<KObject> getStationCameraById(UUID id1); List<KObject> getStationCameraById(UUID id1);
KObject insertProductionLine(String productionLineName, KObject station); KObject insertProductionLine(String productionLineName, KObject station);
KObject getStationByWeighbridge(String weighbridgeCode);
} }
...@@ -159,6 +159,24 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao, ...@@ -159,6 +159,24 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao,
return kObject; return kObject;
} }
@Override
public KObject createOrGet(String retailName, String retailIdNum, KObject station) {
KClass bean = Amino.getStaticMetadataContext().getBean(RetailInfoConstant.ENTITY, KClass.class);
KObject kObject = bean.newInstance();
kObject.set("station", station);
kObject.set("regionalCompany", station.get("regionalCompany"));
kObject.set("retailInfoName", retailName);
kObject.set("idCard", retailIdNum);
kObject.set("address", "请维护");
kObject.set("reason", "系统自动新增,请修改实际情况");
kObject.set("id", UUID.randomUUID());
kObject.set(BaseConstants.CREATE_TIME, new Date());
kObject.set(BaseConstants.DEL, false);
template.save(kObject);
return kObject;
}
private String getRandom() { private String getRandom() {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
SecureRandom random = new SecureRandom(); SecureRandom random = new SecureRandom();
......
...@@ -153,6 +153,7 @@ public class StationDaoImpl extends AbstractBaseDao implements StationDao, Stat ...@@ -153,6 +153,7 @@ public class StationDaoImpl extends AbstractBaseDao implements StationDao, Stat
return kObject; return kObject;
} }
@Override @Override
public UUID create(KObject kObject) { public UUID create(KObject kObject) {
KObject staff = AminoContextHolder.getContext().getStaff(); KObject staff = AminoContextHolder.getContext().getStaff();
...@@ -238,4 +239,20 @@ public class StationDaoImpl extends AbstractBaseDao implements StationDao, Stat ...@@ -238,4 +239,20 @@ public class StationDaoImpl extends AbstractBaseDao implements StationDao, Stat
}); });
} }
@Override
public KObject getStationByWeighbridge(String weighbridgeCode) {
KClass bean = Amino.getStaticMetadataContext().getBean(StationConstant.ENTITY, KClass.class);
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName());
dinasTypeDao.addRegionalCompanyFilter(detachedCriteria);
detachedCriteria.add(Restrictions.eq("del", false));
detachedCriteria.add(Restrictions.or(Restrictions.eq("weighbridgeInCode", weighbridgeCode),Restrictions.eq("weighbridgeOutCode", weighbridgeCode)));
List<KObject> byCriteria = (List<KObject>) template.findByCriteria(detachedCriteria);
if(!byCriteria.isEmpty()){
return byCriteria.get(0);
}
return null;
}
} }
...@@ -26,7 +26,8 @@ public class PlanningCycleServiceImpl implements PlanningCycleService{ ...@@ -26,7 +26,8 @@ public class PlanningCycleServiceImpl implements PlanningCycleService{
* @param date * @param date
* @return * @return
*/ */
public KObject getPlanningCycleObj(PlanningCycleEnum planningCycleType,Date date) { @Override
public KObject getPlanningCycleObj(PlanningCycleEnum planningCycleType, Date date) {
return planningCycleDao.getPlanningCycleObj(planningCycleType, date); return planningCycleDao.getPlanningCycleObj(planningCycleType, date);
} }
......
package com.xyst.dinas.biz.internal.service; package com.xyst.dinas.biz.internal.service;
import com.beecode.amino.core.Amino;
import com.beecode.bap.attachment.common.Page; import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject; import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils; import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.basis.service.WarehouseUserService; import com.beecode.inz.basis.service.WarehouseUserService;
...@@ -14,8 +16,6 @@ import com.xyst.dinas.biz.service.RetailInfoService; ...@@ -14,8 +16,6 @@ import com.xyst.dinas.biz.service.RetailInfoService;
import com.xyst.dinas.biz.warn.*; import com.xyst.dinas.biz.warn.*;
import com.xyst.dinas.biz.warn.service.WarningService; import com.xyst.dinas.biz.warn.service.WarningService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -23,7 +23,6 @@ import java.math.BigDecimal; ...@@ -23,7 +23,6 @@ import java.math.BigDecimal;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class RetailInfoServiceImpl implements RetailInfoService { public class RetailInfoServiceImpl implements RetailInfoService {
...@@ -195,5 +194,24 @@ public class RetailInfoServiceImpl implements RetailInfoService { ...@@ -195,5 +194,24 @@ public class RetailInfoServiceImpl implements RetailInfoService {
return retailInfoDao.selectBuyAmountByIdCard(idCard,fromString); return retailInfoDao.selectBuyAmountByIdCard(idCard,fromString);
} }
@Override
public KObject create(KObject station, KObject dinasType, String retailIdNum, String retailName, String carInfo, Double dealAmount, Double amount) {
KObject orGet = retailInfoDao.createOrGet(retailName, retailIdNum, station);
KClass bean = Amino.getStaticMetadataContext().getBean(RetailInfoConstant.DETAIL_ENTITY, KClass.class);
KObject object = bean.newInstance();
object.set("purchaseAmount",dealAmount);
object.set("master",retailInfoDao.load(orGet.getUuid("id")));
object.set("dinasType",dinasTypeDao.load(object.get("dinasType").getUuid(BaseConstants.ID)));
object.set(BaseConstants.ID,UUID.randomUUID());
retailInfoDao.saveOrUpdate(object);
String newRetailInfoName = orGet.getString("retailInfoName");
String newIdCard = orGet.getString("idCard");
UUID newStation = orGet.get("station").getUuid(BaseConstants.ID);
setWarnInfo(orGet, orGet.getUuid("id"), newRetailInfoName, newIdCard, newStation);
return orGet;
}
} }
...@@ -92,5 +92,10 @@ public class StationServiceImpl implements StationService { ...@@ -92,5 +92,10 @@ public class StationServiceImpl implements StationService {
} }
@Override
public KObject getStationByWeighbridge(String weighbridgeCode) {
return stationDao.getStationByWeighbridge(weighbridgeCode);
}
} }
...@@ -28,4 +28,6 @@ public interface RetailInfoService { ...@@ -28,4 +28,6 @@ public interface RetailInfoService {
Long selectBuyCountByIdCard(String toString, UUID uuid); Long selectBuyCountByIdCard(String toString, UUID uuid);
BigDecimal selectBuyAmountByIdCard(String idCard, UUID fromString); BigDecimal selectBuyAmountByIdCard(String idCard, UUID fromString);
KObject create(KObject station, KObject dinasType, String retailIdNum, String retailName, String carInfo, Double dealAmount, Double amount);
} }
...@@ -27,4 +27,7 @@ public interface StationService { ...@@ -27,4 +27,7 @@ public interface StationService {
List<KObject> queryStationByRegionalCompany(); List<KObject> queryStationByRegionalCompany();
List<KObject> getStationCameraById(UUID id1); List<KObject> getStationCameraById(UUID id1);
KObject getStationByWeighbridge(String weighbridgeCode);
} }
...@@ -165,6 +165,52 @@ ...@@ -165,6 +165,52 @@
<m:properties> <m:properties>
<m:property> <m:property>
<m:key>name</m:key> <m:key>name</m:key>
<m:value>weighbridge_out_code</m:value>
</m:property>
</m:properties>
</m:annotation>
</m:annotations>
<m:id>948e9971-7efa-4082-9403-c52269e13aeb</m:id>
<m:name>weighbridgeOutCode</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>50</m:value>
</m:annotation>
<m:annotation>
<m:type>javax.persistence.Column</m:type>
<m:properties>
<m:property>
<m:key>name</m:key>
<m:value>weighbridge_in_code</m:value>
</m:property>
</m:properties>
</m:annotation>
</m:annotations>
<m:id>6d151a31-ee30-4674-a78b-ff0011bd998c</m:id>
<m:name>weighbridgeInCode</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>50</m:value>
</m:annotation>
<m:annotation>
<m:type>javax.persistence.Column</m:type>
<m:properties>
<m:property>
<m:key>name</m:key>
<m:value>link_man</m:value> <m:value>link_man</m:value>
</m:property> </m:property>
</m:properties> </m:properties>
......
...@@ -50,6 +50,16 @@ ...@@ -50,6 +50,16 @@
<comment>场站名称</comment> <comment>场站名称</comment>
</column> </column>
</property> </property>
<property name="weighbridgeInCode" type="nstring" not-null="false">
<column name="weighbridge_in_code" length="50" >
<comment>进厂地磅编码</comment>
</column>
</property>
<property name="weighbridgeOutCode" type="nstring" not-null="false">
<column name="weighbridge_out_code" length="50" >
<comment>出厂地磅编码</comment>
</column>
</property>
<property name="stationAddress" type="nstring" length="80" not-null="false"> <property name="stationAddress" type="nstring" length="80" not-null="false">
<column name="station_address"> <column name="station_address">
<comment>场站地址</comment> <comment>场站地址</comment>
......
...@@ -135,12 +135,14 @@ public class ContractServiceImpl implements ContractService { ...@@ -135,12 +135,14 @@ public class ContractServiceImpl implements ContractService {
contractInfoDao.update(kObject); contractInfoDao.update(kObject);
} }
@Override
public KObject queryContractInfo(UUID id) { public KObject queryContractInfo(UUID id) {
KObject obj = contractInfoDao.load(id); KObject obj = contractInfoDao.load(id);
return obj; return obj;
} }
@Override
public KObject queryContract(UUID id) { public KObject queryContract(UUID id) {
KObject obj = contractDao.load(id); KObject obj = contractDao.load(id);
......
...@@ -3,72 +3,153 @@ package com.xyst.dinas.sales.constant; ...@@ -3,72 +3,153 @@ package com.xyst.dinas.sales.constant;
public interface SalesRecordConstant { public interface SalesRecordConstant {
public static String ENTITY = "com.xyst.dinas.sales.datamodel.SalesRecord"; public static String ENTITY = "com.xyst.dinas.sales.datamodel.SalesRecord";
//派单表实体 /**
* 派单表实体
*/
public static String VEHICLE_DISPATCH_ENTITY = "com.xyst.dinas.transport.datamodel.VehicleDispatch"; public static String VEHICLE_DISPATCH_ENTITY = "com.xyst.dinas.transport.datamodel.VehicleDispatch";
//运输记录实体 /**
* 运输记录实体
*/
public static String TRANSPORT_RECORD_ENTITY = "com.xyst.dinas.transport.datamodel.TransportRecord"; public static String TRANSPORT_RECORD_ENTITY = "com.xyst.dinas.transport.datamodel.TransportRecord";
//运输记录序列 /**
* 运输记录序列
*/
public static String TRANSPORT_RECORD_ENTITY_SERIAL = "com.xyst.dinas.transport.datamodel.TransportRecord$serial"; public static String TRANSPORT_RECORD_ENTITY_SERIAL = "com.xyst.dinas.transport.datamodel.TransportRecord$serial";
//运输车辆实体 /**
* 运输车辆实体
*/
public static String TRANSPORT_VEHICLE_ENTITY = "com.xyst.dinas.transport.datamodel.TransportVehicle"; public static String TRANSPORT_VEHICLE_ENTITY = "com.xyst.dinas.transport.datamodel.TransportVehicle";
//销售台账ID /**
public static final String ID = "id"; * 销售台账ID
//创建时间 */
public static final String CREATETIME = "createTime"; String ID = "id";
//修改时间 /**
public static final String MODIFYTIME = "modifyTime"; * 创建时间
//项目 */
public static final String PROJECT = "project"; String CREATETIME = "createTime";
//区域公司 /**
public static final String REGIONALCOMPANY = "regionalCompany"; * 修改时间
//合同 */
public static final String CONTRACT = "contract"; String MODIFYTIME = "modifyTime";
//购砂单位 /**
public static final String PURCHASESANDCOMPANY = "purchaseSandCompany"; * 项目
//场站 */
public static final String STATION = "station"; String PROJECT = "project";
//生产线 /**
public static final String PRODUCTIONLINE = "productionLine"; * 区域公司
//散户 */
public static final String RETAILINFO = "retailInfo"; String REGIONALCOMPANY = "regionalCompany";
//砂石种类 /**
public static final String DINASTYPE = "dinasType"; * 合同
//客户类型 */
public static final String CUSTOMERTYPE = "customerType"; String CONTRACT = "contract";
//销售时间 /**
public static final String DEALTIME = "dealTime"; * 购砂单位
//同步时间 */
public static final String SYNCTIME = "syncTime"; String PURCHASESANDCOMPANY = "purchaseSandCompany";
//车辆信息 /**
public static final String CARINFO = "carInfo"; * 场站
//销售数量 */
public static final String DEALAMOUNT = "dealAmount"; String STATION = "station";
//单价 /**
public static final String PRICE = "price"; * 生产线
//总价 */
public static final String AMOUNT = "amount"; String PRODUCTIONLINE = "productionLine";
//付款来源 /**
public static final String PAYMENTSOURCE = "paymentSource"; * 散户
//销售单号 */
public static final String DEALBILLCODE = "dealBillCode"; String RETAILINFO = "retailInfo";
//毛重 /**
public static final String GROSS_WEIGHT = "grossWeight"; * 砂石种类
//皮重 */
public static final String TARE_WEIGHT = "tareWeight"; String DINASTYPE = "dinasType";
/** 审批状态*/ /**
public static final String APPROVE_STATE = "approveState"; * 客户类型
*/
String CUSTOMERTYPE = "customerType";
/**
* 销售时间
*/
String DEALTIME = "dealTime";
/**
* 同步时间
*/
String SYNCTIME = "syncTime";
/**
* 车辆信息
*/
String CARINFO = "carInfo";
/**
* 销售数量
*/
String DEALAMOUNT = "dealAmount";
/**
* 单价
*/
String PRICE = "price";
/**
* 总价
*/
String AMOUNT = "amount";
/**
* 付款来源
*/
String PAYMENTSOURCE = "paymentSource";
/**
* 销售单号
*/
String DEALBILLCODE = "dealBillCode";
/**
* 毛重时间
*/
String GROSS_WEIGHT_TIME = "grossWeightTime";
/**
* 皮重时间
*/
String TARE_WEIGHT_TIME = "tareWeightTime";
/**
* 毛重
*/
String GROSS_WEIGHT = "grossWeight";
/**
* 皮重
*/
String TARE_WEIGHT = "tareWeight";
/**
* 毛重司磅员
*/
String GROSS_WEIGHT_PERSON = "grossWeightPerson";
/**
* 皮重司磅员
*/
String TARE_WEIGHT_PERSON = "tareWeightPerson";
/**
* 配送方式 0自提(运输公司自己拿) 1配送(砂石公司指派车辆) 2散客(没有车牌号,不知何处来. 不知何处去)
*/
String TRANSPORT_TYPE = "transportType";
/**
* 销售类型 0临时销售计划(突发情况) 1销售计划(正常计划,上周分配下周工作) 2.散客(卖点边边角角?)
*/
String SALE_TYPE = "saleType";
/**
* 审批状态
*/
String APPROVE_STATE = "approveState";
/** /**
* 是否废弃 * 是否废弃
*/ */
public static final String DISCARD = "discard"; String DISCARD = "discard";
/** /**
* 是否删除 * 是否删除
*/ */
public static final String DEL = "del"; String DEL = "del";
/** /**
* 负责人 * 负责人
*/ */
public static final String PIC = "pic"; String PIC = "pic";
} }
...@@ -15,6 +15,8 @@ public interface InventoryDao { ...@@ -15,6 +15,8 @@ public interface InventoryDao {
KObject getItemByStationIdAndDinasTypeId(UUID stationId, UUID dinasTypeId); KObject getItemByStationIdAndDinasTypeId(UUID stationId, UUID dinasTypeId);
List<KObject> getItemListByStationId(UUID stationId);
List<KObject> queryLog(List<String> businessObjectId); List<KObject> queryLog(List<String> businessObjectId);
/** /**
......
...@@ -27,4 +27,8 @@ public interface NeedPlanDao { ...@@ -27,4 +27,8 @@ public interface NeedPlanDao {
List<KObject> getProjectByNowPlanningCycle(UUID purchaseSandUnitId, UUID planningCycleId); List<KObject> getProjectByNowPlanningCycle(UUID purchaseSandUnitId, UUID planningCycleId);
KObject queryNeedPlanAmountByCycleId(UUID planningCycleId, UUID projectId); KObject queryNeedPlanAmountByCycleId(UUID planningCycleId, UUID projectId);
List<KObject> getByCarAndPlanningCycle(String carNum, KObject planningCycleObj);
} }
...@@ -14,7 +14,6 @@ import com.beecode.inz.common.util.DateTimeUtils; ...@@ -14,7 +14,6 @@ import com.beecode.inz.common.util.DateTimeUtils;
import com.xyst.dinas.biz.dao.DinasTypeDao; import com.xyst.dinas.biz.dao.DinasTypeDao;
import com.xyst.dinas.sales.enumeration.TransportModeEnum; import com.xyst.dinas.sales.enumeration.TransportModeEnum;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.DetachedCriteria;
...@@ -26,7 +25,6 @@ import org.springframework.lang.Nullable; ...@@ -26,7 +25,6 @@ import org.springframework.lang.Nullable;
import org.springframework.orm.hibernate5.HibernateCallback; import org.springframework.orm.hibernate5.HibernateCallback;
import org.springframework.orm.hibernate5.HibernateTemplate; import org.springframework.orm.hibernate5.HibernateTemplate;
import com.beecode.bcp.type.KObject; import com.beecode.bcp.type.KObject;
import com.beecode.inz.common.BaseConstants;
import com.xyst.dinas.sales.constant.SalesPlanConstant; import com.xyst.dinas.sales.constant.SalesPlanConstant;
import com.xyst.dinas.sales.web.request.SaleaPlanDetailQuery; import com.xyst.dinas.sales.web.request.SaleaPlanDetailQuery;
...@@ -339,5 +337,24 @@ public class SalesPlanDao { ...@@ -339,5 +337,24 @@ public class SalesPlanDao {
}); });
} }
/**
* 根据车牌号和场站获取临时销售计划
* @param carNum
* @param station
* @return
*/
public List<KObject> getSaleTempByCarNum(String carNum, KObject station) {
KClass bean = Amino.getStaticMetadataContext().getBean(SalesPlanConstant.ENTITY_TEMP, KClass.class);
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName());
dinasTypeDao.addRegionalCompanyFilter(detachedCriteria);
detachedCriteria.createAlias("planningCycle", "planningCycle");
detachedCriteria.createAlias("station", "station");
detachedCriteria.add(Restrictions.eq(SalesPlanConstant.APPROVE_STATE, BizProcessState.DONE_WITH_AGREE.getValue()));
detachedCriteria.add(Restrictions.le("planningCycle.startTime", new Date()));
detachedCriteria.add(Restrictions.ge("planningCycle.endTime", new Date()));
detachedCriteria.add(Restrictions.eq("station.id", station.getUuid("id")));
detachedCriteria.add(Restrictions.like("carNumber", "%"+carNum+"%"));
return (List<KObject>) template.findByCriteria(detachedCriteria);
}
} }
...@@ -14,6 +14,9 @@ import com.beecode.bcp.type.KObject; ...@@ -14,6 +14,9 @@ import com.beecode.bcp.type.KObject;
import com.xyst.dinas.sales.constant.InventoryConstant; import com.xyst.dinas.sales.constant.InventoryConstant;
import com.xyst.dinas.sales.dao.InventoryDao; import com.xyst.dinas.sales.dao.InventoryDao;
/**
* @author jiaokai
*/
public class InventoryDaoImpl implements InventoryDao { public class InventoryDaoImpl implements InventoryDao {
@Autowired @Autowired
...@@ -50,7 +53,8 @@ public class InventoryDaoImpl implements InventoryDao { ...@@ -50,7 +53,8 @@ public class InventoryDaoImpl implements InventoryDao {
} }
public Double getStockAmountByDinas(UUID stationId,String dinasTypeName) { @Override
public Double getStockAmountByDinas(UUID stationId, String dinasTypeName) {
String hql = "from " + InventoryConstant.INVENTORY_ENTITY + " where station.id =:stationId and dinasType.dinasTypeName =:dinasTypeName"; String hql = "from " + InventoryConstant.INVENTORY_ENTITY + " where station.id =:stationId and dinasType.dinasTypeName =:dinasTypeName";
return template.execute(session -> { return template.execute(session -> {
...@@ -58,7 +62,9 @@ public class InventoryDaoImpl implements InventoryDao { ...@@ -58,7 +62,9 @@ public class InventoryDaoImpl implements InventoryDao {
query.setParameter("stationId", stationId); query.setParameter("stationId", stationId);
query.setParameter("dinasTypeName", dinasTypeName); query.setParameter("dinasTypeName", dinasTypeName);
List<KObject> resultList = query.getResultList(); List<KObject> resultList = query.getResultList();
if(resultList.isEmpty()) return 0D; if(resultList.isEmpty()) {
return 0D;
}
KObject kObject = resultList.get(0); KObject kObject = resultList.get(0);
double stockAmount = kObject.getDouble(InventoryConstant.amount); double stockAmount = kObject.getDouble(InventoryConstant.amount);
return stockAmount; return stockAmount;
...@@ -87,6 +93,14 @@ public class InventoryDaoImpl implements InventoryDao { ...@@ -87,6 +93,14 @@ public class InventoryDaoImpl implements InventoryDao {
} }
}); });
} }
@Override
public List<KObject> getItemListByStationId(UUID stationId) {
return template.execute(session -> {
Query<KObject> query = session.createQuery("from " + InventoryConstant.INVENTORY_ENTITY + " where (discard is null or discard = 0) and station.id =:stationId ", KObject.class);
query.setParameter("stationId", stationId);
return query.getResultList();
});
}
@Override @Override
public List<KObject> queryLog(List<String> businessObjectId) { public List<KObject> queryLog(List<String> businessObjectId) {
......
...@@ -67,9 +67,7 @@ public class NeedPlanDaoImpl implements NeedPlanDao, NeedPlanConstant { ...@@ -67,9 +67,7 @@ public class NeedPlanDaoImpl implements NeedPlanDao, NeedPlanConstant {
public List<UUID> queryNeedPlanContratByCycleId(UUID planningCycleId) { public List<UUID> queryNeedPlanContratByCycleId(UUID planningCycleId) {
List<UUID> list = new ArrayList<>(); List<UUID> list = new ArrayList<>();
String sql = " SELECT DISTINCT contract FROM xyst_dinas_sales_need_plan WHERE HEX(planning_cycle) =:planningCycleId and (discard is null or discard = 0) "; String sql = " SELECT DISTINCT contract FROM xyst_dinas_sales_need_plan WHERE HEX(planning_cycle) =:planningCycleId and (discard is null or discard = 0) ";
return template.execute(new HibernateCallback<List<UUID>>() { return template.execute(session -> {
@Override
public List<UUID> doInHibernate(Session session) throws HibernateException {
Query<Tuple> query = session.createNativeQuery(sql, Tuple.class); Query<Tuple> query = session.createNativeQuery(sql, Tuple.class);
query.setParameter("planningCycleId", planningCycleId.toString().replaceAll("-", "")); query.setParameter("planningCycleId", planningCycleId.toString().replaceAll("-", ""));
List<Tuple> result = query.getResultList(); List<Tuple> result = query.getResultList();
...@@ -78,7 +76,6 @@ public class NeedPlanDaoImpl implements NeedPlanDao, NeedPlanConstant { ...@@ -78,7 +76,6 @@ public class NeedPlanDaoImpl implements NeedPlanDao, NeedPlanConstant {
list.add(Convert.toUUID(tuple.get(0))); list.add(Convert.toUUID(tuple.get(0)));
} }
return list; return list;
}
}); });
} }
...@@ -148,9 +145,7 @@ public class NeedPlanDaoImpl implements NeedPlanDao, NeedPlanConstant { ...@@ -148,9 +145,7 @@ public class NeedPlanDaoImpl implements NeedPlanDao, NeedPlanConstant {
@Override @Override
public KObject queryNeedPlanAmountByCycleId(UUID planningCycleId, UUID projectId) { public KObject queryNeedPlanAmountByCycleId(UUID planningCycleId, UUID projectId) {
return (KObject)template.execute(new HibernateCallback<KObject>() { return template.execute(session -> {
@Override
public KObject doInHibernate(Session session) throws HibernateException {
Query<KObject> query = session.createQuery("from " + NEED_PLAN_ENTITY + " where project.id=:projectId and planningCycle.id =:planningCycleId and submitState=:submitState and (discard is null or discard = 0) ", KObject.class); Query<KObject> query = session.createQuery("from " + NEED_PLAN_ENTITY + " where project.id=:projectId and planningCycle.id =:planningCycleId and submitState=:submitState and (discard is null or discard = 0) ", KObject.class);
query.setParameter("projectId", projectId); query.setParameter("projectId", projectId);
query.setParameter("planningCycleId", planningCycleId); query.setParameter("planningCycleId", planningCycleId);
...@@ -161,8 +156,18 @@ public class NeedPlanDaoImpl implements NeedPlanDao, NeedPlanConstant { ...@@ -161,8 +156,18 @@ public class NeedPlanDaoImpl implements NeedPlanDao, NeedPlanConstant {
} else { } else {
return resultList.get(0); return resultList.get(0);
} }
}
}); });
} }
@Override
public List<KObject> getByCarAndPlanningCycle(String carNum, KObject planningCycleObj) {
KClass bean = Amino.getStaticMetadataContext().getBean(NEED_PLAN_ENTITY, KClass.class);
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName());
dinasTypeDao.addRegionalCompanyFilter(detachedCriteria);
detachedCriteria.add(Restrictions.eq("submitState", SubmitStateEnum.SUBMITTED.name()));
detachedCriteria.add(Restrictions.eq("planningCycle.id", planningCycleObj.getUuid("id")));
detachedCriteria.add(Restrictions.like("transportLicensePlateNumber", "%"+carNum+"%"));
return (List<KObject>)template.findByCriteria(detachedCriteria);
}
} }
...@@ -16,12 +16,10 @@ import org.json.JSONArray; ...@@ -16,12 +16,10 @@ import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.beecode.amino.common.ValueConvertException;
import com.beecode.amino.core.Amino; import com.beecode.amino.core.Amino;
import com.beecode.bap.log.service.LogService; import com.beecode.bap.log.service.LogService;
import com.beecode.bap.staff.BapContext; import com.beecode.bap.staff.BapContext;
import com.beecode.bap.staff.service.StaffService; import com.beecode.bap.staff.service.StaffService;
import com.beecode.bcp.type.AttributeNotFoundException;
import com.beecode.bcp.type.KClass; import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject; import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.team.pojo.ResponseObj; import com.beecode.inz.basis.team.pojo.ResponseObj;
...@@ -77,7 +75,7 @@ public class InventoryServiceImpl implements InventoryService { ...@@ -77,7 +75,7 @@ public class InventoryServiceImpl implements InventoryService {
public List<StationDinasTypeRelation> getInventoryByRegionalCompany(UUID regionalCompany) { public List<StationDinasTypeRelation> getInventoryByRegionalCompany(UUID regionalCompany) {
updateInventoryBaseInfo(regionalCompany); updateInventoryBaseInfo(regionalCompany);
List<KObject> inventory = inventoryDao.listAllByRegionalCompany(regionalCompany, false, false); List<KObject> inventory = inventoryDao.listAllByRegionalCompany(regionalCompany, false, false);
List<StationDinasTypeRelation> result = new ArrayList<StationDinasTypeRelation>(); List<StationDinasTypeRelation> result = new ArrayList<>();
for(KObject item : inventory) { for(KObject item : inventory) {
StationDinasTypeRelation r = new StationDinasTypeRelation(); StationDinasTypeRelation r = new StationDinasTypeRelation();
r.setStationId(item.get("station").getUuid("id")); r.setStationId(item.get("station").getUuid("id"));
...@@ -142,10 +140,6 @@ public class InventoryServiceImpl implements InventoryService { ...@@ -142,10 +140,6 @@ public class InventoryServiceImpl implements InventoryService {
log.set("staffId", bapContext.getCurrentStaff().getUuid("id")); log.set("staffId", bapContext.getCurrentStaff().getUuid("id"));
log.set("deptId", bapContext.getCurrentStaff().get("department").getUuid("id")); log.set("deptId", bapContext.getCurrentStaff().get("department").getUuid("id"));
logService.addLog(log); logService.addLog(log);
} catch (AttributeNotFoundException e) {
e.printStackTrace();
} catch (ValueConvertException e) {
e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -267,6 +261,23 @@ public class InventoryServiceImpl implements InventoryService { ...@@ -267,6 +261,23 @@ public class InventoryServiceImpl implements InventoryService {
} }
@Override @Override
public List<StationDinasTypeRelation> getItemListByStationId(UUID stationId) {
List<KObject> itemListByStationId = inventoryDao.getItemListByStationId(stationId);
List<StationDinasTypeRelation> result = new ArrayList<>();
for(KObject item : itemListByStationId) {
StationDinasTypeRelation r = new StationDinasTypeRelation();
r.setStationId(item.get("station").getUuid("id"));
r.setStationName(item.get("station").getString("stationName"));
r.setDinasTypeId(item.get("dinasType").getUuid("id"));
r.setDinasTypeName(item.get("dinasType").getString("dinasTypeName"));
r.setAmount(item.getBigDecimal("amount"));
r.setPrice(item.getBigDecimal("price"));
result.add(r);
}
return result;
}
@Override
public Object queryWarnSettingById(UUID id) { public Object queryWarnSettingById(UUID id) {
KObject warnSetting = warnSettingDao.queryWarnSettingById(id); KObject warnSetting = warnSettingDao.queryWarnSettingById(id);
String billId = warnSetting.getString("billId"); String billId = warnSetting.getString("billId");
...@@ -282,4 +293,11 @@ public class InventoryServiceImpl implements InventoryService { ...@@ -282,4 +293,11 @@ public class InventoryServiceImpl implements InventoryService {
map.put("billId", warnSetting.getString("billId")); map.put("billId", warnSetting.getString("billId"));
return map; return map;
} }
@Override
public KObject getItemByStationIdAndDinasTypeId(UUID id, UUID dinasTypeId) {
return inventoryDao.getItemByStationIdAndDinasTypeId(id, dinasTypeId);
}
} }
...@@ -9,6 +9,7 @@ import java.util.Map; ...@@ -9,6 +9,7 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.xyst.dinas.biz.enumeration.PlanningCycleEnum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.beecode.bcp.type.KObject; import com.beecode.bcp.type.KObject;
...@@ -123,25 +124,21 @@ public class NeedPlanServiceImpl implements NeedPlanService { ...@@ -123,25 +124,21 @@ public class NeedPlanServiceImpl implements NeedPlanService {
public Object queryNeedPlanAmountByCycleId(UUID planningCycleId, UUID projectId) { public Object queryNeedPlanAmountByCycleId(UUID planningCycleId, UUID projectId) {
KObject needPlanKObject = needPlanDao.queryNeedPlanAmountByCycleId(planningCycleId, projectId); KObject needPlanKObject = needPlanDao.queryNeedPlanAmountByCycleId(planningCycleId, projectId);
KObject salesPlanKObject = salesPlanDao.querySalesPlanAmountByCycleId(planningCycleId); KObject salesPlanKObject = salesPlanDao.querySalesPlanAmountByCycleId(planningCycleId);
//Map<String, Object> map = new HashMap<String, Object>();
List<Map<String, Object>> planList = new ArrayList<>(); List<Map<String, Object>> planList = new ArrayList<>();
List<UUID> dinasTypeIdList = new ArrayList<>(); List<UUID> dinasTypeIdList = new ArrayList<>();
if (needPlanKObject != null) { if (needPlanKObject != null) {
List<KObject> needPlanDetails = needPlanKObject.get("NeedPlanDetails").toList(); List<KObject> needPlanDetails = needPlanKObject.get("NeedPlanDetails").toList();
if (needPlanDetails != null && needPlanDetails.size() > 0) { if (needPlanDetails != null && needPlanDetails.size() > 0) {
//List<Map<String, Object>> needPlanList = new ArrayList<>(); for (KObject planDetail : needPlanDetails) {
for (int i = 0; i < needPlanDetails.size(); i++) { Map<String, Object> needPlanMap = new HashMap<>();
Map<String, Object> needPlanMap = new HashMap<String, Object>(); needPlanMap.put("dinasTypeId", planDetail.get("dinasType").getUuid("id"));
KObject needPlanDetail = needPlanDetails.get(i); needPlanMap.put("dinasTypeName", planDetail.get("dinasType").getString("dinasTypeName"));
needPlanMap.put("dinasTypeId", needPlanDetail.get("dinasType").getUuid("id")); needPlanMap.put("actualSaleAmount", planDetail.getBigDecimal("effectiveSale"));
needPlanMap.put("dinasTypeName", needPlanDetail.get("dinasType").getString("dinasTypeName")); needPlanMap.put("needPlanAmount", planDetail.getBigDecimal("needPlanAmount")); //需用计划量
needPlanMap.put("actualSaleAmount", needPlanDetail.getBigDecimal("effectiveSale"));
needPlanMap.put("needPlanAmount", needPlanDetail.getBigDecimal("needPlanAmount")); //需用计划量
needPlanMap.put("salesPlanAmount", new BigDecimal("0")); needPlanMap.put("salesPlanAmount", new BigDecimal("0"));
planList.add(needPlanMap); planList.add(needPlanMap);
dinasTypeIdList.add(needPlanDetail.get("dinasType").getUuid("id")); dinasTypeIdList.add(planDetail.get("dinasType").getUuid("id"));
} }
//map.put("needPlanDetails", needPlanList);
} }
} }
if (salesPlanKObject != null) { if (salesPlanKObject != null) {
...@@ -186,4 +183,13 @@ public class NeedPlanServiceImpl implements NeedPlanService { ...@@ -186,4 +183,13 @@ public class NeedPlanServiceImpl implements NeedPlanService {
KObject salesPlanByTimeKObject = salesPlanDao.querySalesPlanByTime(startTime, endTime); KObject salesPlanByTimeKObject = salesPlanDao.querySalesPlanByTime(startTime, endTime);
return salesPlanByTimeKObject; return salesPlanByTimeKObject;
} }
@Override
public List<KObject> queryNeedPlanByCarNumAndPlanningCycle(KObject station, String carNum, Date date) {
//
String planningCycle = station.get("regionalCompany").getString("planningCycle");
PlanningCycleEnum planningCycleEnum = PlanningCycleEnum.valueOf(planningCycle);
KObject planningCycleObj = planningCycleService.getPlanningCycleObj(planningCycleEnum, date);
return needPlanDao.getByCarAndPlanningCycle(carNum,planningCycleObj);
}
} }
package com.xyst.dinas.sales.internal.service; package com.xyst.dinas.sales.internal.service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.transaction.Transactional;
import org.antlr.grammar.v3.ANTLRv3Parser.id_return;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import com.beecode.amino.core.Amino; import com.beecode.amino.core.Amino;
import com.beecode.bap.staff.service.StaffService;
import com.beecode.bap.workflow.core.BizProcessState; import com.beecode.bap.workflow.core.BizProcessState;
import com.beecode.bcp.core.context.AminoContextHolder; import com.beecode.bcp.core.context.AminoContextHolder;
import com.beecode.bcp.type.KClass; import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject; import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.Null;
import com.beecode.inz.basis.team.pojo.ResponseObj; import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.beecode.inz.common.BaseConstants; import com.beecode.inz.common.BaseConstants;
import com.beecode.xlib.utils.StringUtil;
import com.jiuqi.np.syntax.parser.ANTLRParser.ifthen_eval_return;
import com.xyst.dinas.biz.constant.DinasTypeConstant; import com.xyst.dinas.biz.constant.DinasTypeConstant;
import com.xyst.dinas.biz.constant.PlanningCycleConstant; import com.xyst.dinas.biz.constant.PlanningCycleConstant;
import com.xyst.dinas.biz.service.PlanningCycleService; import com.xyst.dinas.biz.service.PlanningCycleService;
...@@ -37,12 +16,22 @@ import com.xyst.dinas.project.constant.ProjectFiledConstant; ...@@ -37,12 +16,22 @@ import com.xyst.dinas.project.constant.ProjectFiledConstant;
import com.xyst.dinas.project.constant.PurchaseSandCompanyConstant; import com.xyst.dinas.project.constant.PurchaseSandCompanyConstant;
import com.xyst.dinas.sales.constant.NeedPlanConstant; import com.xyst.dinas.sales.constant.NeedPlanConstant;
import com.xyst.dinas.sales.constant.SalesPlanConstant; import com.xyst.dinas.sales.constant.SalesPlanConstant;
import com.xyst.dinas.sales.dao.InventoryDao;
import com.xyst.dinas.sales.dao.SalesPlanDao; import com.xyst.dinas.sales.dao.SalesPlanDao;
import com.xyst.dinas.sales.entity.SalesPlan; import com.xyst.dinas.sales.entity.SalesPlan;
import com.xyst.dinas.sales.entity.SalesPlanDetail; import com.xyst.dinas.sales.entity.SalesPlanDetail;
import com.xyst.dinas.sales.service.NeedPlanService; import com.xyst.dinas.sales.service.NeedPlanService;
import com.xyst.dinas.sales.service.SalesPlanService; import com.xyst.dinas.sales.service.SalesPlanService;
import com.xyst.dinas.sales.web.request.SaleaPlanDetailQuery; import com.xyst.dinas.sales.web.request.SaleaPlanDetailQuery;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import javax.transaction.Transactional;
import java.math.BigDecimal;
import java.util.*;
/** /**
* 销售计划 * 销售计划
* *
...@@ -50,7 +39,7 @@ import com.xyst.dinas.sales.web.request.SaleaPlanDetailQuery; ...@@ -50,7 +39,7 @@ import com.xyst.dinas.sales.web.request.SaleaPlanDetailQuery;
* @date 2021年4月13日 * @date 2021年4月13日
*/ */
@Transactional @Transactional
public class SalesPlanServiceImpl implements SalesPlanService{ public class SalesPlanServiceImpl implements SalesPlanService {
@Autowired @Autowired
private SalesPlanDao salesPlanDao; private SalesPlanDao salesPlanDao;
...@@ -61,8 +50,9 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -61,8 +50,9 @@ public class SalesPlanServiceImpl implements SalesPlanService{
private PlanningCycleService planningCycleService; private PlanningCycleService planningCycleService;
@Autowired @Autowired
private StaffService staffService; private InventoryDao inventoryDao;
@Override
@Transactional @Transactional
public int createSalesPlanDetail(KObject salesPlan, KObject contract) { public int createSalesPlanDetail(KObject salesPlan, KObject contract) {
...@@ -84,11 +74,11 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -84,11 +74,11 @@ public class SalesPlanServiceImpl implements SalesPlanService{
UUID dinasTypeId = dinasType.getUuid(BaseConstants.ID); UUID dinasTypeId = dinasType.getUuid(BaseConstants.ID);
UUID planningCycleId = salesPlan.get("planningCycle").getUuid(BaseConstants.ID); UUID planningCycleId = salesPlan.get("planningCycle").getUuid(BaseConstants.ID);
KObject needPlanDetail = needPlanService.queryNeedPlanAmountByDinasType(planningCycleId, contractId, dinasTypeId); KObject needPlanDetail = needPlanService.queryNeedPlanAmountByDinasType(planningCycleId, contractId, dinasTypeId);
double requiredAmount= needPlanDetail!=null?needPlanDetail.getDouble(NeedPlanConstant.needPlanAmount):0D;//需用量 double requiredAmount = needPlanDetail != null ? needPlanDetail.getDouble(NeedPlanConstant.needPlanAmount) : 0D;//需用量
Double planAmount = null;//本期分配量 Double planAmount = null;//本期分配量
//新增销售计划明细 //新增销售计划明细
KObject planDetailObj = detailClass.newInstance(); KObject planDetailObj = detailClass.newInstance();
planDetailObj.set(BaseConstants.MASTER,salesPlan); planDetailObj.set(BaseConstants.MASTER, salesPlan);
planDetailObj.set(SalesPlanConstant.contract, contract); planDetailObj.set(SalesPlanConstant.contract, contract);
planDetailObj.set(SalesPlanConstant.contractName, contractName); planDetailObj.set(SalesPlanConstant.contractName, contractName);
planDetailObj.set(SalesPlanConstant.project, project); planDetailObj.set(SalesPlanConstant.project, project);
...@@ -104,13 +94,16 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -104,13 +94,16 @@ public class SalesPlanServiceImpl implements SalesPlanService{
planDetailObj.set(SalesPlanConstant.dinasTypeName, dinasTypeName); planDetailObj.set(SalesPlanConstant.dinasTypeName, dinasTypeName);
UUID detailId = salesPlanDao.create(planDetailObj); UUID detailId = salesPlanDao.create(planDetailObj);
if(detailId!=null) detailCount++; if (detailId != null) {
detailCount++;
}
} }
return detailCount; return detailCount;
} }
@Override
@Transactional @Transactional
public KObject createSalesPlanMaster(KObject regionalCompany,KObject planningCycleObj) { public KObject createSalesPlanMaster(KObject regionalCompany, KObject planningCycleObj) {
KClass kclass = Amino.getApplicationMetadataContext().getBean(SalesPlanConstant.ENTITY, KClass.class); KClass kclass = Amino.getApplicationMetadataContext().getBean(SalesPlanConstant.ENTITY, KClass.class);
KObject kObject = kclass.newInstance(); KObject kObject = kclass.newInstance();
...@@ -118,33 +111,39 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -118,33 +111,39 @@ public class SalesPlanServiceImpl implements SalesPlanService{
kObject.set("planningCycle", planningCycleObj); kObject.set("planningCycle", planningCycleObj);
kObject.set("approveState", BizProcessState.NOT_IN_PROCESS.getValue()); kObject.set("approveState", BizProcessState.NOT_IN_PROCESS.getValue());
kObject.set(BaseConstants.CREATE_TIME, new Date()); kObject.set(BaseConstants.CREATE_TIME, new Date());
kObject.set(BaseConstants.DEL,false); kObject.set(BaseConstants.DEL, false);
kObject.set(BaseConstants.DISCARD,false); kObject.set(BaseConstants.DISCARD, false);
salesPlanDao.create(kObject); salesPlanDao.create(kObject);
return kObject; return kObject;
} }
@Override
public void deleteSalesPlan(KObject salesPlan) { public void deleteSalesPlan(KObject salesPlan) {
salesPlanDao.delete(salesPlan); salesPlanDao.delete(salesPlan);
} }
@Override
public int deleteSalesPlanDetails(UUID masterId, @Nullable UUID contractId) { public int deleteSalesPlanDetails(UUID masterId, @Nullable UUID contractId) {
return salesPlanDao.deleteDetails(masterId, contractId); return salesPlanDao.deleteDetails(masterId, contractId);
} }
@Override
public void update(KObject salesPlan) { public void update(KObject salesPlan) {
salesPlanDao.update(salesPlan); salesPlanDao.update(salesPlan);
} }
public void approveSalesPlanForDaily(UUID id,int approveState,String approveMemo) { @Override
public void approveSalesPlanForDaily(UUID id, int approveState, String approveMemo) {
salesPlanDao.modifyApproveStateForDaily(id, approveState, approveMemo); salesPlanDao.modifyApproveStateForDaily(id, approveState, approveMemo);
} }
public void approveSalesPlanForTemp(UUID id,int approveState,String approveMemo) { @Override
public void approveSalesPlanForTemp(UUID id, int approveState, String approveMemo) {
salesPlanDao.modifyApproveStateForTemp(id, approveState, approveMemo); salesPlanDao.modifyApproveStateForTemp(id, approveState, approveMemo);
} }
@Override
public Object querySalesPlanDetails(SaleaPlanDetailQuery saleaPlanDetailQuery) { public Object querySalesPlanDetails(SaleaPlanDetailQuery saleaPlanDetailQuery) {
ArrayList<SalesPlanDetail> salesPlanDetails = new ArrayList<>(); ArrayList<SalesPlanDetail> salesPlanDetails = new ArrayList<>();
// KObject kObject = salesPlanDao.load(salesPlanId); // KObject kObject = salesPlanDao.load(salesPlanId);
...@@ -155,7 +154,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -155,7 +154,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
salesPlan.setModifyTime(salesPlanKObject.getString("modifyTime")); salesPlan.setModifyTime(salesPlanKObject.getString("modifyTime"));
salesPlan.setModifier(salesPlanKObject.isNull("modifier") ? null : salesPlanKObject.get("modifier").getUuid("id")); salesPlan.setModifier(salesPlanKObject.isNull("modifier") ? null : salesPlanKObject.get("modifier").getUuid("id"));
salesPlan.setCreateTime(salesPlanKObject.getString("createTime")); salesPlan.setCreateTime(salesPlanKObject.getString("createTime"));
salesPlan.setCreator(salesPlanKObject.isNull("creator") ? null :salesPlanKObject.get("creator").getUuid("id")); salesPlan.setCreator(salesPlanKObject.isNull("creator") ? null : salesPlanKObject.get("creator").getUuid("id"));
salesPlan.setApproveMemo(salesPlanKObject.getString("approveMemo")); salesPlan.setApproveMemo(salesPlanKObject.getString("approveMemo"));
salesPlan.setBillCode(salesPlanKObject.getString("billCode")); salesPlan.setBillCode(salesPlanKObject.getString("billCode"));
...@@ -184,8 +183,8 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -184,8 +183,8 @@ public class SalesPlanServiceImpl implements SalesPlanService{
salesPlanDetail.setContract(contract.getUuid(BaseConstants.ID)); salesPlanDetail.setContract(contract.getUuid(BaseConstants.ID));
salesPlanDetail.setProject(project.getUuid(BaseConstants.ID)); salesPlanDetail.setProject(project.getUuid(BaseConstants.ID));
salesPlanDetail.setDinasType(dinasType.getUuid(BaseConstants.ID)); salesPlanDetail.setDinasType(dinasType.getUuid(BaseConstants.ID));
salesPlanDetail.setStation(station.isNull()?null:station.getUuid(BaseConstants.ID)); salesPlanDetail.setStation(station.isNull() ? null : station.getUuid(BaseConstants.ID));
salesPlanDetail.setStationName((station.isNull()?null:station.getString("stationName"))); salesPlanDetail.setStationName((station.isNull() ? null : station.getString("stationName")));
salesPlanDetail.setPurchaseSandUnit(purchaseSandUnit.getUuid(BaseConstants.ID)); salesPlanDetail.setPurchaseSandUnit(purchaseSandUnit.getUuid(BaseConstants.ID));
salesPlanDetail.setContractName(contract.getString(ContractConstant.CONTRACT_NAME)); salesPlanDetail.setContractName(contract.getString(ContractConstant.CONTRACT_NAME));
salesPlanDetail.setProjectName(project.getString(ProjectFiledConstant.PROJECT_NAME)); salesPlanDetail.setProjectName(project.getString(ProjectFiledConstant.PROJECT_NAME));
...@@ -230,6 +229,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -230,6 +229,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
} }
@Override
public KObject querySalesPlanById(UUID id) { public KObject querySalesPlanById(UUID id) {
return salesPlanDao.load(id); return salesPlanDao.load(id);
} }
...@@ -238,6 +238,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -238,6 +238,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
/***************临时销售计划*****************/ /***************临时销售计划*****************/
@Override
public KObject queryTempSalesPlan(UUID id) { public KObject queryTempSalesPlan(UUID id) {
return salesPlanDao.queryTempSalesPlan(id); return salesPlanDao.queryTempSalesPlan(id);
} }
...@@ -258,7 +259,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -258,7 +259,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
//校验逻辑 //校验逻辑
if (!jsonObject.isNull("isCommit") && jsonObject.getInt("isCommit") == 1) { if (!jsonObject.isNull("isCommit") && jsonObject.getInt("isCommit") == 1) {
List<Map<String, Object>> submitSalesPlanVerifyList = submitSalesPlanVerify(salesPlanId, jsonArray); List<Map<String, Object>> submitSalesPlanVerifyList = submitSalesPlanVerify(salesPlanId, jsonArray);
if(submitSalesPlanVerifyList.size() > 0) { if (submitSalesPlanVerifyList.size() > 0) {
return submitSalesPlanVerifyList; return submitSalesPlanVerifyList;
} }
//改状态 //改状态
...@@ -310,7 +311,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -310,7 +311,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
for (int k = 0; k < jsonArray.length(); k++) { for (int k = 0; k < jsonArray.length(); k++) {
JSONObject jsonObject = jsonArray.getJSONObject(k); JSONObject jsonObject = jsonArray.getJSONObject(k);
BigDecimal distributedVolum = calcDistributedVolum(jsonObject, startTime, endTime); BigDecimal distributedVolum = calcDistributedVolum(jsonObject, startTime, endTime);
if(jsonObject.getBigDecimal("planAmount").compareTo(BigDecimal.ZERO) != 0 && (jsonObject.getBigDecimal("planAmount").compareTo(distributedVolum) ==1 || jsonObject.getBigDecimal("planAmount").compareTo(jsonObject.getBigDecimal("contractAmount")) ==1)) { //大于等于 if (jsonObject.getBigDecimal("planAmount").compareTo(BigDecimal.ZERO) != 0 && (jsonObject.getBigDecimal("planAmount").compareTo(distributedVolum) == 1 || jsonObject.getBigDecimal("planAmount").compareTo(jsonObject.getBigDecimal("contractAmount")) == 1)) { //大于等于
Map<String, Object> verifyMap = new HashMap<String, Object>(); Map<String, Object> verifyMap = new HashMap<String, Object>();
verifyMap.put("contractName", jsonObject.getString("contractName")); verifyMap.put("contractName", jsonObject.getString("contractName"));
verifyMap.put("dinasTypeName", jsonObject.getString("dinasTypeName")); verifyMap.put("dinasTypeName", jsonObject.getString("dinasTypeName"));
...@@ -324,7 +325,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -324,7 +325,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
return verifyList; return verifyList;
} }
public BigDecimal calcDistributedVolum(JSONObject jsonObject,Date startTime,Date endTime) { public BigDecimal calcDistributedVolum(JSONObject jsonObject, Date startTime, Date endTime) {
//合同可用余量 //合同可用余量
BigDecimal contractAmount = jsonObject.getBigDecimal("contractAmount"); BigDecimal contractAmount = jsonObject.getBigDecimal("contractAmount");
//实际销售量 //实际销售量
...@@ -339,7 +340,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -339,7 +340,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
//筛选同一个砂石类型下的明细 //筛选同一个砂石类型下的明细
//计算临时销售计划本期分配量之和 //计算临时销售计划本期分配量之和
BigDecimal totalSalesPlanAmount = new BigDecimal("0"); BigDecimal totalSalesPlanAmount = new BigDecimal("0");
if(salesTempPlanByTimeList.size() > 0) { if (salesTempPlanByTimeList.size() > 0) {
for (int i = 0; i < salesTempPlanByTimeList.size(); i++) { for (int i = 0; i < salesTempPlanByTimeList.size(); i++) {
KObject salesTempPlan = salesTempPlanByTimeList.get(i); KObject salesTempPlan = salesTempPlanByTimeList.get(i);
List<KObject> salesPlanTempDetails = salesTempPlan.get("SalesPlanTempDetails").toList(); List<KObject> salesPlanTempDetails = salesTempPlan.get("SalesPlanTempDetails").toList();
...@@ -380,7 +381,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -380,7 +381,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
//筛选同一个砂石类型下的明细 //筛选同一个砂石类型下的明细
//计算临时销售计划本期分配量之和 //计算临时销售计划本期分配量之和
BigDecimal totalSalesPlanAmount = new BigDecimal("0"); BigDecimal totalSalesPlanAmount = new BigDecimal("0");
if(salesTempPlanByTimeList.size() > 0) { if (salesTempPlanByTimeList.size() > 0) {
for (int i = 0; i < salesTempPlanByTimeList.size(); i++) { for (int i = 0; i < salesTempPlanByTimeList.size(); i++) {
KObject salesTempPlan = salesTempPlanByTimeList.get(i); KObject salesTempPlan = salesTempPlanByTimeList.get(i);
List<KObject> salesPlanTempDetails = salesTempPlan.get("SalesPlanTempDetails").toList(); List<KObject> salesPlanTempDetails = salesTempPlan.get("SalesPlanTempDetails").toList();
...@@ -392,7 +393,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -392,7 +393,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
} }
//可分配量 <=合同可用余量+实际销售量 - 临时销售计划分配量之和 //可分配量 <=合同可用余量+实际销售量 - 临时销售计划分配量之和
if(true) { if (true) {
} }
} }
...@@ -402,7 +403,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -402,7 +403,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
@Override @Override
public Object submitTempSalesPlan(JSONObject jsonObject) { public Object submitTempSalesPlan(JSONObject jsonObject) {
List<Map<String, Object>> verifyTempSalesPlanList = verifyTempSalesPlan(jsonObject); List<Map<String, Object>> verifyTempSalesPlanList = verifyTempSalesPlan(jsonObject);
if(verifyTempSalesPlanList.size() > 0) { if (verifyTempSalesPlanList.size() > 0) {
return ResponseObj.success("校验不通过", verifyTempSalesPlanList); return ResponseObj.success("校验不通过", verifyTempSalesPlanList);
} else { } else {
return ResponseObj.success(null); return ResponseObj.success(null);
...@@ -425,7 +426,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -425,7 +426,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
//获取临时销售计划明细 //获取临时销售计划明细
JSONArray salesPlanTempDetails = jsonObject.getJSONArray("SalesPlanTempDetails"); JSONArray salesPlanTempDetails = jsonObject.getJSONArray("SalesPlanTempDetails");
List<Map<String, Object>> verifyList = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> verifyList = new ArrayList<Map<String, Object>>();
if(salesPlanTempDetails.length() > 0) { if (salesPlanTempDetails.length() > 0) {
for (int i = 0; i < salesPlanTempDetails.length(); i++) { for (int i = 0; i < salesPlanTempDetails.length(); i++) {
JSONObject salesPlanTempDetail = salesPlanTempDetails.getJSONObject(i); JSONObject salesPlanTempDetail = salesPlanTempDetails.getJSONObject(i);
//获取砂石类型 //获取砂石类型
...@@ -438,7 +439,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -438,7 +439,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
//筛选同一个砂石类型下的明细 //筛选同一个砂石类型下的明细
//计算临时销售计划本期分配量之和 //计算临时销售计划本期分配量之和
BigDecimal totalTempSalesPlanAmount = new BigDecimal("0"); BigDecimal totalTempSalesPlanAmount = new BigDecimal("0");
if(salesTempPlanByTimeList.size() > 0) { if (salesTempPlanByTimeList.size() > 0) {
for (int k = 0; k < salesTempPlanByTimeList.size(); k++) { for (int k = 0; k < salesTempPlanByTimeList.size(); k++) {
KObject salesTempPlan = salesTempPlanByTimeList.get(k); KObject salesTempPlan = salesTempPlanByTimeList.get(k);
List<KObject> oldSalesPlanTempDetails = salesTempPlan.get("SalesPlanTempDetails").toList(); List<KObject> oldSalesPlanTempDetails = salesTempPlan.get("SalesPlanTempDetails").toList();
...@@ -452,7 +453,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -452,7 +453,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
BigDecimal totalSalesPlanAmount = new BigDecimal("0"); BigDecimal totalSalesPlanAmount = new BigDecimal("0");
//销售计划内的实际销售量 //销售计划内的实际销售量
BigDecimal actualSaleTotalAmount = new BigDecimal("0"); BigDecimal actualSaleTotalAmount = new BigDecimal("0");
if(salesPlanByTimeKObject != null) { if (salesPlanByTimeKObject != null) {
//for (int k = 0; k < salesPlanByTimeList.size(); k++) { //for (int k = 0; k < salesPlanByTimeList.size(); k++) {
//KObject salesPlan = salesPlanByTimeList.get(k); //KObject salesPlan = salesPlanByTimeList.get(k);
List<KObject> oldSalesPlanDetails = salesPlanByTimeKObject.get("SalesPlanDetails").toList(); List<KObject> oldSalesPlanDetails = salesPlanByTimeKObject.get("SalesPlanDetails").toList();
...@@ -465,7 +466,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -465,7 +466,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
} }
//可分配量 <=合同可用余量+实际销售量 - 临时销售计划分配量之和 - 日常销售计划分配量 //可分配量 <=合同可用余量+实际销售量 - 临时销售计划分配量之和 - 日常销售计划分配量
BigDecimal distributedVolum = contractAvailableAmount.add(actualSaleTotalAmount).subtract(totalTempSalesPlanAmount).subtract(totalSalesPlanAmount); BigDecimal distributedVolum = contractAvailableAmount.add(actualSaleTotalAmount).subtract(totalTempSalesPlanAmount).subtract(totalSalesPlanAmount);
if(salesPlanAmount.compareTo(BigDecimal.ZERO) != 0 && (salesPlanAmount.compareTo(distributedVolum) ==1 || salesPlanAmount.compareTo(contractAvailableAmount) ==1)) { //大于 if (salesPlanAmount.compareTo(BigDecimal.ZERO) != 0 && (salesPlanAmount.compareTo(distributedVolum) == 1 || salesPlanAmount.compareTo(contractAvailableAmount) == 1)) { //大于
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("dinasTypeName", salesPlanTempDetail.getString("dinasTypeName")); map.put("dinasTypeName", salesPlanTempDetail.getString("dinasTypeName"));
map.put("distributedVolum", distributedVolum); map.put("distributedVolum", distributedVolum);
...@@ -478,8 +479,6 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -478,8 +479,6 @@ public class SalesPlanServiceImpl implements SalesPlanService{
} }
/** /**
* 根据需用计划中查询出的条件查询对应销售计划中拥有的砂石类型 * 根据需用计划中查询出的条件查询对应销售计划中拥有的砂石类型
* *
...@@ -490,11 +489,12 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -490,11 +489,12 @@ public class SalesPlanServiceImpl implements SalesPlanService{
*/ */
@Override @Override
public List<KObject> getDinasTypeListByNeedPlanInfo(UUID purchaseSandUnitId, UUID planningCycleId, UUID projectId) { public List<KObject> getDinasTypeListByNeedPlanInfo(UUID purchaseSandUnitId, UUID planningCycleId, UUID projectId) {
return salesPlanDao.getDinasTypeListByNeedPlanInfo(purchaseSandUnitId,planningCycleId,projectId); return salesPlanDao.getDinasTypeListByNeedPlanInfo(purchaseSandUnitId, planningCycleId, projectId);
} }
/** /**
* 查询今天提交并审批通过的所有临时销售计划中的购砂单位 * 查询今天提交并审批通过的所有临时销售计划中的购砂单位
*
* @param date * @param date
* @return * @return
*/ */
...@@ -512,29 +512,210 @@ public class SalesPlanServiceImpl implements SalesPlanService{ ...@@ -512,29 +512,210 @@ public class SalesPlanServiceImpl implements SalesPlanService{
*/ */
@Override @Override
public List<KObject> getPlanningCycleByNowPlanningCycleAndSandUnitId(UUID purchaseSandUnitId, Date date) { public List<KObject> getPlanningCycleByNowPlanningCycleAndSandUnitId(UUID purchaseSandUnitId, Date date) {
return salesPlanDao.getPlanningCycleByNowPlanningCycleAndSandUnitId(purchaseSandUnitId,date); return salesPlanDao.getPlanningCycleByNowPlanningCycleAndSandUnitId(purchaseSandUnitId, date);
} }
/** /**
* 根据购砂公司和计划获取所有项目 * 根据购砂公司和计划获取所有项目
*
* @param purchaseSandUnitId * @param purchaseSandUnitId
* @param planningCycleId * @param planningCycleId
* @return * @return
*/ */
@Override @Override
public List<KObject> getProjectByNowPlanningCycle(UUID purchaseSandUnitId, UUID planningCycleId) { public List<KObject> getProjectByNowPlanningCycle(UUID purchaseSandUnitId, UUID planningCycleId) {
return salesPlanDao.getProjectByNowPlanningCycle(purchaseSandUnitId,planningCycleId); return salesPlanDao.getProjectByNowPlanningCycle(purchaseSandUnitId, planningCycleId);
} }
/** /**
* 根据购砂公司和计划和项目获取所有的砂石类型 * 根据购砂公司和计划和项目获取所有的砂石类型
*
* @param purchaseSandUnitId * @param purchaseSandUnitId
* @param planningCycleId * @param planningCycleId
* @return * @return
*/ */
@Override @Override
public List<KObject> getSealTempDinasTypeListByNeedPlanInfo(UUID purchaseSandUnitId, UUID planningCycleId, UUID projectId) { public List<KObject> getSealTempDinasTypeListByNeedPlanInfo(UUID purchaseSandUnitId, UUID planningCycleId, UUID projectId) {
return salesPlanDao.getSealTempDinasTypeListByNeedPlanInfo(purchaseSandUnitId,planningCycleId,projectId); return salesPlanDao.getSealTempDinasTypeListByNeedPlanInfo(purchaseSandUnitId, planningCycleId, projectId);
}
@Override
public List<Map<String, Object>> querySalesPlanByCarNum(KObject station, String carNum) {
//根据车牌号获取需用计划,每个车牌可能有多个需用计划
List<KObject> plans = needPlanService.queryNeedPlanByCarNumAndPlanningCycle(station, carNum, new Date());
//根据计划周期和合同编号获取本次购砂单位实际可以分配的砂石类型
//根据需用计划中计划周期和合同获取销售计划
ArrayList<Map<String, Object>> maps = new ArrayList<>();
List<KObject> saleTempByCarNum = salesPlanDao.getSaleTempByCarNum(carNum, station);
//车牌号 本次周期 本次周期id 所属项目名称 所属项目编号 所属项目id 砂石类型 本周期需用量 需用计划id 本周期分配总量 销售计划id 本周期已拉取量 生产线A库存 生产线B库存
for (KObject plan : plans) {
KObject needPlanDetails = plan.get("NeedPlanDetails");
KObject contract = plan.get("contract");
KObject planningCycle = plan.get("planningCycle");
KObject project = plan.get("project");
KObject purchaseSandUnit = plan.get("purchaseSandUnit");
//根据需用计划中的时间获取销售计划
List<KObject> dinasTypeListByNeedPlanInfo = salesPlanDao.getDinasTypeListByNeedPlanInfo(purchaseSandUnit.getUuid("id"), planningCycle.getUuid("id"), project.getUuid("id"));
for (KObject needPlanDetail : needPlanDetails) {
KObject dinasType = needPlanDetail.get("dinasType");
UUID dinasTypeId = dinasType.getUuid("id");
KObject inventory = inventoryDao.getItemByStationIdAndDinasTypeId(station.getUuid("id"), dinasTypeId);
HashMap<String, Object> stringObjectHashMap = new HashMap<>();
//销售计划
setSalePlanHashMap(contract,carNum, plan, planningCycle, project, dinasTypeListByNeedPlanInfo, needPlanDetail, inventory, stringObjectHashMap, 1);
maps.add(stringObjectHashMap);
}
}
//临时销售计划
//根据id获取临时销售计划
//车牌号 本次周期 本次周期id 所属项目名称 所属项目编号 所属项目id 砂石类型 本周期需用量 需用计划id 本周期分配总量 销售计划id 本周期已拉取量
for (KObject salePlanTemp : saleTempByCarNum) {
Map<String, Object> stringObjectHashMap = new HashMap<>();
KObject project = salePlanTemp.get("project");
KObject planningCycle = salePlanTemp.get("planningCycle");
KObject salesPlanTempDetails = salePlanTemp.get("SalesPlanTempDetails");
List<KObject> saleTempDetails = salesPlanTempDetails.toList();
KObject contract = salePlanTemp.get("contract");
for (KObject saleTempDetail : saleTempDetails) {
KObject dinasType = saleTempDetail.get("dinasType");
KObject inventory = inventoryDao.getItemByStationIdAndDinasTypeId(station.getUuid("id"), dinasType.getUuid("id"));
setSalePlanTempHashMap(contract,carNum, planningCycle, project, stringObjectHashMap, dinasType, saleTempDetail, inventory, 0);
maps.add(stringObjectHashMap);
}
}
return maps;
}
private void setSalePlanTempHashMap(KObject contract,String carNum, KObject planningCycle, KObject project, Map<String, Object> stringObjectHashMap, KObject dinasType, KObject saleTempDetail, KObject inventory, int saleType) {
//车牌号
stringObjectHashMap.put("carNum", carNum);
//计划周期
stringObjectHashMap.put("planningCycleTitle", planningCycle.getString("title"));
//计划id
stringObjectHashMap.put("planningCycleId", planningCycle.getUuid("id"));
//项目名称
stringObjectHashMap.put("projectName", project.getString("projectName"));
//项目编码
stringObjectHashMap.put("projectCode", project.getString("projectNum"));
//项目id
stringObjectHashMap.put("projectId", project.getUuid("id"));
//合同id
stringObjectHashMap.put("contractId", contract.getUuid("id"));
//砂石类型名称
stringObjectHashMap.put("dinasTypeName", dinasType.getString("dinasTypeName"));
//砂石类型id
stringObjectHashMap.put("dinasTypeId", dinasType.getUuid("id"));
//本次需用量
stringObjectHashMap.put("needPlanAmount", saleTempDetail.getBigDecimal("salesPlanAmount"));
//需用计划id
stringObjectHashMap.put("needPlanId", saleTempDetail.getUuid("id"));
//需用计划砂石id
stringObjectHashMap.put("needDinasTypeId", saleTempDetail.getUuid("id"));
//本周期已拉取量
stringObjectHashMap.put("effectiveSale", saleTempDetail.getBigDecimal("actualSaleAmount"));
//本周期分配量
stringObjectHashMap.put("planAmount", saleTempDetail.getBigDecimal("salesPlanAmount"));
stringObjectHashMap.put("salePlanId", saleTempDetail.get("master").getUuid("id"));
//获取砂石今日库存
//库存id
UUID id = inventory.getUuid("id");
stringObjectHashMap.put("inventoryId", id);
//库存量(吨)
BigDecimal amount = inventory.getBigDecimal("amount");
stringObjectHashMap.put("inventoryAmount", amount);
//单价
BigDecimal price = inventory.getBigDecimal("price");
stringObjectHashMap.put("price", price);
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);
}
//销售类型
stringObjectHashMap.put("saleType", saleType);
//运输类型
stringObjectHashMap.put("transportType", 0);
stringObjectHashMap.put("canSale",true);
}
private void setSalePlanHashMap(KObject contract, String carNum, KObject plan, KObject planningCycle, KObject project, List<KObject> dinasTypeListByNeedPlanInfo, KObject needPlanDetail, KObject inventory, final HashMap<String, Object> stringObjectHashMap, Integer saleType) {
KObject dinasType = needPlanDetail.get("dinasType");
UUID dinasTypeId = dinasType.getUuid("id");
BigDecimal needPlanAmount = needPlanDetail.getBigDecimal("needPlanAmount");
//车牌号
stringObjectHashMap.put("carNum", carNum);
//计划周期
stringObjectHashMap.put("planningCycleTitle", planningCycle.getString("title"));
//计划id
stringObjectHashMap.put("planningCycleId", planningCycle.getUuid("id"));
//项目名称
stringObjectHashMap.put("projectName", project.getString("projectName"));
//项目编码
stringObjectHashMap.put("projectCode", project.getString("projectNum"));
//项目id
stringObjectHashMap.put("projectId", project.getUuid("id"));
//合同id
stringObjectHashMap.put("contractId", contract.getUuid("id"));
//砂石类型名称
stringObjectHashMap.put("dinasTypeName", dinasType.getString("dinasTypeName"));
//砂石类型id
stringObjectHashMap.put("dinasTypeId", dinasTypeId);
//本次需用量
stringObjectHashMap.put("needPlanAmount", needPlanAmount);
//需用计划id
stringObjectHashMap.put("needPlanId", plan.getUuid("id"));
//需用计划砂石id
stringObjectHashMap.put("needDinasTypeId", needPlanDetail.getUuid("id"));
//本周期已拉取量
stringObjectHashMap.put("effectiveSale", needPlanDetail.getBigDecimal("effectiveSale"));
//本周期分配量
dinasTypeListByNeedPlanInfo.stream().filter(
a -> a.get("dinasType").getUuid("id").toString().equals(dinasTypeId.toString()))
.findFirst().ifPresent(a -> {
BigDecimal planAmount = a.getBigDecimal("planAmount");
UUID uuid = a.get("master").getUuid("id");
stringObjectHashMap.put("planAmount", planAmount);
stringObjectHashMap.put("salePlanId", uuid);
});
//获取砂石今日库存
if(!stringObjectHashMap.containsKey("planAmount")){
stringObjectHashMap.put("canSale",false);
stringObjectHashMap.put("canSaleTitle","本周期不允许采购该砂石");
}else {
stringObjectHashMap.put("canSale",true);
}
//库存id
UUID id = inventory.getUuid("id");
stringObjectHashMap.put("inventoryId", id);
//库存量(吨)
BigDecimal price = inventory.getBigDecimal("price");
BigDecimal amount = inventory.getBigDecimal("amount");
stringObjectHashMap.put("inventoryAmount", amount);
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);
}
//单价
stringObjectHashMap.put("price", price);
//销售类型
stringObjectHashMap.put("saleType", saleType);
stringObjectHashMap.put("transportType", 0);
} }
......
...@@ -4,9 +4,9 @@ import com.beecode.bcp.type.KClass; ...@@ -4,9 +4,9 @@ import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject; import com.beecode.bcp.type.KObject;
import com.xyst.dinas.biz.dao.*; import com.xyst.dinas.biz.dao.*;
import com.xyst.dinas.biz.service.PlanningCycleService; import com.xyst.dinas.biz.service.PlanningCycleService;
import com.xyst.dinas.biz.service.RetailInfoService;
import com.xyst.dinas.contract.internal.dao.ContractDao; import com.xyst.dinas.contract.internal.dao.ContractDao;
import com.xyst.dinas.contract.service.ContractService; import com.xyst.dinas.contract.service.ContractService;
import com.xyst.dinas.project.dao.ProjectFiledDao;
import com.xyst.dinas.project.dao.PurchaseSandCompanyDao; import com.xyst.dinas.project.dao.PurchaseSandCompanyDao;
import com.xyst.dinas.sales.constant.CustomerTypeEnum; import com.xyst.dinas.sales.constant.CustomerTypeEnum;
import com.xyst.dinas.sales.constant.PayMentSourceEnum; import com.xyst.dinas.sales.constant.PayMentSourceEnum;
...@@ -42,8 +42,6 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -42,8 +42,6 @@ public class SalesRecordServiceImpl implements SalesRecordService {
@Autowired @Autowired
private SalesRecordDao salesRecordDao; private SalesRecordDao salesRecordDao;
@Autowired @Autowired
private ProjectFiledDao projectFiledDao;
@Autowired
DinasOrganizationDao dinasOrganizationDao; DinasOrganizationDao dinasOrganizationDao;
@Autowired @Autowired
ContractDao contractDao; ContractDao contractDao;
...@@ -54,7 +52,7 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -54,7 +52,7 @@ public class SalesRecordServiceImpl implements SalesRecordService {
@Autowired @Autowired
ProductionLineDao ProductionLineDao; ProductionLineDao ProductionLineDao;
@Autowired @Autowired
RetailInfoDao retailInfoDao; RetailInfoService retailInfoService;
@Autowired @Autowired
DinasTypeDao dinasTypeDao; DinasTypeDao dinasTypeDao;
@Autowired @Autowired
...@@ -77,103 +75,88 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -77,103 +75,88 @@ public class SalesRecordServiceImpl implements SalesRecordService {
@Transactional @Transactional
@Override @Override
public String saveSalesRecordService(List<SalesRecordInfo> salesRecordInfoList) { public String saveSalesRecordService(List<SalesRecordInfo> salesRecordInfoList, KObject station) {
String state = "success"; String state = "success";
try { try {
Date thentime = new Date(); Date thentime = new Date();
List<UUID> salesRecordIdList = new ArrayList<UUID>(); List<UUID> salesRecordIdList = new ArrayList<>();
for (SalesRecordInfo salesRecordInfo : salesRecordInfoList) { for (SalesRecordInfo salesRecordInfo : salesRecordInfoList) {
// 获取项目KObject
KObject project = null;
project = entityExistenceCheck("项目",
projectFiledDao.load(UUID.fromString(dataExistenceCheck("项目", salesRecordInfo.getProject()))), true);
// 获取区域公司KObject
KObject regionalCompany = null;
regionalCompany = entityExistenceCheck("区域公司", dinasOrganizationDao
.load(UUID.fromString(dataExistenceCheck("区域公司", salesRecordInfo.getRegionalCompany()))), true);
// 获取合同KObject
KObject contract = null;
contract = entityExistenceCheck("合同",
contractDao.load(UUID.fromString(dataExistenceCheck("合同", salesRecordInfo.getContract()))), true);
// 获取购砂单位KObject
KObject purchaseSandCompany = null;
// 获取散户KObject
KObject retailInfo = null;
if ((CustomerTypeEnum.PurchaseSandCompany.name()).equals(salesRecordInfo.getCustomerType())) {
purchaseSandCompany = entityExistenceCheck("购砂单位", purchaseSandCompanyDao.load(
UUID.fromString(dataExistenceCheck("购砂单位", salesRecordInfo.getPurchaseSandCompany()))), true);
} else {
retailInfo = entityExistenceCheck("散户", retailInfoDao
.load(UUID.fromString(dataExistenceCheck("散户", salesRecordInfo.getRetailInfo()))), true);
}
// 获取场站KObject
KObject station = null;
station = entityExistenceCheck("场站",
stationDao.load(UUID.fromString(dataExistenceCheck("场站", salesRecordInfo.getStation()))), true);
// 获取生产线KObject
KObject productionLine = null;
productionLine = entityExistenceCheck("生产线", ProductionLineDao
.load(UUID.fromString(dataExistenceCheck("生产线", salesRecordInfo.getProductionLine()))), true);
// 获取砂石类型 // 获取砂石类型
KObject dinasType = null; KObject dinasType = null;
dinasType = entityExistenceCheck("砂石类型", dinasType = dinasTypeDao.load(UUID.fromString(salesRecordInfo.getDinasType()));
dinasTypeDao.load(UUID.fromString(dataExistenceCheck("砂石类型", salesRecordInfo.getDinasType()))), true);
Date modifyTime = generateDate("修改时间", "yyyy-MM-dd", salesRecordInfo.getModifyTime()); KObject regionalCompany = null;
Date dealtime = generateDate("销售时间", "yyyy-MM-dd", salesRecordInfo.getDealTime());
// 获取销售台账Kobject //获取区域公司
regionalCompany = station.get("regionalCompany");
KObject salesRecord = salesRecordClass.newInstance(); KObject salesRecord = salesRecordClass.newInstance();
salesRecord.set(SalesRecordConstant.ID, UUID.randomUUID()); salesRecord.set(SalesRecordConstant.ID, UUID.randomUUID());
salesRecord.set(SalesRecordConstant.CREATETIME, thentime); salesRecord.set(SalesRecordConstant.CREATETIME, thentime);
salesRecord.set(SalesRecordConstant.MODIFYTIME, modifyTime); salesRecord.set(SalesRecordConstant.STATION, station);
salesRecord.set(SalesRecordConstant.DEALTIME, salesRecordInfo.getDealTime());
salesRecord.set(SalesRecordConstant.GROSS_WEIGHT, salesRecordInfo.getGrossWeight());
salesRecord.set(SalesRecordConstant.TARE_WEIGHT, salesRecordInfo.getTareWeight());
salesRecord.set(SalesRecordConstant.GROSS_WEIGHT_TIME, salesRecordInfo.getGrossWeightTime());
salesRecord.set(SalesRecordConstant.TARE_WEIGHT_TIME, salesRecordInfo.getTareWeightTime());
salesRecord.set(SalesRecordConstant.GROSS_WEIGHT_PERSON, salesRecordInfo.getGrossWeightPerson());
salesRecord.set(SalesRecordConstant.TARE_WEIGHT_PERSON, salesRecordInfo.getTareWeightPerson());
salesRecord.set(SalesRecordConstant.SYNCTIME, thentime);
salesRecord.set(SalesRecordConstant.DEALBILLCODE, salesRecordInfo.getDealBillCode());
salesRecord.set(SalesRecordConstant.CARINFO, salesRecordInfo.getCarInfo());
salesRecord.set(SalesRecordConstant.DEALAMOUNT, salesRecordInfo.getDealAmount());
salesRecord.set(SalesRecordConstant.PRICE, salesRecordInfo.getPrice());
salesRecord.set(SalesRecordConstant.PAYMENTSOURCE, salesRecordInfo.getPaymentSource());
salesRecord.set(SalesRecordConstant.TRANSPORT_TYPE, salesRecordInfo.getTransportType());
salesRecord.set(SalesRecordConstant.SALE_TYPE, salesRecordInfo.getSaleType());
salesRecord.set(SalesRecordConstant.REGIONALCOMPANY, regionalCompany);
salesRecord.set(SalesRecordConstant.DINASTYPE, dinasType);
salesRecord.set(SalesRecordConstant.CARINFO, salesRecordInfo.getCarInfo());
//如果是散客则全部新增
if (2 == salesRecordInfo.getSaleType()) {
salesRecordInfo.setCustomerType(CustomerTypeEnum.RetailInfo.name());
retailInfoService.create(station, dinasType, salesRecordInfo.getRetailName(), salesRecordInfo.getRetailIdNum(), salesRecordInfo.getCarInfo(), salesRecordInfo.getDealAmount(), salesRecordInfo.getAmount());
} else {
//如果不为2则必定有合同 项目 购砂单位 区域公司
salesRecordInfo.setCustomerType(CustomerTypeEnum.PurchaseSandCompany.name());
// 获取项目KObject
KObject project = null;
KObject contract = null;
KObject purchaseSandCompany = null;
contract = contractDao.load(UUID.fromString(salesRecordInfo.getContract()));
// 获取合同KObject
project = contract.get("project");
// 获取区域公司KObject
regionalCompany = contract.get("regionalCompany");
// 获取购砂单位KObject
purchaseSandCompany = contract.get("purchaseSandUnit");
// 获取销售台账Kobject
salesRecord.set(SalesRecordConstant.PROJECT, project); salesRecord.set(SalesRecordConstant.PROJECT, project);
salesRecord.set(SalesRecordConstant.REGIONALCOMPANY, regionalCompany); salesRecord.set(SalesRecordConstant.REGIONALCOMPANY, regionalCompany);
salesRecord.set(SalesRecordConstant.CONTRACT, contract); salesRecord.set(SalesRecordConstant.CONTRACT, contract);
if (CustomerTypeEnum.PurchaseSandCompany.name().equals(salesRecordInfo.getCustomerType())) { if (CustomerTypeEnum.PurchaseSandCompany.name().equals(salesRecordInfo.getCustomerType())) {
salesRecord.set(SalesRecordConstant.PURCHASESANDCOMPANY, purchaseSandCompany); salesRecord.set(SalesRecordConstant.PURCHASESANDCOMPANY, purchaseSandCompany);
} else if (null != salesRecordInfo.getRetailInfo()) {
salesRecord.set(SalesRecordConstant.RETAILINFO, retailInfo);
} }
salesRecord.set(SalesRecordConstant.STATION, station); salesRecord.set(SalesRecordConstant.DEALAMOUNT,salesRecordInfo.getDealAmount() == null ? BigDecimal.ZERO: BigDecimal.valueOf(salesRecordInfo.getDealAmount()));
salesRecord.set(SalesRecordConstant.PRODUCTIONLINE, productionLine);
salesRecord.set(SalesRecordConstant.DINASTYPE, dinasType);
salesRecord.set(SalesRecordConstant.CUSTOMERTYPE,
dataExistenceCheck("客户类型", salesRecordInfo.getCustomerType()));
salesRecord.set(SalesRecordConstant.DEALTIME, dealtime);
salesRecord.set(SalesRecordConstant.SYNCTIME, thentime);
salesRecord.set(SalesRecordConstant.CARINFO, dataExistenceCheck("车辆信息", salesRecordInfo.getCarInfo()));
salesRecord.set(SalesRecordConstant.DEALAMOUNT,
salesRecordInfo.getDealAmount() == null ? BigDecimal.ZERO
: new BigDecimal(salesRecordInfo.getDealAmount()));
salesRecord.set(SalesRecordConstant.PRICE, salesRecordInfo.getPrice() == null ? BigDecimal.ZERO
: new BigDecimal(salesRecordInfo.getPrice()));
salesRecord.set(SalesRecordConstant.AMOUNT, salesRecordInfo.getAmount() == null ? BigDecimal.ZERO
: new BigDecimal(salesRecordInfo.getAmount()));
salesRecord.set(SalesRecordConstant.PAYMENTSOURCE,
dataExistenceCheck("付款来源", salesRecordInfo.getPaymentSource()));
salesRecord.set(SalesRecordConstant.DEALBILLCODE,
dataExistenceCheck("销售单号", salesRecordInfo.getDealBillCode()));
salesRecord.set(SalesRecordConstant.DISCARD, false); salesRecord.set(SalesRecordConstant.DISCARD, false);
salesRecord.set(SalesRecordConstant.DEL, false); salesRecord.set(SalesRecordConstant.DEL, false);
BigDecimal DEALAMOUNT = BigDecimal.ZERO BigDecimal DEALAMOUNT = BigDecimal.ZERO
.subtract(new BigDecimal(salesRecord.getDouble(SalesRecordConstant.DEALAMOUNT))); .subtract(BigDecimal.valueOf(salesRecord.getDouble(SalesRecordConstant.DEALAMOUNT)));
// 付款来源未定,暂时按使用预付款处理。
BigDecimal AMOUNT; BigDecimal AMOUNT;
if (PayMentSourceEnum.Advance.name().equals(salesRecordInfo.getPaymentSource())) { if (PayMentSourceEnum.Advance.name().equals(salesRecordInfo.getPaymentSource())) {
AMOUNT = BigDecimal.ZERO AMOUNT = BigDecimal.ZERO.subtract(BigDecimal.valueOf(salesRecord.getDouble(SalesRecordConstant.AMOUNT)));
.subtract(new BigDecimal(salesRecord.getDouble(SalesRecordConstant.AMOUNT)));
} else { } else {
AMOUNT = BigDecimal.ZERO; AMOUNT = BigDecimal.ZERO;
} }
if (CustomerTypeEnum.PurchaseSandCompany.name().equals(salesRecordInfo.getCustomerType())) {
// 更新合同子表合同砂石余量(吨)-更新合同表付款余额、销售总量信息 // 更新合同子表合同砂石余量(吨)-更新合同表付款余额、销售总量信息
boolean flag = contractService.modifyInventory(UUID.fromString(salesRecordInfo.getContract()), boolean flag = contractService.modifyInventory(UUID.fromString(salesRecordInfo.getContract()),
UUID.fromString(salesRecordInfo.getDinasType()), DEALAMOUNT, AMOUNT); UUID.fromString(salesRecordInfo.getDinasType()), DEALAMOUNT, AMOUNT);
if (!flag) {
throw new SyncException("销售台账信息存储报出错:合同子表中无此砂石类型数据");
}
// 更新销售计划 // 更新销售计划
UUID planningCycleId = planningCycleService UUID planningCycleId = planningCycleService
.getPlanningCycleObjBySum(regionalCompany.getString("planningCycle"), dealtime); .getPlanningCycleObjBySum(regionalCompany.getString("planningCycle"), salesRecordInfo.getDealTime());
KObject salesPlan = entityExistenceCheck("销售计划", salesPlanDao.querySalesPlanByPlan( KObject salesPlan = entityExistenceCheck("销售计划", salesPlanDao.querySalesPlanByPlan(
UUID.fromString(salesRecordInfo.getRegionalCompany()), planningCycleId), false); UUID.fromString(salesRecordInfo.getRegionalCompany()), planningCycleId), false);
BigDecimal actualSaleTotalAmount = salesPlan.get("actualSaleTotalAmount") == null ? BigDecimal.ZERO BigDecimal actualSaleTotalAmount = salesPlan.get("actualSaleTotalAmount") == null ? BigDecimal.ZERO
...@@ -182,9 +165,6 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -182,9 +165,6 @@ public class SalesRecordServiceImpl implements SalesRecordService {
salesPlanDao.update(salesPlan); salesPlanDao.update(salesPlan);
boolean flag1 = salesPlanDao.updateSalesPlanAmount(salesPlan, dinasType.getUuid("id"), contract.getUuid("id"), boolean flag1 = salesPlanDao.updateSalesPlanAmount(salesPlan, dinasType.getUuid("id"), contract.getUuid("id"),
project.getUuid("id"), purchaseSandCompany.getUuid("id"), DEALAMOUNT); project.getUuid("id"), purchaseSandCompany.getUuid("id"), DEALAMOUNT);
if (!flag1) {
//throw new SyncException("销售台账信息存储报出错:销售计划子表更新数据报错");
}
KObject needPlanAmount = entityExistenceCheck("需用计划", KObject needPlanAmount = entityExistenceCheck("需用计划",
needPlanServiceImpl.queryNeedPlanAmountByDinasType(planningCycleId, contract.getUuid("id"), needPlanServiceImpl.queryNeedPlanAmountByDinasType(planningCycleId, contract.getUuid("id"),
dinasType.getUuid("id")), false); dinasType.getUuid("id")), false);
...@@ -194,8 +174,6 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -194,8 +174,6 @@ public class SalesRecordServiceImpl implements SalesRecordService {
needPlanAmount.set("effectiveSale", effectiveSale.subtract(DEALAMOUNT)); needPlanAmount.set("effectiveSale", effectiveSale.subtract(DEALAMOUNT));
needPlanDao.update(needPlanAmount); needPlanDao.update(needPlanAmount);
} }
} }
// 此处为Jason格式,多重嵌套 // 此处为Jason格式,多重嵌套
// 更新库存量 // 更新库存量
...@@ -209,7 +187,7 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -209,7 +187,7 @@ public class SalesRecordServiceImpl implements SalesRecordService {
item.put("dinasTypeId", dinasType.get("id")); item.put("dinasTypeId", dinasType.get("id"));
item.put("stationName", ""); item.put("stationName", "");
item.put("dinasTypeName", ""); item.put("dinasTypeName", "");
item.put("amount", BigDecimal.ZERO.subtract(DEALAMOUNT)); item.put("amount", BigDecimal.ZERO.subtract(BigDecimal.valueOf(salesRecordInfo.getDealAmount())));
data.put(item); data.put(item);
param.put("regionalCompany", regionalCompany.getUuid("id")); param.put("regionalCompany", regionalCompany.getUuid("id"));
param.put("data", data); param.put("data", data);
...@@ -222,9 +200,7 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -222,9 +200,7 @@ public class SalesRecordServiceImpl implements SalesRecordService {
saveAstTransportRecord(salesRecord); saveAstTransportRecord(salesRecord);
salesRecordIdList.add(salesRecordId); salesRecordIdList.add(salesRecordId);
} }
} catch (Exception e) {
} catch (SyncException e) {
state = "failure";
throw new SyncException("销售台账信息存储报出错:" + e.getMessage()); throw new SyncException("销售台账信息存储报出错:" + e.getMessage());
} }
return state; return state;
...@@ -295,7 +271,7 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -295,7 +271,7 @@ public class SalesRecordServiceImpl implements SalesRecordService {
HashMap<String, Object> error1 = new HashMap<>(); HashMap<String, Object> error1 = new HashMap<>();
HashSet<String> strings = new HashSet<>(); HashSet<String> strings = new HashSet<>();
try { try {
error1.put("error",true); error1.put("error", true);
//验证文件名是否正确,并生成对应的Workbook对象 //验证文件名是否正确,并生成对应的Workbook对象
String filename = file.getOriginalFilename(); String filename = file.getOriginalFilename();
...@@ -325,10 +301,10 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -325,10 +301,10 @@ public class SalesRecordServiceImpl implements SalesRecordService {
strings.add("数据为空"); strings.add("数据为空");
return error1; return error1;
} }
strings=cellValidate(sheet,lastRowNum); strings = cellValidate(sheet, lastRowNum);
if(strings.size()>0){ if (strings.size() > 0) {
error1.put("error",true); error1.put("error", true);
error1.put("message",strings); error1.put("message", strings);
return error1; return error1;
} }
HashSet<KObject> organizations = new HashSet<>(); HashSet<KObject> organizations = new HashSet<>();
...@@ -336,19 +312,19 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -336,19 +312,19 @@ public class SalesRecordServiceImpl implements SalesRecordService {
HashSet<KObject> dinasTypes = new HashSet<>(); HashSet<KObject> dinasTypes = new HashSet<>();
HashSet<KObject> retailInfos = new HashSet<>(); HashSet<KObject> retailInfos = new HashSet<>();
Set<String> noExist = createNoExist(sheet, lastRowNum, organizations, stations, dinasTypes, retailInfos, strings); Set<String> noExist = createNoExist(sheet, lastRowNum, organizations, stations, dinasTypes, retailInfos, strings);
if(noExist!=null && !noExist.isEmpty()){ if (noExist != null && !noExist.isEmpty()) {
strings.addAll(noExist); strings.addAll(noExist);
} }
if(strings.size()>0){ if (strings.size() > 0) {
error1.put("error",true); error1.put("error", true);
error1.put("message",strings); error1.put("message", strings);
return error1; return error1;
} }
error1.clear(); error1.clear();
return error1; return error1;
} }
private Set<String> createNoExist(Sheet sheet ,int lastRowNum,Set<KObject> organizations,Set<KObject> stations,Set<KObject> dinasTypes,Set<KObject> retailInfos,Set<String> strings){ private Set<String> createNoExist(Sheet sheet, int lastRowNum, Set<KObject> organizations, Set<KObject> stations, Set<KObject> dinasTypes, Set<KObject> retailInfos, Set<String> strings) {
Row row; Row row;
List<KObject> saleRecord = new ArrayList<>(); List<KObject> saleRecord = new ArrayList<>();
...@@ -363,11 +339,11 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -363,11 +339,11 @@ public class SalesRecordServiceImpl implements SalesRecordService {
//集团名称 //集团名称
String orgName = row.getCell(0).getStringCellValue().trim(); String orgName = row.getCell(0).getStringCellValue().trim();
Optional<KObject> hasOrg = organizations.stream().filter(a -> a.getString("name").equals(orgName)).findFirst(); Optional<KObject> hasOrg = organizations.stream().filter(a -> a.getString("name").equals(orgName)).findFirst();
if(!hasOrg.isPresent()){ if (!hasOrg.isPresent()) {
organization = dinasOrganizationDao.queryOrganizationByName(orgName); organization = dinasOrganizationDao.queryOrganizationByName(orgName);
if(organization==null||organization.isNull()||organization.isEmpty()){ if (organization == null || organization.isNull() || organization.isEmpty()) {
//如果没有所属集团,应该报错 //如果没有所属集团,应该报错
strings.add("请创建集团:"+orgName); strings.add("请创建集团:" + orgName);
continue; continue;
} }
organizations.add(organization); organizations.add(organization);
...@@ -375,73 +351,71 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -375,73 +351,71 @@ public class SalesRecordServiceImpl implements SalesRecordService {
//场站名称 //场站名称
String stationName = row.getCell(1).getStringCellValue().trim(); String stationName = row.getCell(1).getStringCellValue().trim();
Optional<KObject> hasStation = stations.stream().filter(a -> a.getString("stationName").equals(stationName)).findFirst(); Optional<KObject> hasStation = stations.stream().filter(a -> a.getString("stationName").equals(stationName)).findFirst();
if(!hasStation.isPresent()){ if (!hasStation.isPresent()) {
assert organization != null; assert organization != null;
List<KObject> kObjects = stationDao.listStationInfoByRegionalCompany(organization.getUuid("id")); List<KObject> kObjects = stationDao.listStationInfoByRegionalCompany(organization.getUuid("id"));
Optional<KObject> filterStation = kObjects.stream().filter(a -> a.getString("stationName").equals(stationName)).findFirst(); Optional<KObject> filterStation = kObjects.stream().filter(a -> a.getString("stationName").equals(stationName)).findFirst();
if(!filterStation.isPresent()){ if (!filterStation.isPresent()) {
//创建场站 //创建场站
station = stationDao.createNoInfoStation(stationName, organization); station = stationDao.createNoInfoStation(stationName, organization);
stations.add(station); stations.add(station);
}else { } else {
station = filterStation.get(); station = filterStation.get();
stations.add(station); stations.add(station);
} }
}else { } else {
station= hasStation.get(); station = hasStation.get();
} }
//生产线名称 //生产线名称
String productionLineName = row.getCell(2).getStringCellValue().trim(); String productionLineName = row.getCell(2).getStringCellValue().trim();
KObject productions = station.get("productionLines"); KObject productions = station.get("productionLines");
if(null!=productions&&!productions.isNull()){ if (null != productions && !productions.isNull()) {
List<KObject> kObjects = productions.toList(); List<KObject> kObjects = productions.toList();
Optional<KObject> name = kObjects.stream().filter(a -> productionLineName.equals(a.getString("name"))).findFirst(); Optional<KObject> name = kObjects.stream().filter(a -> productionLineName.equals(a.getString("name"))).findFirst();
if(!name.isPresent()){ if (!name.isPresent()) {
productionLine = stationDao.insertProductionLine(productionLineName, station); productionLine = stationDao.insertProductionLine(productionLineName, station);
kObjects.add(productionLine); kObjects.add(productionLine);
}else { } else {
productionLine = name.get(); productionLine = name.get();
ArrayList<KObject> kObjects1 = new ArrayList<>(); ArrayList<KObject> kObjects1 = new ArrayList<>();
kObjects1.add(productionLine); kObjects1.add(productionLine);
station.set("productionLines",kObjects1); station.set("productionLines", kObjects1);
} }
} }
String dinasTypeName = row.getCell(3).getStringCellValue().trim(); String dinasTypeName = row.getCell(3).getStringCellValue().trim();
//砂石类型 //砂石类型
Optional<KObject> dinasTypeName1 = dinasTypes.stream().filter(a -> a.getString("dinasTypeName").equals(dinasTypeName)).findFirst(); Optional<KObject> dinasTypeName1 = dinasTypes.stream().filter(a -> a.getString("dinasTypeName").equals(dinasTypeName)).findFirst();
if(!dinasTypeName1.isPresent()) { if (!dinasTypeName1.isPresent()) {
List<KObject> byName = dinasTypeDao.getByName(dinasTypeName, null); List<KObject> byName = dinasTypeDao.getByName(dinasTypeName, null);
if (byName == null || byName.size() < 1) { if (byName == null || byName.size() < 1) {
KObject kObject = dinasTypeDao.insertNoInfo(dinasTypeName, station, organization); KObject kObject = dinasTypeDao.insertNoInfo(dinasTypeName, station, organization);
dinasTypes.add(kObject); dinasTypes.add(kObject);
dinasType=kObject; dinasType = kObject;
} else { } else {
dinasTypes.add(byName.get(0)); dinasTypes.add(byName.get(0));
dinasType=byName.get(0); dinasType = byName.get(0);
} }
}else { } else {
dinasTypes.add(dinasTypeName1.get()); dinasTypes.add(dinasTypeName1.get());
dinasType=dinasTypeName1.get(); dinasType = dinasTypeName1.get();
} }
//散户名称 //散户名称
String retailName = row.getCell(6).getStringCellValue().trim(); String retailName = row.getCell(6).getStringCellValue().trim();
Optional<KObject> retailInfoName1 = retailInfos.stream().filter(a -> a.getString("retailInfoName").equals(retailName)).findFirst(); Optional<KObject> retailInfoName1 = retailInfos.stream().filter(a -> a.getString("retailInfoName").equals(retailName)).findFirst();
if(!retailInfoName1.isPresent()){ // if (!retailInfoName1.isPresent()) {
List<KObject> retailInfoName = retailInfoDao.getByName(retailName, null); // List<KObject> retailInfoName = retailInfoService.getByName(retailName, null);
if(retailInfoName!=null && retailInfoName.size()>0){ // if (retailInfoName != null && retailInfoName.size() > 0) {
retailInfos.add(retailInfoName.get(0)); // retailInfos.add(retailInfoName.get(0));
retailInfo= retailInfoName.get(0); // retailInfo = retailInfoName.get(0);
}else { // } else {
KObject k = retailInfoDao.insertNoInfo(retailName,station,organization); // KObject k = retailInfoDao.insertNoInfo(retailName, station, organization);
retailInfos.add(k); // retailInfos.add(k);
retailInfo= k; // retailInfo = k;
} // }
}else { // } else {
retailInfo = retailInfoName1.get(); // retailInfo = retailInfoName1.get();
} // }
String carNumber = row.getCell(5).getStringCellValue(); String carNumber = row.getCell(5).getStringCellValue();
String billCode = row.getCell(4).getStringCellValue(); String billCode = row.getCell(4).getStringCellValue();
BigDecimal grossWeight = BigDecimal.valueOf(row.getCell(9).getNumericCellValue()); BigDecimal grossWeight = BigDecimal.valueOf(row.getCell(9).getNumericCellValue());
...@@ -450,10 +424,10 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -450,10 +424,10 @@ public class SalesRecordServiceImpl implements SalesRecordService {
BigDecimal price = BigDecimal.valueOf(row.getCell(13).getNumericCellValue()); BigDecimal price = BigDecimal.valueOf(row.getCell(13).getNumericCellValue());
BigDecimal amount = BigDecimal.valueOf(row.getCell(14).getNumericCellValue()); BigDecimal amount = BigDecimal.valueOf(row.getCell(14).getNumericCellValue());
Date dateCellValue = row.getCell(15).getDateCellValue(); Date dateCellValue = row.getCell(15).getDateCellValue();
KObject record = createRecord(organization, retailInfo, station, productionLine, dinasType, carNumber, billCode, grossWeight, tareWeight, dealAmount, price, amount,dateCellValue); KObject record = createRecord(organization, retailInfo, station, productionLine, dinasType, carNumber, billCode, grossWeight, tareWeight, dealAmount, price, amount, dateCellValue);
saleRecord.add(record); saleRecord.add(record);
} }
if(strings.size()>0){ if (strings.size() > 0) {
return strings; return strings;
} }
salesRecordDao.insertList(saleRecord); salesRecordDao.insertList(saleRecord);
...@@ -461,8 +435,8 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -461,8 +435,8 @@ public class SalesRecordServiceImpl implements SalesRecordService {
} }
private KObject createRecord(KObject regionalCompany,KObject retailInfo,KObject station,KObject productionLine,KObject dinasType,String carNum, private KObject createRecord(KObject regionalCompany, KObject retailInfo, KObject station, KObject productionLine, KObject dinasType, String carNum,
String billCode,BigDecimal grossWeight,BigDecimal tareWeight,BigDecimal dealAmount,BigDecimal price,BigDecimal amount,Date dealTime){ String billCode, BigDecimal grossWeight, BigDecimal tareWeight, BigDecimal dealAmount, BigDecimal price, BigDecimal amount, Date dealTime) {
KObject salesRecord = salesRecordClass.newInstance(); KObject salesRecord = salesRecordClass.newInstance();
salesRecord.set(SalesRecordConstant.ID, UUID.randomUUID()); salesRecord.set(SalesRecordConstant.ID, UUID.randomUUID());
salesRecord.set(SalesRecordConstant.CREATETIME, new Date()); salesRecord.set(SalesRecordConstant.CREATETIME, new Date());
...@@ -474,23 +448,23 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -474,23 +448,23 @@ public class SalesRecordServiceImpl implements SalesRecordService {
salesRecord.set(SalesRecordConstant.STATION, station); salesRecord.set(SalesRecordConstant.STATION, station);
salesRecord.set(SalesRecordConstant.PRODUCTIONLINE, productionLine); salesRecord.set(SalesRecordConstant.PRODUCTIONLINE, productionLine);
salesRecord.set(SalesRecordConstant.DINASTYPE, dinasType); salesRecord.set(SalesRecordConstant.DINASTYPE, dinasType);
salesRecord.set(SalesRecordConstant.CUSTOMERTYPE,CustomerTypeEnum.RetailInfo.name()); salesRecord.set(SalesRecordConstant.CUSTOMERTYPE, CustomerTypeEnum.RetailInfo.name());
salesRecord.set(SalesRecordConstant.DEALTIME, dealTime); salesRecord.set(SalesRecordConstant.DEALTIME, dealTime);
salesRecord.set(SalesRecordConstant.SYNCTIME, new Date()); salesRecord.set(SalesRecordConstant.SYNCTIME, new Date());
salesRecord.set(SalesRecordConstant.CARINFO, carNum); salesRecord.set(SalesRecordConstant.CARINFO, carNum);
salesRecord.set(SalesRecordConstant.DEALAMOUNT, dealAmount); salesRecord.set(SalesRecordConstant.DEALAMOUNT, dealAmount);
salesRecord.set(SalesRecordConstant.PRICE, price); salesRecord.set(SalesRecordConstant.PRICE, price);
salesRecord.set(SalesRecordConstant.AMOUNT, amount); salesRecord.set(SalesRecordConstant.AMOUNT, amount);
salesRecord.set(SalesRecordConstant.PAYMENTSOURCE,PayMentSourceEnum.Cash.name()); salesRecord.set(SalesRecordConstant.PAYMENTSOURCE, PayMentSourceEnum.Cash.name());
salesRecord.set(SalesRecordConstant.DEALBILLCODE,billCode); salesRecord.set(SalesRecordConstant.DEALBILLCODE, billCode);
salesRecord.set(SalesRecordConstant.GROSS_WEIGHT,grossWeight); salesRecord.set(SalesRecordConstant.GROSS_WEIGHT, grossWeight);
salesRecord.set(SalesRecordConstant.TARE_WEIGHT,tareWeight); salesRecord.set(SalesRecordConstant.TARE_WEIGHT, tareWeight);
salesRecord.set(SalesRecordConstant.DISCARD, false); salesRecord.set(SalesRecordConstant.DISCARD, false);
salesRecord.set(SalesRecordConstant.DEL, false); salesRecord.set(SalesRecordConstant.DEL, false);
return salesRecord; return salesRecord;
} }
private HashSet<String> cellValidate(Sheet sheet,int lastRowNum){ private HashSet<String> cellValidate(Sheet sheet, int lastRowNum) {
Cell cell; Cell cell;
HashSet<String> strings = new HashSet<>(); HashSet<String> strings = new HashSet<>();
//校验 //校验
...@@ -498,27 +472,27 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -498,27 +472,27 @@ public class SalesRecordServiceImpl implements SalesRecordService {
Row row = sheet.getRow(rowNum); Row row = sheet.getRow(rowNum);
//集团名称 场站名称 生产线名称 物资 流水号 车号 客户 毛重司磅员 皮重司磅员 毛重 皮重 净重 扣重 单价 金额 毛重时间 皮重时间 余额 //集团名称 场站名称 生产线名称 物资 流水号 车号 客户 毛重司磅员 皮重司磅员 毛重 皮重 净重 扣重 单价 金额 毛重时间 皮重时间 余额
//前9列全是string 集团名称 场站名称 生产线名称 物资 流水号 车号 客户 毛重司磅员 皮重司磅员 //前9列全是string 集团名称 场站名称 生产线名称 物资 流水号 车号 客户 毛重司磅员 皮重司磅员
for (int i = 0; i<9;i++) { for (int i = 0; i < 9; i++) {
cell = row.getCell(i); cell = row.getCell(i);
boolean b = validateCellStringValueIsNotNull(cell); boolean b = validateCellStringValueIsNotNull(cell);
if(!b){ if (!b) {
strings.add("第"+(rowNum+1)+"行,第"+(i+1)+"列,数据为空或者格式错误"); strings.add("第" + (rowNum + 1) + "行,第" + (i + 1) + "列,数据为空或者格式错误");
} }
} }
//中间6列全是数字 毛重 皮重 净重 扣重 单价 金额 //中间6列全是数字 毛重 皮重 净重 扣重 单价 金额
for (int i = 9; i<15;i++) { for (int i = 9; i < 15; i++) {
cell = row.getCell(i); cell = row.getCell(i);
boolean b = validateCellNumberValueIsNotNull(cell); boolean b = validateCellNumberValueIsNotNull(cell);
if(!b){ if (!b) {
strings.add("第"+(rowNum+1)+"行,第"+(i+1)+"列,数据为空或者格式错误"); strings.add("第" + (rowNum + 1) + "行,第" + (i + 1) + "列,数据为空或者格式错误");
} }
} }
//最后2列为时间类型 //最后2列为时间类型
for (int i = 16; i<18;i++) { for (int i = 16; i < 18; i++) {
cell = row.getCell(i); cell = row.getCell(i);
boolean b = validateCellDateValueIsNotNull(cell); boolean b = validateCellDateValueIsNotNull(cell);
if(!b){ if (!b) {
strings.add("第"+(rowNum+1)+"行,第"+(i+1)+"列,数据为空或者格式错误"); strings.add("第" + (rowNum + 1) + "行,第" + (i + 1) + "列,数据为空或者格式错误");
} }
} }
} }
...@@ -527,56 +501,59 @@ public class SalesRecordServiceImpl implements SalesRecordService { ...@@ -527,56 +501,59 @@ public class SalesRecordServiceImpl implements SalesRecordService {
/** /**
* 校验是否为空并且为字符类型 * 校验是否为空并且为字符类型
*
* @param cell * @param cell
* @return * @return
*/ */
private boolean validateCellStringValueIsNotNull(Cell cell){ private boolean validateCellStringValueIsNotNull(Cell cell) {
if(cell==null){ if (cell == null) {
return false; return false;
} }
try { try {
RichTextString richStringCellValue = cell.getRichStringCellValue(); RichTextString richStringCellValue = cell.getRichStringCellValue();
return richStringCellValue != null && !StringUtils.isBlank(richStringCellValue.toString()); return richStringCellValue != null && !StringUtils.isBlank(richStringCellValue.toString());
}catch (Exception e){ } catch (Exception e) {
return false; return false;
} }
} }
/** /**
* 校验是否为空并且是数字类 * 校验是否为空并且是数字类
*
* @param cell * @param cell
* @return * @return
*/ */
private boolean validateCellNumberValueIsNotNull(Cell cell){ private boolean validateCellNumberValueIsNotNull(Cell cell) {
if(cell==null){ if (cell == null) {
return false; return false;
} }
try { try {
CellType cellTypeEnum = cell.getCellTypeEnum(); CellType cellTypeEnum = cell.getCellTypeEnum();
return cellTypeEnum.compareTo(CellType.NUMERIC) == 0; return cellTypeEnum.compareTo(CellType.NUMERIC) == 0;
}catch (Exception e){ } catch (Exception e) {
return false; return false;
} }
} }
/** /**
* 校验是否为空并且是时间类型 * 校验是否为空并且是时间类型
*
* @param cell * @param cell
* @return * @return
*/ */
private boolean validateCellDateValueIsNotNull(Cell cell){ private boolean validateCellDateValueIsNotNull(Cell cell) {
if(cell==null){ if (cell == null) {
return false; return false;
} }
try { try {
Date dateCellValue = cell.getDateCellValue(); Date dateCellValue = cell.getDateCellValue();
return dateCellValue !=null; return dateCellValue != null;
}catch (Exception e){ } catch (Exception e) {
return false; return false;
} }
} }
private UUID getUUid(){ private UUID getUUid() {
return UUID.randomUUID(); return UUID.randomUUID();
} }
} }
...@@ -3,6 +3,7 @@ package com.xyst.dinas.sales.service; ...@@ -3,6 +3,7 @@ package com.xyst.dinas.sales.service;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.team.pojo.ResponseObj; import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.xyst.dinas.sales.entity.InventoryLog; import com.xyst.dinas.sales.entity.InventoryLog;
import com.xyst.dinas.sales.entity.StationDinasTypeRelation; import com.xyst.dinas.sales.entity.StationDinasTypeRelation;
...@@ -12,6 +13,9 @@ public interface InventoryService { ...@@ -12,6 +13,9 @@ public interface InventoryService {
public List<StationDinasTypeRelation> getInventoryByRegionalCompany(UUID regionalCompany); public List<StationDinasTypeRelation> getInventoryByRegionalCompany(UUID regionalCompany);
public ResponseObj<String> modifyInventory(String body, boolean isLog, boolean autoCalculate); public ResponseObj<String> modifyInventory(String body, boolean isLog, boolean autoCalculate);
public List<InventoryLog> queryLog(UUID regionalCompany); public List<InventoryLog> queryLog(UUID regionalCompany);
List<StationDinasTypeRelation> getItemListByStationId(UUID stationId);
Object queryWarnSettingById(UUID id); Object queryWarnSettingById(UUID id);
/** /**
...@@ -22,4 +26,8 @@ public interface InventoryService { ...@@ -22,4 +26,8 @@ public interface InventoryService {
* @return * @return
*/ */
public Double getStockAmountByDinas(UUID stationId,String dinasTypeName); public Double getStockAmountByDinas(UUID stationId,String dinasTypeName);
KObject getItemByStationIdAndDinasTypeId(UUID id, UUID dinasTypeId);
} }
...@@ -30,4 +30,6 @@ public interface NeedPlanService { ...@@ -30,4 +30,6 @@ public interface NeedPlanService {
Object queryNeedPlanAmountByCycleId(UUID fromString, UUID fromString2); Object queryNeedPlanAmountByCycleId(UUID fromString, UUID fromString2);
KObject querySalePlanByCycleId(UUID fromString); KObject querySalePlanByCycleId(UUID fromString);
List<KObject> queryNeedPlanByCarNumAndPlanningCycle(KObject station, String carNum, Date date);
} }
...@@ -88,4 +88,6 @@ public interface SalesPlanService { ...@@ -88,4 +88,6 @@ public interface SalesPlanService {
List<KObject> getProjectByNowPlanningCycle(UUID purchaseSandUnitId, UUID planningCycleId); List<KObject> getProjectByNowPlanningCycle(UUID purchaseSandUnitId, UUID planningCycleId);
List<KObject> getSealTempDinasTypeListByNeedPlanInfo(UUID purchaseSandUnitId, UUID planningCycleId, UUID projectId); List<KObject> getSealTempDinasTypeListByNeedPlanInfo(UUID purchaseSandUnitId, UUID planningCycleId, UUID projectId);
List<Map<String, Object>> querySalesPlanByCarNum(KObject station, String carNum);
} }
...@@ -3,6 +3,7 @@ package com.xyst.dinas.sales.service; ...@@ -3,6 +3,7 @@ package com.xyst.dinas.sales.service;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import com.beecode.bcp.type.KObject;
import com.xyst.dinas.sales.web.info.SalesRecordInfo; import com.xyst.dinas.sales.web.info.SalesRecordInfo;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -12,9 +13,10 @@ public interface SalesRecordService { ...@@ -12,9 +13,10 @@ public interface SalesRecordService {
* 通过销售台账List对台账进行存储 * 通过销售台账List对台账进行存储
* 主要用于外部接口调用 * 主要用于外部接口调用
* @param salesRecordList 销售台账List * @param salesRecordList 销售台账List
* @param station
* @return 返回存储状态 failure/失败 success/成功 * @return 返回存储状态 failure/失败 success/成功
*/ */
String saveSalesRecordService(List<SalesRecordInfo> salesRecordList); String saveSalesRecordService(List<SalesRecordInfo> salesRecordList, KObject station);
HashMap<String,Object> qualityReportExcelImport(MultipartFile file); HashMap<String,Object> qualityReportExcelImport(MultipartFile file);
} }
...@@ -19,21 +19,6 @@ public class SalesRecordController { ...@@ -19,21 +19,6 @@ public class SalesRecordController {
@Autowired @Autowired
SalesRecordService salesRecordService; SalesRecordService salesRecordService;
/**
* 通过List传递 销售台账数据,进行存储
*
* @param salesRecordList 销售台账队列
* @return
*/
@PostMapping(value = "/salesRecord/save", consumes = "application/json")
public Object saveSalesRecord(@RequestBody List<SalesRecordInfo> salesRecordList) {
if (salesRecordList.isEmpty()) {
return ResponseObj.error("传递的销售台账数据条数为0!请确认!");
} else {
return salesRecordService.saveSalesRecordService(salesRecordList);
}
}
/** /**
* create by: 导入销售记录,没有的数据全部新建 * create by: 导入销售记录,没有的数据全部新建
......
package com.xyst.dinas.sales.web.info; package com.xyst.dinas.sales.web.info;
import java.util.Date;
public class SalesRecordInfo { public class SalesRecordInfo {
/** /**
* 修改时间 * 修改时间
*/ */
private String modifyTime; private String modifyTime;
/** /**
* 项目 * 项目
*/ */
...@@ -27,13 +30,13 @@ public class SalesRecordInfo { ...@@ -27,13 +30,13 @@ public class SalesRecordInfo {
*/ */
private String station; private String station;
/** /**
* 生产线 * 散户名称
*/ */
private String productionLine; private String retailName;
/** /**
* 散户 * 散户身份证号
*/ */
private String retailInfo; private String retailIdNum;
/** /**
* 砂石种类 * 砂石种类
*/ */
...@@ -45,12 +48,62 @@ public class SalesRecordInfo { ...@@ -45,12 +48,62 @@ public class SalesRecordInfo {
/** /**
* 销售时间 * 销售时间
*/ */
private String dealTime; private Date dealTime;
/** /**
* 车辆信息 * 车辆信息
*/ */
private String carInfo; private String carInfo;
/**
* 毛重时间
*/
private Date grossWeightTime;
/**
* 皮重时间
*/
private Date tareWeightTime;
/**
* 皮重
*/
private String tareWeight;
/**
* 毛重
*/
private String grossWeight;
/**
* 毛重司磅员
*/
private String grossWeightPerson;
/**
* 皮重司磅员
*/
private String tareWeightPerson;
/**
* 计划周期
*/
private String planningCycle;
/**
* 需用计划id
*/
private String needPlan;
/**
* 销售计划id
*/
private String salePlan;
/**
* 临时销售计划id
*/
private String salePlanTemp;
/** /**
* 销售数量 * 销售数量
*/ */
...@@ -72,6 +125,25 @@ public class SalesRecordInfo { ...@@ -72,6 +125,25 @@ public class SalesRecordInfo {
*/ */
private String dealBillCode; private String dealBillCode;
/**
* 配送方式 0自提(运输公司自己拿) 1配送(砂石公司指派车辆) 2散客(没有车牌号,不知何处来. 不知何处去)
*/
private Integer transportType;
/**
* 销售类型 0临时销售计划(突发情况) 1销售计划(正常计划,上周分配下周工作) 2.散客(卖点边边角角?)
*/
private Integer saleType;
public String getGrossWeight() {
return grossWeight;
}
public void setGrossWeight(String grossWeight) {
this.grossWeight = grossWeight;
}
public String getModifyTime() { public String getModifyTime() {
return modifyTime; return modifyTime;
} }
...@@ -120,20 +192,20 @@ public class SalesRecordInfo { ...@@ -120,20 +192,20 @@ public class SalesRecordInfo {
this.station = station; this.station = station;
} }
public String getProductionLine() { public String getRetailName() {
return productionLine; return retailName;
} }
public void setProductionLine(String productionLine) { public void setRetailName(String retailName) {
this.productionLine = productionLine; this.retailName = retailName;
} }
public String getRetailInfo() { public String getRetailIdNum() {
return retailInfo; return retailIdNum;
} }
public void setRetailInfo(String retailInfo) { public void setRetailIdNum(String retailIdNum) {
this.retailInfo = retailInfo; this.retailIdNum = retailIdNum;
} }
public String getDinasType() { public String getDinasType() {
...@@ -152,13 +224,6 @@ public class SalesRecordInfo { ...@@ -152,13 +224,6 @@ public class SalesRecordInfo {
this.customerType = customerType; this.customerType = customerType;
} }
public String getDealTime() {
return dealTime;
}
public void setDealTime(String dealTime) {
this.dealTime = dealTime;
}
public String getCarInfo() { public String getCarInfo() {
return carInfo; return carInfo;
...@@ -208,4 +273,100 @@ public class SalesRecordInfo { ...@@ -208,4 +273,100 @@ public class SalesRecordInfo {
this.dealBillCode = dealBillCode; this.dealBillCode = dealBillCode;
} }
public String getTareWeight() {
return tareWeight;
}
public void setTareWeight(String tareWeight) {
this.tareWeight = tareWeight;
}
public String getGrossWeightPerson() {
return grossWeightPerson;
}
public void setGrossWeightPerson(String grossWeightPerson) {
this.grossWeightPerson = grossWeightPerson;
}
public String getTareWeightPerson() {
return tareWeightPerson;
}
public void setTareWeightPerson(String tareWeightPerson) {
this.tareWeightPerson = tareWeightPerson;
}
public String getPlanningCycle() {
return planningCycle;
}
public void setPlanningCycle(String planningCycle) {
this.planningCycle = planningCycle;
}
public String getNeedPlan() {
return needPlan;
}
public void setNeedPlan(String needPlan) {
this.needPlan = needPlan;
}
public String getSalePlan() {
return salePlan;
}
public void setSalePlan(String salePlan) {
this.salePlan = salePlan;
}
public String getSalePlanTemp() {
return salePlanTemp;
}
public void setSalePlanTemp(String salePlanTemp) {
this.salePlanTemp = salePlanTemp;
}
public Integer getTransportType() {
return transportType;
}
public void setTransportType(Integer transportType) {
this.transportType = transportType;
}
public Integer getSaleType() {
return saleType;
}
public void setSaleType(Integer saleType) {
this.saleType = saleType;
}
public Date getDealTime() {
return dealTime;
}
public void setDealTime(Date dealTime) {
this.dealTime = dealTime;
}
public Date getGrossWeightTime() {
return grossWeightTime;
}
public void setGrossWeightTime(Date grossWeightTime) {
this.grossWeightTime = grossWeightTime;
}
public Date getTareWeightTime() {
return tareWeightTime;
}
public void setTareWeightTime(Date tareWeightTime) {
this.tareWeightTime = tareWeightTime;
}
} }
...@@ -52,6 +52,12 @@ ...@@ -52,6 +52,12 @@
<attribute id='9ed97388-563a-4634-a555-b56bb1664dd0' name='customerType' columnName='customer_type' title='客户类型' type='string' default='' precision='' isArray='false'> <attribute id='9ed97388-563a-4634-a555-b56bb1664dd0' name='customerType' columnName='customer_type' title='客户类型' type='string' default='' precision='' isArray='false'>
<annotation id='9f44e7df-2ecb-490d-a420-2f53f09e3c38' attributeId='fe172826-06ad-4e73-9a8c-5dbab39d0394' name='length' value='20'></annotation> <annotation id='9f44e7df-2ecb-490d-a420-2f53f09e3c38' attributeId='fe172826-06ad-4e73-9a8c-5dbab39d0394' name='length' value='20'></annotation>
</attribute> </attribute>
<attribute id='33dda8c2-be30-4edd-acda-a250eea496be' name='grossWeightTime' columnName='gross_weight_time' title='毛重时间' type='datetime' default='' precision='' isArray='false'>
<annotation id='25ad8d73-11be-4198-8ce7-6de67049f642' attributeId='e58aed21-0e20-40d7-bcd6-3804eea2bf35' name='length' value='50'></annotation>
</attribute>
<attribute id='ecfdaf26-7e34-4753-9dfb-f5e0a9789ef2' name='tareWeightTime' columnName='tare_weight_time' title='皮重时间' type='datetime' default='' precision='' isArray='false'>
<annotation id='832abd8c-84bb-4247-888c-ffe608196db5' attributeId='86c500bb-811d-4329-ab72-2d0312899ee2' name='length' value='50'></annotation>
</attribute>
<attribute id='46656ba1-31bc-4b40-a63d-4a2a4b9f7944' name='dealTime' columnName='deal_time' title='销售时间' type='datetime' default='' precision='' isArray='false'> <attribute id='46656ba1-31bc-4b40-a63d-4a2a4b9f7944' name='dealTime' columnName='deal_time' title='销售时间' type='datetime' default='' precision='' isArray='false'>
<annotation id='18fc1ef9-5b5c-4000-a2d9-7a5d3e5a2fd5' attributeId='b6d2026b-a671-4054-86f2-cce248a72464' name='length' value='50'></annotation> <annotation id='18fc1ef9-5b5c-4000-a2d9-7a5d3e5a2fd5' attributeId='b6d2026b-a671-4054-86f2-cce248a72464' name='length' value='50'></annotation>
</attribute> </attribute>
...@@ -66,6 +72,20 @@ ...@@ -66,6 +72,20 @@
<annotation id='c342cc44-eabb-4f24-8872-b3cd6085b269' attributeId='1faca45c-ea26-47cc-a2ef-ae00daf88586' name='precision' value='12'></annotation> <annotation id='c342cc44-eabb-4f24-8872-b3cd6085b269' attributeId='1faca45c-ea26-47cc-a2ef-ae00daf88586' name='precision' value='12'></annotation>
<annotation id='ae5380d7-75c6-44ff-862f-c9d6c3af409d' attributeId='88762e9e-7c48-40e0-aac1-abcf20e9071a' name='scale' value='4'></annotation> <annotation id='ae5380d7-75c6-44ff-862f-c9d6c3af409d' attributeId='88762e9e-7c48-40e0-aac1-abcf20e9071a' name='scale' value='4'></annotation>
</attribute> </attribute>
<attribute id='deccf7b5-4378-4573-b927-5fd413a22f11' name='saleType' columnName='sale_type' title='销售类型' type='int' default='' precision='' isArray='false'>
<annotation id='da39a35a-ed92-40e4-8722-c19fb4b90e0e' attributeId='b141e95e-fcf8-412d-a439-7ba8197c9cad' name='length' value='undefined'>
</annotation>
</attribute>
<attribute id='1d5e96fc-1a8a-4de5-956b-1f26ca610edb' name='transportType' columnName='transport_type' title='运输类型' type='int' default='' precision='' isArray='false'>
<annotation id='27dca184-5deb-4b6a-a779-ee7e5a6b86e0' attributeId='56a58524-5fc2-42b6-bb77-81d11bad00a9' name='length' value='undefined'>
</annotation>
</attribute>
<attribute id='6da43868-9ade-4c8c-8184-4e4f2a585455' name='grossWeightPerson' columnName='gross_weight_person' title='毛重司磅员' type='string' default='' precision='' isArray='false'>
<annotation id='df61be64-a793-48ad-8764-733862575107' attributeId='1bb51ae4-5a99-4afa-b439-dc99289924d2' name='length' value='20'></annotation>
</attribute>
<attribute id='9669004f-a72e-43df-94e7-401bde16bb11' name='tareWeightPerson' columnName='tare_weight_person' title='皮重司磅员' type='string' default='' precision='' isArray='false'>
<annotation id='57941f0d-a850-49c3-9a35-a0762e89d73e' attributeId='be1a801f-3542-4982-9aee-7eb6a4975d0f' name='length' value='20'></annotation>
</attribute>
<attribute id='c4a69b63-8456-4e68-a7d3-b775bf2709c3' name='grossWeight' columnName='gross_weight' title='毛重' type='fixnum' default='' precision='' isArray='false'> <attribute id='c4a69b63-8456-4e68-a7d3-b775bf2709c3' name='grossWeight' columnName='gross_weight' title='毛重' type='fixnum' default='' precision='' isArray='false'>
<annotation id='39f8e296-529b-4dfc-8d22-9a553d3a667f' attributeId='c484caff-a78f-415c-a00d-80aa30cea477' name='length' value='100'></annotation> <annotation id='39f8e296-529b-4dfc-8d22-9a553d3a667f' attributeId='c484caff-a78f-415c-a00d-80aa30cea477' name='length' value='100'></annotation>
<annotation id='a30c74ee-a692-4975-a98e-37b81061b580' attributeId='39eea597-3d56-4309-82c4-9017051c19bd' name='precision' value='12'></annotation> <annotation id='a30c74ee-a692-4975-a98e-37b81061b580' attributeId='39eea597-3d56-4309-82c4-9017051c19bd' name='precision' value='12'></annotation>
......
...@@ -41,4 +41,6 @@ public class PaymentDetailsController { ...@@ -41,4 +41,6 @@ public class PaymentDetailsController {
return ResponseObj.error("查询回款明细操作后台失败!详情请查看日志", e.getMessage()); return ResponseObj.error("查询回款明细操作后台失败!详情请查看日志", e.getMessage());
} }
} }
} }
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
LEFT JOIN Station AS station on station.id = salesRecord.station LEFT JOIN Station AS station on station.id = salesRecord.station
LEFT JOIN DinasType AS dinasType ON salesRecord.dinasType = dinasType.id LEFT JOIN DinasType AS dinasType ON salesRecord.dinasType = dinasType.id
WHERE 1=1 WHERE 1=1
AND salesRecord.syncTime &gt;= :?startDate AND salesRecord.dealTime &gt;= :?startDate
AND salesRecord.syncTime &lt;= :?endDate AND salesRecord.dealTime &lt;= :?endDate
ORDER BY salesRecord.syncTime ORDER BY salesRecord.dealTime
LIMIT :?limitNum LIMIT :?limitNum
</sql> </sql>
</template> </template>
......
...@@ -7,6 +7,7 @@ import com.xyst.dinas.transport.service.VehicleDispatchService; ...@@ -7,6 +7,7 @@ import com.xyst.dinas.transport.service.VehicleDispatchService;
import com.xyst.dinas.transport.task.VehicleDispatchStatusTask; import com.xyst.dinas.transport.task.VehicleDispatchStatusTask;
import com.xyst.dinas.transport.task.VehicleDispatchStatusTaskRegister; import com.xyst.dinas.transport.task.VehicleDispatchStatusTaskRegister;
import com.xyst.dinas.transport.web.VehicleDispatchController; import com.xyst.dinas.transport.web.VehicleDispatchController;
import com.xyst.dinas.transport.web.WeighbridgeSyncController;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
public class VehicleDispatchConfiguration { public class VehicleDispatchConfiguration {
...@@ -33,4 +34,9 @@ public class VehicleDispatchConfiguration { ...@@ -33,4 +34,9 @@ public class VehicleDispatchConfiguration {
public VehicleDispatchStatusTaskRegister vehicleDispatchStatusTaskRegister() { public VehicleDispatchStatusTaskRegister vehicleDispatchStatusTaskRegister() {
return new VehicleDispatchStatusTaskRegister(); return new VehicleDispatchStatusTaskRegister();
} }
@Bean
public WeighbridgeSyncController weighbridgeSyncController() {
return new WeighbridgeSyncController();
}
} }
...@@ -5,6 +5,7 @@ import com.beecode.bcp.type.KObject; ...@@ -5,6 +5,7 @@ import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.dao.BaseDao; import com.beecode.inz.basis.dao.BaseDao;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.UUID; import java.util.UUID;
public interface VehicleDispatchDao extends BaseDao { public interface VehicleDispatchDao extends BaseDao {
...@@ -18,4 +19,5 @@ public interface VehicleDispatchDao extends BaseDao { ...@@ -18,4 +19,5 @@ public interface VehicleDispatchDao extends BaseDao {
void updateStatusToStart(); void updateStatusToStart();
List<KObject> findByDriver(KObject vehicle, KObject station);
} }
...@@ -37,8 +37,6 @@ public class VehicleDispatchDaoImpl extends AbstractBaseDao implements VehicleDi ...@@ -37,8 +37,6 @@ public class VehicleDispatchDaoImpl extends AbstractBaseDao implements VehicleDi
@Autowired @Autowired
private VehicleDriverUserDao vehicleDriverUserDao; private VehicleDriverUserDao vehicleDriverUserDao;
@Autowired
private DriverUserDao driverUserDao;
/** /**
...@@ -101,14 +99,14 @@ public class VehicleDispatchDaoImpl extends AbstractBaseDao implements VehicleDi ...@@ -101,14 +99,14 @@ public class VehicleDispatchDaoImpl extends AbstractBaseDao implements VehicleDi
collect = new ArrayList<>(); collect = new ArrayList<>();
collect.add(vehicleId); collect.add(vehicleId);
} }
if(collect.isEmpty()){ if (collect.isEmpty()) {
return null; return null;
} }
Page<KObject> kObjectPage = new Page<>(); Page<KObject> kObjectPage = new Page<>();
KClass bean = Amino.getStaticMetadataContext().getBean(ENTITY, KClass.class); KClass bean = Amino.getStaticMetadataContext().getBean(ENTITY, KClass.class);
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName()); DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName());
detachedCriteria.add(Restrictions.eq(BaseConstants.DEL, false)); detachedCriteria.add(Restrictions.eq(BaseConstants.DEL, false));
if(status!=null){ if (status != null) {
detachedCriteria.add(Restrictions.eq("dispatchStatus", status)); detachedCriteria.add(Restrictions.eq("dispatchStatus", status));
} }
detachedCriteria.createAlias(PLANNING_CYCLE, PLANNING_CYCLE); detachedCriteria.createAlias(PLANNING_CYCLE, PLANNING_CYCLE);
...@@ -140,9 +138,9 @@ public class VehicleDispatchDaoImpl extends AbstractBaseDao implements VehicleDi ...@@ -140,9 +138,9 @@ public class VehicleDispatchDaoImpl extends AbstractBaseDao implements VehicleDi
{ {
Query<UUID> query1 = session.createQuery("select a.id from " + ENTITY + " as a inner join a." + PLANNING_CYCLE + " as p on a.planningCycle=p.id " + Query<UUID> query1 = session.createQuery("select a.id from " + ENTITY + " as a inner join a." + PLANNING_CYCLE + " as p on a.planningCycle=p.id " +
"where p." + PLANNING_CYCLE_START_TIME + " <= current_timestamp() " + "where p." + PLANNING_CYCLE_START_TIME + " <= current_timestamp() " +
" and a.dispatchStatus =" + PriceAdjustmentAdjustmentStatusEnum.NOT_STARTED.getValue(),UUID.class); " and a.dispatchStatus =" + PriceAdjustmentAdjustmentStatusEnum.NOT_STARTED.getValue(), UUID.class);
Optional<List<UUID>> optional = Optional.ofNullable(query1.getResultList()); Optional<List<UUID>> optional = Optional.ofNullable(query1.getResultList());
if (optional.isPresent()&&optional.get().size()>0) { if (optional.isPresent() && optional.get().size() > 0) {
Query query = session.createQuery("update " + ENTITY + " as b SET b.dispatchStatus = 1 where b.id in ( :ids)"); Query query = session.createQuery("update " + ENTITY + " as b SET b.dispatchStatus = 1 where b.id in ( :ids)");
query.setParameter("ids", optional.get()); query.setParameter("ids", optional.get());
return query.executeUpdate(); return query.executeUpdate();
...@@ -152,7 +150,19 @@ public class VehicleDispatchDaoImpl extends AbstractBaseDao implements VehicleDi ...@@ -152,7 +150,19 @@ public class VehicleDispatchDaoImpl extends AbstractBaseDao implements VehicleDi
); );
} }
@Override
public List<KObject> findByDriver(KObject vehicle, KObject station) {
KClass bean = Amino.getStaticMetadataContext().getBean(ENTITY, KClass.class);
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName());
detachedCriteria.add(Restrictions.eq(BaseConstants.DEL, false));
detachedCriteria.add(Restrictions.eq("dispatchStatus", PriceAdjustmentAdjustmentStatusEnum.PROCESSING.getValue()));
detachedCriteria.createAlias(PLANNING_CYCLE, PLANNING_CYCLE);
detachedCriteria.add(Restrictions.eq("transportVehicle.id", vehicle.getUuid("id")));
detachedCriteria.add(Restrictions.ge(PLANNING_CYCLE + ".endTime", new Date()));
detachedCriteria.add(Restrictions.le(PLANNING_CYCLE + ".startTime", new Date()));
detachedCriteria.addOrder(Order.desc(PLANNING_CYCLE + ".startTime"));
return (List<KObject>)template.findByCriteria(detachedCriteria);
}
} }
...@@ -8,15 +8,18 @@ import com.xyst.dinas.biz.dao.DinasTypeDao; ...@@ -8,15 +8,18 @@ import com.xyst.dinas.biz.dao.DinasTypeDao;
import com.xyst.dinas.price.enumeration.PriceAdjustmentAdjustmentStatusEnum; import com.xyst.dinas.price.enumeration.PriceAdjustmentAdjustmentStatusEnum;
import com.xyst.dinas.sales.constant.SalesPlanConstant; import com.xyst.dinas.sales.constant.SalesPlanConstant;
import com.xyst.dinas.sales.constant.SalesRecordConstant; import com.xyst.dinas.sales.constant.SalesRecordConstant;
import com.xyst.dinas.sales.dao.InventoryDao;
import com.xyst.dinas.transport.constant.VehicleDriverUserConstant; import com.xyst.dinas.transport.constant.VehicleDriverUserConstant;
import com.xyst.dinas.transport.constant.VehicleDispatchConstant; import com.xyst.dinas.transport.constant.VehicleDispatchConstant;
import com.xyst.dinas.transport.dao.VehicleDispatchDao; import com.xyst.dinas.transport.dao.VehicleDispatchDao;
import com.xyst.dinas.transport.dao.VehicleDriverUserDao;
import com.xyst.dinas.transport.enumeration.DispatchTypeEnum; import com.xyst.dinas.transport.enumeration.DispatchTypeEnum;
import com.xyst.dinas.transport.service.VehicleDispatchService; import com.xyst.dinas.transport.service.VehicleDispatchService;
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 javax.transaction.Transactional; import javax.transaction.Transactional;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
/** /**
...@@ -35,6 +38,10 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService { ...@@ -35,6 +38,10 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
@Autowired @Autowired
private DriverUserDao driverUserDao; private DriverUserDao driverUserDao;
@Autowired
private VehicleDriverUserDao vehicleDriverUserDao;
@Autowired
private InventoryDao inventoryDao;
@Override @Override
public UUID create(KObject kobject) { public UUID create(KObject kobject) {
...@@ -68,9 +75,9 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService { ...@@ -68,9 +75,9 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
KObject planningCycle; KObject planningCycle;
if (dispatchType == DispatchTypeEnum.NEED_PLAN.getValue()) { if (dispatchType == DispatchTypeEnum.NEED_PLAN.getValue()) {
load = vehicleDispatchDao.load(SalesPlanConstant.ENTITY_DETAIL, sealDetailId); load = vehicleDispatchDao.load(SalesPlanConstant.ENTITY_DETAIL, sealDetailId);
planningCycle= load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.PLANNING_CYCLE); planningCycle = load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.PLANNING_CYCLE);
kobject.set(VehicleDispatchConstant.PURCHASE_SAND_UNIT, load.get(VehicleDispatchConstant.PURCHASE_SAND_UNIT)); kobject.set(VehicleDispatchConstant.PURCHASE_SAND_UNIT, load.get(VehicleDispatchConstant.PURCHASE_SAND_UNIT));
kobject.set(VehicleDispatchConstant.PLANNING_CYCLE,planningCycle ); kobject.set(VehicleDispatchConstant.PLANNING_CYCLE, planningCycle);
kobject.set(VehicleDispatchConstant.PROJECT, load.get(VehicleDispatchConstant.PROJECT)); kobject.set(VehicleDispatchConstant.PROJECT, load.get(VehicleDispatchConstant.PROJECT));
kobject.set(VehicleDispatchConstant.CONTRACT, load.get(VehicleDispatchConstant.CONTRACT)); kobject.set(VehicleDispatchConstant.CONTRACT, load.get(VehicleDispatchConstant.CONTRACT));
kobject.set(VehicleDispatchConstant.DINAS_TYPE, load.get(VehicleDispatchConstant.DINAS_TYPE)); kobject.set(VehicleDispatchConstant.DINAS_TYPE, load.get(VehicleDispatchConstant.DINAS_TYPE));
...@@ -79,18 +86,18 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService { ...@@ -79,18 +86,18 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
} else { } else {
load = vehicleDispatchDao.load(SalesPlanConstant.ENTITY_TEMP_DETAIL, sealDetailId); load = vehicleDispatchDao.load(SalesPlanConstant.ENTITY_TEMP_DETAIL, sealDetailId);
planningCycle=load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.PLANNING_CYCLE); planningCycle = load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.PLANNING_CYCLE);
kobject.set(VehicleDispatchConstant.PURCHASE_SAND_UNIT, load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.CONTRACT).get(VehicleDispatchConstant.PURCHASE_SAND_UNIT)); kobject.set(VehicleDispatchConstant.PURCHASE_SAND_UNIT, load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.CONTRACT).get(VehicleDispatchConstant.PURCHASE_SAND_UNIT));
kobject.set(VehicleDispatchConstant.PLANNING_CYCLE,planningCycle ); kobject.set(VehicleDispatchConstant.PLANNING_CYCLE, planningCycle);
kobject.set(VehicleDispatchConstant.PROJECT, load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.PROJECT)); kobject.set(VehicleDispatchConstant.PROJECT, load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.PROJECT));
kobject.set(VehicleDispatchConstant.CONTRACT, load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.CONTRACT)); kobject.set(VehicleDispatchConstant.CONTRACT, load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.CONTRACT));
kobject.set(VehicleDispatchConstant.DINAS_TYPE, load.get(VehicleDispatchConstant.DINAS_TYPE)); kobject.set(VehicleDispatchConstant.DINAS_TYPE, load.get(VehicleDispatchConstant.DINAS_TYPE));
kobject.set(VehicleDispatchConstant.STATION, load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.STATION)); kobject.set(VehicleDispatchConstant.STATION, load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.STATION));
kobject.set(VehicleDispatchConstant.PLAN_AMOUNT, load.getBigDecimal("salesPlanAmount")); kobject.set(VehicleDispatchConstant.PLAN_AMOUNT, load.getBigDecimal("salesPlanAmount"));
} }
kobject.set("dispatchStatus",PriceAdjustmentAdjustmentStatusEnum.NOT_STARTED.getValue()); kobject.set("dispatchStatus", PriceAdjustmentAdjustmentStatusEnum.NOT_STARTED.getValue());
if(planningCycle.getDate(VehicleDispatchConstant.PLANNING_CYCLE_START_TIME).before(new Date())){ if (planningCycle.getDate(VehicleDispatchConstant.PLANNING_CYCLE_START_TIME).before(new Date())) {
kobject.set("dispatchStatus",PriceAdjustmentAdjustmentStatusEnum.PROCESSING.getValue()); kobject.set("dispatchStatus", PriceAdjustmentAdjustmentStatusEnum.PROCESSING.getValue());
} }
kobject.set("transportVehicle", vehicleDispatchDao.load(VehicleDriverUserConstant.TRANSPORT_VEHICLE_ENTITY, kobject.get("transportVehicle").getUuid("id"))); kobject.set("transportVehicle", vehicleDispatchDao.load(VehicleDriverUserConstant.TRANSPORT_VEHICLE_ENTITY, kobject.get("transportVehicle").getUuid("id")));
kobject.set("transportCompany", vehicleDispatchDao.load(VehicleDriverUserConstant.TRANSPORT_COMPANY_ENTITY, kobject.get("transportCompany").getUuid("id"))); kobject.set("transportCompany", vehicleDispatchDao.load(VehicleDriverUserConstant.TRANSPORT_COMPANY_ENTITY, kobject.get("transportCompany").getUuid("id")));
...@@ -130,7 +137,7 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService { ...@@ -130,7 +137,7 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
@Override @Override
public void endVehicleDispatchById(UUID id) { public void endVehicleDispatchById(UUID id) {
vehicleDispatchDao.setAttribute(id,"dispatchStatus", PriceAdjustmentAdjustmentStatusEnum.OVER.getValue()); vehicleDispatchDao.setAttribute(id, "dispatchStatus", PriceAdjustmentAdjustmentStatusEnum.OVER.getValue());
} }
@Override @Override
...@@ -141,12 +148,88 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService { ...@@ -141,12 +148,88 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
@Override @Override
public void confirmTransportRecord(Map map) { public void confirmTransportRecord(Map map) {
KObject load = vehicleDispatchDao.load(SalesRecordConstant.TRANSPORT_RECORD_ENTITY, map.get("id").toString()); KObject load = vehicleDispatchDao.load(SalesRecordConstant.TRANSPORT_RECORD_ENTITY, map.get("id").toString());
load.set("confirmStatus",1); load.set("confirmStatus", 1);
load.set("confirmTime",new Date()); load.set("confirmTime", new Date());
load.set("driverUser", driverUserDao.findById(DriverUserContextHolder.getContext().getDriverUser().getId())); load.set("driverUser", driverUserDao.findById(DriverUserContextHolder.getContext().getDriverUser().getId()));
load.set("receiverName", map.get("receiverName").toString()); load.set("receiverName", map.get("receiverName").toString());
load.set("memo", map.get("memo").toString()); load.set("memo", map.get("memo").toString());
load.set("contactNumber", map.get("contactNumber").toString()); load.set("contactNumber", map.get("contactNumber").toString());
vehicleDispatchDao.update(load); vehicleDispatchDao.update(load);
} }
/**
* 根据车牌号获取配送单
*
* @param station
* @param carNum
* @return
*/
@Override
public Collection<? extends Map<String, Object>> vehicleDispatchService(KObject station, String carNum) {
UUID companyId = station.get("regionalCompany").getUuid("id");
KObject vehicle = vehicleDriverUserDao.selectVehicleByPlateNumber(carNum, companyId);
if(vehicle==null||vehicle.isNull()||vehicle.isEmpty()){
return null;
}
List<KObject> dispatchs = vehicleDispatchDao.findByDriver(vehicle, station);
List<Map<String, Object>> maps = new ArrayList<>();
for (KObject dispatch : dispatchs) {
KObject planningCycle = dispatch.get("planningCycle");
KObject project = dispatch.get("project");
KObject dinasType = dispatch.get("dinasType");
KObject contract = dispatch.get("contract");
Map<String, Object> stringObjectHashMap = new HashMap<String, Object>();
//车牌号
stringObjectHashMap.put("carNum", carNum);
//计划周期
stringObjectHashMap.put("planningCycleTitle", planningCycle.getString("title"));
//计划id
stringObjectHashMap.put("planningCycleId", planningCycle.getUuid("id"));
//项目名称
stringObjectHashMap.put("projectName", project.getString("projectName"));
//项目编码
stringObjectHashMap.put("projectCode", project.getString("projectNum"));
//项目id
stringObjectHashMap.put("projectId", project.getUuid("id"));
//项目id
stringObjectHashMap.put("contractId", contract.getUuid("id"));
//砂石类型名称
stringObjectHashMap.put("dinasTypeName", dinasType.getString("dinasTypeName"));
//砂石类型id
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"));
//获取砂石今日库存
//库存id
KObject inventory = inventoryDao.getItemByStationIdAndDinasTypeId(station.getUuid("id"), dinasType.getUuid("id"));
UUID id = inventory.getUuid("id");
stringObjectHashMap.put("inventoryId", id);
//库存量(吨)
BigDecimal amount = inventory.getBigDecimal("amount");
stringObjectHashMap.put("inventoryAmount", amount);
//单价
BigDecimal price = inventory.getBigDecimal("price");
stringObjectHashMap.put("price", price);
//销售类型
stringObjectHashMap.put("planAmount", dispatch.getBigDecimal("planAmount"));
stringObjectHashMap.put("saleType", dispatch.getInt("dispatchType"));
//运输类型
stringObjectHashMap.put("transportType", 1);
if(amount.compareTo(new BigDecimal("0"))<1){
stringObjectHashMap.put("canSale", false);
stringObjectHashMap.put("canSaleTitle", "今日已售罄");
}
maps.add(stringObjectHashMap);
}
return maps;
}
} }
...@@ -2,6 +2,7 @@ package com.xyst.dinas.transport.service; ...@@ -2,6 +2,7 @@ package com.xyst.dinas.transport.service;
import com.beecode.bcp.type.KObject; import com.beecode.bcp.type.KObject;
import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
...@@ -20,4 +21,7 @@ public interface VehicleDispatchService { ...@@ -20,4 +21,7 @@ public interface VehicleDispatchService {
void confirmTransportRecord(Map id); void confirmTransportRecord(Map id);
Collection<? extends Map<String, Object>> vehicleDispatchService(KObject station, String carNum);
} }
package com.xyst.dinas.transport.web;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.xyst.dinas.biz.service.StationService;
import com.xyst.dinas.sales.entity.StationDinasTypeRelation;
import com.xyst.dinas.sales.service.InventoryService;
import com.xyst.dinas.sales.service.SalesPlanService;
import com.xyst.dinas.sales.service.SalesRecordService;
import com.xyst.dinas.sales.web.info.SalesRecordInfo;
import com.xyst.dinas.transport.service.VehicleDispatchService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@RestController
/**
* 地磅同步接口
* @author scol
*/
public class WeighbridgeSyncController {
@Autowired
private StationService stationService;
@Autowired
private SalesPlanService salesPlanService;
@Autowired
private SalesRecordService salesRecordService;
@Autowired
private VehicleDispatchService vehicleDispatchService;
@Autowired
private InventoryService inventoryService;
/**
* 通过List传递 销售台账数据,进行存储
*
* @param salesRecordList 销售台账队列
* @return
*/
@PostMapping(value = "/weighbridgeSync/saveSalesRecord", consumes = "application/json")
public Object saveSalesRecord(@RequestParam String weighbridgeCode,@RequestBody List<SalesRecordInfo> salesRecordList) {
//根据地磅id查询场站
if(StringUtils.isBlank(weighbridgeCode)){
return ResponseObj.error(500,"地磅唯一编码不能为空");
}
KObject station = stationService.getStationByWeighbridge(weighbridgeCode);
if(station==null){
return ResponseObj.error(500,"没有查询到地磅匹配的场站");
}
if (salesRecordList.isEmpty()) {
return ResponseObj.error("传递的销售台账数据条数为0!请确认!");
} else {
return salesRecordService.saveSalesRecordService(salesRecordList,station);
}
}
/**
* 根据车牌号和地磅唯一编码获取本场站下本车辆今日销售计划和临时销售计划
* @param
* @return
*/
@PostMapping("/weighbridgeSync/getSalePlanDetail")
public Object approveSalesPlan(@RequestParam String weighbridgeCode,@RequestParam String carNum) {
//根据地磅id查询场站
if(StringUtils.isBlank(weighbridgeCode)){
return ResponseObj.error(500,"地磅唯一编码不能为空");
}
KObject station = stationService.getStationByWeighbridge(weighbridgeCode);
if(station==null){
return ResponseObj.error(500,"没有查询到地磅匹配的场站");
}
if(StringUtils.isBlank(carNum)){
return ResponseObj.error(500,"车牌号不能为空");
}
//根据车牌查询所属合同和销售计划
List<Map<String,Object>> salesPlan = salesPlanService.querySalesPlanByCarNum(station,carNum);
Collection<? extends Map<String, Object>> maps = vehicleDispatchService.vehicleDispatchService(station, carNum);
if(maps!=null){
salesPlan.addAll(maps);
}
return ResponseObj.success("查询成功",salesPlan);
}
/**
* 根据车牌号和地磅唯一编码获取本场站下本车辆今日销售计划和临时销售计划
* @param
* @return
*/
@PostMapping("/weighbridgeSync/getDinasTypePrice")
public Object getDinasTypePrice(@RequestParam String weighbridgeCode,@RequestParam String carNum,@RequestParam String dinasTypeId) {
//根据地磅id查询场站
if(StringUtils.isBlank(weighbridgeCode)){
return ResponseObj.error(500,"地磅唯一编码不能为空");
}
KObject station = stationService.getStationByWeighbridge(weighbridgeCode);
if(station==null){
return ResponseObj.error(500,"没有查询到地磅匹配的场站");
}
if(StringUtils.isBlank(carNum)){
return ResponseObj.error(500,"车牌号不能为空");
}
if(StringUtils.isBlank(dinasTypeId)){
return ResponseObj.error(500,"砂石类型不能为空");
}
KObject itemByStationIdAndDinasTypeId = inventoryService.getItemByStationIdAndDinasTypeId(station.getUuid("id"), UUID.fromString("dinasTypeId"));
BigDecimal price = itemByStationIdAndDinasTypeId.getBigDecimal("price");
return ResponseObj.success("查询成功",price);
}
/**
* 根据车牌号和地磅唯一编码获取本场站下本车辆今日销售计划和临时销售计划
* @param
* @return
*/
@PostMapping("/weighbridgeSync/getAllDinasType")
public Object getAllDinasType(@RequestParam String weighbridgeCode) {
//根据地磅id查询场站
if(StringUtils.isBlank(weighbridgeCode)){
return ResponseObj.error(500,"地磅唯一编码不能为空");
}
KObject station = stationService.getStationByWeighbridge(weighbridgeCode);
if(station==null){
return ResponseObj.error(500,"没有查询到地磅匹配的场站");
}
List<StationDinasTypeRelation> allDinasTypes = inventoryService.getItemListByStationId(station.getUuid("id"));
return ResponseObj.success("查询成功",allDinasTypes);
}
}
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