You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
3.1 KiB
Java

5 years ago
package com.gszc.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.gszc.entity.Industry;
import com.gszc.entity.InvoiceCategory;
import com.gszc.entity.Park;
import com.gszc.entity.Park;
import com.gszc.mapper.IndustryMapper;
import com.gszc.mapper.InvoiceCategoryMapper;
import com.gszc.mapper.ParkMapper;
import com.gszc.mapper.ParkMapper;
import com.gszc.service.IParkService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
* <p>
*
* </p>
*
* @author ky
* @since 2020-05-26
*/
@Service
@Transactional
public class ParkServiceImpl extends ServiceImpl<ParkMapper, Park> implements IParkService {
@Autowired
ParkMapper parkMapper;
@Autowired
IndustryMapper industryMapper;
@Autowired
InvoiceCategoryMapper invoiceCategoryMapper;
public void addPark(Park park){
String id = UUID.randomUUID().toString();
park.setId(id);
park.setCreateDate(new Date());
park.setModifyDate(new Date());
parkMapper.insert(park);
}
public void deletePark(Park park){
parkMapper.deleteById(park);
}
public void updatePark(Park park){
parkMapper.updateById(park);
}
public List<Park> queryParkByCompanyType(String type){
List<Park> result = parkMapper.selectList(new EntityWrapper<Park>().like("company_category", type).orderBy("create_date", false));
for(Park park:result){
String industryCategory = park.getIndustryCategory();
String[] split = industryCategory.split(",");
JSONArray jsonArray = new JSONArray();
for(int i=0;i<split.length;i++){
Industry industry = industryMapper.selectById(split[i]);
jsonArray.add(industry);
}
park.setIndustry(jsonArray);
}
return result;
}
public List<Industry> queryIndustryList(){
List<Industry> industryList = industryMapper.selectList(new EntityWrapper<Industry>().orderBy("create_date", false));
return industryList;
}
public List<InvoiceCategory> queryInvoiceCategoryList(){
List<InvoiceCategory> InvoiceCategoryList = invoiceCategoryMapper.selectList(new EntityWrapper<InvoiceCategory>().orderBy("id", true));
return InvoiceCategoryList;
}
public List<InvoiceCategory> queryInvoiceCategoryByPark(String parkId) {
List<InvoiceCategory> list = new ArrayList<>();
Park park = parkMapper.selectById(parkId);
String invoiceCategory = park.getInvoiceCategory();
String[] split = invoiceCategory.split(",");
for(int i = 0;i<split.length;i++){
InvoiceCategory invoiceCategory1 = invoiceCategoryMapper.selectById(split[i]);
list.add(invoiceCategory1);
}
return list;
}
}