|
|
|
@ -23,6 +23,8 @@ import jnpf.saleorder.entity.Salesorder_item0Entity;
|
|
|
|
|
import jnpf.saleorder.service.SaleorderitemService;
|
|
|
|
|
import jnpf.saleorder.service.Salesorder_item0Service;
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
|
import org.bytedeco.opencv.presets.opencv_core;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import jnpf.base.entity.ProvinceEntity;
|
|
|
|
|
import jnpf.collection.model.collection.*;
|
|
|
|
@ -97,6 +99,13 @@ public class CollectionController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private PoundlistService poundlistService;
|
|
|
|
|
|
|
|
|
|
@GetMapping("/autoSerialNum")
|
|
|
|
|
@Transactional
|
|
|
|
|
public ActionResult autoSerialNum(@Param("param") String param,@Param("batchNum") String batchNum) throws DataException {
|
|
|
|
|
String result = generaterSwapUtil.getBillNumber(param, false);
|
|
|
|
|
return ActionResult.success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提交
|
|
|
|
|
*
|
|
|
|
@ -109,21 +118,75 @@ public class CollectionController {
|
|
|
|
|
String[] idList = ids.split(",");
|
|
|
|
|
for (String id : idList) {
|
|
|
|
|
CollectionEntity collectionEntity = collectionService.getInfo(id);
|
|
|
|
|
if (ObjectUtils.isNotEmpty(collectionEntity)) {
|
|
|
|
|
if (collectionEntity.getStatus().equals("1")) {
|
|
|
|
|
return ActionResult.fail("已提交,无需再次提交");
|
|
|
|
|
}
|
|
|
|
|
if (collectionEntity.getStatus().equals("2")) {
|
|
|
|
|
return ActionResult.fail("已认款,无需再次提交");
|
|
|
|
|
}
|
|
|
|
|
if (collectionEntity.getAmountCollected() == null || collectionEntity.getAmountCollected().compareTo(BigDecimal.ZERO) < 1) {
|
|
|
|
|
return ActionResult.fail("请先输入收款金额");
|
|
|
|
|
if (collectionEntity.getStatus().equals("1")){
|
|
|
|
|
return ActionResult.fail("已提交");
|
|
|
|
|
}
|
|
|
|
|
if (collectionEntity.getStatus().equals("2")){
|
|
|
|
|
return ActionResult.fail("已认款");
|
|
|
|
|
}
|
|
|
|
|
if (collectionEntity.getStatus().equals("0")) {
|
|
|
|
|
QueryWrapper<Collection_item0Entity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(Collection_item0Entity::getCollectionId, id);
|
|
|
|
|
List<Collection_item0Entity> collection_item0EntityList = collection_item0Service.list(queryWrapper);//查询收款单子表信息
|
|
|
|
|
for (Collection_item0Entity collection_item0Entity : collection_item0EntityList) {
|
|
|
|
|
BigDecimal sum = new BigDecimal(0);
|
|
|
|
|
SaleorderitemEntity saleordercetEntity = saleorderitemService.getById(collection_item0Entity.getSalesorderId());//查询销售订单信息
|
|
|
|
|
if (saleordercetEntity.getAmountCollected() == null) {
|
|
|
|
|
saleordercetEntity.setAmountCollected(new BigDecimal(0));
|
|
|
|
|
}
|
|
|
|
|
// if (saleordercetEntity.getAmountCollected().equals(saleordercetEntity.getPrice())) {
|
|
|
|
|
// return ActionResult.fail("已回款金额等于金额");
|
|
|
|
|
// }
|
|
|
|
|
if (collectionEntity.getAmountCollected() == null || collectionEntity.getAmountCollected().compareTo(BigDecimal.ZERO) < 1) {
|
|
|
|
|
return ActionResult.fail("请先输入回款金额");
|
|
|
|
|
} else {
|
|
|
|
|
sum = saleordercetEntity.getAmountCollected().add(collection_item0Entity.getAmount());
|
|
|
|
|
if (sum.compareTo(saleordercetEntity.getPrice()) > 0) {
|
|
|
|
|
return ActionResult.fail("总回款金额大于金额");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
QueryWrapper<Salesorder_item0Entity> queryWrapper1 = new QueryWrapper<>();
|
|
|
|
|
queryWrapper1.lambda().eq(Salesorder_item0Entity::getSalesOrderId,saleordercetEntity.getId());
|
|
|
|
|
List<Salesorder_item0Entity> list = salesorder_item0Service.list(queryWrapper1);
|
|
|
|
|
List<PoundlistEntity> poundlist = new ArrayList<>();
|
|
|
|
|
for (Salesorder_item0Entity saleItem : list){
|
|
|
|
|
PoundlistEntity poundlistEntity = collectionService.queryPoundInfo(saleItem.getPoundlistId());
|
|
|
|
|
if (ObjectUtils.isNotEmpty(poundlistEntity)) {
|
|
|
|
|
poundlist.add(poundlistEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (poundlist.size() > 0) {
|
|
|
|
|
poundlist = poundlist.stream().sorted(Comparator.comparing(PoundlistEntity::getAdvance).reversed()
|
|
|
|
|
.thenComparing(Comparator.comparing(PoundlistEntity::getPoundDate))).collect(Collectors.toList());
|
|
|
|
|
}else{
|
|
|
|
|
return ActionResult.fail("磅单为空");
|
|
|
|
|
}
|
|
|
|
|
BigDecimal amount = new BigDecimal(0);
|
|
|
|
|
List<PoundlistEntity> poundlist1 = new ArrayList<>();
|
|
|
|
|
for (PoundlistEntity pound : poundlist){
|
|
|
|
|
if (pound.getSalesPrice()!=null && pound.getSettlement()!=null) {
|
|
|
|
|
amount = amount.add(pound.getSalesPrice().multiply(pound.getSettlement()));
|
|
|
|
|
if (amount.compareTo(sum) < 1) {
|
|
|
|
|
poundlist1.add(pound);
|
|
|
|
|
}else{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (PoundlistEntity poundlistEntity : poundlist1){
|
|
|
|
|
poundlistEntity.setIsCollection("1");
|
|
|
|
|
if (poundlistEntity.getPaymentDate() == null){
|
|
|
|
|
poundlistEntity.setPaymentDate(new Date());
|
|
|
|
|
}
|
|
|
|
|
poundlistService.updateById(poundlistEntity);
|
|
|
|
|
}
|
|
|
|
|
saleordercetEntity.setAmountCollected(sum);
|
|
|
|
|
// saleordercetEntity.setStatus("3");
|
|
|
|
|
saleorderitemService.updateById(saleordercetEntity);
|
|
|
|
|
collectionEntity.setStatus("1");
|
|
|
|
|
collectionService.updateById(collectionEntity);
|
|
|
|
|
return ActionResult.success("提交成功");
|
|
|
|
|
}
|
|
|
|
|
collectionEntity.setStatus("1");
|
|
|
|
|
collectionService.updateById(collectionEntity);
|
|
|
|
|
return ActionResult.success("提交成功");
|
|
|
|
|
} else {
|
|
|
|
|
return ActionResult.fail("数据为空");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.fail("请选择一条数据");
|
|
|
|
@ -140,83 +203,24 @@ public class CollectionController {
|
|
|
|
|
public ActionResult confirmPrice(@PathVariable("ids") String ids) {
|
|
|
|
|
String[] idList = ids.split(",");
|
|
|
|
|
for (String id : idList) {
|
|
|
|
|
CollectionEntity collectionEntity = collectionService.getInfo(id);
|
|
|
|
|
if (collectionEntity.getStatus().equals("0")){
|
|
|
|
|
return ActionResult.fail("提交中");
|
|
|
|
|
}
|
|
|
|
|
if (collectionEntity.getStatus().equals("2")){
|
|
|
|
|
return ActionResult.fail("已认款");
|
|
|
|
|
}
|
|
|
|
|
if (collectionEntity.getStatus().equals("1")) {
|
|
|
|
|
QueryWrapper<Collection_item0Entity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(Collection_item0Entity::getCollectionId, id);
|
|
|
|
|
List<Collection_item0Entity> collection_item0EntityList = collection_item0Service.list(queryWrapper);//查询收款单子表信息
|
|
|
|
|
for (Collection_item0Entity collection_item0Entity : collection_item0EntityList) {
|
|
|
|
|
BigDecimal sum = new BigDecimal(0);
|
|
|
|
|
SaleorderitemEntity saleordercetEntity = saleorderitemService.getById(collection_item0Entity.getSalesorderId());//查询销售订单信息
|
|
|
|
|
if (saleordercetEntity.getAmountCollected() == null) {
|
|
|
|
|
saleordercetEntity.setAmountCollected(new BigDecimal(0));
|
|
|
|
|
}
|
|
|
|
|
if (saleordercetEntity.getAmountCollected().equals(saleordercetEntity.getPrice())) {
|
|
|
|
|
return ActionResult.fail("已回款金额等于金额");
|
|
|
|
|
}
|
|
|
|
|
if (saleordercetEntity.getAmountCollected() != null && collection_item0Entity.getAmount() != null) {
|
|
|
|
|
sum = saleordercetEntity.getAmountCollected().add(collection_item0Entity.getAmount());
|
|
|
|
|
if (sum.compareTo(saleordercetEntity.getPrice()) > 0) {
|
|
|
|
|
return ActionResult.fail("总回款金额大于金额");
|
|
|
|
|
}
|
|
|
|
|
// saleordercetEntity.setAmountCollected(sum);
|
|
|
|
|
// saleordercetEntity.setStatus("3");
|
|
|
|
|
// saleorderitemService.updateById(saleordercetEntity);
|
|
|
|
|
} else {
|
|
|
|
|
return ActionResult.fail("已回款金额或回款金额不能为空");
|
|
|
|
|
}
|
|
|
|
|
QueryWrapper<Salesorder_item0Entity> queryWrapper1 = new QueryWrapper<>();
|
|
|
|
|
queryWrapper1.lambda().eq(Salesorder_item0Entity::getSalesOrderId,saleordercetEntity.getId());
|
|
|
|
|
List<Salesorder_item0Entity> list = salesorder_item0Service.list(queryWrapper1);
|
|
|
|
|
List<PoundlistEntity> poundlist = new ArrayList<>();
|
|
|
|
|
// List<PoundlistEntity> poundsort = new LinkedList<>();
|
|
|
|
|
for (Salesorder_item0Entity saleItem : list){
|
|
|
|
|
PoundlistEntity poundlistEntity = collectionService.queryPoundInfo(saleItem.getPoundlistId());
|
|
|
|
|
if (ObjectUtils.isNotEmpty(poundlistEntity)) {
|
|
|
|
|
poundlist.add(poundlistEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (poundlist.size() > 0) {
|
|
|
|
|
poundlist = poundlist.stream().sorted(Comparator.comparing(PoundlistEntity::getAdvance).reversed()
|
|
|
|
|
.thenComparing(Comparator.comparing(PoundlistEntity::getPoundDate))).collect(Collectors.toList());
|
|
|
|
|
}else{
|
|
|
|
|
return ActionResult.fail("磅单为空");
|
|
|
|
|
CollectionEntity collectionEntity = collectionService.getInfo(id);
|
|
|
|
|
if (ObjectUtils.isNotEmpty(collectionEntity)) {
|
|
|
|
|
if (collectionEntity.getStatus().equals("0")) {
|
|
|
|
|
return ActionResult.fail("请先提交");
|
|
|
|
|
}
|
|
|
|
|
BigDecimal amount = new BigDecimal(0);
|
|
|
|
|
List<PoundlistEntity> poundlist1 = new ArrayList<>();
|
|
|
|
|
for (PoundlistEntity pound : poundlist){
|
|
|
|
|
if (pound.getSalesPrice()!=null && pound.getSettlement()!=null) {
|
|
|
|
|
amount = amount.add(pound.getSalesPrice().multiply(pound.getSettlement()));
|
|
|
|
|
if (amount.compareTo(sum) < 1) {
|
|
|
|
|
poundlist1.add(pound);
|
|
|
|
|
}else{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (collectionEntity.getStatus().equals("2")) {
|
|
|
|
|
return ActionResult.fail("已认款,无需再次提交");
|
|
|
|
|
}
|
|
|
|
|
for (PoundlistEntity poundlistEntity : poundlist1){
|
|
|
|
|
poundlistEntity.setIsCollection("1");
|
|
|
|
|
if (poundlistEntity.getPaymentDate() == null){
|
|
|
|
|
poundlistEntity.setPaymentDate(new Date());
|
|
|
|
|
}
|
|
|
|
|
saleordercetEntity.setAmountCollected(sum);
|
|
|
|
|
// saleordercetEntity.setStatus("3");
|
|
|
|
|
saleorderitemService.updateById(saleordercetEntity);
|
|
|
|
|
poundlistService.updateById(poundlistEntity);
|
|
|
|
|
collectionEntity.setStatus("2");
|
|
|
|
|
collectionService.updateById(collectionEntity);
|
|
|
|
|
return ActionResult.success("认款成功");
|
|
|
|
|
if (collectionEntity.getAmountCollected() == null || collectionEntity.getAmountCollected().compareTo(BigDecimal.ZERO) < 1) {
|
|
|
|
|
return ActionResult.fail("请先输入收款金额");
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.fail("收款金额不足");
|
|
|
|
|
collectionEntity.setStatus("2");
|
|
|
|
|
collectionService.updateById(collectionEntity);
|
|
|
|
|
return ActionResult.success("认款成功");
|
|
|
|
|
} else {
|
|
|
|
|
return ActionResult.fail("数据为空");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.fail("请选择一条数据");
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
@ -258,9 +262,21 @@ public class CollectionController {
|
|
|
|
|
@PostMapping
|
|
|
|
|
@Transactional
|
|
|
|
|
public ActionResult create(@RequestBody @Valid CollectionCrForm collectionCrForm) throws DataException {
|
|
|
|
|
if (collectionCrForm.getCollection_item0List().size()>0) {
|
|
|
|
|
SaleorderitemEntity saleorderitemEntity = saleorderitemService.getInfo(collectionCrForm.getCollection_item0List().get(0).getSalesorderId());
|
|
|
|
|
if (saleorderitemEntity.getAmountCollected() == null){
|
|
|
|
|
saleorderitemEntity.setAmountCollected(new BigDecimal(0));
|
|
|
|
|
}
|
|
|
|
|
if (saleorderitemEntity.getAmountCollected().equals(saleorderitemEntity.getPrice()) ||
|
|
|
|
|
saleorderitemEntity.getAmountCollected().compareTo(saleorderitemEntity.getPrice()) == 1){
|
|
|
|
|
return ActionResult.fail("已回完款,无需回款");
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
return ActionResult.fail("销售订单不存在");
|
|
|
|
|
}
|
|
|
|
|
String mainId =RandomUtil.uuId();
|
|
|
|
|
UserInfo userInfo=userProvider.get();
|
|
|
|
|
collectionCrForm.setDocumentNo(generaterSwapUtil.getBillNumber("collection", false));
|
|
|
|
|
// collectionCrForm.setDocumentNo(generaterSwapUtil.getBillNumber("collection", false));
|
|
|
|
|
CollectionEntity entity = JsonUtil.getJsonToBean(collectionCrForm, CollectionEntity.class);
|
|
|
|
|
entity.setId(mainId);
|
|
|
|
|
collectionService.save(entity);
|
|
|
|
@ -437,20 +453,22 @@ public class CollectionController {
|
|
|
|
|
|
|
|
|
|
//子表
|
|
|
|
|
List<Collection_item0Entity> Collection_item0List = collectionService.GetCollection_item0List(id);
|
|
|
|
|
for(Collection_item0Entity collection_item0Entity : Collection_item0List){
|
|
|
|
|
QueryWrapper<SaleorderitemEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(SaleorderitemEntity::getId,collection_item0Entity.getSalesorderId());
|
|
|
|
|
SaleorderitemEntity saleorderitemEntity = saleorderitemService.getOne(queryWrapper);
|
|
|
|
|
collection_item0Entity.setPrice(saleorderitemEntity.getPrice());
|
|
|
|
|
collection_item0Entity.setAmountCollected(saleorderitemEntity.getAmountCollected());
|
|
|
|
|
collection_item0Entity.setContractId(saleorderitemEntity.getContractId());
|
|
|
|
|
collection_item0Entity.setSalesorderId(saleorderitemEntity.getId());
|
|
|
|
|
collection_item0Entity.setCreatorTime(saleorderitemEntity.getCreatorTime());
|
|
|
|
|
collection_item0Entity.setNum(saleorderitemEntity.getNum());
|
|
|
|
|
collection_item0Entity.setAdvanceAmount(saleorderitemEntity.getAdvanceAmount());
|
|
|
|
|
collection_item0Entity.setRate(saleorderitemEntity.getRate());
|
|
|
|
|
collection_item0Entity.setNotPrice(saleorderitemEntity.getNotPrice());
|
|
|
|
|
}
|
|
|
|
|
for(Collection_item0Entity collection_item0Entity : Collection_item0List) {
|
|
|
|
|
QueryWrapper<SaleorderitemEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(SaleorderitemEntity::getId, collection_item0Entity.getSalesorderId());
|
|
|
|
|
SaleorderitemEntity saleorderitemEntity = saleorderitemService.getOne(queryWrapper);
|
|
|
|
|
if (ObjectUtils.isNotEmpty(saleorderitemEntity)) {
|
|
|
|
|
collection_item0Entity.setPrice(saleorderitemEntity.getPrice());
|
|
|
|
|
collection_item0Entity.setAmountCollected(saleorderitemEntity.getAmountCollected());
|
|
|
|
|
collection_item0Entity.setContractId(saleorderitemEntity.getContractId());
|
|
|
|
|
collection_item0Entity.setSalesorderId(saleorderitemEntity.getId());
|
|
|
|
|
collection_item0Entity.setCreatorTime(saleorderitemEntity.getCreatorTime());
|
|
|
|
|
collection_item0Entity.setNum(saleorderitemEntity.getNum());
|
|
|
|
|
collection_item0Entity.setAdvanceAmount(saleorderitemEntity.getAdvanceAmount());
|
|
|
|
|
collection_item0Entity.setRate(saleorderitemEntity.getRate());
|
|
|
|
|
collection_item0Entity.setNotPrice(saleorderitemEntity.getNotPrice());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
vo.setCollection_item0List(JsonUtil.getJsonToList(Collection_item0List,Collection_item0Model.class ));
|
|
|
|
|
//副表
|
|
|
|
|
return ActionResult.success(vo);
|
|
|
|
@ -470,23 +488,25 @@ public class CollectionController {
|
|
|
|
|
//子表数据转换
|
|
|
|
|
List<Collection_item0Entity> jg_collection_item0List = collectionService.GetCollection_item0List(id);
|
|
|
|
|
List<Collection_item0Model> jg_collection_item0ModelList = JsonUtil.getJsonToList(jg_collection_item0List,Collection_item0Model.class);
|
|
|
|
|
for(Collection_item0Model jg_collection_item0Model : jg_collection_item0ModelList){
|
|
|
|
|
for(Collection_item0Model jg_collection_item0Model : jg_collection_item0ModelList) {
|
|
|
|
|
QueryWrapper<SaleorderitemEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(SaleorderitemEntity::getId,jg_collection_item0Model.getSalesorderId());
|
|
|
|
|
queryWrapper.lambda().eq(SaleorderitemEntity::getId, jg_collection_item0Model.getSalesorderId());
|
|
|
|
|
SaleorderitemEntity saleorderitemEntity = saleorderitemService.getOne(queryWrapper);
|
|
|
|
|
jg_collection_item0Model.setPrice(String.valueOf(saleorderitemEntity.getPrice()));
|
|
|
|
|
jg_collection_item0Model.setAmountCollected(String.valueOf(saleorderitemEntity.getAmountCollected()));
|
|
|
|
|
jg_collection_item0Model.setContractId(saleorderitemEntity.getContractId());
|
|
|
|
|
jg_collection_item0Model.setSalesorderId(saleorderitemEntity.getDocumentNo());
|
|
|
|
|
jg_collection_item0Model.setNum(String.valueOf(saleorderitemEntity.getNum()));
|
|
|
|
|
jg_collection_item0Model.setAdvanceAmount(String.valueOf(saleorderitemEntity.getAdvanceAmount()));
|
|
|
|
|
jg_collection_item0Model.setRate(String.valueOf(saleorderitemEntity.getRate()));
|
|
|
|
|
jg_collection_item0Model.setNotPrice(String.valueOf(saleorderitemEntity.getNotPrice()));
|
|
|
|
|
if (ObjectUtils.isNotEmpty(saleorderitemEntity)) {
|
|
|
|
|
jg_collection_item0Model.setPrice(String.valueOf(saleorderitemEntity.getPrice()));
|
|
|
|
|
jg_collection_item0Model.setAmountCollected(String.valueOf(saleorderitemEntity.getAmountCollected()));
|
|
|
|
|
jg_collection_item0Model.setContractId(saleorderitemEntity.getContractId());
|
|
|
|
|
jg_collection_item0Model.setSalesorderId(saleorderitemEntity.getDocumentNo());
|
|
|
|
|
jg_collection_item0Model.setNum(String.valueOf(saleorderitemEntity.getNum()));
|
|
|
|
|
jg_collection_item0Model.setAdvanceAmount(String.valueOf(saleorderitemEntity.getAdvanceAmount()));
|
|
|
|
|
jg_collection_item0Model.setRate(String.valueOf(saleorderitemEntity.getRate()));
|
|
|
|
|
jg_collection_item0Model.setNotPrice(String.valueOf(saleorderitemEntity.getNotPrice()));
|
|
|
|
|
// Map<String,Object> salesorderIdMap = new HashMap<>();
|
|
|
|
|
// jg_collection_item0Model.setSalesorderId(generaterSwapUtil.getPopupSelectValue("400235058386036741","id","document_no",jg_collection_item0Model.getSalesorderId(),salesorderIdMap));
|
|
|
|
|
Map<String,Object> deleteTimeMap = new HashMap<>();
|
|
|
|
|
jg_collection_item0Model.setContractId(generaterSwapUtil.getPopupSelectValue("398848549678332037","id","contract_code",jg_collection_item0Model.getContractId(),deleteTimeMap));
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> deleteTimeMap = new HashMap<>();
|
|
|
|
|
jg_collection_item0Model.setContractId(generaterSwapUtil.getPopupSelectValue("398848549678332037", "id", "contract_code", jg_collection_item0Model.getContractId(), deleteTimeMap));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
vo.setCollection_item0List(jg_collection_item0ModelList);
|
|
|
|
|
|
|
|
|
|
//附表数据转换
|
|
|
|
|