Commit 77729e2c by 高晓磊

同步地磅接口提交

parent 42ead20f
......@@ -499,6 +499,7 @@ public class SecurityConfig {
.antMatchers("/workflow/api/**").permitAll()
.antMatchers("/dnaserver/**").permitAll()
.antMatchers("/dinasBiz/organization/queryOrganizationByUserName").permitAll()
.antMatchers("/weighbridgeSync/**").permitAll()
.anyRequest().authenticated();//listAll,modifySelfPassword,loadAuctionByAsset临时开放
http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint);
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 {
BigDecimal selectBuyAmountByIdCard(String idCard, UUID fromString);
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 {
List<KObject> getStationCameraById(UUID id1);
KObject insertProductionLine(String productionLineName, KObject station);
KObject getStationByWeighbridge(String weighbridgeCode);
}
......@@ -159,6 +159,24 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao,
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() {
StringBuilder s = new StringBuilder();
SecureRandom random = new SecureRandom();
......
......@@ -153,6 +153,7 @@ public class StationDaoImpl extends AbstractBaseDao implements StationDao, Stat
return kObject;
}
@Override
public UUID create(KObject kObject) {
KObject staff = AminoContextHolder.getContext().getStaff();
......@@ -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{
* @param date
* @return
*/
public KObject getPlanningCycleObj(PlanningCycleEnum planningCycleType,Date date) {
@Override
public KObject getPlanningCycleObj(PlanningCycleEnum planningCycleType, Date date) {
return planningCycleDao.getPlanningCycleObj(planningCycleType, date);
}
......
package com.xyst.dinas.biz.internal.service;
import com.beecode.amino.core.Amino;
import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.basis.service.WarehouseUserService;
......@@ -14,8 +16,6 @@ import com.xyst.dinas.biz.service.RetailInfoService;
import com.xyst.dinas.biz.warn.*;
import com.xyst.dinas.biz.warn.service.WarningService;
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.transaction.annotation.Transactional;
......@@ -23,7 +23,6 @@ import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Transactional(rollbackFor = Exception.class)
public class RetailInfoServiceImpl implements RetailInfoService {
......@@ -195,5 +194,24 @@ public class RetailInfoServiceImpl implements RetailInfoService {
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 {
}
@Override
public KObject getStationByWeighbridge(String weighbridgeCode) {
return stationDao.getStationByWeighbridge(weighbridgeCode);
}
}
......@@ -28,4 +28,6 @@ public interface RetailInfoService {
Long selectBuyCountByIdCard(String toString, UUID uuid);
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 {
List<KObject> queryStationByRegionalCompany();
List<KObject> getStationCameraById(UUID id1);
KObject getStationByWeighbridge(String weighbridgeCode);
}
......@@ -165,6 +165,52 @@
<m:properties>
<m:property>
<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:property>
</m:properties>
......
......@@ -50,6 +50,16 @@
<comment>场站名称</comment>
</column>
</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">
<column name="station_address">
<comment>场站地址</comment>
......
......@@ -135,12 +135,14 @@ public class ContractServiceImpl implements ContractService {
contractInfoDao.update(kObject);
}
@Override
public KObject queryContractInfo(UUID id) {
KObject obj = contractInfoDao.load(id);
return obj;
}
@Override
public KObject queryContract(UUID id) {
KObject obj = contractDao.load(id);
......
......@@ -2,73 +2,154 @@ package com.xyst.dinas.sales.constant;
public interface SalesRecordConstant {
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 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_VEHICLE_ENTITY = "com.xyst.dinas.transport.datamodel.TransportVehicle";
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 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_VEHICLE_ENTITY = "com.xyst.dinas.transport.datamodel.TransportVehicle";
//销售台账ID
public static final String ID = "id";
//创建时间
public static final String CREATETIME = "createTime";
//修改时间
public static final String MODIFYTIME = "modifyTime";
//项目
public static final String PROJECT = "project";
//区域公司
public static final String REGIONALCOMPANY = "regionalCompany";
//合同
public static final String CONTRACT = "contract";
//购砂单位
public static final String PURCHASESANDCOMPANY = "purchaseSandCompany";
//场站
public static final String STATION = "station";
//生产线
public static final String PRODUCTIONLINE = "productionLine";
//散户
public static final String RETAILINFO = "retailInfo";
//砂石种类
public static final String DINASTYPE = "dinasType";
//客户类型
public static final String CUSTOMERTYPE = "customerType";
//销售时间
public static final String DEALTIME = "dealTime";
//同步时间
public static final String SYNCTIME = "syncTime";
//车辆信息
public static final String CARINFO = "carInfo";
//销售数量
public static final String DEALAMOUNT = "dealAmount";
//单价
public static final String PRICE = "price";
//总价
public static final String AMOUNT = "amount";
//付款来源
public static final String PAYMENTSOURCE = "paymentSource";
//销售单号
public static final String DEALBILLCODE = "dealBillCode";
//毛重
public static final String GROSS_WEIGHT = "grossWeight";
//皮重
public static final String TARE_WEIGHT = "tareWeight";
/** 审批状态*/
public static final String APPROVE_STATE = "approveState";
/**
* 是否废弃
*/
public static final String DISCARD = "discard";
/**
* 是否删除
*/
public static final String DEL = "del";
/**
* 负责人
*/
public static final String PIC = "pic";
/**
* 销售台账ID
*/
String ID = "id";
/**
* 创建时间
*/
String CREATETIME = "createTime";
/**
* 修改时间
*/
String MODIFYTIME = "modifyTime";
/**
* 项目
*/
String PROJECT = "project";
/**
* 区域公司
*/
String REGIONALCOMPANY = "regionalCompany";
/**
* 合同
*/
String CONTRACT = "contract";
/**
* 购砂单位
*/
String PURCHASESANDCOMPANY = "purchaseSandCompany";
/**
* 场站
*/
String STATION = "station";
/**
* 生产线
*/
String PRODUCTIONLINE = "productionLine";
/**
* 散户
*/
String RETAILINFO = "retailInfo";
/**
* 砂石种类
*/
String DINASTYPE = "dinasType";
/**
* 客户类型
*/
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";
/**
* 是否废弃
*/
String DISCARD = "discard";
/**
* 是否删除
*/
String DEL = "del";
/**
* 负责人
*/
String PIC = "pic";
}
......@@ -14,7 +14,9 @@ public interface InventoryDao {
void save(KObject kobj);
KObject getItemByStationIdAndDinasTypeId(UUID stationId, UUID dinasTypeId);
List<KObject> getItemListByStationId(UUID stationId);
List<KObject> queryLog(List<String> businessObjectId);
/**
......
......@@ -27,4 +27,8 @@ public interface NeedPlanDao {
List<KObject> getProjectByNowPlanningCycle(UUID purchaseSandUnitId, UUID planningCycleId);
KObject queryNeedPlanAmountByCycleId(UUID planningCycleId, UUID projectId);
List<KObject> getByCarAndPlanningCycle(String carNum, KObject planningCycleObj);
}
......@@ -14,7 +14,6 @@ import com.beecode.inz.common.util.DateTimeUtils;
import com.xyst.dinas.biz.dao.DinasTypeDao;
import com.xyst.dinas.sales.enumeration.TransportModeEnum;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.DetachedCriteria;
......@@ -26,7 +25,6 @@ import org.springframework.lang.Nullable;
import org.springframework.orm.hibernate5.HibernateCallback;
import org.springframework.orm.hibernate5.HibernateTemplate;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.common.BaseConstants;
import com.xyst.dinas.sales.constant.SalesPlanConstant;
import com.xyst.dinas.sales.web.request.SaleaPlanDetailQuery;
......@@ -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;
import com.xyst.dinas.sales.constant.InventoryConstant;
import com.xyst.dinas.sales.dao.InventoryDao;
/**
* @author jiaokai
*/
public class InventoryDaoImpl implements InventoryDao {
@Autowired
......@@ -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";
return template.execute(session -> {
......@@ -58,7 +62,9 @@ public class InventoryDaoImpl implements InventoryDao {
query.setParameter("stationId", stationId);
query.setParameter("dinasTypeName", dinasTypeName);
List<KObject> resultList = query.getResultList();
if(resultList.isEmpty()) return 0D;
if(resultList.isEmpty()) {
return 0D;
}
KObject kObject = resultList.get(0);
double stockAmount = kObject.getDouble(InventoryConstant.amount);
return stockAmount;
......@@ -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
public List<KObject> queryLog(List<String> businessObjectId) {
......
......@@ -67,18 +67,15 @@ public class NeedPlanDaoImpl implements NeedPlanDao, NeedPlanConstant {
public List<UUID> queryNeedPlanContratByCycleId(UUID planningCycleId) {
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) ";
return template.execute(new HibernateCallback<List<UUID>>() {
@Override
public List<UUID> doInHibernate(Session session) throws HibernateException {
Query<Tuple> query = session.createNativeQuery(sql, Tuple.class);
query.setParameter("planningCycleId", planningCycleId.toString().replaceAll("-", ""));
List<Tuple> result = query.getResultList();
for (Tuple tuple : result) {
HashMap<String, Object> map = new HashMap<>();
list.add(Convert.toUUID(tuple.get(0)));
}
return list;
return template.execute(session -> {
Query<Tuple> query = session.createNativeQuery(sql, Tuple.class);
query.setParameter("planningCycleId", planningCycleId.toString().replaceAll("-", ""));
List<Tuple> result = query.getResultList();
for (Tuple tuple : result) {
HashMap<String, Object> map = new HashMap<>();
list.add(Convert.toUUID(tuple.get(0)));
}
return list;
});
}
......@@ -148,21 +145,29 @@ public class NeedPlanDaoImpl implements NeedPlanDao, NeedPlanConstant {
@Override
public KObject queryNeedPlanAmountByCycleId(UUID planningCycleId, UUID projectId) {
return (KObject)template.execute(new HibernateCallback<KObject>() {
@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.setParameter("projectId", projectId);
query.setParameter("planningCycleId", planningCycleId);
query.setParameter("submitState", "SUBMITTED");
List<KObject> resultList = query.getResultList();
if(resultList.isEmpty()) {
return null;
} else {
return resultList.get(0);
}
return template.execute(session -> {
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("planningCycleId", planningCycleId);
query.setParameter("submitState", "SUBMITTED");
List<KObject> resultList = query.getResultList();
if(resultList.isEmpty()) {
return null;
} else {
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;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import com.beecode.amino.common.ValueConvertException;
import com.beecode.amino.core.Amino;
import com.beecode.bap.log.service.LogService;
import com.beecode.bap.staff.BapContext;
import com.beecode.bap.staff.service.StaffService;
import com.beecode.bcp.type.AttributeNotFoundException;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.team.pojo.ResponseObj;
......@@ -77,7 +75,7 @@ public class InventoryServiceImpl implements InventoryService {
public List<StationDinasTypeRelation> getInventoryByRegionalCompany(UUID regionalCompany) {
updateInventoryBaseInfo(regionalCompany);
List<KObject> inventory = inventoryDao.listAllByRegionalCompany(regionalCompany, false, false);
List<StationDinasTypeRelation> result = new ArrayList<StationDinasTypeRelation>();
List<StationDinasTypeRelation> result = new ArrayList<>();
for(KObject item : inventory) {
StationDinasTypeRelation r = new StationDinasTypeRelation();
r.setStationId(item.get("station").getUuid("id"));
......@@ -142,10 +140,6 @@ public class InventoryServiceImpl implements InventoryService {
log.set("staffId", bapContext.getCurrentStaff().getUuid("id"));
log.set("deptId", bapContext.getCurrentStaff().get("department").getUuid("id"));
logService.addLog(log);
} catch (AttributeNotFoundException e) {
e.printStackTrace();
} catch (ValueConvertException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
......@@ -267,6 +261,23 @@ public class InventoryServiceImpl implements InventoryService {
}
@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) {
KObject warnSetting = warnSettingDao.queryWarnSettingById(id);
String billId = warnSetting.getString("billId");
......@@ -282,4 +293,11 @@ public class InventoryServiceImpl implements InventoryService {
map.put("billId", warnSetting.getString("billId"));
return map;
}
@Override
public KObject getItemByStationIdAndDinasTypeId(UUID id, UUID dinasTypeId) {
return inventoryDao.getItemByStationIdAndDinasTypeId(id, dinasTypeId);
}
}
......@@ -9,6 +9,7 @@ import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import com.xyst.dinas.biz.enumeration.PlanningCycleEnum;
import org.springframework.beans.factory.annotation.Autowired;
import com.beecode.bcp.type.KObject;
......@@ -123,25 +124,21 @@ public class NeedPlanServiceImpl implements NeedPlanService {
public Object queryNeedPlanAmountByCycleId(UUID planningCycleId, UUID projectId) {
KObject needPlanKObject = needPlanDao.queryNeedPlanAmountByCycleId(planningCycleId, projectId);
KObject salesPlanKObject = salesPlanDao.querySalesPlanAmountByCycleId(planningCycleId);
//Map<String, Object> map = new HashMap<String, Object>();
List<Map<String, Object>> planList = new ArrayList<>();
List<UUID> dinasTypeIdList = new ArrayList<>();
if (needPlanKObject != null) {
List<KObject> needPlanDetails = needPlanKObject.get("NeedPlanDetails").toList();
if (needPlanDetails != null && needPlanDetails.size() > 0) {
//List<Map<String, Object>> needPlanList = new ArrayList<>();
for (int i = 0; i < needPlanDetails.size(); i++) {
Map<String, Object> needPlanMap = new HashMap<String, Object>();
KObject needPlanDetail = needPlanDetails.get(i);
needPlanMap.put("dinasTypeId", needPlanDetail.get("dinasType").getUuid("id"));
needPlanMap.put("dinasTypeName", needPlanDetail.get("dinasType").getString("dinasTypeName"));
needPlanMap.put("actualSaleAmount", needPlanDetail.getBigDecimal("effectiveSale"));
needPlanMap.put("needPlanAmount", needPlanDetail.getBigDecimal("needPlanAmount")); //需用计划量
needPlanMap.put("salesPlanAmount", new BigDecimal("0"));
planList.add(needPlanMap);
dinasTypeIdList.add(needPlanDetail.get("dinasType").getUuid("id"));
}
//map.put("needPlanDetails", needPlanList);
for (KObject planDetail : needPlanDetails) {
Map<String, Object> needPlanMap = new HashMap<>();
needPlanMap.put("dinasTypeId", planDetail.get("dinasType").getUuid("id"));
needPlanMap.put("dinasTypeName", planDetail.get("dinasType").getString("dinasTypeName"));
needPlanMap.put("actualSaleAmount", planDetail.getBigDecimal("effectiveSale"));
needPlanMap.put("needPlanAmount", planDetail.getBigDecimal("needPlanAmount")); //需用计划量
needPlanMap.put("salesPlanAmount", new BigDecimal("0"));
planList.add(needPlanMap);
dinasTypeIdList.add(planDetail.get("dinasType").getUuid("id"));
}
}
}
if (salesPlanKObject != null) {
......@@ -186,4 +183,13 @@ public class NeedPlanServiceImpl implements NeedPlanService {
KObject salesPlanByTimeKObject = salesPlanDao.querySalesPlanByTime(startTime, endTime);
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);
}
}
......@@ -3,6 +3,7 @@ package com.xyst.dinas.sales.service;
import java.util.List;
import java.util.UUID;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.xyst.dinas.sales.entity.InventoryLog;
import com.xyst.dinas.sales.entity.StationDinasTypeRelation;
......@@ -12,6 +13,9 @@ public interface InventoryService {
public List<StationDinasTypeRelation> getInventoryByRegionalCompany(UUID regionalCompany);
public ResponseObj<String> modifyInventory(String body, boolean isLog, boolean autoCalculate);
public List<InventoryLog> queryLog(UUID regionalCompany);
List<StationDinasTypeRelation> getItemListByStationId(UUID stationId);
Object queryWarnSettingById(UUID id);
/**
......@@ -22,4 +26,8 @@ public interface InventoryService {
* @return
*/
public Double getStockAmountByDinas(UUID stationId,String dinasTypeName);
KObject getItemByStationIdAndDinasTypeId(UUID id, UUID dinasTypeId);
}
......@@ -30,4 +30,6 @@ public interface NeedPlanService {
Object queryNeedPlanAmountByCycleId(UUID fromString, UUID fromString2);
KObject querySalePlanByCycleId(UUID fromString);
List<KObject> queryNeedPlanByCarNumAndPlanningCycle(KObject station, String carNum, Date date);
}
......@@ -88,4 +88,6 @@ public interface SalesPlanService {
List<KObject> getProjectByNowPlanningCycle(UUID purchaseSandUnitId, UUID planningCycleId);
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;
import java.util.HashMap;
import java.util.List;
import com.beecode.bcp.type.KObject;
import com.xyst.dinas.sales.web.info.SalesRecordInfo;
import org.springframework.web.multipart.MultipartFile;
......@@ -12,9 +13,10 @@ public interface SalesRecordService {
* 通过销售台账List对台账进行存储
* 主要用于外部接口调用
* @param salesRecordList 销售台账List
* @param station
* @return 返回存储状态 failure/失败 success/成功
*/
String saveSalesRecordService(List<SalesRecordInfo> salesRecordList);
String saveSalesRecordService(List<SalesRecordInfo> salesRecordList, KObject station);
HashMap<String,Object> qualityReportExcelImport(MultipartFile file);
}
......@@ -19,21 +19,6 @@ public class SalesRecordController {
@Autowired
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: 导入销售记录,没有的数据全部新建
......
package com.xyst.dinas.sales.web.info;
import java.util.Date;
public class SalesRecordInfo {
/**
* 修改时间
*/
private String modifyTime;
/**
* 项目
*/
......@@ -27,13 +30,13 @@ public class SalesRecordInfo {
*/
private String station;
/**
* 生产线
* 散户名称
*/
private String productionLine;
private String retailName;
/**
* 散户
* 散户身份证号
*/
private String retailInfo;
private String retailIdNum;
/**
* 砂石种类
*/
......@@ -45,12 +48,62 @@ public class SalesRecordInfo {
/**
* 销售时间
*/
private String dealTime;
private Date dealTime;
/**
* 车辆信息
*/
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 {
*/
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() {
return modifyTime;
}
......@@ -120,20 +192,20 @@ public class SalesRecordInfo {
this.station = station;
}
public String getProductionLine() {
return productionLine;
public String getRetailName() {
return retailName;
}
public void setProductionLine(String productionLine) {
this.productionLine = productionLine;
public void setRetailName(String retailName) {
this.retailName = retailName;
}
public String getRetailInfo() {
return retailInfo;
public String getRetailIdNum() {
return retailIdNum;
}
public void setRetailInfo(String retailInfo) {
this.retailInfo = retailInfo;
public void setRetailIdNum(String retailIdNum) {
this.retailIdNum = retailIdNum;
}
public String getDinasType() {
......@@ -152,13 +224,6 @@ public class SalesRecordInfo {
this.customerType = customerType;
}
public String getDealTime() {
return dealTime;
}
public void setDealTime(String dealTime) {
this.dealTime = dealTime;
}
public String getCarInfo() {
return carInfo;
......@@ -208,4 +273,100 @@ public class SalesRecordInfo {
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 @@
<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>
</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'>
<annotation id='18fc1ef9-5b5c-4000-a2d9-7a5d3e5a2fd5' attributeId='b6d2026b-a671-4054-86f2-cce248a72464' name='length' value='50'></annotation>
</attribute>
......@@ -66,6 +72,20 @@
<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>
</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'>
<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>
......
......@@ -41,4 +41,6 @@ public class PaymentDetailsController {
return ResponseObj.error("查询回款明细操作后台失败!详情请查看日志", e.getMessage());
}
}
}
......@@ -22,9 +22,9 @@
LEFT JOIN Station AS station on station.id = salesRecord.station
LEFT JOIN DinasType AS dinasType ON salesRecord.dinasType = dinasType.id
WHERE 1=1
AND salesRecord.syncTime &gt;= :?startDate
AND salesRecord.syncTime &lt;= :?endDate
ORDER BY salesRecord.syncTime
AND salesRecord.dealTime &gt;= :?startDate
AND salesRecord.dealTime &lt;= :?endDate
ORDER BY salesRecord.dealTime
LIMIT :?limitNum
</sql>
</template>
......
......@@ -7,6 +7,7 @@ import com.xyst.dinas.transport.service.VehicleDispatchService;
import com.xyst.dinas.transport.task.VehicleDispatchStatusTask;
import com.xyst.dinas.transport.task.VehicleDispatchStatusTaskRegister;
import com.xyst.dinas.transport.web.VehicleDispatchController;
import com.xyst.dinas.transport.web.WeighbridgeSyncController;
import org.springframework.context.annotation.Bean;
public class VehicleDispatchConfiguration {
......@@ -33,4 +34,9 @@ public class VehicleDispatchConfiguration {
public VehicleDispatchStatusTaskRegister vehicleDispatchStatusTaskRegister() {
return new VehicleDispatchStatusTaskRegister();
}
@Bean
public WeighbridgeSyncController weighbridgeSyncController() {
return new WeighbridgeSyncController();
}
}
......@@ -5,6 +5,7 @@ import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.dao.BaseDao;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public interface VehicleDispatchDao extends BaseDao {
......@@ -18,4 +19,5 @@ public interface VehicleDispatchDao extends BaseDao {
void updateStatusToStart();
List<KObject> findByDriver(KObject vehicle, KObject station);
}
......@@ -37,8 +37,6 @@ public class VehicleDispatchDaoImpl extends AbstractBaseDao implements VehicleDi
@Autowired
private VehicleDriverUserDao vehicleDriverUserDao;
@Autowired
private DriverUserDao driverUserDao;
/**
......@@ -101,14 +99,14 @@ public class VehicleDispatchDaoImpl extends AbstractBaseDao implements VehicleDi
collect = new ArrayList<>();
collect.add(vehicleId);
}
if(collect.isEmpty()){
if (collect.isEmpty()) {
return null;
}
Page<KObject> kObjectPage = new Page<>();
KClass bean = Amino.getStaticMetadataContext().getBean(ENTITY, KClass.class);
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName());
detachedCriteria.add(Restrictions.eq(BaseConstants.DEL, false));
if(status!=null){
if (status != null) {
detachedCriteria.add(Restrictions.eq("dispatchStatus", status));
}
detachedCriteria.createAlias(PLANNING_CYCLE, PLANNING_CYCLE);
......@@ -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 " +
"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());
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.setParameter("ids", optional.get());
return query.executeUpdate();
......@@ -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;
import com.xyst.dinas.price.enumeration.PriceAdjustmentAdjustmentStatusEnum;
import com.xyst.dinas.sales.constant.SalesPlanConstant;
import com.xyst.dinas.sales.constant.SalesRecordConstant;
import com.xyst.dinas.sales.dao.InventoryDao;
import com.xyst.dinas.transport.constant.VehicleDriverUserConstant;
import com.xyst.dinas.transport.constant.VehicleDispatchConstant;
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.service.VehicleDispatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import javax.transaction.Transactional;
import java.math.BigDecimal;
import java.util.*;
/**
......@@ -35,6 +38,10 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
@Autowired
private DriverUserDao driverUserDao;
@Autowired
private VehicleDriverUserDao vehicleDriverUserDao;
@Autowired
private InventoryDao inventoryDao;
@Override
public UUID create(KObject kobject) {
......@@ -68,9 +75,9 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
KObject planningCycle;
if (dispatchType == DispatchTypeEnum.NEED_PLAN.getValue()) {
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.PLANNING_CYCLE,planningCycle );
kobject.set(VehicleDispatchConstant.PLANNING_CYCLE, planningCycle);
kobject.set(VehicleDispatchConstant.PROJECT, load.get(VehicleDispatchConstant.PROJECT));
kobject.set(VehicleDispatchConstant.CONTRACT, load.get(VehicleDispatchConstant.CONTRACT));
kobject.set(VehicleDispatchConstant.DINAS_TYPE, load.get(VehicleDispatchConstant.DINAS_TYPE));
......@@ -79,18 +86,18 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
} else {
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.PLANNING_CYCLE,planningCycle );
kobject.set(VehicleDispatchConstant.PLANNING_CYCLE, planningCycle);
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.DINAS_TYPE, load.get(VehicleDispatchConstant.DINAS_TYPE));
kobject.set(VehicleDispatchConstant.STATION, load.get(BaseConstants.MASTER).get(VehicleDispatchConstant.STATION));
kobject.set(VehicleDispatchConstant.PLAN_AMOUNT, load.getBigDecimal("salesPlanAmount"));
}
kobject.set("dispatchStatus",PriceAdjustmentAdjustmentStatusEnum.NOT_STARTED.getValue());
if(planningCycle.getDate(VehicleDispatchConstant.PLANNING_CYCLE_START_TIME).before(new Date())){
kobject.set("dispatchStatus",PriceAdjustmentAdjustmentStatusEnum.PROCESSING.getValue());
kobject.set("dispatchStatus", PriceAdjustmentAdjustmentStatusEnum.NOT_STARTED.getValue());
if (planningCycle.getDate(VehicleDispatchConstant.PLANNING_CYCLE_START_TIME).before(new Date())) {
kobject.set("dispatchStatus", PriceAdjustmentAdjustmentStatusEnum.PROCESSING.getValue());
}
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")));
......@@ -130,7 +137,7 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
@Override
public void endVehicleDispatchById(UUID id) {
vehicleDispatchDao.setAttribute(id,"dispatchStatus", PriceAdjustmentAdjustmentStatusEnum.OVER.getValue());
vehicleDispatchDao.setAttribute(id, "dispatchStatus", PriceAdjustmentAdjustmentStatusEnum.OVER.getValue());
}
@Override
......@@ -141,12 +148,88 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
@Override
public void confirmTransportRecord(Map map) {
KObject load = vehicleDispatchDao.load(SalesRecordConstant.TRANSPORT_RECORD_ENTITY, map.get("id").toString());
load.set("confirmStatus",1);
load.set("confirmTime",new Date());
load.set("confirmStatus", 1);
load.set("confirmTime", new Date());
load.set("driverUser", driverUserDao.findById(DriverUserContextHolder.getContext().getDriverUser().getId()));
load.set("receiverName", map.get("receiverName").toString());
load.set("memo", map.get("memo").toString());
load.set("contactNumber", map.get("contactNumber").toString());
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;
import com.beecode.bcp.type.KObject;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
......@@ -20,4 +21,7 @@ public interface VehicleDispatchService {
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