6 changed files with 282 additions and 0 deletions
-
51src/main/java/com/spring/modules/Tooling/controller/BaseConfigController.java
-
20src/main/java/com/spring/modules/Tooling/dao/BaseConfigDao.java
-
47src/main/java/com/spring/modules/Tooling/dao/impl/BaseConfigDaoImpl.java
-
110src/main/java/com/spring/modules/Tooling/data/BaseConfigData.java
-
20src/main/java/com/spring/modules/Tooling/service/BaseConfigService.java
-
34src/main/java/com/spring/modules/Tooling/service/impl/BaseConfigServiceImpl.java
@ -0,0 +1,51 @@ |
|||
package com.spring.modules.Tooling.controller; |
|||
|
|||
import com.spring.modules.Tooling.data.BaseConfigData; |
|||
import com.spring.modules.Tooling.data.BaseConfigData; |
|||
import com.spring.modules.Tooling.service.BaseConfigService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @description: 配置参数的 |
|||
* @author LR |
|||
* @date 2024/8/27 16:43 |
|||
* @version 1.0 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/plm/baseConfig") |
|||
public class BaseConfigController { |
|||
|
|||
@Autowired |
|||
private BaseConfigService baseConfigService; |
|||
|
|||
/** |
|||
* @description: 按照类型获取基础的配置参数 |
|||
* @author LR |
|||
* @date 2024/10/20 10:34 |
|||
* @version 1.0 |
|||
*/ |
|||
@PostMapping(value="/getBaseConfigBySiteAndType") |
|||
public Object getBaseConfigBySiteAndType(@RequestBody BaseConfigData inData) { |
|||
Map<String, Object> resultMap = new HashMap<>(); |
|||
try { |
|||
BaseConfigData resultRow = baseConfigService.getBaseConfigBySiteAndType(inData); |
|||
resultMap.put("success", true); |
|||
resultMap.put("code", "200"); |
|||
resultMap.put("resultRow", resultRow); |
|||
} catch (Exception e) { |
|||
resultMap.put("success", false); |
|||
resultMap.put("code", "400"); |
|||
resultMap.put("msg", e.getMessage()); |
|||
} |
|||
return resultMap; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package com.spring.modules.Tooling.dao; |
|||
|
|||
import com.spring.modules.Tooling.data.BaseConfigData; |
|||
|
|||
/** |
|||
* @description: 基础配置参数 |
|||
* @author LR |
|||
* @date 2024/10/20 10:35 |
|||
* @version 1.0 |
|||
*/ |
|||
public interface BaseConfigDao { |
|||
|
|||
/** |
|||
* @description: 按照类型获取基础的配置参数 |
|||
* @author LR |
|||
* @date 2024/10/20 10:48 |
|||
* @version 1.0 |
|||
*/ |
|||
BaseConfigData getBaseConfigBySiteAndType(String site, String firstType, String secondType); |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
package com.spring.modules.Tooling.dao.impl; |
|||
|
|||
import com.spring.modules.Tooling.dao.BaseConfigDao; |
|||
import com.spring.modules.Tooling.data.BaseConfigData; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.jdbc.core.BeanPropertyRowMapper; |
|||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @description: 基础配置的dao实现 |
|||
* @author LR |
|||
* @date 2024/10/20 10:36 |
|||
* @version 1.0 |
|||
*/ |
|||
@Repository |
|||
public class BaseConfigDaoImpl implements BaseConfigDao { |
|||
|
|||
@Autowired |
|||
private NamedParameterJdbcTemplate parameterJdbcTemplate; |
|||
|
|||
@Override |
|||
public BaseConfigData getBaseConfigBySiteAndType(String site, String firstType, String secondType){ |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<String, Object>(); |
|||
sql.append("SELECT site, first_type, second_type, base_data, base_desc, status, sort_no, remark FROM tbl_base_data"); |
|||
sql.append(" WHERE status = 1 AND site = :site AND first_type = :firstType"); |
|||
if(!(null == secondType || "".equals(secondType))){ |
|||
sql.append(" AND second_type = :secondType"); |
|||
paramMap.put("secondType", secondType); |
|||
} |
|||
//添加排序 |
|||
sql.append(" ORDER BY sort_no"); |
|||
paramMap.put("site", site); |
|||
paramMap.put("firstType", firstType); |
|||
List<BaseConfigData> resultList = parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(BaseConfigData.class)); |
|||
//返回结果集 |
|||
if(resultList.size() > 0){ |
|||
return resultList.get(0); |
|||
} |
|||
return null; |
|||
} |
|||
} |
|||
@ -0,0 +1,110 @@ |
|||
package com.spring.modules.Tooling.data; |
|||
|
|||
import org.apache.ibatis.type.Alias; |
|||
|
|||
/** |
|||
* |
|||
* @ClassName: BaseConfigData |
|||
* @Description: 工艺输出类 |
|||
* @author mumu |
|||
* @date 2018年12月22日 |
|||
* |
|||
*/ |
|||
@Alias("BaseConfigData") |
|||
public class BaseConfigData { |
|||
private int id;// 工艺 |
|||
private String site;// 工厂编号 |
|||
private String firstType;// 类型 |
|||
private String secondType;// 类型 |
|||
private String baseData;// 工艺 |
|||
private String baseDesc;// 工艺描述 |
|||
private Integer status;// 状态 |
|||
private String remark;// 备注 |
|||
private String siteCon;// 工厂查询条件 |
|||
private String ifsRowVersion;// 查询 |
|||
|
|||
public BaseConfigData() { |
|||
// TODO Auto-generated constructor stub |
|||
} |
|||
|
|||
public int getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(int id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getSite() { |
|||
return site; |
|||
} |
|||
|
|||
public void setSite(String site) { |
|||
this.site = site; |
|||
} |
|||
|
|||
public String getFirstType() { |
|||
return firstType; |
|||
} |
|||
|
|||
public void setFirstType(String firstType) { |
|||
this.firstType = firstType; |
|||
} |
|||
|
|||
public String getSecondType() { |
|||
return secondType; |
|||
} |
|||
|
|||
public void setSecondType(String secondType) { |
|||
this.secondType = secondType; |
|||
} |
|||
|
|||
public String getBaseData() { |
|||
return baseData; |
|||
} |
|||
|
|||
public void setBaseData(String baseData) { |
|||
this.baseData = baseData; |
|||
} |
|||
|
|||
public String getBaseDesc() { |
|||
return baseDesc; |
|||
} |
|||
|
|||
public void setBaseDesc(String baseDesc) { |
|||
this.baseDesc = baseDesc; |
|||
} |
|||
|
|||
public Integer getStatus() { |
|||
return status; |
|||
} |
|||
|
|||
public void setStatus(Integer status) { |
|||
this.status = status; |
|||
} |
|||
|
|||
public String getRemark() { |
|||
return remark; |
|||
} |
|||
|
|||
public void setRemark(String remark) { |
|||
this.remark = remark; |
|||
} |
|||
|
|||
public String getSiteCon() { |
|||
return siteCon; |
|||
} |
|||
|
|||
public void setSiteCon(String siteCon) { |
|||
this.siteCon = siteCon; |
|||
} |
|||
|
|||
public String getIfsRowVersion() { |
|||
return ifsRowVersion; |
|||
} |
|||
|
|||
public void setIfsRowVersion(String ifsRowVersion) { |
|||
this.ifsRowVersion = ifsRowVersion; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package com.spring.modules.Tooling.service; |
|||
|
|||
import com.spring.modules.Tooling.data.BaseConfigData; |
|||
|
|||
/** |
|||
* @description: 基础配置参数的使用放 |
|||
* @author LR |
|||
* @date 2024/10/20 10:31 |
|||
* @version 1.0 |
|||
*/ |
|||
public interface BaseConfigService { |
|||
|
|||
/** |
|||
* @description: 获取基础的配置参数 |
|||
* @author LR |
|||
* @date 2024/10/20 10:35 |
|||
* @version 1.0 |
|||
*/ |
|||
BaseConfigData getBaseConfigBySiteAndType(BaseConfigData inData); |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
package com.spring.modules.Tooling.service.impl; |
|||
|
|||
import com.spring.modules.Tooling.dao.BaseConfigDao; |
|||
import com.spring.modules.Tooling.data.BaseConfigData; |
|||
import com.spring.modules.Tooling.service.BaseConfigService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* @description: 基础配置参数的使用放 |
|||
* @author LR |
|||
* @date 2024/10/20 10:33 |
|||
* @version 1.0 |
|||
*/ |
|||
@Service |
|||
public class BaseConfigServiceImpl implements BaseConfigService { |
|||
|
|||
@Autowired |
|||
private BaseConfigDao baseConfigDao; |
|||
|
|||
@Override |
|||
public BaseConfigData getBaseConfigBySiteAndType(BaseConfigData inData) { |
|||
//公共参数 |
|||
String site = inData.getSite(); |
|||
String firstType = inData.getFirstType(); |
|||
String secondType = inData.getSecondType(); |
|||
//判断能否查询到当前配置数据 |
|||
BaseConfigData resultRow = baseConfigDao.getBaseConfigBySiteAndType(site, firstType, secondType); |
|||
if(resultRow == null){ |
|||
throw new RuntimeException("请联系管理员维护当前的默认设置!"); |
|||
} |
|||
return resultRow; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue