diff --git a/lzbi-admin/src/main/resources/application-dev.yml b/lzbi-admin/src/main/resources/application-dev.yml index 2be7870..3435ab3 100644 --- a/lzbi-admin/src/main/resources/application-dev.yml +++ b/lzbi-admin/src/main/resources/application-dev.yml @@ -129,3 +129,16 @@ target-model: outputOfPlant: TM000FDL # 发电量 provideWaterAverageTemperature: TM000GSJW # 供水均温 answerWaterAverageTemperature: TM000HSJW # 回水均温 + +# 微信相关配置 +wechat: + # 小程序ID + appId: wx4c96b81e6331fefa + # 小程序密钥 + appSecret: b7258ba1e7db304d086cb83f034b3b60 + # 小程序登录接口 + code2Session: https://api.weixin.qq.com/sns/jscode2session?appid={appid}&secret={secret}&js_code={js_code}&grant_type={grant_type} + # 获取接口调用凭据 + accessToken: https://api.weixin.qq.com/cgi-bin/token?appid={appid}&secret={secret}&grant_type={grant_type} + # 获取手机号 + phoneNumber: https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token={access_token} diff --git a/lzbi-admin/src/main/resources/application-prod.yml b/lzbi-admin/src/main/resources/application-prod.yml index 44c5474..44c5e46 100644 --- a/lzbi-admin/src/main/resources/application-prod.yml +++ b/lzbi-admin/src/main/resources/application-prod.yml @@ -1,7 +1,7 @@ # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 - port: 9001 + port: 9012 # redis 配置 spring: @@ -86,19 +86,28 @@ spring: # username: lmjt_sys # password: lmjt_sys # 从库数据源 - slave: - # 从数据源开关/默认关闭 - url: jdbc:mysql://10.10.10.56:13306/lzdc_bi_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: luenmei - password: 123456 - workDB: - driverClassName: org.postgresql.Driver - #type: com.alibaba.druid.pool.DruidDataSource - url: jdbc:postgresql://10.10.10.56:5432/dctestdb?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai - username: postgres - password: 123456 +# slave: +# # 从数据源开关/默认关闭 +# url: jdbc:mysql://10.10.10.56:13306/lzdc_bi_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: luenmei +# password: 123456 +# workDB: +# driverClassName: org.postgresql.Driver +# #type: com.alibaba.druid.pool.DruidDataSource +# url: jdbc:postgresql://10.10.10.59:5432/dcdatabase?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai +# username: postgres +# password: 123456 primary: master +luenmeilz: + #视频设备监控地址 + vedio-server: + url: http://10.10.10.40:18000 + login: /api/v1/login?username={username}&password={password} + deviceList: /api/v1/devicesconfig?device={device}&start={start}&limit={limit} + channelList: /api/v1/channelsconfig?device={device}&start={start}&limit={limit} + channelStream: /api/v1/devices/channelstream?device={device}&channel={channel}&protocol={protocol}&Token={Token}&type={type} + # 日志配置 logging: file: @@ -106,3 +115,16 @@ logging: level: com.lzbi: debug org.springframework: warn + +# 微信相关配置 +wechat: + # 小程序ID + appId: wx4c96b81e6331fefa + # 小程序密钥 + appSecret: b7258ba1e7db304d086cb83f034b3b60 + # 小程序登录接口 + code2Session: https://api.weixin.qq.com/sns/jscode2session?appid={appid}&secret={secret}&js_code={js_code}&grant_type={grant_type} + # 获取接口调用凭据 + accessToken: https://api.weixin.qq.com/cgi-bin/token?appid={appid}&secret={secret}&grant_type={grant_type} + # 获取手机号 + phoneNumber: https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token={access_token} diff --git a/lzbi-common/src/main/java/com/lzbi/common/config/WechatConfig.java b/lzbi-common/src/main/java/com/lzbi/common/config/WechatConfig.java new file mode 100644 index 0000000..6a551dc --- /dev/null +++ b/lzbi-common/src/main/java/com/lzbi/common/config/WechatConfig.java @@ -0,0 +1,35 @@ +package com.lzbi.common.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * 微信配置 + */ +@Data +@Component +@ConfigurationProperties(prefix = "wechat") +public class WechatConfig { + + /** + * 小程序 appId + */ + private String appId; + /** + * 小程序 appSecret + */ + private String appSecret; + /** + * 小程序登录接口 url + */ + private String code2Session; + /** + * 获取接口调用凭据口 url + */ + private String accessToken; + /** + * 获取手机号接口 url + */ + private String phoneNumber; +} diff --git a/lzbi-common/src/main/java/com/lzbi/common/constant/BizConstants.java b/lzbi-common/src/main/java/com/lzbi/common/constant/BizConstants.java new file mode 100644 index 0000000..f0e1f3f --- /dev/null +++ b/lzbi-common/src/main/java/com/lzbi/common/constant/BizConstants.java @@ -0,0 +1,53 @@ +package com.lzbi.common.constant; + +/** + * 业务常量 + */ +public interface BizConstants { + + /** + * 指标类别 + */ + interface TargetType { + /** + * 单日 + */ + String DAY = "1"; + /** + * 累计 + */ + String ACCUMULATIVE = "2"; + } + + /** + * 部门类别 + */ + interface DcDeptAttr { + + /** + * 公司 + */ + String COMANY = "1002"; + + /** + * 热源 + */ + String HEAT_SOURCE = "1003"; + } + + /** + * 资产类别 + */ + interface DcAssetAttr { + + /** + * 换热站 + */ + String HEAT_EXCHANGE_STATION = "1001"; + + /** + * 热源 + */ + String HEAT_SOURCE = "1002"; + } +} diff --git a/lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java b/lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java index 281cdb3..8085e97 100644 --- a/lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java +++ b/lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java @@ -115,6 +115,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers( "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() + .antMatchers("/wechat/biz/login/**").permitAll() // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated() .and() diff --git a/lzbi-module/pom.xml b/lzbi-module/pom.xml index 60c1075..07151be 100644 --- a/lzbi-module/pom.xml +++ b/lzbi-module/pom.xml @@ -27,6 +27,10 @@ spring-boot-devtools true + + com.lzbi + lzbi-system + diff --git a/lzbi-module/src/main/java/com/lzbi/asset/domain/AssetParamsVO.java b/lzbi-module/src/main/java/com/lzbi/asset/domain/AssetParamsVO.java new file mode 100644 index 0000000..1a49094 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/asset/domain/AssetParamsVO.java @@ -0,0 +1,18 @@ +package com.lzbi.asset.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class AssetParamsVO { + + private List treeData; + + private Map> paramsPartitionMap; +} diff --git a/lzbi-module/src/main/java/com/lzbi/asset/domain/DcBusiParamSource.java b/lzbi-module/src/main/java/com/lzbi/asset/domain/DcBusiParamSource.java index 3b7c343..50a09e1 100644 --- a/lzbi-module/src/main/java/com/lzbi/asset/domain/DcBusiParamSource.java +++ b/lzbi-module/src/main/java/com/lzbi/asset/domain/DcBusiParamSource.java @@ -1,70 +1,85 @@ package com.lzbi.asset.domain; -import com.baomidou.mybatisplus.annotation.IdType; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.annotation.TableId; -import java.io.Serializable; import java.util.Date; -import lombok.AllArgsConstructor; import lombok.Data; -import lombok.NoArgsConstructor; +import io.swagger.annotations.ApiModelProperty; import lombok.experimental.Accessors; +import com.lzbi.common.annotation.Excel; import com.lzbi.module.base.BaseModuleEntity; /** - * 采集参数来源信息表; - * @author : zhousq - * @date : 2023-12-5 + * 采集参数来源信息对象 dc_busi_param_source + * + * @author win + * @date 2024-01-17 */ @Data -@NoArgsConstructor -@AllArgsConstructor @Accessors(chain = true) -@ApiModel(value = "采集参数来源信息表",description = "") -@TableName("dc_busi_param_source") -public class DcBusiParamSource extends BaseModuleEntity{ +public class DcBusiParamSource extends BaseModuleEntity +{ + private static final long serialVersionUID = 1L; + /** 参数编码 */ - @ApiModelProperty(name = "参数编码",notes = "") - private String paramCode ; + @Excel(name = "参数编码") + @ApiModelProperty(name = "参数编码",notes = "paramCode") + private String paramCode; + /** 参数名称 */ - @ApiModelProperty(name = "参数名称",notes = "") - private String paramName ; + @Excel(name = "参数名称") + @ApiModelProperty(name = "参数名称",notes = "paramName") + private String paramName; + /** 分组名称 */ - @ApiModelProperty(name = "分组名称",notes = "") - private String groupName ; + @Excel(name = "分组名称") + @ApiModelProperty(name = "分组名称",notes = "groupName") + private String groupName; + /** 分组编码 */ - @ApiModelProperty(name = "分组编码",notes = "") - private String groupCode ; + @Excel(name = "分组编码") + @ApiModelProperty(name = "分组编码",notes = "groupCode") + private String groupCode; + + /** 资产编码(不是统计单元) */ + @Excel(name = "资产编码", readConverterExp = "不=是统计单元") + @ApiModelProperty(name = "资产编码",notes = "") + private String assetCode; + + /** 资产名称(不是统计单元) */ + @Excel(name = "资产名称", readConverterExp = "不=是统计单元") + @ApiModelProperty(name = "资产名称",notes = "") + private String assetName; + + /** 分区 */ + @Excel(name = "分区") + @ApiModelProperty(name = "分区",notes = "partion") + private String partion; + /** 扩展属性 */ - @ApiModelProperty(name = "扩展属性",notes = "") - private String extPro ; + @Excel(name = "扩展属性") + @ApiModelProperty(name = "扩展属性",notes = "extPro") + private String extPro; + /** 来源类型 */ - @ApiModelProperty(name = "来源类型",notes = "") - private String sourceType ; + @Excel(name = "来源类型") + @ApiModelProperty(name = "来源类型",notes = "sourceType") + private String sourceType; + /** 是否有效 */ - @ApiModelProperty(name = "是否有效",notes = "") - private String enabledFlag ; + @Excel(name = "是否有效") + @ApiModelProperty(name = "是否有效",notes = "enabledFlag") + private String enabledFlag; + /** 主键 */ - @ApiModelProperty(name = "主键",notes = "") - @TableId(type= IdType.AUTO) - private Long id ; - /** 所属专业 */ - @ApiModelProperty(name = "所属专业",notes = "") - private String fieldCode ; - /** 所属名称 */ - @ApiModelProperty(name = "所属名称",notes = "") - private String fieldName ; - private String value; - private String label; + private Long id; - public String getValue() { - return this.paramCode; - } + /** 所属专业 */ + @Excel(name = "所属专业") + @ApiModelProperty(name = "所属专业",notes = "fieldCode") + private String fieldCode; + /** 所属名称 */ + @Excel(name = "所属名称") + @ApiModelProperty(name = "所属名称",notes = "fieldName") + private String fieldName; - public String getLabel() { - return this.paramCode; - } -} \ No newline at end of file +} diff --git a/lzbi-module/src/main/java/com/lzbi/asset/domain/ElementTreeVO.java b/lzbi-module/src/main/java/com/lzbi/asset/domain/ElementTreeVO.java new file mode 100644 index 0000000..234f9eb --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/asset/domain/ElementTreeVO.java @@ -0,0 +1,80 @@ +package com.lzbi.asset.domain; + +import java.util.List; + +/** + * elementUI树形结构返回值 + */ +public class ElementTreeVO { + + /** + * 值 + */ + private Object value; + /** + * 名称 + */ + private String label; + /** + * 是否禁用 + */ + private boolean disabled; + /** + * 是否有下级节点 + */ + private boolean isLeaf; + /** + * 下级节点 + */ + private List children; + + private List data; + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public boolean getDisabled() { + return disabled; + } + + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } + + public boolean getIsLeaf() { + return isLeaf; + } + + public void setIsLeaf(boolean leaf) { + isLeaf = leaf; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/asset/domain/ParamsPartitionVO.java b/lzbi-module/src/main/java/com/lzbi/asset/domain/ParamsPartitionVO.java new file mode 100644 index 0000000..98a3db3 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/asset/domain/ParamsPartitionVO.java @@ -0,0 +1,26 @@ +package com.lzbi.asset.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ParamsPartitionVO { + + /** + * 值 + */ + private String paramsCode; + + /** + * 名称 + */ + private String paramsName; + + /** + * 分区 + */ + private String partition; +} diff --git a/lzbi-module/src/main/java/com/lzbi/asset/domain/TreeVO.java b/lzbi-module/src/main/java/com/lzbi/asset/domain/TreeVO.java new file mode 100644 index 0000000..1a1dd80 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/asset/domain/TreeVO.java @@ -0,0 +1,17 @@ +package com.lzbi.asset.domain; + +import lombok.Data; + +import java.util.List; + +@Data +public class TreeVO { + + private String value; + + private String label; + + private boolean disabled; + + private List options; +} diff --git a/lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBaseAssetInfoMapper.java b/lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBaseAssetInfoMapper.java index 3fdc95e..8a2dbe0 100644 --- a/lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBaseAssetInfoMapper.java +++ b/lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBaseAssetInfoMapper.java @@ -3,6 +3,7 @@ package com.lzbi.asset.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.lzbi.asset.domain.DcBaseAssetInfo; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -25,6 +26,7 @@ public interface DcBaseAssetInfoMapper extends BaseMapper */ public DcBaseAssetInfo selectDcBaseAssetInfoById(Long id); public DcBaseAssetInfo selectDcBaseAssetInfoByCode(String assetcode); + public DcBaseAssetInfo selectDcBaseAssetInfoByAliasName(@Param("assetNameAlias") String assetNameAlias); public HashMap selectDcBaseAssetInfoMap(); /** diff --git a/lzbi-module/src/main/java/com/lzbi/asset/service/DcBusiParamSourceService.java b/lzbi-module/src/main/java/com/lzbi/asset/service/DcBusiParamSourceService.java index 77f185b..9ffff5d 100644 --- a/lzbi-module/src/main/java/com/lzbi/asset/service/DcBusiParamSourceService.java +++ b/lzbi-module/src/main/java/com/lzbi/asset/service/DcBusiParamSourceService.java @@ -1,11 +1,22 @@ package com.lzbi.asset.service; +import com.alibaba.fastjson2.JSONArray; import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.lzbi.asset.domain.ElementTreeVO; +import com.lzbi.asset.domain.TreeVO; import com.lzbi.asset.mapper.DcBusiParamSourceMapper; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.lzbi.asset.domain.DcBusiParamSource; +import org.springframework.util.CollectionUtils; +import org.springframework.web.client.RestTemplate; + +import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * 采集参数来源信息表;(dc_busi_param_source)表服务接口 @@ -15,6 +26,9 @@ import java.util.List; @Service public class DcBusiParamSourceService extends ServiceImpl implements IService { + @Autowired + private RestTemplate restTemplate; + public List selectByVo( DcBusiParamSource dcBusiParamSource){ return baseMapper.selectByVo(dcBusiParamSource); } @@ -22,4 +36,18 @@ public class DcBusiParamSourceService extends ServiceImpl selectParamSourceTree(String paramsName){ + List list = new ArrayList<>(); + ElementTreeVO elementTreeVO = new ElementTreeVO(); + elementTreeVO.setValue("IOT"); + elementTreeVO.setLabel("IOT平台"); + String result = restTemplate.getForObject("http://127.0.0.1:9010/biz/common/orgAssetParamsTree", String.class); + if (null != result) { + List elementTreeVOS = JSONArray.parseArray(result, ElementTreeVO.class); + elementTreeVO.setIsLeaf(Boolean.TRUE); + elementTreeVO.setChildren(elementTreeVOS); + } + list.add(elementTreeVO); + return list; + } } \ No newline at end of file diff --git a/lzbi-module/src/main/java/com/lzbi/bill/controller/DcBusiTargetInputMasterController.java b/lzbi-module/src/main/java/com/lzbi/bill/controller/DcBusiTargetInputMasterController.java new file mode 100644 index 0000000..854c93f --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/bill/controller/DcBusiTargetInputMasterController.java @@ -0,0 +1,154 @@ +package com.lzbi.bill.controller; +import com.lzbi.draft.domain.req.ConfirmReq; +import com.lzbi.draft.domain.req.ProductionDailySheetReq; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.lzbi.common.annotation.Log; +import com.lzbi.common.core.controller.BaseController; +import com.lzbi.common.core.domain.AjaxResult; +import com.lzbi.common.enums.BusinessType; +import com.lzbi.bill.domain. DcBusiTargetInputMaster; +import com.lzbi.bill.service.DcBusiTargetInputMasterService; +import com.lzbi.common.utils.poi.ExcelUtil; +import com.lzbi.common.core.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; + +/** + * 指标录入单Controller + * + * @author lienbo + * @date 2024-01-19 + */ +@RestController +@RequestMapping("/bill/DcBusiTargetInputMaster") +public class DcBusiTargetInputMasterController extends BaseController +{ + @Autowired + private DcBusiTargetInputMasterService dcBusiTargetInputMasterService; + + /** + * 查询指标录入单列表 + */ + @ApiOperation("查询指标录入单列表") + @ApiImplicitParams({ + @ApiImplicitParam(name = "DcBusiTargetInputMaster", value = "", dataType = "DcBusiTargetInputMaster", dataTypeClass = DcBusiTargetInputMaster.class), + }) + @PreAuthorize("@ss.hasPermi('bill:DcBusiTargetInputMaster:list')") + @GetMapping("/list") + public TableDataInfo list(DcBusiTargetInputMaster DcBusiTargetInputMaster) + { + startPage(); + List< DcBusiTargetInputMaster> list = dcBusiTargetInputMasterService.selectDcBusiTargetInputMasterList(DcBusiTargetInputMaster); + return getDataTable(list); + } + + /** + * 导出指标录入单列表 + */ + @ApiOperation("导出指标录入单列表") + @ApiImplicitParams({ + @ApiImplicitParam(name = "DcBusiTargetInputMaster", value = "", dataType = "DcBusiTargetInputMaster", dataTypeClass = DcBusiTargetInputMaster.class), + }) + @PreAuthorize("@ss.hasPermi('bill:DcBusiTargetInputMaster:export')") + @Log(title = "指标录入单", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response,DcBusiTargetInputMaster DcBusiTargetInputMaster) + { + List list = dcBusiTargetInputMasterService.selectDcBusiTargetInputMasterList(DcBusiTargetInputMaster); + ExcelUtil util = new ExcelUtil(DcBusiTargetInputMaster.class); + util.exportExcel(response, list, "指标录入单数据"); + } + + /** + * 获取指标录入单详细信息 + */ + @ApiOperation("获取指标录入单详细信息") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "", dataType = "Long", dataTypeClass = Long.class), + }) + @PreAuthorize("@ss.hasPermi('bill:DcBusiTargetInputMaster:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(dcBusiTargetInputMasterService.selectDcBusiTargetInputMasterById(id)); + } + + /** + * 新增指标录入单 + */ + @ApiOperation("新增指标录入单") + @ApiImplicitParams({ + @ApiImplicitParam(name = "DcBusiTargetInputMaster", value = "", dataType = "DcBusiTargetInputMaster", dataTypeClass = DcBusiTargetInputMaster.class), + }) + @PreAuthorize("@ss.hasPermi('bill:DcBusiTargetInputMaster:add')") + @Log(title = "指标录入单", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody DcBusiTargetInputMaster DcBusiTargetInputMaster) + { + return toAjax(dcBusiTargetInputMasterService.insertDcBusiTargetInputMaster(DcBusiTargetInputMaster)); + } + + /** + * 修改指标录入单 + */ + + @ApiOperation("修改指标录入单") + @ApiImplicitParams({ + @ApiImplicitParam(name = "DcBusiTargetInputMaster", value = "", dataType = "DcBusiTargetInputMaster", dataTypeClass = DcBusiTargetInputMaster.class), + }) + @PreAuthorize("@ss.hasPermi('bill:DcBusiTargetInputMaster:edit')") + @Log(title = "指标录入单", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody DcBusiTargetInputMaster DcBusiTargetInputMaster) + { + return toAjax(dcBusiTargetInputMasterService.updateDcBusiTargetInputMaster(DcBusiTargetInputMaster)); + } + + /** + * 删除指标录入单 + */ + @ApiOperation("删除指标录入单") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ids", value = "", dataType = "Long", dataTypeClass =Long.class), + }) + @PreAuthorize("@ss.hasPermi('bill:DcBusiTargetInputMaster:remove')") + @Log(title = "指标录入单", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(dcBusiTargetInputMasterService.deleteDcBusiTargetInputMasterByIds(ids)); + } + + /** + * 上传生产日报 + * @param file + * @return + */ + @PostMapping("/upload/production/daily") + public AjaxResult uploadProductionDaily(MultipartFile file) { + return dcBusiTargetInputMasterService.uploadProductionDaily(file); + } + + /** + * 确认日报数据 + * @param list + * @return + */ + @PostMapping("/confirm") + public AjaxResult confirm(@RequestBody ConfirmReq confirmReq) { + return dcBusiTargetInputMasterService.confirm(confirmReq); + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/bill/controller/DcBusiTargetInputSubController.java b/lzbi-module/src/main/java/com/lzbi/bill/controller/DcBusiTargetInputSubController.java new file mode 100644 index 0000000..d8d1ac4 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/bill/controller/DcBusiTargetInputSubController.java @@ -0,0 +1,131 @@ +package com.lzbi.bill.controller; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.lzbi.common.annotation.Log; +import com.lzbi.common.core.controller.BaseController; +import com.lzbi.common.core.domain.AjaxResult; +import com.lzbi.common.enums.BusinessType; +import com.lzbi.bill.domain. DcBusiTargetInputSub; +import com.lzbi.bill.service.DcBusiTargetInputSubService; +import com.lzbi.common.utils.poi.ExcelUtil; +import com.lzbi.common.core.page.TableDataInfo; + +/** + * 指标录入单子Controller + * + * @author lienbo + * @date 2024-01-19 + */ +@RestController +@RequestMapping("/bill/DcBusiTargetInputSub") +public class DcBusiTargetInputSubController extends BaseController +{ + @Autowired + private DcBusiTargetInputSubService dcBusiTargetInputSubService; + + /** + * 查询指标录入单子列表 + */ + @ApiOperation("查询指标录入单子列表") + @ApiImplicitParams({ + @ApiImplicitParam(name = "DcBusiTargetInputSub", value = "", dataType = "DcBusiTargetInputSub", dataTypeClass = DcBusiTargetInputSub.class), + }) + @PreAuthorize("@ss.hasPermi('bill:DcBusiTargetInputSub:list')") + @GetMapping("/list") + public TableDataInfo list(DcBusiTargetInputSub DcBusiTargetInputSub) + { + startPage(); + List< DcBusiTargetInputSub> list = dcBusiTargetInputSubService.selectDcBusiTargetInputSubList(DcBusiTargetInputSub); + return getDataTable(list); + } + + /** + * 导出指标录入单子列表 + */ + @ApiOperation("导出指标录入单子列表") + @ApiImplicitParams({ + @ApiImplicitParam(name = "DcBusiTargetInputSub", value = "", dataType = "DcBusiTargetInputSub", dataTypeClass = DcBusiTargetInputSub.class), + }) + @PreAuthorize("@ss.hasPermi('bill:DcBusiTargetInputSub:export')") + @Log(title = "指标录入单子", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response,DcBusiTargetInputSub DcBusiTargetInputSub) + { + List list = dcBusiTargetInputSubService.selectDcBusiTargetInputSubList(DcBusiTargetInputSub); + ExcelUtil util = new ExcelUtil(DcBusiTargetInputSub.class); + util.exportExcel(response, list, "指标录入单子数据"); + } + + /** + * 获取指标录入单子详细信息 + */ + @ApiOperation("获取指标录入单子详细信息") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "", dataType = "Long", dataTypeClass = Long.class), + }) + @PreAuthorize("@ss.hasPermi('bill:DcBusiTargetInputSub:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(dcBusiTargetInputSubService.selectDcBusiTargetInputSubById(id)); + } + + /** + * 新增指标录入单子 + */ + @ApiOperation("新增指标录入单子") + @ApiImplicitParams({ + @ApiImplicitParam(name = "DcBusiTargetInputSub", value = "", dataType = "DcBusiTargetInputSub", dataTypeClass = DcBusiTargetInputSub.class), + }) + @PreAuthorize("@ss.hasPermi('bill:DcBusiTargetInputSub:add')") + @Log(title = "指标录入单子", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody DcBusiTargetInputSub DcBusiTargetInputSub) + { + return toAjax(dcBusiTargetInputSubService.insertDcBusiTargetInputSub(DcBusiTargetInputSub)); + } + + /** + * 修改指标录入单子 + */ + + @ApiOperation("修改指标录入单子") + @ApiImplicitParams({ + @ApiImplicitParam(name = "DcBusiTargetInputSub", value = "", dataType = "DcBusiTargetInputSub", dataTypeClass = DcBusiTargetInputSub.class), + }) + @PreAuthorize("@ss.hasPermi('bill:DcBusiTargetInputSub:edit')") + @Log(title = "指标录入单子", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody DcBusiTargetInputSub DcBusiTargetInputSub) + { + return toAjax(dcBusiTargetInputSubService.updateDcBusiTargetInputSub(DcBusiTargetInputSub)); + } + + /** + * 删除指标录入单子 + */ + @ApiOperation("删除指标录入单子") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ids", value = "", dataType = "Long", dataTypeClass =Long.class), + }) + @PreAuthorize("@ss.hasPermi('bill:DcBusiTargetInputSub:remove')") + @Log(title = "指标录入单子", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(dcBusiTargetInputSubService.deleteDcBusiTargetInputSubByIds(ids)); + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/bill/domain/DcBusiTargetInputMaster.java b/lzbi-module/src/main/java/com/lzbi/bill/domain/DcBusiTargetInputMaster.java new file mode 100644 index 0000000..2cd8927 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/bill/domain/DcBusiTargetInputMaster.java @@ -0,0 +1,110 @@ +package com.lzbi.bill.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import lombok.Data; +import io.swagger.annotations.ApiModelProperty; +import lombok.experimental.Accessors; +import com.lzbi.common.annotation.Excel; +import com.lzbi.module.base.BaseModuleEntity; + +/** + * 指标录入单对象 dc_busi_target_input_master + * + * @author lienbo + * @date 2024-01-19 + */ +@Data +@Accessors(chain = true) +public class DcBusiTargetInputMaster extends BaseModuleEntity +{ + private static final long serialVersionUID = 1L; + + /** 单据号 */ + @Excel(name = "单据号") + @ApiModelProperty(name = "单据号",notes = "billSerial") + private String billSerial; + + /** 单据类别 */ + @Excel(name = "单据类别") + @ApiModelProperty(name = "单据类别",notes = "biilType") + private String biilType; + + /** 公司ID */ + @Excel(name = "公司ID") + @ApiModelProperty(name = "公司ID",notes = "companyId") + private Long companyId; + + /** 公司名称 */ + @Excel(name = "公司名称") + @ApiModelProperty(name = "公司名称",notes = "companyName") + private String companyName; + + /** 组织机构名称 */ + @Excel(name = "组织机构名称") + @ApiModelProperty(name = "组织机构名称",notes = "organizeName") + private String organizeName; + + /** 组织机构ID */ + @Excel(name = "组织机构ID") + @ApiModelProperty(name = "组织机构ID",notes = "oragnizeId") + private Long oragnizeId; + + /** 统计单元编码 */ + @Excel(name = "统计单元编码") + @ApiModelProperty(name = "统计单元编码",notes = "assetCode") + private String assetCode; + + /** 统计单元名称 */ + @Excel(name = "统计单元名称") + @ApiModelProperty(name = "统计单元名称",notes = "assetName") + private String assetName; + + /** 统计专业代码 */ + @Excel(name = "统计专业代码") + @ApiModelProperty(name = "统计专业代码",notes = "fieldCode") + private String fieldCode; + + /** 统计专业名称 */ + @Excel(name = "统计专业名称") + @ApiModelProperty(name = "统计专业名称",notes = "fieldName") + private String fieldName; + + /** 主键 */ + private Long id; + + /** 年 */ + @Excel(name = "年") + @ApiModelProperty(name = "年",notes = "year") + private String year; + + /** 月 */ + @Excel(name = "月") + @ApiModelProperty(name = "月",notes = "month") + private String month; + + /** 创建人 */ + private String createdBy; + + /** 创建时间 */ + private Date createdTime; + + /** 更新人 */ + private String updatedBy; + + /** 更新时间 */ + private Date updatedTime; + + /** 审核状态;0待审核 1 已经审核 2已处理 */ + @Excel(name = "审核状态;0待审核 1 已经审核 2已处理") + @ApiModelProperty(name = "审核状态;0待审核 1 已经审核 2已处理",notes = "checkStatus") + private String checkStatus; + + /** 审核类型;1人工2自动 */ + @Excel(name = "审核类型;1人工2自动") + @ApiModelProperty(name = "审核类型;1人工2自动",notes = "checkType") + private String checkType; + +} diff --git a/lzbi-module/src/main/java/com/lzbi/bill/domain/DcBusiTargetInputSub.java b/lzbi-module/src/main/java/com/lzbi/bill/domain/DcBusiTargetInputSub.java new file mode 100644 index 0000000..6b4c5c3 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/bill/domain/DcBusiTargetInputSub.java @@ -0,0 +1,111 @@ +package com.lzbi.bill.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import lombok.Data; +import io.swagger.annotations.ApiModelProperty; +import lombok.experimental.Accessors; +import com.lzbi.common.annotation.Excel; +import com.lzbi.module.base.BaseModuleEntity; + +/** + * 指标录入单子对象 dc_busi_target_input_sub + * + * @author lienbo + * @date 2024-01-19 + */ +@Data +@Accessors(chain = true) +public class DcBusiTargetInputSub extends BaseModuleEntity +{ + private static final long serialVersionUID = 1L; + + /** 创建人 */ + private String createdBy; + + /** 创建时间 */ + private Date createdTime; + + /** 更新人 */ + private String updatedBy; + + /** 更新时间 */ + private Date updatedTime; + + /** 主键 */ + private Long id; + + /** 主单据编号 */ + @Excel(name = "主单据编号") + @ApiModelProperty(name = "主单据编号",notes = "billNoMaster") + private String billNoMaster; + + /** 指标编码 */ + @Excel(name = "指标编码") + @ApiModelProperty(name = "指标编码",notes = "targetCode") + private String targetCode; + + /** 指标名称 */ + @Excel(name = "指标名称") + @ApiModelProperty(name = "指标名称",notes = "targetName") + private String targetName; + + /** 指标单位 */ + @Excel(name = "指标单位") + @ApiModelProperty(name = "指标单位",notes = "tagetUnit") + private String tagetUnit; + + /** 日 */ + @Excel(name = "日") + @ApiModelProperty(name = "日",notes = "day") + private String day; + + /** 结果值 */ + @Excel(name = "结果值") + @ApiModelProperty(name = "结果值",notes = "valResult") + private BigDecimal valResult; + + /** 公司ID */ + @Excel(name = "公司ID") + @ApiModelProperty(name = "公司ID",notes = "companyId") + private Long companyId; + + /** 公司名称 */ + @Excel(name = "公司名称") + @ApiModelProperty(name = "公司名称",notes = "companyName") + private String companyName; + + /** 组织机构名称 */ + @Excel(name = "组织机构名称") + @ApiModelProperty(name = "组织机构名称",notes = "organizeName") + private String organizeName; + + /** 组织机构ID */ + @Excel(name = "组织机构ID") + @ApiModelProperty(name = "组织机构ID",notes = "oragnizeId") + private Long oragnizeId; + + /** 统计单元编码 */ + @Excel(name = "统计单元编码") + @ApiModelProperty(name = "统计单元编码",notes = "assetCode") + private String assetCode; + + /** 统计单元名称 */ + @Excel(name = "统计单元名称") + @ApiModelProperty(name = "统计单元名称",notes = "assetName") + private String assetName; + + /** 统计专业代码 */ + @Excel(name = "统计专业代码") + @ApiModelProperty(name = "统计专业代码",notes = "fieldCode") + private String fieldCode; + + /** 统计专业名称 */ + @Excel(name = "统计专业名称") + @ApiModelProperty(name = "统计专业名称",notes = "fieldName") + private String fieldName; + +} diff --git a/lzbi-module/src/main/java/com/lzbi/bill/mapper/DcBusiTargetInputMasterMapper.java b/lzbi-module/src/main/java/com/lzbi/bill/mapper/DcBusiTargetInputMasterMapper.java new file mode 100644 index 0000000..2ef614e --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/bill/mapper/DcBusiTargetInputMasterMapper.java @@ -0,0 +1,63 @@ +package com.lzbi.bill.mapper; + +import java.util.List; +import com.lzbi.bill.domain.DcBusiTargetInputMaster; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * 指标录入单Mapper接口 + * + * @author lienbo + * @date 2024-01-19 + */ + +public interface DcBusiTargetInputMasterMapper extends BaseMapper +{ + /** + * 查询指标录入单 + * + * @param id 指标录入单主键 + * @return 指标录入单 + */ + public DcBusiTargetInputMaster selectDcBusiTargetInputMasterById(Long id); + + /** + * 查询指标录入单列表 + * + * @param dcBusiTargetInputMaster 指标录入单 + * @return 指标录入单集合 + */ + public List selectDcBusiTargetInputMasterList(DcBusiTargetInputMaster dcBusiTargetInputMaster); + + /** + * 新增指标录入单 + * + * @param dcBusiTargetInputMaster 指标录入单 + * @return 结果 + */ + public int insertDcBusiTargetInputMaster(DcBusiTargetInputMaster dcBusiTargetInputMaster); + + /** + * 修改指标录入单 + * + * @param dcBusiTargetInputMaster 指标录入单 + * @return 结果 + */ + public int updateDcBusiTargetInputMaster(DcBusiTargetInputMaster dcBusiTargetInputMaster); + + /** + * 删除指标录入单 + * + * @param id 指标录入单主键 + * @return 结果 + */ + public int deleteDcBusiTargetInputMasterById(Long id); + + /** + * 批量删除指标录入单 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteDcBusiTargetInputMasterByIds(Long[] ids); +} diff --git a/lzbi-module/src/main/java/com/lzbi/bill/mapper/DcBusiTargetInputSubMapper.java b/lzbi-module/src/main/java/com/lzbi/bill/mapper/DcBusiTargetInputSubMapper.java new file mode 100644 index 0000000..723aa01 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/bill/mapper/DcBusiTargetInputSubMapper.java @@ -0,0 +1,63 @@ +package com.lzbi.bill.mapper; + +import java.util.List; +import com.lzbi.bill.domain.DcBusiTargetInputSub; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * 指标录入单子Mapper接口 + * + * @author lienbo + * @date 2024-01-19 + */ + +public interface DcBusiTargetInputSubMapper extends BaseMapper +{ + /** + * 查询指标录入单子 + * + * @param id 指标录入单子主键 + * @return 指标录入单子 + */ + public DcBusiTargetInputSub selectDcBusiTargetInputSubById(Long id); + + /** + * 查询指标录入单子列表 + * + * @param dcBusiTargetInputSub 指标录入单子 + * @return 指标录入单子集合 + */ + public List selectDcBusiTargetInputSubList(DcBusiTargetInputSub dcBusiTargetInputSub); + + /** + * 新增指标录入单子 + * + * @param dcBusiTargetInputSub 指标录入单子 + * @return 结果 + */ + public int insertDcBusiTargetInputSub(DcBusiTargetInputSub dcBusiTargetInputSub); + + /** + * 修改指标录入单子 + * + * @param dcBusiTargetInputSub 指标录入单子 + * @return 结果 + */ + public int updateDcBusiTargetInputSub(DcBusiTargetInputSub dcBusiTargetInputSub); + + /** + * 删除指标录入单子 + * + * @param id 指标录入单子主键 + * @return 结果 + */ + public int deleteDcBusiTargetInputSubById(Long id); + + /** + * 批量删除指标录入单子 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteDcBusiTargetInputSubByIds(Long[] ids); +} diff --git a/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputMasterService.java b/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputMasterService.java new file mode 100644 index 0000000..6589c19 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputMasterService.java @@ -0,0 +1,255 @@ +package com.lzbi.bill.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.lzbi.asset.domain.DcBaseAssetInfo; +import com.lzbi.asset.mapper.DcBaseAssetInfoMapper; +import com.lzbi.bill.domain.DcBusiTargetInputMaster; +import com.lzbi.bill.domain.DcBusiTargetInputSub; +import com.lzbi.bill.mapper.DcBusiTargetInputMasterMapper; +import com.lzbi.common.core.domain.AjaxResult; +import com.lzbi.common.utils.DateUtils; +import com.lzbi.draft.domain.req.ConfirmReq; +import com.lzbi.draft.domain.req.ProductionDailySheetReq; +import com.lzbi.draft.domain.vo.ProductionDailySheetVO; +import com.lzbi.targetFolder.domain.DcBaseAssetTarget; +import com.lzbi.targetFolder.mapper.DcBaseAssetTargetMapper; +import org.apache.commons.collections4.IteratorUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.util.ObjectUtils; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 指标录入单Service业务层处理 + * + * @author lienbo + * @date 2024-01-19 + */ +@Service +public class DcBusiTargetInputMasterService extends ServiceImpl implements IService +{ + + @Resource + private DcBaseAssetInfoMapper dcBaseAssetInfoMapper; + + @Resource + private DcBaseAssetTargetMapper dcBaseAssetTargetMapper; + + /** + * 查询指标录入单 + * + * @param id 指标录入单主键 + * @return 指标录入单 + */ + public DcBusiTargetInputMaster selectDcBusiTargetInputMasterById(Long id) + { + return baseMapper.selectDcBusiTargetInputMasterById(id); + } + + /** + * 查询指标录入单列表 + * + * @param dcBusiTargetInputMaster 指标录入单 + * @return 指标录入单 + */ + public List selectDcBusiTargetInputMasterList(DcBusiTargetInputMaster dcBusiTargetInputMaster) + { + return baseMapper.selectDcBusiTargetInputMasterList(dcBusiTargetInputMaster); + } + + /** + * 新增指标录入单 + * + * @param dcBusiTargetInputMaster 指标录入单 + * @return 结果 + */ + + public int insertDcBusiTargetInputMaster(DcBusiTargetInputMaster dcBusiTargetInputMaster) + { + dcBusiTargetInputMaster.setCreatedTime(DateUtils.getNowDate()); + return baseMapper.insertDcBusiTargetInputMaster(dcBusiTargetInputMaster); + } + + /** + * 修改指标录入单 + * + * @param dcBusiTargetInputMaster 指标录入单 + * @return 结果 + */ + + public int updateDcBusiTargetInputMaster(DcBusiTargetInputMaster dcBusiTargetInputMaster) + { + dcBusiTargetInputMaster.setUpdatedTime(DateUtils.getNowDate()); + return baseMapper.updateDcBusiTargetInputMaster(dcBusiTargetInputMaster); + } + + /** + * 批量删除指标录入单 + * + * @param ids 需要删除的指标录入单主键 + * @return 结果 + */ + + public int deleteDcBusiTargetInputMasterByIds(Long[] ids) + { + return baseMapper.deleteDcBusiTargetInputMasterByIds(ids); + } + + /** + * 删除指标录入单信息 + * + * @param id 指标录入单主键 + * @return 结果 + */ + + public int deleteDcBusiTargetInputMasterById(Long id) + { + return baseMapper.deleteDcBusiTargetInputMasterById(id); + } + + public AjaxResult uploadProductionDaily(MultipartFile file) { + List list = new ArrayList<>(); + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + XSSFWorkbook hssfWorkbook = new XSSFWorkbook(inputStream); + int numberOfSheets = hssfWorkbook.getNumberOfSheets(); + DataFormatter formatter = new DataFormatter(); + for (int j = 0; j < numberOfSheets; j++) { + XSSFSheet sheetAt = hssfWorkbook.getSheetAt(j); + String sheetName = sheetAt.getSheetName(); + //获取数据总行数 + int rows = sheetAt.getPhysicalNumberOfRows(); + List> data = new ArrayList<>(); + //每行数据处理 + for (int i = 0; i < rows; i++) { + //获取一行数据 + XSSFRow row = sheetAt.getRow(i); + if (null != row) { + List cells = IteratorUtils.toList(row.cellIterator()); + List cellList = new ArrayList<>(); + for (int i1 = 0, len1 = cells.size(); i1 < len1; i1++) { + cellList.add(formatter.formatCellValue(cells.get(i1))); + } + data.add(cellList); + } + } + list.add(new ProductionDailySheetVO(j, sheetName, data)); + } + return AjaxResult.success(list); + } catch (Exception e) { + log.error("文件解析异常", e); + return AjaxResult.error(); + } finally { + try { + if (null != inputStream) { + inputStream.close(); + } + } catch (IOException e) { + log.error("文件解析异常", e); + } + } + } + + public AjaxResult confirm(ConfirmReq confirmReq) { + List result = new ArrayList<>(); + List list = confirmReq.getList(); + if (CollectionUtils.isEmpty(list)) { + return AjaxResult.error("请选择需要保存的热源数据"); + } + Map assetMap = new HashMap<>(); + Map> targetMap = new HashMap<>(); + for (ProductionDailySheetReq productionDailySheetReq : list) { + String name = productionDailySheetReq.getName(); + DcBaseAssetInfo dcBaseAssetInfo = dcBaseAssetInfoMapper.selectDcBaseAssetInfoByAliasName(name); + if (ObjectUtils.isEmpty(dcBaseAssetInfo)) { + return AjaxResult.error(name + "sheet页没有对应的统计单元"); + } + DcBaseAssetTarget params = new DcBaseAssetTarget(); + params.setAssetCode(dcBaseAssetInfo.getAssetCode()); + List dcBaseAssetTargets = dcBaseAssetTargetMapper.selectDcBaseAssetTargetList(params); + if (CollectionUtils.isEmpty(dcBaseAssetTargets)) { + return AjaxResult.error(name + "sheet页没有对应的指标"); + } + Map targetMap1 = new HashMap<>(); + dcBaseAssetTargets.forEach(dcBaseAssetTarget -> targetMap1.put(dcBaseAssetTarget.getTargetName(), dcBaseAssetTarget)); + targetMap.put(name, targetMap1); + assetMap.put(name, dcBaseAssetInfo); + } + for (ProductionDailySheetReq productionDailySheetReq : list) { + String name = productionDailySheetReq.getName(); + DcBaseAssetInfo dcBaseAssetInfo = assetMap.get(name); + Map dcBaseAssetTargetMap = targetMap.get(name); + List> data = productionDailySheetReq.getData(); + if (!CollectionUtils.isEmpty(data)) { + Map dayMap = new HashMap<>(); + boolean sign = false; + for (int i = 0, leni = data.size(); i < leni; i++) { + List row = data.get(i); + if ("日期".equals(row.get(0))) { + Map columnMap = new HashMap<>(); + int lenj = row.size(); + for (int j = 1; j < lenj; j++) { + if (!columnMap.containsKey(row.get(j))) { + columnMap.put(row.get(j), j); + } + } + for (int j = 1; j <= 31 && j < lenj; j++) { + String key = j + "日"; + if (columnMap.containsKey(key) && !dayMap.containsKey(key)) { + dayMap.put(j, columnMap.get(key)); + } + } + sign = true; + continue; + } + if (sign) { + String column = row.get(0); + if (StringUtils.isBlank(column)) { + break; + } + DcBaseAssetTarget dcBaseAssetTarget = dcBaseAssetTargetMap.get(column); + if (!ObjectUtils.isEmpty(dcBaseAssetTarget)) { + dayMap.forEach((day, index) -> { + String v = row.get(index); + if (StringUtils.isNotBlank(v)) { + DcBusiTargetInputSub dcBusiTargetInputSub = new DcBusiTargetInputSub(); + BeanUtils.copyProperties(dcBaseAssetTarget, dcBusiTargetInputSub); + dcBusiTargetInputSub.setAssetCode(dcBaseAssetInfo.getAssetCode()); + dcBusiTargetInputSub.setAssetName(dcBaseAssetInfo.getAssetName()); + dcBusiTargetInputSub.setCompanyId(dcBaseAssetInfo.getComanyId()); + dcBusiTargetInputSub.setOragnizeId(dcBaseAssetInfo.getOrgId()); +// dcBusiTargetInputSub.setCompanyName(); +// dcBusiTargetInputSub.setOrganizeName(); + dcBusiTargetInputSub.setTagetUnit(dcBaseAssetTarget.getFieldUnit()); + dcBusiTargetInputSub.setDay(String.valueOf(day)); + dcBusiTargetInputSub.setValResult(new BigDecimal(v)); + result.add(dcBusiTargetInputSub); + } + }); + } + } + } + } + } + return AjaxResult.success(result); + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputSubService.java b/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputSubService.java new file mode 100644 index 0000000..b143a9c --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputSubService.java @@ -0,0 +1,91 @@ +package com.lzbi.bill.service; + +import java.util.List; +import com.lzbi.common.utils.DateUtils; +import org.springframework.stereotype.Service; +import com.lzbi.bill.domain.DcBusiTargetInputSub; +import com.lzbi.bill.mapper.DcBusiTargetInputSubMapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +/** + * 指标录入单子Service业务层处理 + * + * @author lienbo + * @date 2024-01-19 + */ +@Service +public class DcBusiTargetInputSubService extends ServiceImpl implements IService +{ + + /** + * 查询指标录入单子 + * + * @param id 指标录入单子主键 + * @return 指标录入单子 + */ + public DcBusiTargetInputSub selectDcBusiTargetInputSubById(Long id) + { + return baseMapper.selectDcBusiTargetInputSubById(id); + } + + /** + * 查询指标录入单子列表 + * + * @param dcBusiTargetInputSub 指标录入单子 + * @return 指标录入单子 + */ + public List selectDcBusiTargetInputSubList(DcBusiTargetInputSub dcBusiTargetInputSub) + { + return baseMapper.selectDcBusiTargetInputSubList(dcBusiTargetInputSub); + } + + /** + * 新增指标录入单子 + * + * @param dcBusiTargetInputSub 指标录入单子 + * @return 结果 + */ + + public int insertDcBusiTargetInputSub(DcBusiTargetInputSub dcBusiTargetInputSub) + { + dcBusiTargetInputSub.setCreatedTime(DateUtils.getNowDate()); + return baseMapper.insertDcBusiTargetInputSub(dcBusiTargetInputSub); + } + + /** + * 修改指标录入单子 + * + * @param dcBusiTargetInputSub 指标录入单子 + * @return 结果 + */ + + public int updateDcBusiTargetInputSub(DcBusiTargetInputSub dcBusiTargetInputSub) + { + dcBusiTargetInputSub.setUpdatedTime(DateUtils.getNowDate()); + return baseMapper.updateDcBusiTargetInputSub(dcBusiTargetInputSub); + } + + /** + * 批量删除指标录入单子 + * + * @param ids 需要删除的指标录入单子主键 + * @return 结果 + */ + + public int deleteDcBusiTargetInputSubByIds(Long[] ids) + { + return baseMapper.deleteDcBusiTargetInputSubByIds(ids); + } + + /** + * 删除指标录入单子信息 + * + * @param id 指标录入单子主键 + * @return 结果 + */ + + public int deleteDcBusiTargetInputSubById(Long id) + { + return baseMapper.deleteDcBusiTargetInputSubById(id); + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/common/SelectOptionsControl.java b/lzbi-module/src/main/java/com/lzbi/common/SelectOptionsControl.java index 33a6049..f9f3e0a 100644 --- a/lzbi-module/src/main/java/com/lzbi/common/SelectOptionsControl.java +++ b/lzbi-module/src/main/java/com/lzbi/common/SelectOptionsControl.java @@ -146,4 +146,14 @@ public class SelectOptionsControl extends BaseController { dcBusiParamSource.setFieldCode(fcode); return AjaxResult.success(dcBusiParamSourceService.selectByVo(dcBusiParamSource)); } + + /** + * 查询采集参数树形结构 + * @param paramsName 参数名称 + * @return + */ + @GetMapping("/selectParamSourceTree") + public AjaxResult selectParamSourceTree(@RequestParam(value = "paramsName", required = false) String paramsName) { + return AjaxResult.success(dcBusiParamSourceService.selectParamSourceTree(paramsName)); + } } diff --git a/lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java b/lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java index 3d4d466..3e03dd9 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java +++ b/lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java @@ -197,14 +197,4 @@ public class ReportController extends BaseController { public List getThourWeather(@Validated ReadQueryReq readQueryReq) { return workParamReadService.getThourWeather(readQueryReq); } - - @PostMapping("/upload/production/daily") - public AjaxResult uploadProductionDaily(MultipartFile file) { - return reportService.uploadProductionDaily(file); - } - - @PostMapping("/save/production/daily") - public AjaxResult saveProductionDaily(@RequestBody List list) { - return reportService.saveProductionDaily(list); - } } diff --git a/lzbi-module/src/main/java/com/lzbi/draft/domain/req/ConfirmReq.java b/lzbi-module/src/main/java/com/lzbi/draft/domain/req/ConfirmReq.java new file mode 100644 index 0000000..48e9dcf --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/draft/domain/req/ConfirmReq.java @@ -0,0 +1,11 @@ +package com.lzbi.draft.domain.req; + +import lombok.Data; + +import java.util.List; + +@Data +public class ConfirmReq { + + private List list; +} diff --git a/lzbi-module/src/main/java/com/lzbi/draft/service/ReportService.java b/lzbi-module/src/main/java/com/lzbi/draft/service/ReportService.java index d67c002..d92e06d 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/service/ReportService.java +++ b/lzbi-module/src/main/java/com/lzbi/draft/service/ReportService.java @@ -79,49 +79,7 @@ public class ReportService { return list; } - public AjaxResult uploadProductionDaily(MultipartFile file) { - List list = new ArrayList<>(); - InputStream inputStream = null; - try { - inputStream = file.getInputStream(); - XSSFWorkbook hssfWorkbook = new XSSFWorkbook(inputStream); - int numberOfSheets = hssfWorkbook.getNumberOfSheets(); - DataFormatter formatter = new DataFormatter(); - for (int j = 0; j < numberOfSheets; j++) { - XSSFSheet sheetAt = hssfWorkbook.getSheetAt(j); - String sheetName = sheetAt.getSheetName(); - //获取数据总行数 - int rows = sheetAt.getPhysicalNumberOfRows(); - List> data = new ArrayList<>(); - //每行数据处理 - for (int i = 0; i < rows; i++) { - //获取一行数据 - XSSFRow row = sheetAt.getRow(i); - if (null != row) { - List cells = IteratorUtils.toList(row.cellIterator()); - List cellList = new ArrayList<>(); - for (int i1 = 0, len1 = cells.size(); i1 < len1; i1++) { - cellList.add(formatter.formatCellValue(cells.get(i1))); - } - data.add(cellList); - } - } - list.add(new ProductionDailySheetVO(j, sheetName, data)); - } - return AjaxResult.success(list); - } catch (Exception e) { - log.error("文件解析异常", e); - return AjaxResult.error(); - } finally { - try { - if (null != inputStream) { - inputStream.close(); - } - } catch (IOException e) { - log.error("文件解析异常", e); - } - } - } + public AjaxResult saveProductionDaily(List list) { if (CollectionUtils.isEmpty(list)) { diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/controller/BizController.java b/lzbi-module/src/main/java/com/lzbi/wechat/controller/BizController.java new file mode 100644 index 0000000..1b10b2d --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/controller/BizController.java @@ -0,0 +1,97 @@ +package com.lzbi.wechat.controller; + +import com.lzbi.common.core.domain.AjaxResult; +import com.lzbi.wechat.service.DeptService; +import com.lzbi.wechat.service.TargetService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/wechat/biz") +public class BizController { + + @Autowired + @Qualifier("wechatDeptService") + private DeptService deptService; + + @Autowired + private TargetService targetService; + + /** + * 获取自己所在部门 + * @return + */ + @GetMapping("/dept/self/list") + public AjaxResult getSelfDeptList() { + return AjaxResult.success(deptService.getSelfDeptList()); + } + + /** + * 获取供热面积 + * @return + */ + @GetMapping("/heatRadiatingArea") + public AjaxResult getHeatRadiatingArea(@RequestParam("deptId") Long deptId) { + return AjaxResult.success(targetService.getHeatRadiatingArea(deptId)); + } + + /** + * 获取公司指标值 + * @return + */ + @GetMapping("/comany/target") + public AjaxResult getComanyTarget(@RequestParam("deptId") Long deptId) { + return AjaxResult.success(targetService.getComanyTarget(deptId)); + } + + /** + * 获取热源指标值 + * @param type 1、单日指标,2、累计指标 + * @return + */ + @GetMapping("/heatSource/target") + public AjaxResult getHeatSourceTarget(@RequestParam("deptId") Long deptId, @RequestParam("type") String type) { + return AjaxResult.success(targetService.getHeatSourceTarget(deptId, type)); + } + + /** + * 获取换热站参数 + * @return + */ + @GetMapping("/heatExchangeStation/params") + public AjaxResult getHeatExchangeStationParams(@RequestParam("deptId") Long deptId) { + return AjaxResult.success(targetService.getHeatExchangeStationParams(deptId)); + } + + /** + * 获取完成率 + * @return + */ + @GetMapping("/finishingRate") + public AjaxResult getFinishingRate(@RequestParam("deptId") Long deptId) { + return AjaxResult.success(targetService.getFinishingRate(deptId)); + } + + /** + * 获取完成率 + * @return + */ + @GetMapping("/finishingRateLine") + public AjaxResult getFinishingRateLine(@RequestParam("deptId") Long deptId) { + return AjaxResult.success(targetService.finishingRateLine(deptId)); + } + + /** + * 获取下属部门列表 + * @return + */ + @GetMapping("/dept/children") + public AjaxResult getDeptChildren(@RequestParam("deptId") Long deptId) { + return AjaxResult.success(deptService.getDeptChildren(deptId)); + } + +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/controller/LoginController.java b/lzbi-module/src/main/java/com/lzbi/wechat/controller/LoginController.java new file mode 100644 index 0000000..1bd8e35 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/controller/LoginController.java @@ -0,0 +1,36 @@ +package com.lzbi.wechat.controller; + +import com.lzbi.common.constant.Constants; +import com.lzbi.common.core.domain.AjaxResult; +import com.lzbi.common.core.domain.model.LoginBody; +import com.lzbi.framework.web.service.SysLoginService; +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; + +@RestController +@RequestMapping("/wechat/biz/login") +public class LoginController { + + @Autowired + private SysLoginService loginService; + + /** + * 登录方法 + * + * @param loginBody 登录信息 + * @return 结果 + */ + @PostMapping("/username") + public AjaxResult login(@RequestBody LoginBody loginBody) + { + AjaxResult ajax = AjaxResult.success(); + // 生成令牌 + String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), + loginBody.getUuid()); + ajax.put(Constants.TOKEN, token); + return ajax; + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/controller/WechatController.java b/lzbi-module/src/main/java/com/lzbi/wechat/controller/WechatController.java new file mode 100644 index 0000000..1dba9d4 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/controller/WechatController.java @@ -0,0 +1,54 @@ +package com.lzbi.wechat.controller; + +import com.lzbi.common.core.domain.AjaxResult; +import com.lzbi.wechat.domain.req.CodeLoginReq; +import com.lzbi.wechat.domain.req.PhoneNumberLoginReq; +import com.lzbi.wechat.domain.req.PhoneNumberReq; +import com.lzbi.wechat.service.WechatService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +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; + +/** + * 微信服务相关接口控制器 + */ +@RestController +@RequestMapping("/wechat/server") +public class WechatController { + + @Autowired + private WechatService wechatService; + + /** + * 登录凭证登录 + * @param codeLoginReq + * @return + */ + @PostMapping("/codeLogin") + public AjaxResult codeLogin(@Validated @RequestBody CodeLoginReq codeLoginReq) { + return AjaxResult.success("操作成功", wechatService.codeLogin(codeLoginReq)); + } + + /** + * 获取手机号 + * @param phoneNumberReq + * @return + */ + @PostMapping("/phoneNumber") + public AjaxResult getPhoneNumber(@Validated @RequestBody PhoneNumberReq phoneNumberReq) { + return AjaxResult.success("操作成功", wechatService.getPhoneNumber(phoneNumberReq)); + } + + /** + * 手机号登录 + * @param phoneNumberLoginReq + * @return + */ + @PostMapping("/phoneNumberLogin") + public AjaxResult phoneNumberLogin(@Validated @RequestBody PhoneNumberLoginReq phoneNumberLoginReq) { + return AjaxResult.success("操作成功", wechatService.phoneNumberLogin(phoneNumberLoginReq)); + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/SysWechat.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/SysWechat.java new file mode 100644 index 0000000..fdaac4d --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/SysWechat.java @@ -0,0 +1,30 @@ +package com.lzbi.wechat.domain; + +import lombok.Data; + +/** + * 微信用户关系实体类 + */ +@Data +public class SysWechat { + + /** + * id + */ + private Long id; + /** + * 微信用户唯一标识 + */ + private String openId; + /** + * 手机号 + */ + private String phone; + + public SysWechat() {} + + public SysWechat(String openId, String phone) { + this.openId = openId; + this.phone = phone; + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatAccessTokenRep.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatAccessTokenRep.java new file mode 100644 index 0000000..1c8c204 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatAccessTokenRep.java @@ -0,0 +1,14 @@ +package com.lzbi.wechat.domain.rep; + +import lombok.Data; + +/** + * 获取接口调用凭据 + */ +@Data +public class WechatAccessTokenRep extends WechatBaseRep{ + + private String access_token; + + private Long expires_in; +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatBaseRep.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatBaseRep.java new file mode 100644 index 0000000..b5d57f5 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatBaseRep.java @@ -0,0 +1,19 @@ +package com.lzbi.wechat.domain.rep; + +import lombok.Data; + +/** + * 微信接口返回值 + */ +@Data +public class WechatBaseRep { + + /** + * 错误码 + */ + private Integer errcode; + /** + * 错误信息 + */ + private String errmsg; +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatCodeLoginRep.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatCodeLoginRep.java new file mode 100644 index 0000000..d716557 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatCodeLoginRep.java @@ -0,0 +1,23 @@ +package com.lzbi.wechat.domain.rep; + +import lombok.Data; + +/** + * 微信登录凭证登录返回值 + */ +@Data +public class WechatCodeLoginRep extends WechatBaseRep { + + /** + * 会话密钥 + */ + private String session_key; + /** + * 用户在开放平台的唯一标识符,若当前小程序已绑定到微信开放平台账号下会返回 + */ + private String unionid; + /** + * 用户唯一标识 + */ + private String openid; +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatPhoneNumberRep.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatPhoneNumberRep.java new file mode 100644 index 0000000..03988a5 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatPhoneNumberRep.java @@ -0,0 +1,28 @@ +package com.lzbi.wechat.domain.rep; + +import lombok.Data; + +/** + * 获取手机号返回值 + */ +@Data +public class WechatPhoneNumberRep extends WechatBaseRep { + + /** + * 手机号信息 + */ + private PhoneInfo phone_info; + + /** + * 手机号信息 + */ + @Data + public static class PhoneInfo { + + private String phoneNumber; + + private String purePhoneNumber; + + private String countryCode; + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/CodeLoginReq.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/CodeLoginReq.java new file mode 100644 index 0000000..04f1daf --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/CodeLoginReq.java @@ -0,0 +1,18 @@ +package com.lzbi.wechat.domain.req; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * 微信授权登录请求参数 + */ +@Data +public class CodeLoginReq { + + /** + * 登录时获取的 code,可通过wx.login获取 + */ + @NotBlank(message = "登录凭证不能为空") + private String code; +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberLoginReq.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberLoginReq.java new file mode 100644 index 0000000..8178cf9 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberLoginReq.java @@ -0,0 +1,19 @@ +package com.lzbi.wechat.domain.req; + +import lombok.Data; + +/** + * 手机号登录请求参数 + */ +@Data +public class PhoneNumberLoginReq { + + /** + * 手机号 + */ + private String phone; + /** + * 微信用户唯一标识 + */ + private String openId; +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberReq.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberReq.java new file mode 100644 index 0000000..dd386b5 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberReq.java @@ -0,0 +1,18 @@ +package com.lzbi.wechat.domain.req; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * 获取手机号请求参数 + */ +@Data +public class PhoneNumberReq { + + /** + * 手机号获取凭证 + */ + @NotBlank(message = "手机号获取凭证不能为空") + private String code; +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/ChildDeptVO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/ChildDeptVO.java new file mode 100644 index 0000000..3b77a87 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/ChildDeptVO.java @@ -0,0 +1,28 @@ +package com.lzbi.wechat.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ChildDeptVO { + + /** + * 部门id + */ + private Object deptId; + /** + * 部门名称 + */ + private String deptName; + /** + * 一次网供温 + */ + private Double temperatureSupply; + /** + * 一次网回温 + */ + private Double temperatureComeBack; +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/CodeLoginVO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/CodeLoginVO.java new file mode 100644 index 0000000..60fd880 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/CodeLoginVO.java @@ -0,0 +1,14 @@ +package com.lzbi.wechat.domain.vo; + +import lombok.Data; + +/** + * 登录凭证登录返回值 + */ +@Data +public class CodeLoginVO { + + private String token; + + private String openId; +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/DeptVO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/DeptVO.java new file mode 100644 index 0000000..86857e4 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/DeptVO.java @@ -0,0 +1,19 @@ +package com.lzbi.wechat.domain.vo; + +import lombok.Data; + +/** + * 部门返回值 + */ +@Data +public class DeptVO { + + /** + * 部门id + */ + private Long value; + /** + * 部门名称 + */ + private String label; +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/FinishingRateVO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/FinishingRateVO.java new file mode 100644 index 0000000..b75c149 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/FinishingRateVO.java @@ -0,0 +1,22 @@ +package com.lzbi.wechat.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class FinishingRateVO { + + /** + * 指标怕名称列表 + */ + private List names; + /** + * 指标值列表 + */ + private List values; +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetVO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetVO.java new file mode 100644 index 0000000..6a0067f --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetVO.java @@ -0,0 +1,31 @@ +package com.lzbi.wechat.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 指标返回值 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TargetVO { + + /** + * 指标编码 + */ + private String targetCode; + /** + * 指标名称 + */ + private String targetName; + /** + * 指标单位 + */ + private String targetUnit; + /** + * 值 + */ + private Double value; +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/mapper/SysWechatMapper.java b/lzbi-module/src/main/java/com/lzbi/wechat/mapper/SysWechatMapper.java new file mode 100644 index 0000000..5e33e1b --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/mapper/SysWechatMapper.java @@ -0,0 +1,45 @@ +package com.lzbi.wechat.mapper; + +import com.lzbi.wechat.domain.SysWechat; +import org.apache.ibatis.annotations.Param; + +/** + * 微信用户关系数据访问层 + */ +public interface SysWechatMapper { + + /** + * 查询微信用户关系 + * @param id + * @return + */ + SysWechat selectSysWechatById(@Param("id") Long id); + + /** + * 查询微信用户关系 + * @param openId + * @return + */ + SysWechat selectWechatByOpenId(@Param("openId") String openId); + + /** + * 增加微信用户关系 + * @param sysWechat + * @return + */ + int insertSysWechat(SysWechat sysWechat); + + /** + * 修改微信用户关系 + * @param sysWechat + * @return + */ + int updateSysWechat(SysWechat sysWechat); + + /** + * 删除微信用户关系 + * @param id + * @return + */ + int deleteSysWechat(@Param("id") Long id); +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/service/DeptService.java b/lzbi-module/src/main/java/com/lzbi/wechat/service/DeptService.java new file mode 100644 index 0000000..3c54ec2 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/service/DeptService.java @@ -0,0 +1,92 @@ +package com.lzbi.wechat.service; + +import com.lzbi.common.constant.BizConstants; +import com.lzbi.common.core.domain.entity.SysDept; +import com.lzbi.common.core.domain.entity.SysRole; +import com.lzbi.common.core.domain.entity.SysUser; +import com.lzbi.common.core.domain.model.LoginUser; +import com.lzbi.common.utils.SecurityUtils; +import com.lzbi.system.service.ISysDeptService; +import com.lzbi.wechat.domain.vo.ChildDeptVO; +import com.lzbi.wechat.domain.vo.DeptVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@Service("wechatDeptService") +public class DeptService { + + @Autowired + private ISysDeptService sysDeptService; + + public List getSelfDeptList() { + List list = new ArrayList<>(); + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getUser(); + List roles = sysUser.getRoles(); + List roleIds = roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()); + List sysDepts = sysDeptService.selectDeptListByRoleIds(roleIds); + if (!CollectionUtils.isEmpty(sysDepts)) { + list = sysDepts.stream().filter(sysDept -> { + if (BizConstants.DcDeptAttr.COMANY.equals(sysDept.getOrgType())) { + return true; + } else { + return false; + } + }).map(sysDept -> { + DeptVO deptVO = new DeptVO(); + deptVO.setValue(sysDept.getDeptId()); + deptVO.setLabel(sysDept.getDeptName()); + return deptVO; + }).collect(Collectors.toList()); + } + return list; + } + + public List getDeptChildren(Long deptId) { + List list = new ArrayList<>(); + SysDept selfDept = sysDeptService.selectDeptById(deptId); + String orgType = selfDept.getOrgType(); + if (BizConstants.DcDeptAttr.COMANY.equals(orgType)) { +// SysDept query = new SysDept(); +// query.setParentId(deptId); +// query.setOrgType(BizConstants.DcDeptAttr.HEAT_SOURCE); +// List sysDeptList = sysDeptService.selectDeptList(query); +// if (!CollectionUtils.isEmpty(sysDeptList)) { +// list = sysDeptList.stream().map(item -> { +// ChildDeptVO childDeptVO = new ChildDeptVO(); +// childDeptVO.setDeptId(item.getDeptId()); +// childDeptVO.setDeptName(item.getDeptName()); +// childDeptVO.setTemperatureSupply(80D); +// childDeptVO.setTemperatureComeBack(53D); +// return childDeptVO; +// }).collect(Collectors.toList()); +// } + list.add(new ChildDeptVO(103L, "1#热源", 80D, 53D)); + list.add(new ChildDeptVO(104L, "2#热源", 76D, 42D)); + } else { +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.eq("orgCode", deptId); +// queryWrapper.eq("assetType", BizConstants.DcAssetAttr.HEAT_EXCHANGE_STATION); +// List assetInfoList = dcBaseAssetInfoService.list(queryWrapper); +// if (!CollectionUtils.isEmpty(assetInfoList)) { +// list = assetInfoList.stream().map(item -> { +// ChildDeptVO childDeptVO = new ChildDeptVO(); +// childDeptVO.setDeptId(item.getAssetCode()); +// childDeptVO.setDeptName(item.getAssetName()); +// childDeptVO.setTemperatureSupply(80D); +// childDeptVO.setTemperatureComeBack(53D); +// return childDeptVO; +// }).collect(Collectors.toList()); +// } + list.add(new ChildDeptVO(1L, "大唐管井", 90D, 105D)); + list.add(new ChildDeptVO(2L, "汪家分局", 80D, 105D)); + list.add(new ChildDeptVO(3L, "万盈大厦", 90D, 89D)); + } + return list; + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/service/SysWechatService.java b/lzbi-module/src/main/java/com/lzbi/wechat/service/SysWechatService.java new file mode 100644 index 0000000..dd9ff7b --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/service/SysWechatService.java @@ -0,0 +1,62 @@ +package com.lzbi.wechat.service; + +import com.lzbi.wechat.domain.SysWechat; +import com.lzbi.wechat.mapper.SysWechatMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * 微信用户关系业务访问层 + */ +@Service +public class SysWechatService { + + @Resource + private SysWechatMapper sysWechatMapper; + + /** + * 查询微信用户关系 + * @param id + * @return + */ + public SysWechat selectWechatById(Long id) { + return sysWechatMapper.selectSysWechatById(id); + } + + /** + * 查询微信用户关系 + * @param openId + * @return + */ + public SysWechat selectWechatByOpenId(String openId) { + return sysWechatMapper.selectWechatByOpenId(openId); + } + + /** + * 增加微信用户关系 + * @param sysWechat + * @return + */ + public int insertWechat(SysWechat sysWechat) { + return sysWechatMapper.insertSysWechat(sysWechat); + } + + /** + * 修改微信用户关系 + * @param sysWechat + * @return + */ + public int updateWechat(SysWechat sysWechat) { + return sysWechatMapper.updateSysWechat(sysWechat); + } + + /** + * 删除微信用户关系 + * @param id + * @return + */ + public int deleteWechat(Long id) { + return sysWechatMapper.deleteSysWechat(id); + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/service/TargetService.java b/lzbi-module/src/main/java/com/lzbi/wechat/service/TargetService.java new file mode 100644 index 0000000..3f905fe --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/service/TargetService.java @@ -0,0 +1,157 @@ +package com.lzbi.wechat.service; + +import com.lzbi.common.constant.BizConstants; +import com.lzbi.common.core.domain.entity.SysDept; +import com.lzbi.system.service.ISysDeptService; +import com.lzbi.wechat.domain.vo.TargetVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +@Service +public class TargetService { + + @Autowired + private ISysDeptService sysDeptService; + + public Double getHeatRadiatingArea(Long deptId) { + Double result = 314251101D; + return result; + } + + public Map getComanyTarget(Long deptId) { + Map map = new HashMap<>(); + SysDept selfDept = sysDeptService.selectDeptById(deptId); + map.put("00023210", new TargetVO("00023210", "总产热量", "GJ", 14123123D)); + map.put("00023211", new TargetVO("00023211", "水总耗", "GJ", 2697D)); + map.put("00023212", new TargetVO("00023212", "电总耗", "GJ", 16791D)); + map.put("00023213", new TargetVO("00023213", "煤总耗", "GJ", 11679D)); + map.put("00023214", new TargetVO("00023214", "平均单耗", "GJ", 8971D)); + return map; + } + + public Map getHeatSourceTarget(Long deptId, String type) { + Map map = new HashMap<>(); + SysDept selfDept = sysDeptService.selectDeptById(deptId); + if (BizConstants.TargetType.DAY.equals(type)) { + map.put("ycwsh", new TargetVO("ycwsh", "一次网水耗", "GJ", 14123123D)); + map.put("ycwdh", new TargetVO("ycwdh", "一次网电耗", "GJ", 2697D)); + map.put("ycwmh", new TargetVO("ycwmh", "一次网煤耗", "GJ", 16791D)); + map.put("zcrl", new TargetVO("zcrl", "总产热量", "GJ", 11679D)); + map.put("zcql", new TargetVO("zcql", "总产汽量", "GJ", 8971D)); + map.put("zfdl", new TargetVO("zfdl", "总发电量", "GJ", 14123123D)); + map.put("ecwsh", new TargetVO("ecwsh", "二次网水耗", "GJ", 2697D)); + map.put("ecwdh", new TargetVO("ecwdh", "二次网电耗", "GJ", 16791D)); + map.put("xhll", new TargetVO("xhll", "循环流量", "GJ", 11679D)); + map.put("ycwgw", new TargetVO("ycwgw", "一次网供温", "GJ", 8971D)); + map.put("ycwhw", new TargetVO("ycwhw", "一次网回温", "GJ", 8971D)); + map.put("ycwsdh", new TargetVO("ycwsdh", "一次网水单耗", "GJ", 14123123D)); + map.put("ycwddh", new TargetVO("ycwddh", "一次网电单耗", "GJ", 2697D)); + map.put("ycwmdh", new TargetVO("ycwmdh", "一次网煤单耗", "GJ", 16791D)); + map.put("dcrl", new TargetVO("dcrl", "单产热量", "GJ", 11679D)); + map.put("dcql", new TargetVO("dcql", "单产汽量", "GJ", 8971D)); + map.put("dfdl", new TargetVO("dfdl", "单发电量", "GJ", 14123123D)); + map.put("ecwsdh", new TargetVO("ecwsdh", "二次网水单耗", "GJ", 2697D)); + map.put("ecwddh", new TargetVO("ecwddh", "二次网电单耗", "GJ", 16791D)); + } else { + map.put("ycwshlj", new TargetVO("ycwshlj", "一次网水耗", "GJ", 14123123D)); + map.put("ycwdhlj", new TargetVO("ycwdhlj", "一次网电耗", "GJ", 2697D)); + map.put("ycwmhlj", new TargetVO("ycwmhlj", "一次网煤耗", "GJ", 16791D)); + map.put("zcrllj", new TargetVO("zcrllj", "总产热量", "GJ", 11679D)); + map.put("zcqllj", new TargetVO("zcqllj", "总产汽量", "GJ", 8971D)); + map.put("zfdllj", new TargetVO("zfdllj", "总发电量", "GJ", 14123123D)); + map.put("ecwshlj", new TargetVO("ecwshlj", "二次网水耗", "GJ", 2697D)); + map.put("ecwdhlj", new TargetVO("ecwdhlj", "二次网电耗", "GJ", 16791D)); + map.put("xhlllj", new TargetVO("xhllj", "循环流量", "GJ", 11679D)); + map.put("ycwgwlj", new TargetVO("ycwgwlj", "一次网供温", "GJ", 8971D)); + map.put("ycwhwlj", new TargetVO("ycwhwlj", "一次网回温", "GJ", 8971D)); + map.put("ycwsdhlj", new TargetVO("ycwsdhlj", "一次网水单耗", "GJ", 14123123D)); + map.put("ycwddhlj", new TargetVO("ycwddhlj", "一次网电单耗", "GJ", 2697D)); + map.put("ycwmdhlj", new TargetVO("ycwmdhlj", "一次网煤单耗", "GJ", 16791D)); + map.put("dcrllj", new TargetVO("dcrllj", "单产热量", "GJ", 11679D)); + map.put("dcqllj", new TargetVO("dcqllj", "单产汽量", "GJ", 8971D)); + map.put("dfdllj", new TargetVO("dfdllj", "单发电量", "GJ", 14123123D)); + map.put("ecwsdhlj", new TargetVO("ecwsdhlj", "二次网水单耗", "GJ", 2697D)); + map.put("ecwddhlj", new TargetVO("ecwddhlj", "二次网电单耗", "GJ", 16791D)); + } + return map; + } + + public Map getHeatExchangeStationParams(Long deptId) { + Map map = new HashMap<>(); + map.put("014", new TargetVO("014", "一次网回压", "Mpa", 14123123D)); + map.put("013", new TargetVO("013", "一次网供压", "Mpa", 2697D)); + map.put("011", new TargetVO("011", "一次网供温", "°C", 16791D)); + map.put("012", new TargetVO("012", "一次网回温", "°C", 11679D)); + map.put("007", new TargetVO("007", "瞬时流量", "m³/h", 8971D)); + map.put("008", new TargetVO("008", "瞬时热量", "kcal", 14123123D)); + map.put("009", new TargetVO("009", "累计热量", "kcal", 2697D)); + map.put("047", new TargetVO("047", "二次网供水压力", "Mpa", 16791D)); + map.put("048", new TargetVO("048", "二次网回水压力", "Mpa", 11679D)); + map.put("045", new TargetVO("045", "二次网供水温", "°C", 8971D)); + map.put("046", new TargetVO("046", "二次网回水温", "°C", 8971D)); + map.put("001", new TargetVO("001", "电调阀开度给定", "%", 14123123D)); + map.put("002", new TargetVO("002", "电调阀开度反馈", "%", 2697D)); + map.put("015", new TargetVO("015", "水箱水位计", "GJ", 16791D)); + map.put("004", new TargetVO("004", "电调阀控制模式选择", "GJ", 11679D)); + map.put("003", new TargetVO("003", "电调阀远控/就地", "°C", 8971D)); + map.put("044", new TargetVO("044", "二次网压差设定", "%", 14123123D)); + map.put("019", new TargetVO("019", "一次网管道泵上电", "", 2697D)); + map.put("020", new TargetVO("020", "一次网管道泵下电", "", 16791D)); + map.put("005", new TargetVO("005", "二次网供温设定", "", 16791D)); + map.put("018", new TargetVO("018", "一次网管道泵远控/就地", "", 16791D)); + map.put("021", new TargetVO("021", "一次网管道泵启动", "", 16791D)); + map.put("010", new TargetVO("010", "热量累计清零", "kwh", 16791D)); + map.put("017", new TargetVO("017", "总电表", "°C", 16791D)); + map.put("006", new TargetVO("006", "二次网供回水平均温设定", "m³", 16791D)); + map.put("031", new TargetVO("031", "水表(累计补水量)", "%", 16791D)); + map.put("023", new TargetVO("023", "一次网管道泵频率给定", "%", 16791D)); + map.put("028", new TargetVO("028", "一次网混水电调阀开度给定", "%", 16791D)); + map.put("029", new TargetVO("029", "一次网混水电调阀开度反馈", "", 16791D)); + map.put("035", new TargetVO("035", "补水泵1#故障状态", "m³", 16791D)); + map.put("032", new TargetVO("032", "水表(累计补水量清零)", "", 16791D)); + map.put("036", new TargetVO("036", "补水泵2#故障状态", "", 16791D)); + map.put("037", new TargetVO("037", "循环泵远控/就地选择", "", 16791D)); + map.put("038", new TargetVO("038", "循环泵1#/2#泵选择", "", 16791D)); + map.put("039", new TargetVO("039", "循环泵控制模式选择", "", 16791D)); + map.put("025", new TargetVO("025", "一次网管道泵运行/停止状态", "", 16791D)); + map.put("026", new TargetVO("026", "一次网管道泵故障状态", "", 16791D)); + map.put("027", new TargetVO("027", "一次网混水电调阀远控/就地", "", 16791D)); + map.put("033", new TargetVO("033", "补水泵1#运行/停止状态", "", 16791D)); + map.put("034", new TargetVO("034", "补水泵2#运行/停止状态", "", 16791D)); + map.put("040", new TargetVO("040", "循环泵变频上电", "", 16791D)); + map.put("041", new TargetVO("041", "循环泵变频下电", "", 16791D)); + map.put("042", new TargetVO("042", "循环泵变频启动", "", 16791D)); + map.put("043", new TargetVO("043", "循环泵变频停止", "", 16791D)); + map.put("022", new TargetVO("022", "一次网管道泵停止", "", 16791D)); + map.put("030", new TargetVO("030", "水表(瞬时补水量)", "m³", 16791D)); + map.put("066", new TargetVO("066", "一次网管道泵启/停", "", 16791D)); + map.put("024", new TargetVO("024", "一次网管道泵频率反馈", "", 16791D)); + return map; + } + + public List> getFinishingRate(Long deptId) { + List> list = new ArrayList<>(); + List names = Arrays.asList("name", "水耗", "电耗", "煤耗"); + List values = Arrays.asList("总完成率", 90D, 80D, 95D); + list.add(names); + list.add(values); + return list; + } + + public List> finishingRateLine(Long deptId) { + List> list = new ArrayList<>(); + List list1 = Arrays.asList("product", "2012", "2013", "2014", "2015", "2016", "2017"); + List list2 = Arrays.asList("Milk Tea", 56.5, 82.1, 88.7, 70.1, 53.4, 85.1); + List list3 = Arrays.asList("Matcha Latte", 51.1, 51.4, 55.1, 53.3, 73.8, 68.7); + List list4 = Arrays.asList("Cheese Cocoa", 40.1, 62.2, 69.5, 36.4, 45.2, 32.5); + List list5 = Arrays.asList("Walnut Brownie", 25.2, 37.1, 41.2, 18, 33.9, 49.1); + list.add(list1); + list.add(list2); + list.add(list3); + list.add(list4); + list.add(list5); + return list; + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/service/WechatService.java b/lzbi-module/src/main/java/com/lzbi/wechat/service/WechatService.java new file mode 100644 index 0000000..2c294b5 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/wechat/service/WechatService.java @@ -0,0 +1,163 @@ +package com.lzbi.wechat.service; + +import com.alibaba.fastjson2.JSONObject; +import com.lzbi.common.config.WechatConfig; +import com.lzbi.common.core.domain.entity.SysUser; +import com.lzbi.common.core.domain.model.LoginUser; +import com.lzbi.common.core.redis.RedisCache; +import com.lzbi.common.exception.ServiceException; +import com.lzbi.framework.web.service.SysLoginService; +import com.lzbi.framework.web.service.SysPermissionService; +import com.lzbi.framework.web.service.TokenService; +import com.lzbi.system.service.ISysUserService; +import com.lzbi.wechat.domain.SysWechat; +import com.lzbi.wechat.domain.rep.WechatAccessTokenRep; +import com.lzbi.wechat.domain.rep.WechatCodeLoginRep; +import com.lzbi.wechat.domain.rep.WechatPhoneNumberRep; +import com.lzbi.wechat.domain.req.CodeLoginReq; +import com.lzbi.wechat.domain.req.PhoneNumberLoginReq; +import com.lzbi.wechat.domain.req.PhoneNumberReq; +import com.lzbi.wechat.domain.vo.CodeLoginVO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.client.RestTemplate; + +import java.util.HashMap; +import java.util.Map; + +/** + * 微信服务业务逻辑层 + */ +@Slf4j +@Service +public class WechatService { + + @Autowired + private WechatConfig wechatConfig; + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private SysWechatService sysWechatService; + + @Autowired + private ISysUserService sysUserService; + + @Autowired + private SysLoginService sysLoginService; + + @Autowired + private TokenService tokenService; + + @Autowired + private SysPermissionService permissionService; + + /** + * 登录凭证登录 + * + * @param codeLoginReq + * @return + */ + public CodeLoginVO codeLogin(CodeLoginReq codeLoginReq) { + CodeLoginVO codeLoginVO = new CodeLoginVO(); + // 微信登录凭证登录请求,获取到open_id + Map params = new HashMap<>(); + params.put("appid", wechatConfig.getAppId()); + params.put("secret", wechatConfig.getAppSecret()); + params.put("js_code", codeLoginReq.getCode()); + params.put("grant_type", "authorization_code"); + WechatCodeLoginRep resp = restTemplate.getForObject(wechatConfig.getCode2Session(), WechatCodeLoginRep.class, params); + if (ObjectUtils.isNotEmpty(resp) && 0L == resp.getErrcode()) { + String openid = resp.getOpenid(); + codeLoginVO.setOpenId(openid); + // 根据open_id到数据库中查询sysWechat信息 + SysWechat sysWechat = sysWechatService.selectWechatByOpenId(openid); + // 查询到了的话,执行登录操作,返回token + if (ObjectUtils.isNotEmpty(sysWechat)) { + SysUser sysUser = sysUserService.selectUserByPhonenumber(sysWechat.getPhone()); + if (ObjectUtils.isNotEmpty(sysUser)) { + String token = this.getToken(sysUser); + codeLoginVO.setToken(token); + } + } + } else { + log.error("调用微信服务小程序登录接口时失败,{}, {}", resp.getErrcode(), resp.getErrmsg()); + throw new ServiceException(resp.getErrmsg(), resp.getErrcode()); + } + return codeLoginVO; + } + + @Transactional(rollbackFor = Exception.class) + public String phoneNumberLogin(PhoneNumberLoginReq phoneNumberLoginReq) { + // 微信和用户信息绑定 + SysWechat sysWechat = new SysWechat(phoneNumberLoginReq.getOpenId(), phoneNumberLoginReq.getPhone()); + int i = sysWechatService.insertWechat(sysWechat); + if (i > 0) { + // 获取token + SysUser sysUser = sysUserService.selectUserByPhonenumber(sysWechat.getPhone()); + if (ObjectUtils.isNotEmpty(sysUser)) { + return this.getToken(sysUser); + } + } + return null; + } + + /** + * 获取手机号 + * @param phoneNumberReq + * @return + */ + public String getPhoneNumber(PhoneNumberReq phoneNumberReq) { + // 获取接口调用凭据 + Map getAccessTokenParams = new HashMap<>(); + getAccessTokenParams.put("appid", wechatConfig.getAppId()); + getAccessTokenParams.put("secret", wechatConfig.getAppSecret()); + getAccessTokenParams.put("grant_type", "client_credential"); + WechatAccessTokenRep wechatAccessTokenRep = restTemplate.getForObject(wechatConfig.getAccessToken(), WechatAccessTokenRep.class, getAccessTokenParams); + if (ObjectUtils.isNotEmpty(wechatAccessTokenRep) && null == wechatAccessTokenRep.getErrcode()) { + // 获取手机号 + String accessToken = wechatAccessTokenRep.getAccess_token(); + Map getPhoneNumberParams = new HashMap<>(); + getPhoneNumberParams.put("access_token", accessToken); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + Map getPhoneNumberBody = new HashMap<>(); + getPhoneNumberBody.put("code", phoneNumberReq.getCode()); + HttpEntity entity = new HttpEntity<>(JSONObject.toJSONString(getPhoneNumberBody), headers); + WechatPhoneNumberRep resp = restTemplate.postForObject(wechatConfig.getPhoneNumber(), entity, WechatPhoneNumberRep.class, getPhoneNumberParams); + if (ObjectUtils.isNotEmpty(resp) && 0L == resp.getErrcode()) { + if (null != resp.getPhone_info()) { + return resp.getPhone_info().getPurePhoneNumber(); + } + } else { + log.error("调用微信服务获取手机号接口时失败,{}, {}", resp.getErrcode(), resp.getErrmsg()); + throw new ServiceException(resp.getErrmsg(), resp.getErrcode()); + } + } else { + log.error("调用微信服务获取access_token接口时失败,{}, {}", wechatAccessTokenRep.getErrcode(), wechatAccessTokenRep.getErrmsg()); + throw new ServiceException(wechatAccessTokenRep.getErrmsg(), wechatAccessTokenRep.getErrcode()); + } + return null; + } + + /** + * 获取token + * @param sysUser + * @return + */ + private String getToken(SysUser sysUser) { + LoginUser loginUser = new LoginUser(sysUser.getUserId(), sysUser.getDeptId(), sysUser, permissionService.getMenuPermission(sysUser)); + sysLoginService.recordLoginInfo(loginUser.getUserId()); + // 生成token + return tokenService.createToken(loginUser); + } + +} diff --git a/lzbi-module/src/main/resources/mapper/SysWechatMapper.xml b/lzbi-module/src/main/resources/mapper/SysWechatMapper.xml new file mode 100644 index 0000000..7db2713 --- /dev/null +++ b/lzbi-module/src/main/resources/mapper/SysWechatMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + insert into sys_wechat (open_id, phone) values (#{openId}, #{phone}) + + + + update sys_wechat set open_id = #{openId}, phone = #{phone} where id = #{id} + + + + delete from sys_wechat where id = #{id} + + \ No newline at end of file diff --git a/lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml b/lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml index 317cec1..5d3c800 100644 --- a/lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml +++ b/lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml @@ -15,6 +15,7 @@ + @@ -36,6 +37,7 @@ DELETE_TIME, id, asset_name, + asset_name_alias, asset_code, asset_class, flag_validate_dept, @@ -71,6 +73,10 @@ where id = #{id} + @@ -76,7 +42,7 @@ and delete_by = #{deleteBy} and delete_time = #{deleteTime} and param_code = #{paramCode} - and param_name = #{paramName} + and instr(param_name, #{paramName} ) > 0 and group_name = #{groupName} and group_code = #{groupCode} and ext_pro = #{extPro} diff --git a/lzbi-module/src/main/resources/mapper/draft/DcBusiTargetInputMasterMapper.xml b/lzbi-module/src/main/resources/mapper/draft/DcBusiTargetInputMasterMapper.xml new file mode 100644 index 0000000..3cc3970 --- /dev/null +++ b/lzbi-module/src/main/resources/mapper/draft/DcBusiTargetInputMasterMapper.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select bill_serial, biil_type, company_id, company_name, organize_name, oragnize_id, asset_code, asset_name, field_code, field_name, id, year, month, tenant_id, revision, created_by, created_time, updated_by, updated_time, delete_by, delete_time, check_status, check_type from dc_busi_target_input_master + + + + + + + + insert into dc_busi_target_input_master + + bill_serial, + biil_type, + company_id, + company_name, + organize_name, + oragnize_id, + asset_code, + asset_name, + field_code, + field_name, + year, + month, + tenant_id, + revision, + created_by, + created_time, + updated_by, + updated_time, + delete_by, + delete_time, + check_status, + check_type, + + + #{billSerial}, + #{biilType}, + #{companyId}, + #{companyName}, + #{organizeName}, + #{oragnizeId}, + #{assetCode}, + #{assetName}, + #{fieldCode}, + #{fieldName}, + #{year}, + #{month}, + #{tenantId}, + #{revision}, + #{createdBy}, + #{createdTime}, + #{updatedBy}, + #{updatedTime}, + #{deleteBy}, + #{deleteTime}, + #{checkStatus}, + #{checkType}, + + + + + update dc_busi_target_input_master + + bill_serial = #{billSerial}, + biil_type = #{biilType}, + company_id = #{companyId}, + company_name = #{companyName}, + organize_name = #{organizeName}, + oragnize_id = #{oragnizeId}, + asset_code = #{assetCode}, + asset_name = #{assetName}, + field_code = #{fieldCode}, + field_name = #{fieldName}, + year = #{year}, + month = #{month}, + tenant_id = #{tenantId}, + revision = #{revision}, + created_by = #{createdBy}, + created_time = #{createdTime}, + updated_by = #{updatedBy}, + updated_time = #{updatedTime}, + delete_by = #{deleteBy}, + delete_time = #{deleteTime}, + check_status = #{checkStatus}, + check_type = #{checkType}, + + where id = #{id} + + + + delete from dc_busi_target_input_master where id = #{id} + + + + delete from dc_busi_target_input_master where id in + + #{id} + + + \ No newline at end of file diff --git a/lzbi-module/src/main/resources/mapper/draft/DcBusiTargetInputSubMapper.xml b/lzbi-module/src/main/resources/mapper/draft/DcBusiTargetInputSubMapper.xml new file mode 100644 index 0000000..ab281d3 --- /dev/null +++ b/lzbi-module/src/main/resources/mapper/draft/DcBusiTargetInputSubMapper.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select tenant_id, revision, created_by, created_time, updated_by, updated_time, delete_by, delete_time, id, bill_no_master, target_code, target_name, taget_unit, day, val_result, company_id, company_name, organize_name, oragnize_id, asset_code, asset_name, field_code, field_name from dc_busi_target_input_sub + + + + + + + + insert into dc_busi_target_input_sub + + tenant_id, + revision, + created_by, + created_time, + updated_by, + updated_time, + delete_by, + delete_time, + bill_no_master, + target_code, + target_name, + taget_unit, + day, + val_result, + company_id, + company_name, + organize_name, + oragnize_id, + asset_code, + asset_name, + field_code, + field_name, + + + #{tenantId}, + #{revision}, + #{createdBy}, + #{createdTime}, + #{updatedBy}, + #{updatedTime}, + #{deleteBy}, + #{deleteTime}, + #{billNoMaster}, + #{targetCode}, + #{targetName}, + #{tagetUnit}, + #{day}, + #{valResult}, + #{companyId}, + #{companyName}, + #{organizeName}, + #{oragnizeId}, + #{assetCode}, + #{assetName}, + #{fieldCode}, + #{fieldName}, + + + + + update dc_busi_target_input_sub + + tenant_id = #{tenantId}, + revision = #{revision}, + created_by = #{createdBy}, + created_time = #{createdTime}, + updated_by = #{updatedBy}, + updated_time = #{updatedTime}, + delete_by = #{deleteBy}, + delete_time = #{deleteTime}, + bill_no_master = #{billNoMaster}, + target_code = #{targetCode}, + target_name = #{targetName}, + taget_unit = #{tagetUnit}, + day = #{day}, + val_result = #{valResult}, + company_id = #{companyId}, + company_name = #{companyName}, + organize_name = #{organizeName}, + oragnize_id = #{oragnizeId}, + asset_code = #{assetCode}, + asset_name = #{assetName}, + field_code = #{fieldCode}, + field_name = #{fieldName}, + + where id = #{id} + + + + delete from dc_busi_target_input_sub where id = #{id} + + + + delete from dc_busi_target_input_sub where id in + + #{id} + + + \ No newline at end of file diff --git a/lzbi-system/src/main/java/com/lzbi/system/mapper/SysDeptMapper.java b/lzbi-system/src/main/java/com/lzbi/system/mapper/SysDeptMapper.java index 7a4d74f..e08dc57 100644 --- a/lzbi-system/src/main/java/com/lzbi/system/mapper/SysDeptMapper.java +++ b/lzbi-system/src/main/java/com/lzbi/system/mapper/SysDeptMapper.java @@ -121,4 +121,5 @@ public interface SysDeptMapper public List selectCompany(Long parentId); public HashMap selectDeptMap(); + List selectDeptListByRoleIds(List ids); } diff --git a/lzbi-system/src/main/java/com/lzbi/system/mapper/SysUserMapper.java b/lzbi-system/src/main/java/com/lzbi/system/mapper/SysUserMapper.java index 2cbec55..2616fc5 100644 --- a/lzbi-system/src/main/java/com/lzbi/system/mapper/SysUserMapper.java +++ b/lzbi-system/src/main/java/com/lzbi/system/mapper/SysUserMapper.java @@ -43,6 +43,14 @@ public interface SysUserMapper */ public SysUser selectUserByUserName(String userName); + /** + * 根据手机号查询用户 + * + * @param phonenumber + * @return + */ + SysUser selectUserByPhonenumber(@Param("phonenumber") String phonenumber); + /** * 通过用户ID查询用户 * diff --git a/lzbi-system/src/main/java/com/lzbi/system/service/ISysDeptService.java b/lzbi-system/src/main/java/com/lzbi/system/service/ISysDeptService.java index 80e68d5..a0eba9f 100644 --- a/lzbi-system/src/main/java/com/lzbi/system/service/ISysDeptService.java +++ b/lzbi-system/src/main/java/com/lzbi/system/service/ISysDeptService.java @@ -28,6 +28,13 @@ public interface ISysDeptService */ public List selectDeptTreeList(SysDept dept); + /** + * 根据角色id列表查询 + * @param ids + * @return + */ + List selectDeptListByRoleIds(List ids); + /** * 构建前端所需要树结构 * diff --git a/lzbi-system/src/main/java/com/lzbi/system/service/ISysUserService.java b/lzbi-system/src/main/java/com/lzbi/system/service/ISysUserService.java index d79ca7d..5f6e14d 100644 --- a/lzbi-system/src/main/java/com/lzbi/system/service/ISysUserService.java +++ b/lzbi-system/src/main/java/com/lzbi/system/service/ISysUserService.java @@ -203,4 +203,6 @@ public interface ISysUserService * @return 结果 */ public String importUser(List userList, Boolean isUpdateSupport, String operName); + + SysUser selectUserByPhonenumber(String phone); } diff --git a/lzbi-system/src/main/java/com/lzbi/system/service/impl/SysDeptServiceImpl.java b/lzbi-system/src/main/java/com/lzbi/system/service/impl/SysDeptServiceImpl.java index 97a2380..d538005 100644 --- a/lzbi-system/src/main/java/com/lzbi/system/service/impl/SysDeptServiceImpl.java +++ b/lzbi-system/src/main/java/com/lzbi/system/service/impl/SysDeptServiceImpl.java @@ -60,6 +60,11 @@ public class SysDeptServiceImpl implements ISysDeptService { return buildDeptTreeSelect(depts); } + @Override + public List selectDeptListByRoleIds(List ids) { + return deptMapper.selectDeptListByRoleIds(ids); + } + /** * 构建前端所需要树结构 * diff --git a/lzbi-system/src/main/java/com/lzbi/system/service/impl/SysUserServiceImpl.java b/lzbi-system/src/main/java/com/lzbi/system/service/impl/SysUserServiceImpl.java index e6eb7d9..1b2c2f5 100644 --- a/lzbi-system/src/main/java/com/lzbi/system/service/impl/SysUserServiceImpl.java +++ b/lzbi-system/src/main/java/com/lzbi/system/service/impl/SysUserServiceImpl.java @@ -541,4 +541,9 @@ public class SysUserServiceImpl implements ISysUserService } return successMsg.toString(); } + + @Override + public SysUser selectUserByPhonenumber(String phone) { + return userMapper.selectUserByPhonenumber(phone); + } } diff --git a/lzbi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/lzbi-system/src/main/resources/mapper/system/SysDeptMapper.xml index a7faba3..d8ef13b 100644 --- a/lzbi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/lzbi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -112,7 +112,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1 - + + + insert into sys_dept( dept_id, diff --git a/lzbi-system/src/main/resources/mapper/system/SysUserMapper.xml b/lzbi-system/src/main/resources/mapper/system/SysUserMapper.xml index 9183ea4..edcd364 100644 --- a/lzbi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/lzbi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -124,7 +124,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where u.user_name = #{userName} and u.del_flag = '0' - + + + select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1 - - + + insert into sys_user( user_id, dept_id,