diff --git a/.idea/MyBatisCodeHelperDatasource.xml b/.idea/MyBatisCodeHelperDatasource.xml index 905de3ef..59668bd4 100644 --- a/.idea/MyBatisCodeHelperDatasource.xml +++ b/.idea/MyBatisCodeHelperDatasource.xml @@ -6,6 +6,7 @@ diff --git a/src/main/java/com/spring/modules/base/controller/PropertiesController.java b/src/main/java/com/spring/modules/base/controller/PropertiesController.java new file mode 100644 index 00000000..ff8f99d3 --- /dev/null +++ b/src/main/java/com/spring/modules/base/controller/PropertiesController.java @@ -0,0 +1,151 @@ +package com.spring.modules.base.controller; + +import com.spring.common.utils.PageUtils; +import com.spring.common.utils.R; +import com.spring.modules.base.data.PlmPropertiesItemAvailableData; +import com.spring.modules.base.data.PlmPropertiesItemData; +import com.spring.modules.base.service.PropertiesService; +import com.spring.modules.base.utils.ResponseData; +import com.spring.modules.sys.controller.AbstractController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +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.ResponseBody; + +import java.util.List; + +@Controller +@RequestMapping(value = "/properties") +public class PropertiesController extends AbstractController { + @Autowired + private PropertiesService propertiesService; + + + + /** + * @Description 查询点检项目 + * @Title propertiesItemSearch + * @param data + * @author rq + * @date 2023/1/29 15:12 + * @return Object + * @throw + */ + @PostMapping(value="/propertiesItemSearch") + @ResponseBody + public R propertiesItemSearch(@RequestBody PlmPropertiesItemData data){ + PageUtils page = propertiesService.propertiesItemSearch(data); + return R.ok().put("page", page); + } + + /** + * @Description TODO + * @Title plmAdminSave + * @param data + * @author rq + * @date 2023/1/29 15:13 + * @return Object + * @throw + */ + @PostMapping(value="/propertiesItemSave") + @ResponseBody + public Object propertiesItemSave(@RequestBody PlmPropertiesItemData data){ + ResponseData responseData = new ResponseData(); + try { + responseData = propertiesService.propertiesItemSave(data); + } catch (Exception e) { + responseData.setCode("400"); + responseData.setMsg(e.getMessage()); + } + return responseData; + } + /** + * @Description TODO + * @Title plmAdminEdit + * @param data + * @author rq + * @date 2023/1/29 16:49 + * @return Object + * @throw + */ + @PostMapping(value="/propertiesItemEdit") + @ResponseBody + public Object propertiesItemEdit(@RequestBody PlmPropertiesItemData data){ + ResponseData responseData = new ResponseData(); + try { + responseData = propertiesService.propertiesItemEdit(data); + } catch (Exception e) { + responseData.setCode("400"); + responseData.setMsg(e.getMessage()); + } + return responseData; + } + + /** + * @Description TODO + * @Title + * @param data + * @author rq + * @date 2023/1/29 16:49 + * @return Object + * @throw + */ + @PostMapping(value="/propertiesItemDelete") + @ResponseBody + public Object propertiesItemDelete(@RequestBody PlmPropertiesItemData data){ + ResponseData responseData = new ResponseData(); + try { + responseData = propertiesService.propertiesItemDelete(data); + } catch (Exception e) { + responseData.setCode("400"); + responseData.setMsg(e.getMessage()); + } + return responseData; + } + /** + * @Description 获取可选值清单 + * @Title searchItemAvailable + * @param inData + * @author rq + * @date 2023/2/23 10:50 + * @return R + * @throw + */ + @PostMapping("/searchItemAvailable") + public R searchItemAvailable(@RequestBody PlmPropertiesItemAvailableData inData){ + List resultList = propertiesService.searchItemAvailable(inData); + return R.ok().put("rows", resultList).put("total",resultList.size()); + } + + /** + * @Description 保存 编辑可选值 + * @Title saveItemAvailable + * @param inData + * @author rq + * @date 2023/2/23 10:56 + * @return R + * @throw + */ + @PostMapping("/saveItemAvailable") + public R saveItemAvailable(@RequestBody PlmPropertiesItemAvailableData inData){ + propertiesService.saveItemAvailable(inData); + return R.ok(); + } + + /** + * @Description TODO + * @Title saveItemAvailable + * @param inData + * @author rq + * @date 2023/2/23 11:42 + * @return R + * @throw + */ + @PostMapping("/deleteItemAvailable") + public R deleteItemAvailable(@RequestBody PlmPropertiesItemAvailableData inData){ + propertiesService.deleteItemAvailable(inData); + return R.ok(); + } +} diff --git a/src/main/java/com/spring/modules/base/dao/PropertiesMapper.java b/src/main/java/com/spring/modules/base/dao/PropertiesMapper.java new file mode 100644 index 00000000..b9ef2138 --- /dev/null +++ b/src/main/java/com/spring/modules/base/dao/PropertiesMapper.java @@ -0,0 +1,104 @@ +package com.spring.modules.base.dao; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.spring.modules.base.data.PlmPropertiesItemAvailableData; +import com.spring.modules.base.data.PlmPropertiesItemData; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface PropertiesMapper { + IPage plmPropertiesItemSearch(Page PlmPropertiesItemDataPage, @Param("query") PlmPropertiesItemData inData); + + /** + * @Description 检查设备分类编码 + * @Title checkEamAdminLevel + * @param inData + * @author rq + * @date 2023/1/29 15:39 + * @return List + * @throw + */ + List checkEamPropertiesItem(PlmPropertiesItemData inData); + + /** + * @Description 保存新的分类 + * @Title saveNewEamAdminLevel + * @param inData + * @author rq + * @date 2023/1/29 16:12 + * @return void + * @throw + */ + void saveNewEamPropertiesItem(PlmPropertiesItemData inData); + /** + * @Description 编辑分类 + * @Title saveNewEamAdminLevel + * @param inData + * @author rq + * @date 2023/1/29 16:12 + * @return void + * @throw + */ + void plmPropertiesItemEdit(PlmPropertiesItemData inData); + /** + * @Description TODO + * @Title plmAdminLevelDelete + * @param inData + * @author rq + * @date 2023/1/29 17:25 + * @return void + * @throw + */ + void propertiesItemDelete(PlmPropertiesItemData inData); + + /** + * @Description TODO + * @Title searchItemAvailable + * @param inData + * @author rq + * @date 2023/2/23 10:52 + * @return List + * @throw + */ + List searchItemAvailable(PlmPropertiesItemAvailableData inData); + + + /** + * @Description 获取值编号 + * @Title getItemValueNo + * @param inData + * @author rq + * @date 2023/2/23 11:21 + * @return Float + * @throw + */ + Double getItemValueNo(PlmPropertiesItemAvailableData inData); + + /** + * @Description TODO + * @Title saveItemAvailable + * @param inData + * @author rq + * @date 2023/2/23 11:38 + * @return void + * @throw + */ + void saveItemAvailable(PlmPropertiesItemAvailableData inData); + + /** + * @Description TODO + * @Title updateItemAvailable + * @param inData + * @author rq + * @date 2023/2/23 11:38 + * @return void + * @throw + */ + void updateItemAvailable(PlmPropertiesItemAvailableData inData); + + void deleteItemAvailable(PlmPropertiesItemAvailableData inData); +} diff --git a/src/main/java/com/spring/modules/base/data/PlmPropertiesItemAvailableData.java b/src/main/java/com/spring/modules/base/data/PlmPropertiesItemAvailableData.java new file mode 100644 index 00000000..a7ab9594 --- /dev/null +++ b/src/main/java/com/spring/modules/base/data/PlmPropertiesItemAvailableData.java @@ -0,0 +1,8 @@ +package com.spring.modules.base.data; + +import com.spring.modules.base.entity.PlmPropertiesItemAvailable; +import org.apache.ibatis.type.Alias; + +@Alias("PlmPropertiesItemAvailableData") +public class PlmPropertiesItemAvailableData extends PlmPropertiesItemAvailable { +} diff --git a/src/main/java/com/spring/modules/base/data/PlmPropertiesItemData.java b/src/main/java/com/spring/modules/base/data/PlmPropertiesItemData.java new file mode 100644 index 00000000..3636ddea --- /dev/null +++ b/src/main/java/com/spring/modules/base/data/PlmPropertiesItemData.java @@ -0,0 +1,17 @@ +package com.spring.modules.base.data; + +import com.spring.modules.base.entity.PlmPropertiesItem; +import org.apache.ibatis.type.Alias; + +@Alias("PlmPropertiesItemData") +public class PlmPropertiesItemData extends PlmPropertiesItem { + private Integer flag; + + public Integer getFlag() { + return flag; + } + + public void setFlag(Integer flag) { + this.flag = flag; + } +} diff --git a/src/main/java/com/spring/modules/base/entity/PlmPropertiesItem.java b/src/main/java/com/spring/modules/base/entity/PlmPropertiesItem.java new file mode 100644 index 00000000..5d06bc2b --- /dev/null +++ b/src/main/java/com/spring/modules/base/entity/PlmPropertiesItem.java @@ -0,0 +1,196 @@ +package com.spring.modules.base.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.spring.common.utils.QueryPage; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +public class PlmPropertiesItem extends QueryPage { + /** + * + */ + private String site; + + /** + * 属性编码 + */ + private String itemNo; + + /** + * 属性名称 + */ + private String itemDesc; + + /** + * 默认值 + */ + private String defaultValue; + + /** + * 值类型(中文) + */ + private String valueType; + + /** + * 值类型 + */ + private String valueTypeDb; + + /** + * 是否值可选 + */ + private String valueChooseFlag; + + /** + * 创建时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date createdDate; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 最大值 + */ + private Double maxValue; + + /** + * 最小值 + */ + private Double minValue; + + /** + * + */ + private String itemType; + + /** + * + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date updateDate; + + /** + * + */ + private String updateBy; + + public String getSite() { + return site; + } + + public void setSite(String site) { + this.site = site; + } + + public String getItemNo() { + return itemNo; + } + + public void setItemNo(String itemNo) { + this.itemNo = itemNo; + } + + public String getItemDesc() { + return itemDesc; + } + + public void setItemDesc(String itemDesc) { + this.itemDesc = itemDesc; + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public String getValueType() { + return valueType; + } + + public void setValueType(String valueType) { + this.valueType = valueType; + } + + public String getValueTypeDb() { + return valueTypeDb; + } + + public void setValueTypeDb(String valueTypeDb) { + this.valueTypeDb = valueTypeDb; + } + + public String getValueChooseFlag() { + return valueChooseFlag; + } + + public void setValueChooseFlag(String valueChooseFlag) { + this.valueChooseFlag = valueChooseFlag; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public Double getMaxValue() { + return maxValue; + } + + public void setMaxValue(Double maxValue) { + this.maxValue = maxValue; + } + + public Double getMinValue() { + return minValue; + } + + public void setMinValue(Double minValue) { + this.minValue = minValue; + } + + public String getItemType() { + return itemType; + } + + public void setItemType(String itemType) { + this.itemType = itemType; + } + + public Date getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Date updateDate) { + this.updateDate = updateDate; + } + + public String getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } +} + diff --git a/src/main/java/com/spring/modules/base/entity/PlmPropertiesItemAvailable.java b/src/main/java/com/spring/modules/base/entity/PlmPropertiesItemAvailable.java new file mode 100644 index 00000000..73f06154 --- /dev/null +++ b/src/main/java/com/spring/modules/base/entity/PlmPropertiesItemAvailable.java @@ -0,0 +1,103 @@ +package com.spring.modules.base.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.spring.common.utils.QueryPage; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +public class PlmPropertiesItemAvailable extends QueryPage { + /** + * + */ + private String site; + + /** + * + */ + private String itemNo; + + /** + * + */ + private String itemType; + + /** + * + */ + private Double valueNo; + + /** + * + */ + private String availableValue; + + /** + * + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date createdDate; + + /** + * + */ + private String createdBy; + + public String getSite() { + return site; + } + + public void setSite(String site) { + this.site = site; + } + + public String getItemNo() { + return itemNo; + } + + public void setItemNo(String itemNo) { + this.itemNo = itemNo; + } + + public String getItemType() { + return itemType; + } + + public void setItemType(String itemType) { + this.itemType = itemType; + } + + public Double getValueNo() { + return valueNo; + } + + public void setValueNo(Double valueNo) { + this.valueNo = valueNo; + } + + public String getAvailableValue() { + return availableValue; + } + + public void setAvailableValue(String availableValue) { + this.availableValue = availableValue; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } +} + diff --git a/src/main/java/com/spring/modules/base/service/Impl/PropertiesServiceImpl.java b/src/main/java/com/spring/modules/base/service/Impl/PropertiesServiceImpl.java new file mode 100644 index 00000000..bd435275 --- /dev/null +++ b/src/main/java/com/spring/modules/base/service/Impl/PropertiesServiceImpl.java @@ -0,0 +1,112 @@ +package com.spring.modules.base.service.Impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.spring.common.utils.PageUtils; +import com.spring.modules.base.dao.PropertiesMapper; +import com.spring.modules.base.data.PlmPropertiesItemAvailableData; +import com.spring.modules.base.data.PlmPropertiesItemData; +import com.spring.modules.base.service.PropertiesService; +import com.spring.modules.base.utils.ResponseData; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class PropertiesServiceImpl implements PropertiesService { + @Autowired + private PropertiesMapper propertiesMapper; + + @Override + public PageUtils propertiesItemSearch(PlmPropertiesItemData inData){ + IPage resultList = this.propertiesMapper.plmPropertiesItemSearch(new Page(inData.getPage(), inData.getLimit()), inData); + return new PageUtils(resultList); + } + + + @Override + public ResponseData propertiesItemSave(PlmPropertiesItemData inData){ + ResponseData responseData = new ResponseData(); + if("T".equals(inData.getValueTypeDb())){ + inData.setValueType("文本"); + inData.setMaxValue(null); + inData.setMinValue(null); + }else { + inData.setValueType("数字"); + if(inData.getMaxValue() != null&&inData.getMinValue()!=null){ + if(inData.getMaxValue() < inData.getMinValue()){ + throw new RuntimeException("最大值不能小于最小值!"); + } + } + } + List checkPropertiesItemLevel = propertiesMapper.checkEamPropertiesItem(inData); + if(checkPropertiesItemLevel.size() > 0){ + throw new RuntimeException("该编码已存在!"); + } + propertiesMapper.saveNewEamPropertiesItem(inData); + responseData.setMsg("保存成功!"); + responseData.setSuccess(true); + responseData.setCode("0"); + return responseData; + } + @Override + public ResponseData propertiesItemEdit(PlmPropertiesItemData inData){ + ResponseData responseData = new ResponseData(); + if("T".equals(inData.getValueTypeDb())){ + inData.setValueType("文本"); + inData.setMaxValue(null); + inData.setMinValue(null); + }else { + inData.setValueType("数字"); + if(inData.getMaxValue() != null&&inData.getMinValue() != null) { + if (inData.getMaxValue() < inData.getMinValue()) { + throw new RuntimeException("最大值不能小于最小值!"); + } + } + } + List checkEamPropertiesItem = propertiesMapper.checkEamPropertiesItem(inData); + if(checkEamPropertiesItem.size() == 0) { + throw new RuntimeException("该属性不存在请刷新数据!"); + } + // 修改项目内容 + propertiesMapper.plmPropertiesItemEdit(inData); + responseData.setMsg("修改成功!"); + responseData.setSuccess(true); + responseData.setCode("0"); + return responseData; + } + + @Override + public ResponseData propertiesItemDelete(PlmPropertiesItemData inData){ + ResponseData responseData = new ResponseData(); + propertiesMapper.propertiesItemDelete(inData); + responseData.setMsg("删除成功!"); + responseData.setSuccess(true); + responseData.setCode("0"); + return responseData; + } + + @Override + public List searchItemAvailable(PlmPropertiesItemAvailableData inData) { + return propertiesMapper.searchItemAvailable(inData); + } + + @Override + public void saveItemAvailable(PlmPropertiesItemAvailableData inData){ + //判断是新增还是修改 + if(inData.getValueNo() == 0){ + //新增 + Double valueNo = propertiesMapper.getItemValueNo(inData); + inData.setValueNo(valueNo); + propertiesMapper.saveItemAvailable(inData); + }else { + propertiesMapper.updateItemAvailable(inData); + } + } + + @Override + public void deleteItemAvailable(PlmPropertiesItemAvailableData inData){ + propertiesMapper.deleteItemAvailable(inData); + } +} diff --git a/src/main/java/com/spring/modules/base/service/PropertiesService.java b/src/main/java/com/spring/modules/base/service/PropertiesService.java new file mode 100644 index 00000000..9ec73f3f --- /dev/null +++ b/src/main/java/com/spring/modules/base/service/PropertiesService.java @@ -0,0 +1,91 @@ +package com.spring.modules.base.service; + +import com.spring.common.utils.PageUtils; +import com.spring.modules.base.data.PlmPropertiesItemAvailableData; +import com.spring.modules.base.data.PlmPropertiesItemData; +import com.spring.modules.base.utils.ResponseData; + +import java.util.List; + +public interface PropertiesService { + + + /** + * @param inData + * @return List + * @Description + * @Title EamPropertiesItem + * @author rq + * @date 2023/1/29 13:34 + * @throw + */ + PageUtils propertiesItemSearch(PlmPropertiesItemData inData); + + /** + * @param inData + * @return ResponseData + * @Description + * @Title + * @author rq + * @date 2023/1/29 15:19 + * @throw + */ + ResponseData propertiesItemSave(PlmPropertiesItemData inData); + + /** + * @param inData + * @return ResponseData + * @Description + * @Title + * @author rq + * @date 2023/1/29 16:50 + * @throw + */ + ResponseData propertiesItemEdit(PlmPropertiesItemData inData); + + /** + * @param inData + * @return ResponseData + * @Description + * @Title + * @author rq + * @date 2023/1/29 16:50 + * @throw + */ + ResponseData propertiesItemDelete(PlmPropertiesItemData inData); + + + + /** + * @param inData + * @return List + * @Description TODO + * @Title searchItemAvailable + * @author rq + * @date 2023/2/23 10:52 + * @throw + */ + List searchItemAvailable(PlmPropertiesItemAvailableData inData); + + /** + * @param inData + * @return void + * @Description 保存可选值 + * @Title saveItemAvailable + * @author rq + * @date 2023/2/23 10:57 + * @throw + */ + void saveItemAvailable(PlmPropertiesItemAvailableData inData); + + /** + * @param + * @return void + * @Description TODO + * @Title deleteItemAvailable + * @author rq + * @date 2023/2/23 11:43 + * @throw + */ + void deleteItemAvailable(PlmPropertiesItemAvailableData inData); +} diff --git a/src/main/resources/mapper/base/PropertiesMapper.xml b/src/main/resources/mapper/base/PropertiesMapper.xml new file mode 100644 index 00000000..56d3e3a8 --- /dev/null +++ b/src/main/resources/mapper/base/PropertiesMapper.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + Insert into plm_properties_item (site,ItemNo,ItemDesc,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate + ,CreatedBy,MaxValue,MinValue,ItemType) values + (#{site},#{itemNo},#{itemDesc},#{defaultValue},#{valueType},#{valueTypeDb},#{valueChooseFlag},GetDate(), + #{createdBy},#{maxValue,jdbcType=DOUBLE},#{minValue,jdbcType=DOUBLE},#{itemType}) + + + + update plm_properties_item + set ItemDesc=#{itemDesc},DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}, + ValueChooseFlag=#{valueChooseFlag},update_date=GetDate() + ,update_by=#{updateBy},MaxValue=#{maxValue,jdbcType=DOUBLE},MinValue=#{minValue,jdbcType=DOUBLE},ItemType=#{itemType} + WHERE ItemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} + + + + Delete FROM plm_properties_item WHERE ItemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} + + + + + + + + insert into plm_properties_item_available (ItemNo,ValueNo,AvailableValue,CreatedDate,CreatedBy,ItemType,site) + values(#{itemNo},#{valueNo},#{availableValue},GetDate(),#{createdBy},#{itemType},#{site}) + + + + update plm_properties_item_available set AvailableValue = #{availableValue} where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site} + + + + delete from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site} + + \ No newline at end of file