Commit dece5625 authored by luben's avatar luben

Merge branch 'dev-lb' into 'dev'

Dev lb

See merge request !20
parents f3f910da 3874ebfb
...@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.math.BigDecimal;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -77,6 +78,18 @@ public class CompanyEconomyInfoController { ...@@ -77,6 +78,18 @@ public class CompanyEconomyInfoController {
*/ */
@PostMapping(value = "/save") @PostMapping(value = "/save")
public AjaxResult save(@RequestBody GridCompanyEconomyInfoExt infoExt) { public AjaxResult save(@RequestBody GridCompanyEconomyInfoExt infoExt) {
infoExt.setYearSales(infoExt.getSales().toString());
infoExt.setYearTaxes(infoExt.getTaxes().toString());
int sale = 0;
for(String s:infoExt.getSales()){
sale += Integer.parseInt(s);
}
infoExt.setSale(BigDecimal.valueOf(sale));
int tax = 0;
for (String s:infoExt.getTaxes()){
tax += Integer.parseInt(s);
}
infoExt.setTax(BigDecimal.valueOf(tax));
companyEconomyInfoService.save(infoExt); companyEconomyInfoService.save(infoExt);
return AjaxResult.success("提交成功"); return AjaxResult.success("提交成功");
} }
......
package com.ruoyi.web.controller.other;
import com.alibaba.fastjson2.JSON;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.other.Labels;
import com.ruoyi.system.domain.other.LabelsExample;
import com.ruoyi.system.domain.other.vo.LabelsVO;
import com.ruoyi.system.service.other.LabelsFacadeService;
import com.ruoyi.system.service.other.LabelsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Auther: hxc
* @Date: 2019/6/18 0028 14:09
* @Description: 数据字典
*/
@Api(tags = "基本配置 - 数据字典")
@RestController
@RequestMapping("/api/labels")
public class LabelsController extends BaseController {
@Autowired
private LabelsFacadeService commonService;
@Autowired
private LabelsService bsCommonService;
@ApiOperation("列表")
@RequestMapping(value = "/list", method = RequestMethod.POST)
@ResponseBody
public TableDataInfo getCommons(@RequestBody LabelsVO bsCommonVO) {
PageHelper.startPage(bsCommonVO.getPageNum(),bsCommonVO.getPageSize());
LabelsExample example = new LabelsExample();
LabelsExample.Criteria criteria = example.createCriteria();
if (StringUtils.isNotEmpty(bsCommonVO.getParentId())) {
criteria.andParentIdEqualTo(bsCommonVO.getParentId());
}else{
criteria.andParentIdIsNull();
}
example.setOrderByClause(" sort + 0 asc ");
List<Labels> list = bsCommonService.selectByExample(example);
return getDataTable(list);
}
@ApiOperation("删除")
@RequestMapping(value = "", method = RequestMethod.DELETE)
@ResponseBody
public String delete(@RequestBody Labels body) {
try {
return commonService.commit(body, "delete");
} catch (Exception e) {
e.printStackTrace();
return JSON.toJSONString(AjaxResult.error(500, "服务器内部错误"));
}
}
@ApiOperation("创建")
@RequestMapping(value = "", method = RequestMethod.POST)
@ResponseBody
public String insert(@RequestBody Labels body) {
try {
return commonService.commit(body, "insert");
} catch (Exception e) {
e.printStackTrace();
return JSON.toJSONString(AjaxResult.error(500, "服务器内部错误"));
}
}
@ApiOperation("更新")
@RequestMapping(value = "", method = RequestMethod.PATCH)
@ResponseBody
public String update(@RequestBody Labels body) {
try {
return commonService.commit(body, "update");
} catch (Exception e) {
e.printStackTrace();
return JSON.toJSONString(AjaxResult.error(500, "服务器内部错误"));
}
}
@ApiOperation("树结构")
@RequestMapping(value = "/getTreeNode", method = RequestMethod.POST)
@ResponseBody
public AjaxResult getTreeNode(@RequestBody LabelsVO bsCommonVO) {
try {
return commonService.getTreeNode(bsCommonVO);
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error(500, "服务器内部错误");
}
}
@Anonymous
@ApiOperation("获取网格列表")
@RequestMapping(value = "/getWgdxList", method = RequestMethod.GET)
@ResponseBody
public String getWgdxList(@RequestParam(name = "code") String code) {
try {
List<Labels> wgdxList = bsCommonService.getWgdxList(code);
return JSON.toJSONString(AjaxResult.success(wgdxList));
} catch (Exception e) {
e.printStackTrace();
return JSON.toJSONString(AjaxResult.error(500, "服务器内部错误"));
}
}
}
package com.ruoyi.system.domain.grid; package com.ruoyi.system.domain.grid;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
@Data
public class GridCompanyEconomyInfo implements Serializable { public class GridCompanyEconomyInfo implements Serializable {
private String id; private String id;
...@@ -58,71 +62,79 @@ public class GridCompanyEconomyInfo implements Serializable { ...@@ -58,71 +62,79 @@ public class GridCompanyEconomyInfo implements Serializable {
private String companyName; private String companyName;
private static final long serialVersionUID = 1L; private List<String> sales;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
public BigDecimal getSale() {
return sale;
}
public void setSale(BigDecimal sale) {
this.sale = sale;
}
public BigDecimal getTax() {
return tax;
}
public void setTax(BigDecimal tax) {
this.tax = tax;
}
public BigDecimal getPerMu() {
return perMu;
}
public void setPerMu(BigDecimal perMu) { private List<String> taxes;
this.perMu = perMu;
}
public String getYear() { private String yearSales;
return year;
}
public void setYear(String year) { private String yearTaxes;
this.year = year;
}
public String getIsValid() { private static final long serialVersionUID = 1L;
return isValid;
}
public void setIsValid(String isValid) {
this.isValid = isValid;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) { // public String getId() {
this.createTime = createTime; // return id;
} // }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getCompanyId() {
// return companyId;
// }
//
// public void setCompanyId(String companyId) {
// this.companyId = companyId;
// }
//
// public BigDecimal getSale() {
// return sale;
// }
//
// public void setSale(BigDecimal sale) {
// this.sale = sale;
// }
//
// public BigDecimal getTax() {
// return tax;
// }
//
// public void setTax(BigDecimal tax) {
// this.tax = tax;
// }
//
// public BigDecimal getPerMu() {
// return perMu;
// }
//
// public void setPerMu(BigDecimal perMu) {
// this.perMu = perMu;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public String getIsValid() {
// return isValid;
// }
//
// public void setIsValid(String isValid) {
// this.isValid = isValid;
// }
//
// public String getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(String createTime) {
// this.createTime = createTime;
// }
@Override @Override
public String toString() { public String toString() {
......
package com.ruoyi.system.domain.other;
import java.io.Serializable;
public class Labels implements Serializable {
/**
* ID
*
* @mbg.generated
*/
private String id;
private String code;
/**
* 字段名
*
* @mbg.generated
*/
private String name;
/**
* 描述
* 若是选人,这里是names
* @mbg.generated
*/
private String description;
/**
* 父节点
*
* @mbg.generated
*/
private String parentId;
/**
* 是否有效 0:无效 1:有效
*
* @mbg.generated
*/
private String isValid;
/**
* 排序
*
* @mbg.generated
*/
private String sort;
//若是选人,这里是ids
private String ylzd1;
private String ylzd2;
private String ylzd3;
private String ylzd4;
private String ylzd5;
private static final long serialVersionUID = 1L;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getIsValid() {
return isValid;
}
public void setIsValid(String isValid) {
this.isValid = isValid;
}
public String getSort() {
return sort;
}
public void setSort(String sort) {
this.sort = sort;
}
public String getYlzd1() {
return ylzd1;
}
public void setYlzd1(String ylzd1) {
this.ylzd1 = ylzd1;
}
public String getYlzd2() {
return ylzd2;
}
public void setYlzd2(String ylzd2) {
this.ylzd2 = ylzd2;
}
public String getYlzd3() {
return ylzd3;
}
public void setYlzd3(String ylzd3) {
this.ylzd3 = ylzd3;
}
public String getYlzd4() {
return ylzd4;
}
public void setYlzd4(String ylzd4) {
this.ylzd4 = ylzd4;
}
public String getYlzd5() {
return ylzd5;
}
public void setYlzd5(String ylzd5) {
this.ylzd5 = ylzd5;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", code=").append(code);
sb.append(", name=").append(name);
sb.append(", description=").append(description);
sb.append(", parentId=").append(parentId);
sb.append(", isValid=").append(isValid);
sb.append(", sort=").append(sort);
sb.append(", ylzd1=").append(ylzd1);
sb.append(", ylzd2=").append(ylzd2);
sb.append(", ylzd3=").append(ylzd3);
sb.append(", ylzd4=").append(ylzd4);
sb.append(", ylzd5=").append(ylzd5);
sb.append("]");
return sb.toString();
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
BsCommon other = (BsCommon) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()))
&& (this.getParentId() == null ? other.getParentId() == null : this.getParentId().equals(other.getParentId()))
&& (this.getIsValid() == null ? other.getIsValid() == null : this.getIsValid().equals(other.getIsValid()))
&& (this.getSort() == null ? other.getSort() == null : this.getSort().equals(other.getSort()))
&& (this.getYlzd1() == null ? other.getYlzd1() == null : this.getYlzd1().equals(other.getYlzd1()))
&& (this.getYlzd2() == null ? other.getYlzd2() == null : this.getYlzd2().equals(other.getYlzd2()))
&& (this.getYlzd3() == null ? other.getYlzd3() == null : this.getYlzd3().equals(other.getYlzd3()))
&& (this.getYlzd4() == null ? other.getYlzd4() == null : this.getYlzd4().equals(other.getYlzd4()))
&& (this.getYlzd5() == null ? other.getYlzd5() == null : this.getYlzd5().equals(other.getYlzd5()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
result = prime * result + ((getParentId() == null) ? 0 : getParentId().hashCode());
result = prime * result + ((getIsValid() == null) ? 0 : getIsValid().hashCode());
result = prime * result + ((getSort() == null) ? 0 : getSort().hashCode());
result = prime * result + ((getYlzd1() == null) ? 0 : getYlzd1().hashCode());
result = prime * result + ((getYlzd2() == null) ? 0 : getYlzd2().hashCode());
result = prime * result + ((getYlzd3() == null) ? 0 : getYlzd3().hashCode());
result = prime * result + ((getYlzd4() == null) ? 0 : getYlzd4().hashCode());
result = prime * result + ((getYlzd5() == null) ? 0 : getYlzd5().hashCode());
return result;
}
}
package com.ruoyi.system.domain.other.vo;
/**
* @Auther: hxc
* @Date: 2019/6/18 0018 15:46
* @Description:
*/
public class LabelsVO {
private String Id;
private String parentId;
private String code;
private Integer pageNum;
private Integer pageSize;
public String getId() {
return Id;
}
public void setId(String id) {
Id = id;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}
package com.ruoyi.system.mapper.other;
import com.ruoyi.system.domain.other.Labels;
import com.ruoyi.system.domain.other.LabelsExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface LabelsMapper {
long countByExample(LabelsExample example);
int deleteByExample(LabelsExample example);
int deleteByPrimaryKey(String id);
int insert(Labels record);
int insertSelective(Labels record);
Labels selectByPrimaryKey(String id);
List<Labels> selectByExample(LabelsExample example);
int updateByExampleSelective(@Param("record") Labels record, @Param("example") LabelsExample example);
int updateByPrimaryKeySelective(Labels record);
int updateByExample(@Param("record") Labels record, @Param("example") LabelsExample example);
List<Labels> getWgdxList(String code);
}
\ No newline at end of file
...@@ -79,7 +79,12 @@ public class GridCompanyEconomyInfoServiceImpl extends BaseServiceImpl<GridCompa ...@@ -79,7 +79,12 @@ public class GridCompanyEconomyInfoServiceImpl extends BaseServiceImpl<GridCompa
} }
criteria.andIsValidEqualTo("1"); criteria.andIsValidEqualTo("1");
example.setOrderByClause(" year desc "); example.setOrderByClause(" year desc ");
return gridCompanyEconomyInfoMapper.selectByExample(example); List<GridCompanyEconomyInfo> res = gridCompanyEconomyInfoMapper.selectByExample(example);
for (GridCompanyEconomyInfo info : res) {
info.setSales(Arrays.asList(info.getYearSales().substring(1, info.getYearSales().length()-1).split(",")));
info.setTaxes(Arrays.asList(info.getYearTaxes().substring(1, info.getYearTaxes().length()-1).split(",")));
}
return res;
} }
@Override @Override
......
package com.ruoyi.system.service.other;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.other.Labels;
import com.ruoyi.system.domain.other.LabelsExample;
import com.ruoyi.system.domain.other.vo.LabelsVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.lang.reflect.Method;
import java.util.*;
/**
* @Auther: hxc
* @Date: 2019/6/18 0018 09:23
* @Description: 数据字典
*/
@Component
public class LabelsFacadeService {
@Autowired
private LabelsService bsCommonService;
public String commit(Labels body, String method) {
try {
AjaxResult result = new AjaxResult();
Method methodCheck = null;
try {
methodCheck = this.getClass().getMethod(method + "Pre", body.getClass(), result.getClass());
} catch (Exception e) {
methodCheck = null;
}
if (null != methodCheck) {
Object ret = methodCheck.invoke(this, body, result);
if ((ret instanceof Boolean) && !(boolean) ret) {
return JSON.toJSONString(result);
}
}
Method methodCommit = null;
try {
methodCommit = this.getClass().getMethod(method, body.getClass(), result.getClass());
} catch (Exception e) {
methodCommit = null;
}
if (null == methodCommit) {
return JSON.toJSONString(AjaxResult.error(600, "方法未找到:" + method));
}
methodCommit.invoke(this, body, result);
return JSON.toJSONString(result);
} catch (Exception e) {
e.printStackTrace();
return JSON.toJSONString(AjaxResult.error(500, "服务器内部错误"));
}
}
public boolean insertPre(Labels body, AjaxResult result) {
if (null == body) {
result.buildError(500, "body为空");
return false;
}
LabelsExample example = new LabelsExample();
example.createCriteria().andCodeEqualTo(body.getCode());
int count = bsCommonService.countByExample(example);
if (count > 0) {
result.buildError(500, "编码存在,请重新填写!");
return false;
}
return true;
}
public void insert(Labels body, AjaxResult result) {
String id = UUID.randomUUID().toString();
Labels bsCommon = new Labels();
bsCommon.setId(id);
bsCommon.setCode(body.getCode());
bsCommon.setDescription(body.getDescription());
bsCommon.setName(body.getName());
bsCommon.setParentId(body.getParentId());
bsCommon.setIsValid(body.getIsValid());
bsCommon.setSort(body.getSort());
bsCommon.setYlzd1(body.getYlzd1());
bsCommon.setYlzd2(body.getYlzd2());
bsCommon.setYlzd3(body.getYlzd3());
bsCommon.setYlzd4(body.getYlzd4());
bsCommon.setYlzd5(body.getYlzd5());
int ret = bsCommonService.insertSelective(bsCommon);
if (ret > 0) {
result.buildSuccess("success", id);
} else {
result.buildError(600, "新增失败");
}
return;
}
public boolean updatePre(Labels body, AjaxResult result) {
if (null == body) {
result.buildError(500, "body为空");
return false;
}
return true;
}
public void update(Labels body, AjaxResult result) {
String id = body.getId();
Labels bean = get(id, null);
if (null == bean) {
result.buildError(500, "body为空");
return;
}
if (!bean.getCode().equals(body.getCode())) {
LabelsExample example = new LabelsExample();
example.createCriteria().andCodeEqualTo(body.getCode());
int count = bsCommonService.countByExample(example);
if (count > 0) {
result.buildError(500, "编码存在,请重新填写!");
return;
}
}
int ret = bsCommonService.updateByPrimaryKeySelective(body);
if (ret > 0) {
result.buildSuccess("success", id);
} else {
result.buildError(600, "更新失败");
}
return;
}
public Labels get(String id, Labels bsCommon) {
if (null == bsCommon) {
if (StringUtils.isNotEmpty(id)) {
bsCommon = bsCommonService.selectByPrimaryKey(id);
}
if (null == bsCommon) {
return null;
}
}
return bsCommon;
}
public boolean deletePre(Labels body, AjaxResult result) {
if (null == body) {
result.buildError(500, "body为空");
return false;
}
if (!itemIsUUID(body.getId())) {
result.buildError(500, "参数非法");
return false;
}
return true;
}
public void delete(Labels body, AjaxResult result) {
Labels bean = get(body.getId(), null);
if (null == bean) {
result.buildError(500, "找不到该数据");
return;
}
// 如果该网格下有子网格,则无法删除
LabelsExample gridRegionExample = new LabelsExample();
gridRegionExample.createCriteria().andIsValidEqualTo("1").andParentIdEqualTo(body.getId());
int count = bsCommonService.countByExample(gridRegionExample);
if (count > 0) {
result.buildError(600, "有子数据无法删除");
return;
}
// 防止数据残留
int ret = bsCommonService.deleteByStringPrimaryKey(body.getId());
if (ret > 0) {
result.buildSuccess("success", null);
} else {
result.buildError(600, "删除失败");
}
return;
}
public AjaxResult getTreeNode(LabelsVO bsCommonVO) {
LabelsExample bsCommonExample = new LabelsExample();
LabelsExample.Criteria criteria = bsCommonExample.createCriteria();
criteria.andIsValidEqualTo("1");
if(bsCommonVO != null){
if(StringUtils.isNotBlank(bsCommonVO.getCode())){
criteria.andCodeLike("%"+bsCommonVO.getCode()+"%");
}
}
bsCommonExample.setOrderByClause(" sort + 0 ");
List<Labels> bsCommons = bsCommonService.selectByExample(bsCommonExample);
List<Map<String, Object>> jsTreeModels = convertFrBomsCommon(bsCommons);
return AjaxResult.success("success", jsTreeModels);
}
private List<Map<String, Object>> convertFrBomsCommon(List<Labels> bsCommons) {
List<Map<String, Object>> models = new ArrayList<>();
if (!CollectionUtils.isEmpty(bsCommons)) {
for (Labels bsCommon : bsCommons) {
if (StringUtils.isEmpty(bsCommon.getParentId())) {
Map<String, Object> model = new HashMap<>();
model.put("id", bsCommon.getId());
model.put("code", bsCommon.getCode());
model.put("name", bsCommon.getName());
model.put("description", bsCommon.getDescription());
model.put("parentId", bsCommon.getParentId());
model.put("isValid", bsCommon.getIsValid());
model.put("sort", bsCommon.getSort());
List<Map<String, Object>> childrenDocTypes = convertFromWgCodeByParent(bsCommons, bsCommon.getId());
model.put("child", childrenDocTypes);
models.add(model);
}
}
}
return models;
}
private List<Map<String, Object>> convertFromWgCodeByParent(List<Labels> bsCommons, String parentId) {
List<Map<String, Object>> models = new ArrayList<>();
for (Labels bsCommon : bsCommons) {
if (StringUtils.isNotEmpty(bsCommon.getParentId()) && bsCommon.getParentId().equals(parentId)) {
Map<String, Object> model = new HashMap<>();
model.put("id", bsCommon.getId());
model.put("code", bsCommon.getCode());
model.put("name", bsCommon.getName());
model.put("description", bsCommon.getDescription());
model.put("parentId", bsCommon.getParentId());
model.put("isValid", bsCommon.getIsValid());
model.put("sort", bsCommon.getSort());
List<Map<String, Object>> childrenDocTypes = convertFromWgCodeByParent(bsCommons, bsCommon.getId());
model.put("child", childrenDocTypes);
models.add(model);
}
}
return models;
}
private boolean itemIsUUID(String item) {
if (StringUtils.isEmpty(item)) {
return false;
}
return item.matches("(\\w{8}(-\\w{4}){3}-\\w{12}?)");
}
}
package com.ruoyi.system.service.other;
import com.ruoyi.system.domain.other.Labels;
import com.ruoyi.system.domain.other.LabelsExample;
import com.ruoyi.system.service.BaseService;
import java.util.List;
import java.util.Map;
public interface LabelsService extends BaseService<Labels, LabelsExample> {
List<Labels> getWgdxList(String code);
String getName(String code);
String getCode(String name);
List<Labels> getBsCommonMap();
Map<String, String> getMapByCodes(List<String> codes);
}
\ No newline at end of file
package com.ruoyi.system.service.other.impl;
import com.ruoyi.system.domain.other.Labels;
import com.ruoyi.system.domain.other.LabelsExample;
import com.ruoyi.system.listener.MyBaseService;
import com.ruoyi.system.mapper.other.LabelsMapper;
import com.ruoyi.system.service.BaseServiceImpl;
import com.ruoyi.system.service.other.LabelsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author Cesar
* @date ${cTime}
* @desc BsCommonService实现
*/
@Service
@MyBaseService
public class LabelsServiceImpl extends BaseServiceImpl<LabelsMapper, Labels, LabelsExample> implements LabelsService {
private static final Logger LOGGER = LoggerFactory.getLogger(LabelsServiceImpl.class);
@Autowired
private LabelsMapper bsCommonMapper;
@Override
public List<Labels> getWgdxList(String code) {
return bsCommonMapper.getWgdxList(code);
}
@Override
public String getName(String code) {
LabelsExample ex = new LabelsExample();
LabelsExample.Criteria ca = ex.createCriteria();
ca.andCodeEqualTo(code);
ca.andIsValidEqualTo("1");
Labels bsCommon = selectFirstByExample(ex);
if (bsCommon != null) {
return bsCommon.getName();
} else {
return null;
}
}
@Override
public String getCode(String name) {
LabelsExample ex = new LabelsExample();
LabelsExample.Criteria ca = ex.createCriteria();
ca.andNameEqualTo(name);
ca.andIsValidEqualTo("1");
Labels bsCommon = selectFirstByExample(ex);
if (bsCommon != null) {
return bsCommon.getCode();
} else {
return null;
}
}
@Override
public List<Labels> getBsCommonMap() {
LabelsExample ex = new LabelsExample();
LabelsExample.Criteria ca = ex.createCriteria();
ca.andIsValidEqualTo("1");
return this.selectByExample(ex);
}
@Override
public Map<String, String> getMapByCodes(List<String> codes) {
LabelsExample ex = new LabelsExample();
LabelsExample.Criteria ca = ex.createCriteria();
ca.andIsValidEqualTo("1");
ca.andCodeIn(codes);
List<Labels> commonList = bsCommonMapper.selectByExample(ex);
return commonList.stream().collect(Collectors.toMap(Labels::getCode, Labels::getName));
}
}
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
<result column="year" jdbcType="VARCHAR" property="year" /> <result column="year" jdbcType="VARCHAR" property="year" />
<result column="is_valid" jdbcType="VARCHAR" property="isValid" /> <result column="is_valid" jdbcType="VARCHAR" property="isValid" />
<result column="create_time" jdbcType="VARCHAR" property="createTime" /> <result column="create_time" jdbcType="VARCHAR" property="createTime" />
<result column="year_sales" jdbcType="VARCHAR" property="yearSales" />
<result column="year_taxes" jdbcType="VARCHAR" property="yearTaxes" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
...@@ -70,7 +72,7 @@ ...@@ -70,7 +72,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, company_id, sale, tax, per_mu, year, is_valid, create_time id, company_id, sale, tax, per_mu, year, is_valid, create_time, year_sales, year_taxes
</sql> </sql>
<select id="selectByExample" parameterType="com.ruoyi.system.domain.grid.GridCompanyEconomyInfoExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.ruoyi.system.domain.grid.GridCompanyEconomyInfoExample" resultMap="BaseResultMap">
select select
...@@ -105,10 +107,11 @@ ...@@ -105,10 +107,11 @@
<insert id="insert" parameterType="com.ruoyi.system.domain.grid.GridCompanyEconomyInfo"> <insert id="insert" parameterType="com.ruoyi.system.domain.grid.GridCompanyEconomyInfo">
insert into grid_company_economy_info (id, company_id, sale, insert into grid_company_economy_info (id, company_id, sale,
tax, per_mu, year, tax, per_mu, year,
is_valid, create_time) is_valid, create_time, year_sales, year_taxes)
values (#{id,jdbcType=VARCHAR}, #{companyId,jdbcType=VARCHAR}, #{sale,jdbcType=DECIMAL}, values (#{id,jdbcType=VARCHAR}, #{companyId,jdbcType=VARCHAR}, #{sale,jdbcType=DECIMAL},
#{tax,jdbcType=DECIMAL}, #{perMu,jdbcType=DECIMAL}, #{year,jdbcType=VARCHAR}, #{tax,jdbcType=DECIMAL}, #{perMu,jdbcType=DECIMAL}, #{year,jdbcType=VARCHAR},
#{isValid,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}) #{isValid,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}
, #{yearSales,jdbcType=VARCHAR}, #{yearTaxes,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="com.ruoyi.system.domain.grid.GridCompanyEconomyInfo"> <insert id="insertSelective" parameterType="com.ruoyi.system.domain.grid.GridCompanyEconomyInfo">
insert into grid_company_economy_info insert into grid_company_economy_info
...@@ -137,6 +140,12 @@ ...@@ -137,6 +140,12 @@
<if test="createTime != null"> <if test="createTime != null">
create_time, create_time,
</if> </if>
<if test="yearSales != null">
year_sales,
</if>
<if test="yearTaxes != null">
year_taxes,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
...@@ -163,6 +172,12 @@ ...@@ -163,6 +172,12 @@
<if test="createTime != null"> <if test="createTime != null">
#{createTime,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR},
</if> </if>
<if test="yearSales != null">
#{yearSales,jdbcType=VARCHAR},
</if>
<if test="yearTaxes != null">
#{yearTaxes,jdbcType=VARCHAR},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.ruoyi.system.domain.grid.GridCompanyEconomyInfoExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="com.ruoyi.system.domain.grid.GridCompanyEconomyInfoExample" resultType="java.lang.Long">
...@@ -198,6 +213,12 @@ ...@@ -198,6 +213,12 @@
<if test="record.createTime != null"> <if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=VARCHAR},
</if> </if>
<if test="record.yearSales != null">
year_sales = #{record.yearSales,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
year_taxes = #{record.yearTaxes,jdbcType=VARCHAR},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
...@@ -212,7 +233,9 @@ ...@@ -212,7 +233,9 @@
per_mu = #{record.perMu,jdbcType=DECIMAL}, per_mu = #{record.perMu,jdbcType=DECIMAL},
year = #{record.year,jdbcType=VARCHAR}, year = #{record.year,jdbcType=VARCHAR},
is_valid = #{record.isValid,jdbcType=VARCHAR}, is_valid = #{record.isValid,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=VARCHAR} create_time = #{record.createTime,jdbcType=VARCHAR},
year_sales = #{record.yearSales,jdbcType=VARCHAR},
year_taxes = #{record.yearTaxes,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
...@@ -241,6 +264,12 @@ ...@@ -241,6 +264,12 @@
<if test="createTime != null"> <if test="createTime != null">
create_time = #{createTime,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=VARCHAR},
</if> </if>
<if test="record.yearSales != null">
year_sales = #{record.yearSales,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
year_taxes = #{record.yearTaxes,jdbcType=VARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
...@@ -252,7 +281,9 @@ ...@@ -252,7 +281,9 @@
per_mu = #{perMu,jdbcType=DECIMAL}, per_mu = #{perMu,jdbcType=DECIMAL},
year = #{year,jdbcType=VARCHAR}, year = #{year,jdbcType=VARCHAR},
is_valid = #{isValid,jdbcType=VARCHAR}, is_valid = #{isValid,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=VARCHAR} create_time = #{createTime,jdbcType=VARCHAR},
year_sales = #{yearSales,jdbcType=VARCHAR},
year_taxes = #{yearTaxes,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment