diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/controller/DevChangeController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/controller/DevChangeController.java index e1aa543..5f8413c 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/controller/DevChangeController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/controller/DevChangeController.java @@ -2,25 +2,27 @@ package com.bonus.material.devchange.controller; import cn.hutool.core.convert.Convert; import com.bonus.common.biz.config.ListPagingUtil; +import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.material.devchange.domain.CsDeviceChangeDetailsVo; +import com.bonus.material.devchange.domain.CsDeviceChangeVo; import com.bonus.material.devchange.domain.DevChangeVo; +import com.bonus.material.devchange.domain.JjProjectVo; import com.bonus.material.devchange.service.DevChangeService; + import com.bonus.material.device.domain.vo.DevInfoVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -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 org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("/decChange") @Api(value = "设备台账",tags = "设备台账") -public class DevChangeController { +public class DevChangeController extends BaseController { @Autowired private DevChangeService service; @@ -32,15 +34,62 @@ public class DevChangeController { } - @ApiOperation(value = "设备列表") - @PostMapping("/list") - public AjaxResult list(@RequestBody DevChangeVo devInfo) { - List list = service.selectDevInfoList(devInfo); - Integer pageIndex = Convert.toInt(devInfo.getPageNum(), 1); - Integer pageSize = Convert.toInt(devInfo.getPageSize(), 10); - return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list)); + @ApiOperation(value = "出库设备列表") + @GetMapping("/list") + public TableDataInfo devList(DevChangeVo vo) { + startPage(); + List list = service.selectDevInfoList(vo); + return getDataTable(list); + } + /** + * 查询在库 的status =1 + * status =0 出库 + * status=4退役 + * + * 5 维修 + * @param vo + * @return + */ + @ApiOperation(value = "查询工程下拉选集合") + @PostMapping("/getProList") + public AjaxResult list(@RequestBody JjProjectVo vo) { + List list = service.getProList(vo); + return AjaxResult.success(list); + } + + @ApiOperation(value = "查询工程下拉选集合") + @PostMapping("/getVoltageLevel") + public AjaxResult getVoltageLevel(@RequestBody JjProjectVo vo) { + List list = service.getVoltageLevel(vo); + return AjaxResult.success(list); } + + @ApiOperation(value = "新增出库、入库、-退役、维修 ") + @PostMapping("/addChangeInfo") + public AjaxResult addChangeInfo(@RequestBody CsDeviceChangeVo vo) { + return service.addChangeInfo(vo); + } + + + + + + + @ApiOperation(value = "设备流转台账记录") + @GetMapping("/getDevChangeList") + public TableDataInfo getDevChangeList(CsDeviceChangeVo vo) { + startPage(); + List list = service.getDevChangeList(vo); + return getDataTable(list); + } + + @ApiOperation(value = "出库记录单") + @PostMapping("/getDevDetails") + public AjaxResult getDevDetails(@RequestBody CsDeviceChangeDetailsVo vo) { + return service.getDevDetails(vo); + } + } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceChangeDetailsVo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceChangeDetailsVo.java new file mode 100644 index 0000000..6ab0483 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceChangeDetailsVo.java @@ -0,0 +1,49 @@ +package com.bonus.material.devchange.domain; + +import lombok.Data; + +@Data +public class CsDeviceChangeDetailsVo { + + private Integer pageNum; + + private Integer pageSize; + /** + * 主键 + */ + private String id; + + private String devId; + /** + * 变更id + */ + private String changeId; + /** + * 使用时间 + */ + private String useTime; + /** + * 退役原因 + */ + private String reasonId; + /** + * 退役原因 + */ + private String reasonVal; + /** + * 备注 + */ + private String remark; + /** + * 维修人 + */ + private String repairman; + /** + * 维修时间 + */ + private String repairTime; + /** + * 维修内容 + */ + private String repairContent; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceChangeVo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceChangeVo.java new file mode 100644 index 0000000..05e7bc0 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceChangeVo.java @@ -0,0 +1,106 @@ +package com.bonus.material.devchange.domain; + +import lombok.Data; + +@Data +public class CsDeviceChangeVo { + /** + * 地市权限id + */ + private String deptId; + + private Integer pageNum; + + private Integer pageSize; + /** + * 主键 + */ + private String id; + /** + * 变更状前状态 + */ + private String changeStatus; + /** + * 类型 + * 变更类型 1入库 2出库 3 退役 4 维修 + */ + private String type; + /** + * 变更状态 0自用 1共享 + */ + private String status; + /** + * 工程编码 + */ + private String proCode; + /** + * 工程名称 + */ + private String proName; + /** + * 工程类型 + */ + private String proType; + /** + * 设备数量 + */ + private String devNum; + /** + * 电压等级 + */ + private String voltageLevel; + /** + * 使用单位 + */ + private String useUint; + /** + * 省 + */ + private String proProvince; + /** + * 市 + */ + private String proCity; + /** + * 区 + */ + private String proCounty; + /** + * 详细地址 + */ + private String proLocation; + /** + * 创建时间 + */ + private String createTime; + /** + * 创建人 + */ + private String createUser; + /** + * 使用人 + */ + private String userName; + /** + * 联系方式 + */ + private String userPhone; + + private String jsonData; + + private String devId; + /** + * 变更前单位 + */ + private String changeUnit; + + private String keyWord; + + private String startTime; + + private String endTime; + + + + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/DevChangeVo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/DevChangeVo.java index 5c6b641..94f9833 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/DevChangeVo.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/DevChangeVo.java @@ -87,6 +87,8 @@ public class DevChangeVo { * 下次检验日期 */ private String nextDate; + + private String jsonData; /** * 生产厂商 */ @@ -103,9 +105,15 @@ public class DevChangeVo { * 设备状态 */ private String status; + /** + * 年限 + */ + private String year; private List propertyVoList; + private String deptId; + diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/JjProjectVo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/JjProjectVo.java new file mode 100644 index 0000000..af499f0 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/JjProjectVo.java @@ -0,0 +1,47 @@ +package com.bonus.material.devchange.domain; + +import lombok.Data; + +@Data +public class JjProjectVo { + /** + * 工程编码 + */ + private String proCode; + /** + * 工程名称 + */ + private String proName; + /** + * 工程类型 + */ + private String proType; + /** + * 工程类型 + */ + private String proTypeName; + /** + * 电压等级 + */ + private String voltage; + /** + * 组织机构名称 + */ + private String orgName; + /** + * 转化率 + */ + private String mechanizeRate; + /** + * 省 + */ + private String province; + /** + * 市 + */ + private String city; + /** + * 区 + */ + private String county; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/mapper/DevChangeMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/mapper/DevChangeMapper.java index d8b6637..dfdbf3e 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/mapper/DevChangeMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/mapper/DevChangeMapper.java @@ -1,6 +1,11 @@ package com.bonus.material.devchange.mapper; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.devchange.domain.CsDeviceChangeDetailsVo; +import com.bonus.material.devchange.domain.CsDeviceChangeVo; import com.bonus.material.devchange.domain.DevChangeVo; +import com.bonus.material.devchange.domain.JjProjectVo; +import com.bonus.material.device.domain.vo.DevInfoPropertyVo; import com.bonus.material.device.domain.vo.DevInfoVo; import org.apache.ibatis.annotations.Mapper; @@ -18,4 +23,85 @@ public interface DevChangeMapper { * @return */ List selectDevInfoList(DevChangeVo devInfo); + + /** + * 查询设备集合 + * @param vo + * @return + */ + List getDevPropertyList(DevChangeVo vo); + + /** + * 更新数据 + * @param vo + */ + void updateJson(DevChangeVo vo); + + /** + * 查询工程下拉选集合 + * @param vo + * @return + */ + List getProList(JjProjectVo vo); + + /** + * xinz + * @param vo + * @return + */ + int addChangeInfo(CsDeviceChangeVo vo); + + /** + * 新增设备变更记录数据 + * @param deviceChangeDetailsVo + */ + int addDetailsInfo(CsDeviceChangeDetailsVo deviceChangeDetailsVo); + + /** + * + * @param vo + */ + void updateDevInfo(CsDeviceChangeVo vo); + + /** + * 查询设备变更前状态 + * @param devId + * @return + */ + String getChangeStatus(String devId); + + /** + * 查询 设备变更记录 + * @param vo + * @return + */ + List getDevChangeList(CsDeviceChangeVo vo); + + /** + * 获取变更前设备 + * @param devId + * @return + */ + String getChangeUnit(String devId); + + /** + * 查询 设备单位 + * @param devId + * @return + */ + String getChangeUnitById(String devId); + + /** + * 查询出库单 + * @param vo + * @return + */ + List getDevDetails(CsDeviceChangeDetailsVo vo); + + /** + * 电压等级 + * @param vo + * @return + */ + List getVoltageLevel(JjProjectVo vo); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeService.java index be6c61a..07d699b 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeService.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeService.java @@ -1,7 +1,10 @@ package com.bonus.material.devchange.service; import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.devchange.domain.CsDeviceChangeDetailsVo; +import com.bonus.material.devchange.domain.CsDeviceChangeVo; import com.bonus.material.devchange.domain.DevChangeVo; +import com.bonus.material.devchange.domain.JjProjectVo; import com.bonus.material.device.domain.vo.DevInfoVo; import java.util.List; @@ -19,4 +22,39 @@ public interface DevChangeService { * @return */ List selectDevInfoList(DevChangeVo devInfo); + + /** + * 新增 数据变化 + * @param vo + * @return + */ + AjaxResult addChangeInfo(CsDeviceChangeVo vo); + + /** + * 查询工程 下拉选 + * @param vo + * @return + */ + List getProList(JjProjectVo vo); + + /** + * 查询 流转台账记录 + * @param vo + * @return + */ + List getDevChangeList(CsDeviceChangeVo vo); + + /** + * 查询设备出库单 + * @param vo + * @return + */ + AjaxResult getDevDetails(CsDeviceChangeDetailsVo vo); + + /** + * 电压等级下拉选 + * @param vo + * @return + */ + List getVoltageLevel(JjProjectVo vo); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeServiceImpl.java index 8618d63..971b46b 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeServiceImpl.java @@ -1,11 +1,20 @@ package com.bonus.material.devchange.service; +import com.alibaba.cloud.commons.lang.StringUtils; +import com.alibaba.fastjson.JSON; import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.common.utils.StringUtil; +import com.bonus.material.devchange.domain.CsDeviceChangeDetailsVo; +import com.bonus.material.devchange.domain.CsDeviceChangeVo; import com.bonus.material.devchange.domain.DevChangeVo; +import com.bonus.material.devchange.domain.JjProjectVo; import com.bonus.material.devchange.mapper.DevChangeMapper; +import com.bonus.material.device.domain.vo.DevInfoPropertyVo; import com.bonus.material.device.domain.vo.DevInfoVo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.kafka.KafkaProperties; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -42,8 +51,144 @@ public class DevChangeServiceImpl implements DevChangeService { try{ List list=mapper.selectDevInfoList(devInfo); for (DevChangeVo vo:list){ + List devInfoPropertyVos=mapper.getDevPropertyList(vo); + if(devInfoPropertyVos!=null && !devInfoPropertyVos.isEmpty()){ + String json= JSON.toJSONString(devInfoPropertyVos); + vo.setJsonData(json); + mapper.updateJson(vo); + vo.setPropertyVoList(devInfoPropertyVos); + } + } + return list; + }catch (Exception e){ + log.error(e.getMessage()); + } + return new ArrayList<>(); + } + /** + * 新增设备台账数据 + * @param vo + * @return + */ + @Override + public AjaxResult addChangeInfo(CsDeviceChangeVo vo) { + try{ + String username = SecurityUtils.getLoginUser().getUsername(); + vo.setCreateUser(username); + String proCode=vo.getProCode(); + if (StringUtils.isBlank(proCode)) { + return AjaxResult.error("请选择工程"); } + if (StringUtils.isBlank(vo.getType())) { + return AjaxResult.error("请上传类型type:1入库 2出库 3 退役 4 维修"); + } + String json=vo.getJsonData(); + if (StringUtils.isBlank(json)) { + return AjaxResult.error("请选择变更的设备"); + } + List list=JSON.parseArray(json, CsDeviceChangeDetailsVo.class); + if(list==null || list.isEmpty()){ + return AjaxResult.error("请选择变更的设备"); + } + //出库 + if("2".equals(vo.getType())){ + String changeUnit=mapper.getChangeUnit(list.get(0).getDevId()); + vo.setChangeUnit(changeUnit); + } else { + // + String changeUnit=mapper.getChangeUnitById(list.get(0).getDevId()); + vo.setChangeUnit(changeUnit); + } + if("1".equals(vo.getType())){ + //入库厂家 + String changeUnit=mapper.getChangeUnit(list.get(0).getDevId()); + vo.setUseUint(changeUnit); + } + //变更前状态查询 + String changeStatus=mapper.getChangeStatus(list.get(0).getDevId()); + vo.setChangeStatus(changeStatus); + vo.setDevNum(list.size()+""); + int num=mapper.addChangeInfo(vo); + if(num>0){ + for (CsDeviceChangeDetailsVo deviceChangeDetailsVo:list){ + //新增设备列表数据 + deviceChangeDetailsVo.setChangeId(vo.getId()); + //新增设备详情 + int isSuccess= mapper.addDetailsInfo(deviceChangeDetailsVo); + if(isSuccess>0){ + vo.setDevId(deviceChangeDetailsVo.getDevId()); + if("2".startsWith(vo.getType())){ + if("0".equals(vo.getStatus())){ + vo.setChangeStatus("2"); + }else{ + vo.setChangeStatus("3"); + } + }else if("3".startsWith(vo.getType())){ + vo.setChangeStatus("4"); + }else if("4".startsWith(vo.getType())){ + vo.setChangeStatus("5"); + } + mapper.updateDevInfo(vo); + } + } + } + }catch (Exception e){ + log.error(e.getMessage()); + } + return AjaxResult.success(); + } + + /** + * 查询工程下拉选 + * @param vo + * @return + */ + @Override + public List getProList(JjProjectVo vo) { + try{ + return mapper.getProList(vo); + }catch (Exception e){ + log.error(e.getMessage()); + } + return new ArrayList<>(); + } + + /** + * 查询设备流转台账记录 + * @param vo + * @return + */ + @Override + public List getDevChangeList(CsDeviceChangeVo vo) { + try{ + return mapper.getDevChangeList(vo); + }catch (Exception e){ + log.error(e.getMessage()); + } + return new ArrayList<>(); + } + + /** + * 设备出库单记录 + * @param vo + * @return + */ + @Override + public AjaxResult getDevDetails(CsDeviceChangeDetailsVo vo) { + try{ + List list=mapper.getDevDetails(vo); + return AjaxResult.success(list); + }catch (Exception e){ + log.error(e.getMessage()); + } + return AjaxResult.success(new ArrayList<>()); + } + + @Override + public List getVoltageLevel(JjProjectVo vo) { + try{ + return mapper.getVoltageLevel(vo); }catch (Exception e){ log.error(e.getMessage()); } diff --git a/bonus-modules/bonus-material-mall/src/main/resources/bootstrap-material_mall_local.yml b/bonus-modules/bonus-material-mall/src/main/resources/bootstrap-material_mall_local.yml index 8dce47d..f6d8161 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/bootstrap-material_mall_local.yml +++ b/bonus-modules/bonus-material-mall/src/main/resources/bootstrap-material_mall_local.yml @@ -6,13 +6,15 @@ server: spring: cloud: nacos: + username: nacos + password: Jjsp@nacos2023 discovery: # 服务注册地址 - server-addr: 127.0.0.1:8848 + server-addr: 127.0.0.1:18848 namespace: material_mall config: # 配置中心地址 - server-addr: 127.0.0.1:8848 + server-addr: 127.0.0.1:18848 namespace: material_mall # 配置文件格式 file-extension: yml @@ -20,6 +22,7 @@ spring: shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + #加密组件 jasypt: encryptor: diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml index a53fb80..5849971 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml @@ -3,14 +3,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + insert into cs_device_change( + change_status,type, status, pro_code, pro_name, + pro_type, dev_num,voltage_level, use_unit, pro_province, pro_city, + pro_county,pro_location, create_time,create_user,del_flag, user_name, user_phone,change_unit + )values (#{changeStatus},#{type},#{status},#{proCode},#{proName},#{proType},#{devNum},#{voltageLevel},#{useUint} + ,#{proProvince},#{proCity},#{proCounty},#{proLocation},now(),#{createUser},0,#{userName},#{userName},#{changeUnit}) + + + insert into cs_device_change_details( + change_id, dev_id, use_time, reason_id, + reason_val, remark, + repairman,repair_time, repair_content, del_flag + )values ( + #{changeId},#{devId},#{useTime},#{reasonId},#{reasonVal},#{remark},#{repairman},#{repairTime},#{repairContent},0 + ) + + + update ma_dev_info set json_data=#{jsonData} where ma_id=#{devId} + + + update ma_dev_info set xq_unit=#{useUint},user_info=#{userName},user_phone=#{userPhone},on_project=#{proCode}, + change_status=#{changeStatus} + where ma_id=#{devId} + + + + + + + + + + \ No newline at end of file