|
|
|
@ -1,19 +1,34 @@
|
|
|
|
|
package jnpf.poundlist.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
|
|
|
|
import jnpf.Jg_natural.entity.Jg_naturalEntity;
|
|
|
|
|
import jnpf.arinvoices.entity.Arinvoices_item0Entity;
|
|
|
|
|
import jnpf.base.ActionResult;
|
|
|
|
|
import jnpf.base.UserInfo;
|
|
|
|
|
import jnpf.base.controller.BillRuleController;
|
|
|
|
|
import jnpf.base.entity.ProvinceEntity;
|
|
|
|
|
import jnpf.contractfile.entity.ContractFileEntity;
|
|
|
|
|
import jnpf.contractfile.service.ContractFileService;
|
|
|
|
|
import jnpf.customer.entity.CustomerEntity;
|
|
|
|
|
import jnpf.customer.service.CustomerService;
|
|
|
|
|
import jnpf.exception.DataException;
|
|
|
|
|
import jnpf.materialvo.entity.MaterialEntity;
|
|
|
|
|
import jnpf.materialvo.service.MaterialService;
|
|
|
|
|
import jnpf.model.UserGetUserEntity;
|
|
|
|
|
import jnpf.poundlist.entity.*;
|
|
|
|
|
import jnpf.poundlist.mapper.PoundlistMapper;
|
|
|
|
|
import jnpf.poundlist.model.poundlist.PoundlistDTO;
|
|
|
|
|
import jnpf.poundlist.model.poundlist.PoundlistListVO;
|
|
|
|
|
import jnpf.poundlist.service.*;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import jnpf.purchaseorder.entity.PurchaseOrderImportVo;
|
|
|
|
|
import jnpf.purchaseorder.entity.Purchaseorder_item0Entity;
|
|
|
|
|
import jnpf.purchaseorder.entity.PurchaseorderitemEntity;
|
|
|
|
|
import jnpf.purchaseorder.model.purchaseorder.PurchaseorderDTO;
|
|
|
|
|
import jnpf.supplier.entity.SupplierEntity;
|
|
|
|
|
import jnpf.supplier.service.SupplierService;
|
|
|
|
|
import jnpf.supplyProcessAnalysis.entity.ContractMEntity;
|
|
|
|
|
import jnpf.util.RandomUtil;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
@ -30,11 +45,16 @@ import java.lang.reflect.Field;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
|
|
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import jnpf.util.context.SpringContext;
|
|
|
|
|
import jnpf.vehicle.entity.VehicleEntity;
|
|
|
|
|
import jnpf.vehicle.service.VehicleService;
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -77,6 +97,9 @@ public class PoundlistServiceImpl extends ServiceImpl<PoundlistMapper, Poundlist
|
|
|
|
|
@Autowired
|
|
|
|
|
private MaterialService materialService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private GeneraterSwapUtil generaterSwapUtil;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<PoundlistEntity> getList(PoundlistPagination poundlistPagination) {
|
|
|
|
|
String userId = userProvider.get().getUserId();
|
|
|
|
@ -295,6 +318,205 @@ public class PoundlistServiceImpl extends ServiceImpl<PoundlistMapper, Poundlist
|
|
|
|
|
return poundlistMapper.queryPoundListByIdsRenkuan(poundlistIdList, paymentdocId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> importPreview(List<PoundlistEntity> personList) {
|
|
|
|
|
List<Map<String, Object>> dataRow = new ArrayList<>();
|
|
|
|
|
List<Map<String, Object>> columns = new ArrayList<>();
|
|
|
|
|
if(personList != null) {
|
|
|
|
|
for (int i = 0; i < personList.size(); i++) {
|
|
|
|
|
Map<String, Object> dataRowMap = new HashMap<>();
|
|
|
|
|
PoundlistEntity model = personList.get(i);
|
|
|
|
|
dataRowMap.put("customerName", model.getCustomerName());
|
|
|
|
|
dataRowMap.put("vehicleName", model.getVehicleName());
|
|
|
|
|
dataRowMap.put("grossWeight", model.getGrossWeight());
|
|
|
|
|
dataRowMap.put("tareWeight", model.getTareWeight());
|
|
|
|
|
dataRowMap.put("settlement", model.getSettlement());
|
|
|
|
|
dataRowMap.put("unit", model.getUnit());
|
|
|
|
|
dataRowMap.put("salesPrice", model.getSalesPrice());
|
|
|
|
|
dataRowMap.put("salesAmount", model.getSalesAmount());
|
|
|
|
|
dataRow.add(dataRowMap);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 1; i < 10; i++) {
|
|
|
|
|
Map<String, Object> columnsMap = new HashMap<>();
|
|
|
|
|
columnsMap.put("AllowDBNull", true);
|
|
|
|
|
columnsMap.put("AutoIncrement", false);
|
|
|
|
|
columnsMap.put("AutoIncrementSeed", 0);
|
|
|
|
|
columnsMap.put("AutoIncrementStep", 1);
|
|
|
|
|
columnsMap.put("Caption", this.getColumns(i));
|
|
|
|
|
columnsMap.put("ColumnMapping", 1);
|
|
|
|
|
columnsMap.put("ColumnName", this.getColumns(i));
|
|
|
|
|
columnsMap.put("Container", null);
|
|
|
|
|
columnsMap.put("DataType", "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
|
|
|
|
|
columnsMap.put("DateTimeMode", 3);
|
|
|
|
|
columnsMap.put("DefaultValue", null);
|
|
|
|
|
columnsMap.put("DesignMode", false);
|
|
|
|
|
columnsMap.put("Expression", "");
|
|
|
|
|
columnsMap.put("ExtendedProperties", "");
|
|
|
|
|
columnsMap.put("MaxLength", -1);
|
|
|
|
|
columnsMap.put("Namespace", "");
|
|
|
|
|
columnsMap.put("Ordinal", 0);
|
|
|
|
|
columnsMap.put("Prefix", "");
|
|
|
|
|
columnsMap.put("ReadOnly", false);
|
|
|
|
|
columnsMap.put("Site", null);
|
|
|
|
|
columnsMap.put("Table", personList);
|
|
|
|
|
columnsMap.put("Unique", false);
|
|
|
|
|
columns.add(columnsMap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("dataRow", dataRow);
|
|
|
|
|
map.put("columns", columns);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
private String getColumns(Integer key) {
|
|
|
|
|
Map<Integer, String> map = new HashMap<>();
|
|
|
|
|
map.put(1, "客户名称");
|
|
|
|
|
map.put(2, "车号");
|
|
|
|
|
map.put(3, "毛重");
|
|
|
|
|
map.put(4, "皮重");
|
|
|
|
|
map.put(5, "结算重量");
|
|
|
|
|
map.put(6, "单位");
|
|
|
|
|
map.put(7, "销售单价");
|
|
|
|
|
map.put(8, "销售金额");
|
|
|
|
|
return map.get(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入
|
|
|
|
|
*
|
|
|
|
|
* @param dataList
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public PoundlistImportVo importData(List<PoundlistDTO> dataList) throws ParseException, DataException {
|
|
|
|
|
//记录成功了几条
|
|
|
|
|
int sum = 0;
|
|
|
|
|
//记录失败了几条
|
|
|
|
|
int num = 0;
|
|
|
|
|
|
|
|
|
|
List<PoundlistEntity> poundlistEntityList = new ArrayList<>();
|
|
|
|
|
List<PoundlistDTO> errList = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < dataList.size(); i++) {
|
|
|
|
|
PoundlistDTO model = dataList.get(i);
|
|
|
|
|
PoundlistDTO dto = null;
|
|
|
|
|
try {
|
|
|
|
|
dto = model.clone();
|
|
|
|
|
} catch (CloneNotSupportedException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotEmpty(model.getCustomerName())) {
|
|
|
|
|
String userId = userProvider.get().getUserId();
|
|
|
|
|
String departmentId = userProvider.getDepartmentId(userId);
|
|
|
|
|
LambdaQueryWrapper<CustomerEntity> customerWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
customerWrapper.eq(CustomerEntity::getDepartmentId,departmentId);
|
|
|
|
|
customerWrapper.eq(CustomerEntity::getSupplierNm,model.getCustomerName());
|
|
|
|
|
CustomerEntity customerEntity = customerService.getOne(customerWrapper);
|
|
|
|
|
String customerId = "";
|
|
|
|
|
if (ObjectUtils.isNotEmpty(customerEntity) && StringUtils.isNotEmpty(customerEntity.getId())){
|
|
|
|
|
customerId = customerEntity.getId();
|
|
|
|
|
}else{
|
|
|
|
|
dto.setCauseError("未查询到客户,请检查客户名称是否正确");
|
|
|
|
|
errList.add(dto);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotEmpty(model.getVehicleName())) {
|
|
|
|
|
LambdaQueryWrapper<VehicleEntity> vehicleWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
vehicleWrapper.eq(VehicleEntity::getTicketno,model.getVehicleName());
|
|
|
|
|
vehicleWrapper.eq(VehicleEntity::getDepartmentId,departmentId);
|
|
|
|
|
List<VehicleEntity> vehicleList = vehicleService.list(vehicleWrapper);
|
|
|
|
|
if (vehicleList == null || vehicleList.size() == 0){
|
|
|
|
|
dto.setCauseError("未查询到车号,请检查车号是否正确");
|
|
|
|
|
errList.add(dto);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotEmpty(model.getGrossWeight()) || StringUtils.isNotEmpty(model.getTareWeight()) || StringUtils.isNotEmpty(model.getSettlement()) || StringUtils.isNotEmpty(model.getUnit())) {
|
|
|
|
|
if (model.getUnit() != null) {
|
|
|
|
|
if (model.getUnit().equals("吨") || model.getUnit().equals("T")) {
|
|
|
|
|
model.setUnit("0");
|
|
|
|
|
}
|
|
|
|
|
if (model.getUnit().equals("千克") || model.getUnit().equals("KG")) {
|
|
|
|
|
model.setUnit("1");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<String> vehicleId = new ArrayList<>();
|
|
|
|
|
for (VehicleEntity entity : vehicleList){
|
|
|
|
|
vehicleId.add(entity.getId());
|
|
|
|
|
}
|
|
|
|
|
LambdaQueryWrapper<PoundlistEntity> poundlistWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
poundlistWrapper.eq(PoundlistEntity::getCustomerId,customerId);
|
|
|
|
|
poundlistWrapper.eq(PoundlistEntity::getGrossWeight,model.getGrossWeight());
|
|
|
|
|
poundlistWrapper.eq(PoundlistEntity::getTareWeight,model.getTareWeight());
|
|
|
|
|
poundlistWrapper.eq(PoundlistEntity::getSettlement,model.getSettlement());
|
|
|
|
|
poundlistWrapper.eq(PoundlistEntity::getUnit,model.getUnit());
|
|
|
|
|
poundlistWrapper.in(PoundlistEntity::getVehicleId,vehicleId);
|
|
|
|
|
List<PoundlistEntity> poundlistList = poundlistMapper.selectList(poundlistWrapper);
|
|
|
|
|
if (poundlistList != null && poundlistList.size() != 0){
|
|
|
|
|
if (poundlistList.size() == 1){
|
|
|
|
|
PoundlistEntity poundlistEntity = JsonUtil.getJsonToBean(poundlistList.get(0),PoundlistEntity.class);
|
|
|
|
|
poundlistEntity.setDocumentNo(generaterSwapUtil.getBillNumber("salesOrder", false));
|
|
|
|
|
ContractFileEntity entity = contractFileService.getInfo(poundlistEntity.getSalesId());
|
|
|
|
|
if (ObjectUtils.isNotEmpty(entity) && StringUtils.isNotEmpty(entity.getContractNo())) {
|
|
|
|
|
poundlistEntity.setContractNo(entity.getContractNo());
|
|
|
|
|
poundlistEntity.setContractName(entity.getContractName());
|
|
|
|
|
}
|
|
|
|
|
CustomerEntity customer = customerService.getInfo(poundlistEntity.getCustomerId());
|
|
|
|
|
if (ObjectUtils.isNotEmpty(customer) && StringUtils.isNotEmpty(customerEntity.getSupplierNm())){
|
|
|
|
|
poundlistEntity.setCustomerName(customer.getSupplierNm());
|
|
|
|
|
}
|
|
|
|
|
VehicleEntity vehicleEntity = vehicleService.getInfo(poundlistEntity.getVehicleId());
|
|
|
|
|
if (ObjectUtils.isNotEmpty(vehicleEntity) && StringUtils.isNotEmpty(vehicleEntity.getTicketno())){
|
|
|
|
|
poundlistEntity.setVehicleName(vehicleEntity.getTicketno());
|
|
|
|
|
}
|
|
|
|
|
MaterialEntity materialEntity = materialService.getInfo(poundlistEntity.getMaterialId());
|
|
|
|
|
if (ObjectUtils.isNotEmpty(materialEntity) && StringUtils.isNotEmpty(materialEntity.getItemName())){
|
|
|
|
|
poundlistEntity.setMaterialName(materialEntity.getItemName());
|
|
|
|
|
}
|
|
|
|
|
poundlistEntity.setRate("0");
|
|
|
|
|
poundlistEntity.setUnitPrice(new BigDecimal(model.getSalesPrice()));
|
|
|
|
|
poundlistEntity.setPrice(new BigDecimal(model.getSalesAmount()));
|
|
|
|
|
poundlistEntityList.add(poundlistEntity);
|
|
|
|
|
sum++;
|
|
|
|
|
}else{
|
|
|
|
|
dto.setCauseError("【车号-"+model.getVehicleName()+"】出现重复数据,请查验");
|
|
|
|
|
errList.add(dto);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
dto.setCauseError("未查询到磅单");
|
|
|
|
|
errList.add(dto);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
dto.setCauseError("毛重或皮重或结算重量或单位不能为空");
|
|
|
|
|
errList.add(dto);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
dto.setCauseError("车号不能为空");
|
|
|
|
|
errList.add(dto);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
dto.setCauseError("客户名称不能为空");
|
|
|
|
|
errList.add(dto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PoundlistImportVo importVo = new PoundlistImportVo();
|
|
|
|
|
|
|
|
|
|
num = errList.size();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
importVo.setSnum(sum);
|
|
|
|
|
importVo.setFnum(num);
|
|
|
|
|
importVo.setFailResult(errList);
|
|
|
|
|
if (errList.size() > 0) {
|
|
|
|
|
importVo.setResultType(1);
|
|
|
|
|
} else {
|
|
|
|
|
importVo.setResultType(0);
|
|
|
|
|
importVo.setPoundlistEntityList(poundlistEntityList);
|
|
|
|
|
}
|
|
|
|
|
return importVo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void delete(PoundlistEntity entity) {
|
|
|
|
|
if (entity != null) {
|
|
|
|
|