|
@@ -6,23 +6,20 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.winsea.svc.base.base.entity.CommonRoleResource;
|
|
|
+import com.winsea.svc.base.base.exception.EnterpriseException;
|
|
|
import com.winsea.svc.base.base.service.ICommonRoleResourceService;
|
|
|
import com.winsea.svc.base.base.util.DateUtils;
|
|
|
import com.winsea.svc.base.security.entity.User;
|
|
|
import com.winsea.svc.base.security.util.AuthSecurityUtils;
|
|
|
import com.winsea.svc.base.workflow.entity.Workflow;
|
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
|
-import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.YException;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.CollectionWarehousingRecordMapper;
|
|
|
-import com.yh.saas.plugin.yiliangyiyun.service.ICollectionWarehousingRecordService;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.*;
|
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
-import com.yh.saas.plugin.yiliangyiyun.service.IContractManagementInfoService;
|
|
|
-import com.yh.saas.plugin.yiliangyiyun.service.IIdentityAuthenticationInfoService;
|
|
|
-import com.yh.saas.plugin.yiliangyiyun.service.INewWorkflowService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.httpclient.util.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -40,6 +37,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@@ -65,6 +63,9 @@ public class CollectionWarehousingRecordServiceImpl extends ServiceImpl<Collecti
|
|
|
private IIdentityAuthenticationInfoService iIdentityAuthenticationInfoService;
|
|
|
@Autowired
|
|
|
private IContractManagementInfoService contractManagementInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IContractGoodsInfoService contractGoodsInfoService;
|
|
|
+
|
|
|
@Value("${file-root-path}")
|
|
|
private String localPath;
|
|
|
|
|
@@ -141,14 +142,39 @@ public class CollectionWarehousingRecordServiceImpl extends ServiceImpl<Collecti
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String insertCollectionWarehousingRecord(CollectionWarehousingRecord collectionWarehousingRecord) {
|
|
|
-
|
|
|
- List<CollectionWarehousingRecord> collectionWarehousingRecord1 = collectionWarehousingRecord.getCollectionWarehousingRecords();
|
|
|
+ List<CollectionWarehousingRecord> collectionWarehousingRecord1 = collectionWarehousingRecord.getExcelList();
|
|
|
+ ContractManagementInfo contractManagementInfo=contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
+ .eq("contract_no",collectionWarehousingRecord.getContractNo())
|
|
|
+ .eq("comp_id",collectionWarehousingRecord.getCompId()));
|
|
|
+ ContractGoodsInfo contractGoodsInfo=contractGoodsInfoService.selectOne(new EntityWrapper<ContractGoodsInfo>()
|
|
|
+ .eq("contract_id",contractManagementInfo.getId()));
|
|
|
if(!CollectionUtils.isEmpty(collectionWarehousingRecord1)){
|
|
|
- for(int i =0;i<collectionWarehousingRecord1.size();i++){
|
|
|
- CollectionWarehousingRecord warehousingRecord = collectionWarehousingRecord1.get(i);
|
|
|
+ for(CollectionWarehousingRecord warehousingRecord:collectionWarehousingRecord1){
|
|
|
//新增主键id
|
|
|
warehousingRecord.setId(IdGenerator.generateUUID());
|
|
|
- this.insert(warehousingRecord);
|
|
|
+ warehousingRecord.setCompId(contractManagementInfo.getCompId());
|
|
|
+ warehousingRecord.setContractNo(contractManagementInfo.getContractNo());
|
|
|
+ warehousingRecord.setGoodsName(contractGoodsInfo.getGoodsName());
|
|
|
+ //单价x净重=应付
|
|
|
+ warehousingRecord.setAmountIngPayable(warehousingRecord.getUnitHave()*warehousingRecord.getNetWeight());
|
|
|
+ warehousingRecord.setAmountNotPayable(warehousingRecord.getUnitHave()*warehousingRecord.getNetWeight());
|
|
|
+ //收购单价+代收费=销售单价
|
|
|
+ warehousingRecord.setUnitDeduction(warehousingRecord.getUnitHave()+contractManagementInfo.getAgencyCharge());
|
|
|
+ //销售单价x净重=应收
|
|
|
+ warehousingRecord.setAmountNotCollectable(warehousingRecord.getUnitDeduction()*warehousingRecord.getNetWeight());
|
|
|
+ IdentityAuthenticationInfo identityAuthenticationInfo=iIdentityAuthenticationInfoService.selectOne(new EntityWrapper<IdentityAuthenticationInfo>()
|
|
|
+ .eq("customer_number_card",warehousingRecord.getCustomerNumberCard())
|
|
|
+ .eq("authentication_status_key","7"));
|
|
|
+ if (identityAuthenticationInfo!=null){
|
|
|
+ if (!warehousingRecord.getCustomerName().equals(identityAuthenticationInfo.getCustomerName())){
|
|
|
+ warehousingRecord.setCustomerName("");
|
|
|
+ }
|
|
|
+ warehousingRecord.setCustomerPhone(identityAuthenticationInfo.getCustomerPhone());
|
|
|
+ this.insert(warehousingRecord);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ throw new EnterpriseException(warehousingRecord.getCustomerName()+""+warehousingRecord.getCustomerNumberCard(),"身份证号有误或未认证");
|
|
|
+ }
|
|
|
|
|
|
boolean isStartWorkflow = org.apache.commons.lang3.StringUtils.isBlank(warehousingRecord.getWorkflowId());
|
|
|
// 不是退回的单子
|
|
@@ -182,7 +208,7 @@ public class CollectionWarehousingRecordServiceImpl extends ServiceImpl<Collecti
|
|
|
// 插入操作历史
|
|
|
// this.billOperateHisService.saveBillOperateHis(salePlanInfo.getId(), NumberConstant.CONSTANT_PURCHASE, staffName, null,
|
|
|
// salePlanInfo.getStatus(), null, "");
|
|
|
- return "OK";
|
|
|
+ return "ok";
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -213,7 +239,7 @@ public class CollectionWarehousingRecordServiceImpl extends ServiceImpl<Collecti
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String editCollectionWarehousingRecord(CollectionWarehousingRecord collectionWarehousingRecord) {
|
|
|
boolean one = this.updateById(collectionWarehousingRecord);
|
|
|
- if (collectionWarehousingRecord.getStatusFlag().equals(StatusEnum.TASK_RETURN.getFlag())) {
|
|
|
+ if (StatusEnum.TASK_RETURN.getFlag().equals(collectionWarehousingRecord.getStatusFlag())) {
|
|
|
boolean isStartWorkflow = org.apache.commons.lang3.StringUtils.isBlank(collectionWarehousingRecord.getWorkflowId());
|
|
|
// 不是退回的单子
|
|
|
if (isStartWorkflow) {
|
|
@@ -557,9 +583,9 @@ public class CollectionWarehousingRecordServiceImpl extends ServiceImpl<Collecti
|
|
|
|
|
|
rownum++;
|
|
|
// 详情信息
|
|
|
- if (!CollectionUtils.isEmpty(collectionWarehousingRecord.getCollectionWarehousingRecords())) {
|
|
|
- for (int i = 0; i < collectionWarehousingRecord.getCollectionWarehousingRecords().size(); i++) {
|
|
|
- CollectionWarehousingRecord collectionWarehousingRecord1 = collectionWarehousingRecord.getCollectionWarehousingRecords().get(i);
|
|
|
+ if (!CollectionUtils.isEmpty(collectionWarehousingRecord.getCollectionWarehousingRecordList())) {
|
|
|
+ for (int i = 0; i < collectionWarehousingRecord.getCollectionWarehousingRecordList().size(); i++) {
|
|
|
+ CollectionWarehousingRecord collectionWarehousingRecord1 = collectionWarehousingRecord.getCollectionWarehousingRecordList().get(i);
|
|
|
ContractManagementInfo contractManagementInfo=contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
.eq("contract_no",collectionWarehousingRecord1.getContractNo())
|
|
|
.eq("comp_id",collectionWarehousingRecord1.getCompId()));
|
|
@@ -591,8 +617,15 @@ public class CollectionWarehousingRecordServiceImpl extends ServiceImpl<Collecti
|
|
|
cell = rowx.createCell(6);
|
|
|
cell.setCellValue(collectionWarehousingRecord1.getGoodsName());
|
|
|
cell.setCellStyle(styleDetail);
|
|
|
+ String type="";
|
|
|
+ if (collectionWarehousingRecord1.getGoodsName().contains("潮")){
|
|
|
+ type="潮粮";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ type="干粮";
|
|
|
+ }
|
|
|
cell = rowx.createCell(7);
|
|
|
- cell.setCellValue(collectionWarehousingRecord1.getGoodsName());
|
|
|
+ cell.setCellValue(type);
|
|
|
cell.setCellStyle(styleDetail);
|
|
|
cell = rowx.createCell(8);
|
|
|
cell.setCellValue(collectionWarehousingRecord1.getGrade());
|
|
@@ -648,6 +681,122 @@ public class CollectionWarehousingRecordServiceImpl extends ServiceImpl<Collecti
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 批量开发票
|
|
|
+ * @param collectionWarehousingRecord
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String openInvoiceList(CollectionWarehousingRecord collectionWarehousingRecord) {
|
|
|
+ List<CollectionWarehousingRecord> collectionWarehousingRecordList = collectionWarehousingRecord.getCollectionWarehousingRecordList();
|
|
|
+ //批量
|
|
|
+ if (!CollectionUtils.isEmpty(collectionWarehousingRecordList)) {
|
|
|
+ //开自采发票
|
|
|
+ if("1".equals(collectionWarehousingRecord.getFlag())){
|
|
|
+ for (CollectionWarehousingRecord collectionWarehousingRecord1 : collectionWarehousingRecordList) {
|
|
|
+ collectionWarehousingRecord1.setInvoicing("1");
|
|
|
+ collectionWarehousingRecord1.setInvoicingDate(new Date());
|
|
|
+ this.updateById(collectionWarehousingRecord1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //开销售发票
|
|
|
+ else {
|
|
|
+ for (CollectionWarehousingRecord collectionWarehousingRecord1 : collectionWarehousingRecordList) {
|
|
|
+ collectionWarehousingRecord1.setInvoicingSale("1");
|
|
|
+ this.updateById(collectionWarehousingRecord1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 付款
|
|
|
+ * @param collectionWarehousingRecord
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String payMoney(CollectionWarehousingRecord collectionWarehousingRecord) {
|
|
|
+ List<CollectionWarehousingRecord> collectionWarehousingRecordList = collectionWarehousingRecord.getCollectionWarehousingRecordList();
|
|
|
+ Double money = collectionWarehousingRecord.getMoney();
|
|
|
+ //付款多条
|
|
|
+ if (!CollectionUtils.isEmpty(collectionWarehousingRecordList)) {
|
|
|
+ for (CollectionWarehousingRecord collectionWarehousingRecord1 : collectionWarehousingRecordList) {
|
|
|
+ CollectionWarehousingRecord collectionWarehousingRecord2 = this.selectById(collectionWarehousingRecord1.getId());
|
|
|
+ //付款金额大于本次循环未付金额
|
|
|
+ if (money >= collectionWarehousingRecord1.getAmountNotPayable()) {
|
|
|
+ money=money-collectionWarehousingRecord1.getAmountNotPayable();
|
|
|
+ //全部付款
|
|
|
+ collectionWarehousingRecord1.setStatus(StatusEnum.PUR_PAYaLL.getName());
|
|
|
+ collectionWarehousingRecord1.setStatusFlag(StatusEnum.PUR_PAYaLL.getFlag());
|
|
|
+ collectionWarehousingRecord1.setPaymentDate(collectionWarehousingRecord.getPaymentDate());
|
|
|
+ collectionWarehousingRecord1.setPaymentScreenshot(collectionWarehousingRecord2.getPaymentScreenshot() != null ? collectionWarehousingRecord2.getPaymentScreenshot() + '$' + collectionWarehousingRecord.getPaymentScreenshot() : collectionWarehousingRecord.getPaymentScreenshot());
|
|
|
+ collectionWarehousingRecord1.setAmountEdPayable(collectionWarehousingRecord1.getAmountEdPayable() + collectionWarehousingRecord1.getAmountNotPayable());
|
|
|
+ collectionWarehousingRecord1.setAmountNotPayable(0.0d);
|
|
|
+ this.updateById(collectionWarehousingRecord1);
|
|
|
+ } else if (money > 0) {
|
|
|
+ Double moneyTmp =money-collectionWarehousingRecord1.getAmountNotPayable();
|
|
|
+ //部分付款
|
|
|
+ collectionWarehousingRecord1.setStatus(StatusEnum.PUR_PAY.getName());
|
|
|
+ collectionWarehousingRecord1.setStatusFlag(StatusEnum.PUR_PAY.getFlag());
|
|
|
+ collectionWarehousingRecord1.setPaymentDate(collectionWarehousingRecord.getPaymentDate());
|
|
|
+ collectionWarehousingRecord1.setPaymentScreenshot(collectionWarehousingRecord2.getPaymentScreenshot() != null ? collectionWarehousingRecord2.getPaymentScreenshot() + '$' + collectionWarehousingRecord.getPaymentScreenshot() : collectionWarehousingRecord.getPaymentScreenshot());
|
|
|
+ collectionWarehousingRecord1.setAmountEdPayable(collectionWarehousingRecord1.getAmountEdPayable() + money);
|
|
|
+ collectionWarehousingRecord1.setAmountNotPayable(collectionWarehousingRecord1.getAmountNotPayable() - money);
|
|
|
+ this.updateById(collectionWarehousingRecord1);
|
|
|
+ money = moneyTmp;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 收款
|
|
|
+ * @param collectionWarehousingRecord
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String collectMoney(CollectionWarehousingRecord collectionWarehousingRecord) {
|
|
|
+ List<CollectionWarehousingRecord> collectionWarehousingRecordList = collectionWarehousingRecord.getCollectionWarehousingRecordList();
|
|
|
+ Double money = collectionWarehousingRecord.getMoney();
|
|
|
+ //收款多条
|
|
|
+ if (!CollectionUtils.isEmpty(collectionWarehousingRecordList)) {
|
|
|
+ for (CollectionWarehousingRecord collectionWarehousingRecord1 : collectionWarehousingRecordList) {
|
|
|
+ CollectionWarehousingRecord collectionWarehousingRecord2 = this.selectById(collectionWarehousingRecord1.getId());
|
|
|
+ //收款金额大于本次循环未收金额
|
|
|
+ if (money >= collectionWarehousingRecord1.getAmountNotCollectable()) {
|
|
|
+ money = money - collectionWarehousingRecord1.getAmountNotCollectable();
|
|
|
+ //全部收款
|
|
|
+ collectionWarehousingRecord1.setStatus(StatusEnum.PUR_COLLECTaLL.getName());
|
|
|
+ collectionWarehousingRecord1.setStatusFlag(StatusEnum.PUR_COLLECTaLL.getFlag());
|
|
|
+ collectionWarehousingRecord1.setCollectionDate(collectionWarehousingRecord.getCollectionDate());
|
|
|
+ collectionWarehousingRecord1.setCollectionScreenshot(collectionWarehousingRecord2.getCollectionScreenshot() != null ? collectionWarehousingRecord2.getCollectionScreenshot() + '$' + collectionWarehousingRecord.getCollectionScreenshot() : collectionWarehousingRecord.getCollectionScreenshot());
|
|
|
+ collectionWarehousingRecord1.setAmountEdCollectionable(collectionWarehousingRecord1.getAmountEdCollectionable() + collectionWarehousingRecord1.getAmountNotCollectable());
|
|
|
+ collectionWarehousingRecord1.setAmountNotCollectable(0.0d);
|
|
|
+ this.updateById(collectionWarehousingRecord1);
|
|
|
+ } else if (money > 0) {
|
|
|
+ Double moneyTmp = money - collectionWarehousingRecord1.getAmountNotCollectable();
|
|
|
+ //部分收款
|
|
|
+ collectionWarehousingRecord1.setStatus(StatusEnum.PUR_COLLECT.getName());
|
|
|
+ collectionWarehousingRecord1.setStatusFlag(StatusEnum.PUR_COLLECT.getFlag());
|
|
|
+ collectionWarehousingRecord1.setCollectionDate(collectionWarehousingRecord.getCollectionDate());
|
|
|
+ collectionWarehousingRecord1.setCollectionScreenshot(collectionWarehousingRecord2.getCollectionScreenshot() != null ? collectionWarehousingRecord2.getCollectionScreenshot() + '$' + collectionWarehousingRecord.getCollectionScreenshot() : collectionWarehousingRecord.getCollectionScreenshot());
|
|
|
+ collectionWarehousingRecord1.setAmountEdCollectionable(collectionWarehousingRecord1.getAmountEdCollectionable() + money);
|
|
|
+ collectionWarehousingRecord1.setAmountNotCollectable(collectionWarehousingRecord1.getAmountNotCollectable() - money);
|
|
|
+ this.updateById(collectionWarehousingRecord1);
|
|
|
+ money = moneyTmp;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private String addDateOneDay(Date date) {
|
|
|
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|