From a6639b821042d3c510555dd932cf90333b1e14f9 Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Sun, 29 Jun 2025 17:45:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B4=B9=E7=94=A8=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E5=AE=A1=E6=A0=B8=E5=8A=9F=E8=83=BD=E5=8F=8AAES?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/biz/utils/AesEncryptUtils.java | 85 ++++ .../bonus/common/biz/utils/HttpHelper.java | 9 +- .../push/controller/CostPushController.java | 222 +++++++++ .../material/push/domain/ConsumeDataPush.java | 93 ++++ .../material/push/domain/CostPushBean.java | 118 +++++ .../material/push/mapper/CostPushMapper.java | 60 +++ .../push/service/CostPushService.java | 58 +++ .../service/impl/CostPushServiceImpl.java | 429 ++++++++++++++++++ .../mapper/material/push/MybatisGenerator.xml | 221 +++++++++ 9 files changed, 1291 insertions(+), 4 deletions(-) create mode 100644 bonus-common-biz/src/main/java/com/bonus/common/biz/utils/AesEncryptUtils.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/CostPushController.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/ConsumeDataPush.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/CostPushBean.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/CostPushMapper.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/CostPushService.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/CostPushServiceImpl.java create mode 100644 bonus-modules/bonus-material/src/main/resources/mapper/material/push/MybatisGenerator.xml diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/AesEncryptUtils.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/AesEncryptUtils.java new file mode 100644 index 00000000..87ba3f81 --- /dev/null +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/AesEncryptUtils.java @@ -0,0 +1,85 @@ +package com.bonus.common.biz.utils; + +import com.alibaba.fastjson2.JSONObject; +import org.apache.commons.codec.binary.Base64; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.common.biz.utils + * @CreateTime: 2025-06-29 14:36 + * @Description: 前后端数据传输加密工具类 + */ +public class AesEncryptUtils { + + //可配置到Constant中,并读取配置文件注入,16位,自己定义 + private static final String KEY = "$jqgcYouote@c103"; + + //参数分别代表 算法名称/加密模式/数据填充方式 + private static final String ALGORITHMSTR = "AES/ECB/PKCS5Padding"; + + /** + * 加密 + * @param content 加密的字符串 + * @param encryptKey key值 + * @return + * @throws Exception + */ + public static String encrypt(String content, String encryptKey) throws Exception { + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + kgen.init(128); + Cipher cipher = Cipher.getInstance(ALGORITHMSTR); + cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(encryptKey.getBytes(), "AES")); + byte[] b = cipher.doFinal(content.getBytes(StandardCharsets.UTF_8)); + // 采用base64算法进行转码,避免出现中文乱码 + return Base64.encodeBase64String(b); + } + + /** + * 解密 + * @param encryptStr 解密的字符串 + * @param decryptKey 解密的key值 + */ + public static String decrypt(String encryptStr, String decryptKey) throws Exception { + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + kgen.init(128); + Cipher cipher = Cipher.getInstance(ALGORITHMSTR); + cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(decryptKey.getBytes(), "AES")); + // 采用base64算法进行转码,避免出现中文乱码 + byte[] encryptBytes = Base64.decodeBase64(encryptStr); + byte[] decryptBytes = cipher.doFinal(encryptBytes); + return new String(decryptBytes); + } + + public static String encrypt(String content) throws Exception { + return encrypt(content, KEY); + } + + public static String decrypt(String encryptStr) throws Exception { + return decrypt(encryptStr, KEY); + } + + +// public static void main(String[] args) throws Exception { +// Map map=new HashMap<>(); +// map.put("key","value"); +// map.put("中文","汉字"); +// String content = JSONObject.toJSONString(map); +// System.out.println("加密前:" + content); +// +// String encrypt = encrypt(content, KEY); +// System.out.println("加密后:" + encrypt); +// +// +// +// String decrypt = decrypt(encrypt); +// System.out.println("解密后:" + decrypt); +// } +} diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/HttpHelper.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/HttpHelper.java index 6d80a9fa..d6794615 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/HttpHelper.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/HttpHelper.java @@ -1,7 +1,5 @@ package com.bonus.common.biz.utils; -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; @@ -15,11 +13,14 @@ import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; +/** + * @author bonus + */ public class HttpHelper { + public static final String KEY = "$jqgcYouote@c103"; + public static String sendHttpPost(String url, String JSONBody) throws Exception { System.out.println("JSONBody-=========:" + JSONBody); CloseableHttpClient httpClient = HttpClients.createDefault(); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/CostPushController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/CostPushController.java new file mode 100644 index 00000000..51492bdd --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/CostPushController.java @@ -0,0 +1,222 @@ +package com.bonus.material.push.controller; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.nacos.common.utils.StringUtils; +import com.bonus.common.core.exception.ServiceException; +import com.bonus.common.core.utils.DateUtils; +import com.bonus.common.core.utils.poi.ExcelUtil; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.material.push.domain.CostPushBean; +import com.bonus.material.push.service.CostPushService; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.OutputStream; +import java.net.URLEncoder; +import java.util.*; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.push.controller + * @CreateTime: 2025-06-29 13:57 + * @Description: 描述 + */ +@RequestMapping("/backstage/costPush/") +@RestController +public class CostPushController extends BaseController { + + private static final String KEY = "$jqgcYouote@c103"; + + @Autowired + private CostPushService service; + + /** + * 查询费用推送审核--列表 + */ + @RequestMapping(value = "getCostPushCheckList", method = RequestMethod.GET) + public TableDataInfo getCostPushCheckList(CostPushBean o) { + try { + List results = service.getCostPushCheckList(o); + return getDataTable(results); + } catch (Exception e) { + logger.error(e.toString(), e); + throw new ServiceException("数据查询异常,请联系运维人员查询日志处理"); + } + } + + /** + * 查询费用推送审核--合计 + */ + @RequestMapping(value = "getCostPushCheckListCount", method = RequestMethod.GET) + public AjaxResult getCostPushCheckListCount(CostPushBean o) { + try { + CostPushBean results = service.getCostPushCheckListCount(o); + return success(results); + } catch (Exception e) { + logger.error(e.toString(), e); + throw new ServiceException("数据查询异常,请联系运维人员查询日志处理"); + } + } + + /** + * 查询消耗费用推送审核--列表 + */ + @RequestMapping(value = "getConsumPushCheckList", method = RequestMethod.GET) + public TableDataInfo getConsumPushCheckList(CostPushBean o) { + try { + List results = service.getConsumPushCheckList(o); + return getDataTable(results); + } catch (Exception e) { + logger.error(e.toString(), e); + throw new ServiceException("数据查询异常,请联系运维人员查询日志处理"); + } + } + + /** + * 查询消耗费用推送审核--合计 + */ + @RequestMapping(value = "getConsumPushCheckListCount", method = RequestMethod.GET) + public AjaxResult getConsumPushCheckListCount(CostPushBean o) { + try { + CostPushBean results = service.getConsumPushCheckListCount(o); + return success(results); + } catch (Exception e) { + logger.error(e.toString(), e); + throw new ServiceException("数据查询异常,请联系运维人员查询日志处理"); + } + } + + /** + * 审核选中的数据 + */ + @RequestMapping(value = "checkData", method = RequestMethod.POST) + @ResponseBody + public AjaxResult checkData(String chks) { + try { + int res = createParams(chks,"1"); + if (res > 0) { + new Thread(() -> service.pushDataToYouer(chks)).start(); + } + return success("审核成功"); + } catch (Exception e) { + logger.error(e.toString(), e); + throw new ServiceException("数据查询异常,请联系运维人员查询日志处理"); + } + } + + /** + * 消耗性费用审核选中的数据 + */ + @RequestMapping(value = "consumeCheckData", method = RequestMethod.POST) + @ResponseBody + public AjaxResult consumeCheckData(String chks) { + try { + int res = createParams(chks,"2"); + if (res > 0) { + new Thread(() -> service.pushConsumeDataToYouer(chks)).start(); + } + return success("审核成功"); + } catch (Exception e) { + logger.error(e.toString(), e); + throw new ServiceException("数据查询异常,请联系运维人员查询日志处理"); + } + } + + private int createParams(String cheks,String type) { + int res = 0; + if (StringUtils.isNotEmpty(cheks)) { + JSONArray object = JSONObject.parseArray(cheks); + if (object != null && !object.isEmpty()) { + for (int i = 0; i < object.size(); i++) { + CostPushBean bean = new CostPushBean(); + JSONObject idObj = object.getJSONObject(i); + String proId = idObj.getString("projectId"); + String taskId = idObj.getString("taskId"); + String unitId = idObj.getString("unitId"); + bean.setTaskId(taskId); + bean.setProjectId(proId); + bean.setUnitId(unitId); + if("1".equals(type)){ + res = service.updatePushAQStatus(bean); + } + if("2".equals(type)){ + res = service.updatePushXHStatus(bean); + } + } + } + } + return res; + } + + + /** + * 费用审核导出 + */ + @RequestMapping("exportPushCheck") + public void exportPushCheck(HttpServletResponse response, CostPushBean o) { + try { + String month = o.getMonth(); + if (StringUtils.isBlank(month)) { + month = DateUtils.getCurrentMonth(); + } + List results = service.getCostPushCheckList(o); + ExcelUtil excelUtil = new ExcelUtil<>(CostPushBean.class); + excelUtil.exportExcel(response, results, "费用推送审核表" + month + "月份"); + } catch (Exception e) { + logger.error(e.toString(), e); + } + } + + /** + * 消耗品费用审核导出 + */ + @RequestMapping("exportConsPushCheck") + public void exportConsPushCheck(HttpServletResponse response, CostPushBean o) { + try { + String month = o.getMonth(); + if (StringUtils.isBlank(month)) { + month = DateUtils.getCurrentMonth(); + } + List results = service.getConsumPushCheckList(o); + ExcelUtil excelUtil = new ExcelUtil<>(CostPushBean.class); + excelUtil.exportExcel(response, results, "消耗品费用推送审核表" + month + "月份"); + } catch (Exception e) { + logger.error(e.toString(), e); + } + } + + @RequestMapping(value = "findDetails", method = RequestMethod.POST) + @ResponseBody + public TableDataInfo findDetails(CostPushBean o) { + try { + List results = service.findDetails(o); + return getDataTable(results); + } catch (Exception e) { + logger.error(e.toString(), e); + return getDataTable(Collections.emptyList()); + } + } + + @RequestMapping(value = "findOtherDetails", method = RequestMethod.POST) + @ResponseBody + public TableDataInfo findOtherDetails(CostPushBean o) { + try { + List results = service.findOtherDetails(o); + return getDataTable(results); + } catch (Exception e) { + logger.error(e.toString(), e); + return getDataTable(Collections.emptyList()); + } + } + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/ConsumeDataPush.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/ConsumeDataPush.java new file mode 100644 index 00000000..d1ec697a --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/ConsumeDataPush.java @@ -0,0 +1,93 @@ +package com.bonus.material.push.domain; + +import lombok.Data; +import org.apache.ibatis.type.Alias; + +import java.io.Serializable; + +/** + * 消耗品费用推送实体类 描述: + * + * @table: + * @author lvjilong + * @date 2024年5月23日 + */ +@Data +@Alias("ConsumeDataPush") +public class ConsumeDataPush implements Serializable { + + private static final long serialVersionUID = 1L; + + private String id; + + /** + * 工程ID + */ + private String projectId; + + /** + * 工程名称 + */ + private String projectName; + + /** + * 领用单位 + */ + private String unitName; + + /** + * 名称 + */ + private String name; + + /** + * 类型(规格) + */ + private String type; + /** + * 领用数量 + */ + private String quantity; + + /** + * 购置价(不含税) + */ + private String netPrice; + + /** + * 费用 + */ + private String cost; + /** + * 费用月份 + */ + private String expenseTime; + + private String submitUser; + + /** + * 推送月份 + */ + private String month; + + private String body; + + private String pushStatus; + + private String pushRemark; + + /** + * 系统标识 1代表机具系统 2代表机具物资 3代表送变电物资系统 + */ + private String sysType="2"; + + /** + * i8工程编号 + */ + private String pc_no; + + public void setUnit(String unitName) { + this.unitName = unitName; + } + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/CostPushBean.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/CostPushBean.java new file mode 100644 index 00000000..cd732a50 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/CostPushBean.java @@ -0,0 +1,118 @@ +package com.bonus.material.push.domain; + +import com.bonus.common.core.annotation.Excel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.apache.ibatis.type.Alias; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.push.domain + * @CreateTime: 2025-06-29 14:03 + * @Description: 描述 + */ +@Setter +@Getter +@Alias("CostPushBean") +@NoArgsConstructor +@AllArgsConstructor +public class CostPushBean implements java.io.Serializable { + + private static final long serialVersionUID = 1L; + + private String id; + + private String projectId; + + private String unitId; + + @Excel(name = "工程名称", sort = 1) + private String projectName; + + @Excel(name = "单位名称", sort = 2) + private String unitName; + + private String typeName; + + private String modelName; + + private String num; + + private String leaseDate; + + private String backDate; + + private String leaseMoney; + + @Excel(name = "丢失费用", sort = 7) + private String lostMoney; + + @Excel(name = "报废费用", sort = 8) + private String scrapMoney; + + private String repairMoney; + + @Excel(name = "消耗品费用", sort = 9) + private String consMoney; + + @Excel(name = "租赁费用", sort = 6) + private String leasePrice; + + private String time; + + @Excel(name = "推送月份", sort = 4) + private String month; + + private String type; + + private String buyPrice; + + private String isPush; + + private String money; + + private String year; + + private String taskId; + + private String proCode; + + private String dayNum; + + /** + * 类别编号(周转安全工器具-2or周转工器具-1 + */ + private String category = "2"; + + /** + * i8工程编号 + */ + @Excel(name = "i8工程编号", sort = 3) + private String pc_no; + + /** + * 系统标识 1代表机具系统 2代表机具物资 3代表送变电物资系统 + */ + private String sysType = "2"; + + /** + * 提交人 + */ + private String submitUser; + + private String body; + + private String pushStatus = "1"; + + private String pushRemark; + + /** + * 审核状态0 未审核 1已审核 + */ + @Excel(name = "是否审核", sort = 5, readConverterExp = "0=未审核,1=已审核") + private int checkStatus; +} + diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/CostPushMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/CostPushMapper.java new file mode 100644 index 00000000..942e401b --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/CostPushMapper.java @@ -0,0 +1,60 @@ +package com.bonus.material.push.mapper; + +import com.bonus.material.push.domain.ConsumeDataPush; +import com.bonus.material.push.domain.CostPushBean; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.push.mapper + * @CreateTime: 2025-06-29 14:42 + * @Description: 描述 + */ +@Mapper +public interface CostPushMapper { + + /** + * 获取费用推送审核数据 + * @author 吕继龙 + */ + List getCostPushCheckList(CostPushBean o); + + /** + * 获取消耗费用推送审核数据 + * @author 吕继龙 + */ + List getConsumePushCheckList(CostPushBean o); + + /** + * 更新审核状态 + */ + void updateCostPushCheckStatus(String id); + + /** + * 更新提交推送状态 + */ + void updateCostPushStatus(CostPushBean o); + + /** + * 获取消耗品费用集合 + * @return List + */ + List getConsumeDataPushsList(CostPushBean o); + + /** + * 获取推送费用数据 + * @return List + */ + List getToolDataPushList(CostPushBean o); + + List findDetails(CostPushBean o); + + List findOtherDetails(CostPushBean o); + + int updatePushAQStatus(CostPushBean bean); + + int updatePushXHStatus(CostPushBean bean); +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/CostPushService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/CostPushService.java new file mode 100644 index 00000000..5c60b4f2 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/CostPushService.java @@ -0,0 +1,58 @@ +package com.bonus.material.push.service; + +import com.bonus.material.push.domain.CostPushBean; + +import java.util.List; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.push.service + * @CreateTime: 2025-06-29 14:16 + * @Description: 描述 + */ +public interface CostPushService { + + /** + * 获取费用推送审核数据 + */ + List getCostPushCheckList(CostPushBean o); + + /** + * 获取费用推送审核数据 + */ + CostPushBean getCostPushCheckListCount(CostPushBean o); + + /** + * 获取消耗费用推送审核数据 + */ + List getConsumPushCheckList(CostPushBean o); + + CostPushBean getConsumPushCheckListCount(CostPushBean o); + + + List findDetails(CostPushBean o); + + List findOtherDetails(CostPushBean o); + + + /** + * 推送数据到优尔 + */ + void pushDataToYouer(String cheks); + + /** + * 消耗性费用推送数据到优尔 + */ + void pushConsumeDataToYouer(String cheks); + + /** + * 更新安全状态 + */ + int updatePushAQStatus(CostPushBean bean); + + /** + * 更新消耗品状态 + */ + int updatePushXHStatus(CostPushBean bean); +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/CostPushServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/CostPushServiceImpl.java new file mode 100644 index 00000000..bd67ff64 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/CostPushServiceImpl.java @@ -0,0 +1,429 @@ +package com.bonus.material.push.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.nacos.common.utils.StringUtils; +import com.bonus.common.biz.config.DateTimeHelper; +import com.bonus.common.biz.utils.AesEncryptUtils; +import com.bonus.common.biz.utils.HttpHelper; +import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.push.domain.ConsumeDataPush; +import com.bonus.material.push.domain.CostPushBean; +import com.bonus.material.push.mapper.CostPushMapper; +import com.bonus.material.push.service.CostPushService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.push.service.impl + * @CreateTime: 2025-06-29 14:16 + * @Description: + */ +@Service +public class CostPushServiceImpl implements CostPushService { + + @Autowired + private CostPushMapper dao; + + /** + * 获取费用推送审核数据 + */ + @Override + public List getCostPushCheckList(CostPushBean o) { + // TODO Auto-generated method stub + return dao.getCostPushCheckList(o); + } + + /** + * 获取费用推送审核数据 + */ + @Override + public CostPushBean getCostPushCheckListCount(CostPushBean o) { + // TODO Auto-generated method stub + List beanList = dao.getCostPushCheckList(o); + calcTotalMoney(beanList); + return beanList.get(beanList.size() - 1); + } + + /** + * 获取消耗费用推送审核数据 + */ + @Override + public List getConsumPushCheckList(CostPushBean o) { + // TODO Auto-generated method stub + return dao.getConsumePushCheckList(o); + } + + /** + * 获取消耗费用推送数据统计 + */ + @Override + public CostPushBean getConsumPushCheckListCount(CostPushBean o) { + // TODO Auto-generated method stub + List list = dao.getConsumePushCheckList(o); + if (list.isEmpty()) { + return new CostPushBean(); + } + calcTotalMoney(list); + return list.get(list.size() - 1); + } + + @Override + public List findDetails(CostPushBean o) { + List list = dao.findDetails(o); + if (list == null || list.size() <= 0) { + return list; + } else { + double total = 0; + for (CostPushBean bean : list) { + String leaseMoney = bean.getLeaseMoney(); + total += moneyStringToDouble(leaseMoney); + } + CostPushBean newBean = new CostPushBean(); + newBean.setLeaseMoney(String.format("%.2f", total)); + newBean.setProjectName("合计费用"); + list.add(newBean); + return list; + } + } + + @Override + public List findOtherDetails(CostPushBean o) { + return dao.findOtherDetails(o); + } + + /** + * 推送数据到优尔 + */ + @Override + public void pushDataToYouer(String cheks) { + // 对参数进行处理 + List params = createParams(cheks); + //根据ProjectId进行工程分组 + Map> groupedByProjectId = params.stream() + .collect(Collectors.groupingBy(CostPushBean::getProjectId)); + //取出工程分组后的集合 + List> projectList = new ArrayList<>(groupedByProjectId.values()); + if (!projectList.isEmpty()) { + for (List bean : projectList) { + for (CostPushBean costPushBean : bean) { + dao.updateCostPushCheckStatus(costPushBean.getId()); + } + pushToolData(bean); + } + } + } + + /** + * 消耗性费用推送数据到优尔 + */ + @Override + public void pushConsumeDataToYouer(String cheks) { + // 对参数进行处理 + List params = createParams(cheks); + //根据ProjectId进行工程分组 + Map> groupedByProjectId = params.stream() + .collect(Collectors.groupingBy(CostPushBean::getProjectId)); + //取出工程分组后的集合 + List> projectList = new ArrayList<>(groupedByProjectId.values()); + if (!projectList.isEmpty()) { + for (List bean : projectList) { + for (CostPushBean costPushBean : bean) { + dao.updateCostPushCheckStatus(costPushBean.getId()); + } + pushConsumeData(bean); + } + } + } + + /** + * 更新安全状态 + */ + @Override + public int updatePushAQStatus(CostPushBean bean) { + return dao.updatePushAQStatus(bean); + } + + /** + * 更新消耗品状态 + */ + @Override + public int updatePushXHStatus(CostPushBean bean) { + return dao.updatePushXHStatus(bean); + } + + /** + * 费用判断转换,从字符串转换到double类型 + */ + private double moneyStringToDouble(String money) { + if (StringUtils.isEmpty(money)) { + return 0.00; + } else { + return Double.parseDouble(money); + } + } + + /** + * 计算合计费用并添加到数据集合中 + * + * @param list + * @return + */ + private List calcTotalMoney(List list) { + double leasatotal = 0;// 租赁总费用 + double losttotal = 0.00;// 丢失总费用 + double scraptotal = 0;// 报废总费用 + double consttotal = 0;// 维修总费用 + double moneytotal = 0;// 合计总费用 + + if (list != null && !list.isEmpty()) { + for (CostPushBean bean : list) { + String leaseMoney = bean.getLeaseMoney(); + String lostMoney = bean.getLostMoney(); + String scrapMoney = bean.getScrapMoney(); + String consMoney = bean.getConsMoney(); + String money = bean.getMoney(); + leasatotal += moneyStringToDouble(leaseMoney); + losttotal += moneyStringToDouble(lostMoney); + scraptotal += moneyStringToDouble(scrapMoney); + consttotal += moneyStringToDouble(consMoney); + moneytotal += moneyStringToDouble(money); + } + CostPushBean newBean = new CostPushBean(); + newBean.setLeaseMoney(String.format("%.2f", leasatotal)); + newBean.setLostMoney(String.format("%.2f", losttotal)); + newBean.setScrapMoney(String.format("%.2f", scraptotal)); + newBean.setConsMoney(String.format("%.2f", consttotal)); + newBean.setMoney(String.format("%.2f", moneytotal)); + newBean.setProjectName("合计费用"); + list.add(newBean); + } + return list; + } + + /** + * 将费用合计推送至优尔 + */ + private void pushToolData(List params) { + List list = getToolData(params); + // 推送数据租赁费、维修费用、报废费用 + if (!list.isEmpty()) { + httpToolData(list); + for (CostPushBean bean : list) { + // 更新推送状态 + bean.setTime(DateTimeHelper.getNowTime()); + dao.updateCostPushStatus(bean); + } + } + } + + /** + * 获取要推送的租赁费用、维修费用、报废费用 + */ + private List getToolData(List params) { + List result = new ArrayList<>(); + String submitUser = SecurityUtils.getUsername(); + for (CostPushBean bean : params) { + bean.setSubmitUser(submitUser); + bean.setType("1"); + List leaseList = dao.getToolDataPushList(bean); + if (leaseList != null && !leaseList.isEmpty()) { + result.addAll(leaseList); + } + bean.setType("3"); + List scrapList = dao.getToolDataPushList(bean); + if (scrapList != null && !scrapList.isEmpty()) { + result.addAll(scrapList); + } + bean.setType("4"); + List lossList = dao.getToolDataPushList(bean); + if (lossList != null && !lossList.isEmpty()) { + result.addAll(lossList); + } + } + return result; + } + + /** + * 调用接口推送 租赁费、维修费用、报废费用到优尔 + */ + private List httpToolData(List list) { + String content = JSONObject.toJSONString(list); + String encrypt; + try { + // 数据推送,http请求 + encrypt = AesEncryptUtils.encrypt(content, HttpHelper.KEY); + System.err.println("租赁费、维修费用、报废费推送数据解密======:" + AesEncryptUtils.decrypt(encrypt, HttpHelper.KEY)); + Map map = new HashMap(); + map.put("body", encrypt); + String body = JSONObject.toJSONString(map); + String url = "http://10.138.55.105:8097/micro-server/zzaqgjf/syncSafetyTool"; + //String url = "http://192.168.1.134:8036/micro-server/zzaqgjf/syncSafetyTool"; + String data = HttpHelper.sendHttpPost(url, body); + JSONObject object = JSONObject.parseObject(data); + System.err.println(data); + + + String code = object.getString("code"); + if ("200".equals(code)) { + String dataResultString = object.getString("data"); + // 数据解密 + String dataArrayString = AesEncryptUtils.decrypt(dataResultString, HttpHelper.KEY); + System.err.println("四类费用推送返回:"+dataArrayString); + JSONArray dataArray = JSONArray.parseArray(dataArrayString); + if (dataArray != null && !dataArray.isEmpty()) { + // 有数据 + for (int i = 0; i < dataArray.size(); i++) { + JSONObject dataObject = dataArray.getJSONObject(i); + String resultId = dataObject.getString("id"); + String resultPushRemark = dataObject.getString("pushRemark"); + String pushStatus = "2"; + for (int j = 0; j < list.size(); j++) { + CostPushBean costPushBean = list.get(j); + String id = costPushBean.getId(); + if (resultId.equals(id)) { + costPushBean.setPushRemark(resultPushRemark); + costPushBean.setPushStatus(pushStatus); + list.set(j, costPushBean); + } + } + } + } + } + return list; + } catch (Exception e) { + e.printStackTrace(); + return list; + } + } + + + /** + * 构造 查询费用参数 + */ + private List createParams(String cheks) { + if (StringUtils.isNotEmpty(cheks)) { + JSONArray object = JSONObject.parseArray(cheks); + List params = new ArrayList<>(); + if (object != null && !object.isEmpty()) { + for (int i = 0; i < object.size(); i++) { + CostPushBean bean = new CostPushBean(); + JSONObject idObj = object.getJSONObject(i); + String id = idObj.getString("id"); + String proId = idObj.getString("projectId"); + String taskId = idObj.getString("taskId"); + String unitId = idObj.getString("unitId"); + bean.setId(id); + bean.setProjectId(proId); + bean.setTaskId(taskId); + bean.setUnitId(unitId); + params.add(bean); + } + } + return params; + } else { + return Collections.emptyList(); + } + } + + + /** + * 将消耗性费用推送至优尔 主表: 关联表: 描述: TODO + */ + private void pushConsumeData(List params) { + List consumeList = getConsumeDataList(params); + + // 推送消耗品费用到优尔 + if (!consumeList.isEmpty()) { + httpConsumeData(consumeList); + for (ConsumeDataPush bean : consumeList) { + CostPushBean costPushBean = new CostPushBean(); + costPushBean.setTime(DateTimeHelper.getNowTime()); + costPushBean.setPushRemark(bean.getPushRemark()); + costPushBean.setPushStatus(bean.getPushStatus()); + costPushBean.setId(bean.getId()); + // 更新推送状态 + dao.updateCostPushStatus(costPushBean); + } + } + } + + /** + * 获取消耗品推送费用集合 主表: 关联表: 描述: TODO + * + * @return List + */ + private List getConsumeDataList(List params) { + List result = new ArrayList<>(); + String submitUser = SecurityUtils.getUsername(); + for (CostPushBean bean : params) { + bean.setSubmitUser(submitUser); + List tempList = dao.getConsumeDataPushsList(bean); + result.addAll(tempList); + } + return result; + } + + /** + * 调用接口推送 消耗品费用到优尔 + * + * @return boolean + */ + private List httpConsumeData(List list) { + String content = JSONObject.toJSONString(list); + String encrypt; + try { + // 数据推送,http请求 + encrypt = AesEncryptUtils.encrypt(content, HttpHelper.KEY); + System.err.println("消耗品费用加密数据======:" + encrypt); + Map map = new HashMap(); + map.put("body", encrypt); + + String body = JSONObject.toJSONString(map); + String url = "http://10.138.55.105:8097/micro-server/consumetool/syncConsumeTool"; + //String url = "http://192.168.1.134:8036/micro-server/consumetool/syncConsumeTool"; + String data = HttpHelper.sendHttpPost(url, body); + JSONObject object = JSONObject.parseObject(data); + System.err.println(data); + + String code = object.getString("code"); + if ("200".equals(code)) { + String dataResultString = object.getString("data"); + // 数据解密 + String dataArrayString = AesEncryptUtils.decrypt(dataResultString, HttpHelper.KEY); + System.err.println("消耗品费用推送返回:"+dataArrayString); + JSONArray dataArray = JSONArray.parseArray(dataArrayString); + if (dataArray != null && !dataArray.isEmpty()) { + // 有数据 + for (int i = 0; i < dataArray.size(); i++) { + JSONObject dataObject = dataArray.getJSONObject(i); + String resultId = dataObject.getString("id"); + String resultPushRemark = dataObject.getString("pushRemark"); + for (int k = 0; k < list.size(); k++) { + ConsumeDataPush consumeDataPush = list.get(k); + String id = consumeDataPush.getId(); + if (resultId.equals(id)) { + consumeDataPush.setPushRemark(resultPushRemark); + consumeDataPush.setPushStatus("2"); + list.set(k, consumeDataPush); + } + } + } + } + return list; + } else { + return list; + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return list; + } + } + +} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/push/MybatisGenerator.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/MybatisGenerator.xml new file mode 100644 index 00000000..3967a523 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/MybatisGenerator.xml @@ -0,0 +1,221 @@ + + + + + + + + + + + + update + project_month_costs + set + check_status=1 + where + ID=#{id} + + + + + + + + update + project_month_info + set + push_status=#{pushStatus},push_time=#{time},push_remark=#{pushRemark} + where + id = #{id} + + + + update + project_month_info + set + push_status = 3 + where + task_id=#{taskId} and pro_id=#{projectId} and unit_id=#{unitId} and type !=2 + + + + update project_month_info set + push_status=3 + where task_id=#{taskId} and pro_id=#{projectId} and unit_id=#{unitId} and type =2 + + + + \ No newline at end of file