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.
153 lines
5.5 KiB
Java
153 lines
5.5 KiB
Java
package com.gszc.service.impl;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
import com.gszc.entity.*;
|
|
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>().eq("1","1").orderBy("create_date", false));
|
|
return industryList;
|
|
}
|
|
|
|
public List<InvoiceCategory> queryInvoiceCategoryList(){
|
|
List<InvoiceCategory> InvoiceCategoryList = invoiceCategoryMapper.selectList(new EntityWrapper<InvoiceCategory>().eq("1","1").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;
|
|
}
|
|
|
|
public JSONObject queryPark(Integer pageNum, Integer pageSize){
|
|
|
|
Integer count = parkMapper.selectCount(new EntityWrapper<Park>());
|
|
List<Park> result = parkMapper.selectPage(new Page<>((pageNum - 1) * pageSize, pageSize), new EntityWrapper<Park>().eq("1", "1").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);
|
|
|
|
String invoiceCategory = park.getInvoiceCategory();
|
|
String[] split1 = invoiceCategory.split(",");
|
|
JSONArray jsonArray1 = new JSONArray();
|
|
for(int i=0;i<split1.length;i++){
|
|
InvoiceCategory invoiceCategory1 = invoiceCategoryMapper.selectById(split1[i]);
|
|
jsonArray1.add(invoiceCategory1);
|
|
}
|
|
park.setInvoiceCategoryList(jsonArray1);
|
|
}
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("count",count);
|
|
jsonObject.put("data",result);
|
|
return jsonObject;
|
|
}
|
|
|
|
public List<Park> queryParkList(){
|
|
List<Park> result = parkMapper.selectList(new EntityWrapper<Park>().eq("1", "1").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);
|
|
|
|
String invoiceCategory = park.getInvoiceCategory();
|
|
String[] split1 = invoiceCategory.split(",");
|
|
JSONArray jsonArray1 = new JSONArray();
|
|
for(int i=0;i<split1.length;i++){
|
|
InvoiceCategory invoiceCategory1 = invoiceCategoryMapper.selectById(split1[i]);
|
|
jsonArray1.add(invoiceCategory1);
|
|
}
|
|
park.setInvoiceCategoryList(jsonArray1);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
}
|