diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/material/CMaterialController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/material/CMaterialController.java index b2284a0..571bf16 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/material/CMaterialController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/material/CMaterialController.java @@ -1,15 +1,20 @@ package com.ruoyi.web.controller.material; +import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletResponse; - import com.ruoyi.clMaterial.domain.CYlMaterial; import com.ruoyi.clMaterial.service.ICYlMaterialService; import com.ruoyi.common.annotation.DataSource; import com.ruoyi.common.enums.DataSourceType; import com.ruoyi.material.domain.CMaterial; +import com.ruoyi.material.domain.cost; +import com.ruoyi.material.domain.material; +import com.ruoyi.material.domain.temp; import com.ruoyi.materialType.domain.CMaterialType; import com.ruoyi.materialType.service.ICMaterialTypeService; +import com.ruoyi.web.utils.JDBCBatchInsert; +import org.apache.commons.collections4.ListUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -146,4 +151,588 @@ public class CMaterialController extends BaseController { return toAjax(cMaterialService.deleteCMaterialByMaterialIds(materialIds)); } + + /** + * 同步物料材料用量 + */ + @PreAuthorize("@ss.hasPermi('material:material:synchronizeMaterialData')") + @Log(title = "同步物料材料用量", businessType = BusinessType.UPDATE) + @PostMapping("/synchronizeUpdate") + public AjaxResult synchronizeUpdate() throws Exception + { + List templist = cMaterialService.selectTemp(); + List materials = new ArrayList(); + material m = new material(); + + List costs = new ArrayList(); + cost c = new cost(); + + List> averageAssign = ListUtils.partition(templist, 5000); + + + int num = 1; + int num2 = 1; + for(List list:averageAssign){ + for(temp t:list){ + m = new material(); + m.setMaterial_id(num); + m.setMaterial_xingh(t.getModel_1()); + m.setMaterial_guig(t.getSpec_1()); + m.setMaterial_diany(t.getVoltage_1()); + m.setMaterial_dw(t.getUnit_0()); + m.setMaterial_type_id(t.getType_no()); + materials.add(m); + num++; + + if("M001".equals(t.getM_id_M001())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M001()); + c.setCost_cl_qty(t.getName_qty_M001()); + costs.add(c);num2++; + } + if("M002".equals(t.getM_id_M002())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M002()); + c.setCost_cl_qty(t.getName_qty_M002()); + costs.add(c);num2++; + } + if("M003".equals(t.getM_id_M003())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M003()); + c.setCost_cl_qty(t.getName_qty_M003()); + c.setCost_cl_qty_2(t.getName_qty_M003_1()); + costs.add(c);num2++; + } + if("M004".equals(t.getM_id_M004())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M004()); + c.setCost_cl_qty(t.getName_qty_M004()); + c.setCost_cl_qty_2(t.getName_qty_M004_1()); + costs.add(c);num2++; + } + if("M005".equals(t.getM_id_M005())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M005()); + c.setCost_cl_qty(t.getName_qty_M005()); + c.setCost_cl_qty_2(t.getName_qty_M005_1()); + costs.add(c);num2++; + } + if("M006".equals(t.getM_id_M006())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M006()); + c.setCost_cl_qty(t.getName_qty_M006()); + costs.add(c);num2++; + } + if("M007".equals(t.getM_id_M007())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M007()); + c.setCost_cl_qty(t.getName_qty_M007()); + costs.add(c);num2++; + } + if("M008".equals(t.getM_id_M008())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M008()); + c.setCost_cl_qty(t.getName_qty_M008()); + costs.add(c);num2++; + } + if("M009".equals(t.getM_id_M009())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M009()); + c.setCost_cl_qty(t.getName_qty_M009()); + costs.add(c);num2++; + } + if("M010".equals(t.getM_id_M010())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M010()); + c.setCost_cl_qty(t.getName_qty_M010()); + c.setCost_cl_qty_2(t.getName_qty_M010_1()); + costs.add(c);num2++; + } + if("M011".equals(t.getM_id_M011())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M011()); + c.setCost_cl_qty(t.getName_qty_M011()); + costs.add(c);num2++; + } + if("M012".equals(t.getM_id_M012())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M012()); + c.setCost_cl_qty(t.getName_qty_M012()); + costs.add(c);num2++; + } + if("M013".equals(t.getM_id_M013())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M013()); + c.setCost_cl_qty(t.getName_qty_M013()); + costs.add(c);num2++; + }if("M014".equals(t.getM_id_M014())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M014()); + c.setCost_cl_qty(t.getName_qty_M014()); + costs.add(c);num2++; + }if("M015".equals(t.getM_id_M015())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M015()); + c.setCost_cl_qty(t.getName_qty_M015()); + costs.add(c);num2++; + } + if("M016".equals(t.getM_id_M016())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M016()); + c.setCost_cl_qty(t.getName_qty_M016()); + costs.add(c);num2++; + } + if("M017".equals(t.getM_id_M017())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M017()); + c.setCost_cl_qty(t.getName_qty_M017()); + costs.add(c);num2++; + } + if("M018".equals(t.getM_id_M018())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M018()); + c.setCost_cl_qty(t.getName_qty_M018()); + costs.add(c);num2++; + }if("M019".equals(t.getM_id_M019())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M019()); + c.setCost_cl_qty(t.getName_qty_M019()); + c.setCost_cl_qty_2(t.getName_qty_M019_1()); + costs.add(c);num2++; + } + if("M020".equals(t.getM_id_M020())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M020()); + c.setCost_cl_qty(t.getName_qty_M020()); + costs.add(c);num2++; + } + if("M021".equals(t.getM_id_M021())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M021()); + c.setCost_cl_qty(t.getName_qty_M021()); + c.setCost_cl_qty_2(t.getName_qty_M021_1()); + costs.add(c);num2++; + } + if("M022".equals(t.getM_id_M022())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M022()); + c.setCost_cl_qty(t.getName_qty_M022()); + costs.add(c);num2++; + } + if("M023".equals(t.getM_id_M023())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M023()); + c.setCost_cl_qty(t.getName_qty_M023()); + costs.add(c);num2++; + }if("M024".equals(t.getM_id_M024())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M024()); + c.setCost_cl_qty(t.getName_qty_M024()); + costs.add(c);num2++; + }if("M025".equals(t.getM_id_M025())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M025()); + c.setCost_cl_qty(t.getName_qty_M025()); + costs.add(c);num2++; + } + if("M026".equals(t.getM_id_M026())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M026()); + c.setCost_cl_qty(t.getName_qty_M026()); + costs.add(c);num2++; + } + if("M027".equals(t.getM_id_M027())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M027()); + c.setCost_cl_qty(t.getName_qty_M027()); + costs.add(c);num2++; + } + if("M028".equals(t.getM_id_M028())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M028()); + c.setCost_cl_qty(t.getName_qty_M028()); + costs.add(c);num2++; + } + if("M029".equals(t.getM_id_M029())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M029()); + c.setCost_cl_qty(t.getName_qty_M029()); + costs.add(c);num2++; + }if("M030".equals(t.getM_id_M030())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M030()); + c.setCost_cl_qty(t.getName_qty_M030()); + costs.add(c);num2++; + }if("M031".equals(t.getM_id_M031())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M031()); + c.setCost_cl_qty(t.getName_qty_M031()); + costs.add(c);num2++; + }if("M032".equals(t.getM_id_M032())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M032()); + c.setCost_cl_qty(t.getName_qty_M032()); + costs.add(c);num2++; + }if("M033".equals(t.getM_id_M033())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M033()); + c.setCost_cl_qty(t.getName_qty_M033()); + costs.add(c);num2++; + }if("M034".equals(t.getM_id_M034())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M034()); + c.setCost_cl_qty(t.getName_qty_M034()); + costs.add(c);num2++; + } + if("M035".equals(t.getM_id_M035())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M035()); + c.setCost_cl_qty(t.getName_qty_M035()); + costs.add(c);num2++; + }if("M036".equals(t.getM_id_M036())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M036()); + c.setCost_cl_qty(t.getName_qty_M036()); + costs.add(c);num2++; + }if("M037".equals(t.getM_id_M037())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M037()); + c.setCost_cl_qty(t.getName_qty_M037()); + c.setCost_cl_qty_2(t.getName_qty_M037_1()); + costs.add(c);num2++; + } + if("M038".equals(t.getM_id_M038())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M038()); + c.setCost_cl_qty(t.getName_qty_M038()); + costs.add(c);num2++; + } + if("M039".equals(t.getM_id_M039())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M039()); + c.setCost_cl_qty(t.getName_qty_M039()); + c.setCost_cl_qty_2(t.getName_qty_M039_1()); + costs.add(c);num2++; + } + if("M040".equals(t.getM_id_M040())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M040()); + c.setCost_cl_qty(t.getName_qty_M040()); + costs.add(c);num2++; + } + if("M041".equals(t.getM_id_M041())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M041()); + c.setCost_cl_qty(t.getName_qty_M041()); + costs.add(c);num2++; + } + if("M042".equals(t.getM_id_M042())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M042()); + c.setCost_cl_qty(t.getName_qty_M042()); + c.setCost_cl_qty_2(t.getName_qty_M042_1()); + costs.add(c);num2++; + } + if("M043".equals(t.getM_id_M043())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M043()); + c.setCost_cl_qty(t.getName_qty_M043()); + costs.add(c);num2++; + } + if("M044".equals(t.getM_id_M044())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M044()); + c.setCost_cl_qty(t.getName_qty_M044()); + costs.add(c);num2++; + } + if("M045".equals(t.getM_id_M045())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M045()); + c.setCost_cl_qty(t.getName_qty_M045()); + costs.add(c);num2++; + } + if("M046".equals(t.getM_id_M046())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M046()); + c.setCost_cl_qty(t.getName_qty_M046()); + costs.add(c);num2++; + }if("M047".equals(t.getM_id_M047())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M047()); + c.setCost_cl_qty(t.getName_qty_M047()); + costs.add(c);num2++; + }if("M048".equals(t.getM_id_M048())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M048()); + c.setCost_cl_qty(t.getName_qty_M048()); + c.setCost_cl_qty_2(t.getName_qty_M048_1()); + costs.add(c);num2++; + }if("M049".equals(t.getM_id_M049())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M049()); + c.setCost_cl_qty(t.getName_qty_M049()); + costs.add(c);num2++; + } + if("M050".equals(t.getM_id_M050())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M050()); + c.setCost_cl_qty(t.getName_qty_M050()); + costs.add(c);num2++; + } + if("M051".equals(t.getM_id_M051())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M051()); + c.setCost_cl_qty(t.getName_qty_M051()); + costs.add(c);num2++; + } + if("M052".equals(t.getM_id_M052())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M052()); + c.setCost_cl_qty(t.getName_qty_M052()); + costs.add(c);num2++; + } + if("M053".equals(t.getM_id_M053())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M053()); + c.setCost_cl_qty(t.getName_qty_M053()); + costs.add(c);num2++; + } + if("M054".equals(t.getM_id_M054())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M054()); + c.setCost_cl_qty(t.getName_qty_M054()); + costs.add(c);num2++; + }if("M055".equals(t.getM_id_M055())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M055()); + c.setCost_cl_qty(t.getName_qty_M055()); + costs.add(c);num2++; + }if("M056".equals(t.getM_id_M056())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M056()); + c.setCost_cl_qty(t.getName_qty_M056()); + costs.add(c);num2++; + }if("M057".equals(t.getM_id_M057())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M057()); + c.setCost_cl_qty(t.getName_qty_M057()); + costs.add(c);num2++; + }if("M058".equals(t.getM_id_M058())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M058()); + c.setCost_cl_qty(t.getName_qty_M058()); + costs.add(c);num2++; + } + if("M059".equals(t.getM_id_M059())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M059()); + c.setCost_cl_qty(t.getName_qty_M059()); + costs.add(c);num2++; + } + if("M060".equals(t.getM_id_M060())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M060()); + c.setCost_cl_qty(t.getName_qty_M060()); + costs.add(c);num2++; + } + if("M061".equals(t.getM_id_M061())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M061()); + c.setCost_cl_qty(t.getName_qty_M061()); + costs.add(c);num2++; + } + if("M062".equals(t.getM_id_M062())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M062()); + c.setCost_cl_qty(t.getName_qty_M062()); + costs.add(c);num2++; + } + if("M063".equals(t.getM_id_M063())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M063()); + c.setCost_cl_qty(t.getName_qty_M063()); + costs.add(c);num2++; + } + if("M064".equals(t.getM_id_M064())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M064()); + c.setCost_cl_qty(t.getName_qty_M064()); + costs.add(c);num2++; + } + if("M065".equals(t.getM_id_M065())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M065()); + c.setCost_cl_qty(t.getName_qty_M065()); + costs.add(c);num2++; + } + if("M066".equals(t.getM_id_M066())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M066()); + c.setCost_cl_qty(t.getName_qty_M066()); + costs.add(c);num2++; + } + if("M067".equals(t.getM_id_M067())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M067()); + c.setCost_cl_qty(t.getName_qty_M067()); + costs.add(c);num2++; + } + if("M068".equals(t.getM_id_M068())){ + c = new cost(); + c.setCost_id(num2); + c.setCost_material_id(m.getMaterial_id()); + c.setCost_cl_id(t.getM_id_M068()); + c.setCost_cl_qty(t.getName_qty_M068()); + costs.add(c);num2++; + } + } + } + + + System.out.println("materials===================="+materials.size()); + System.out.println("costs======================="+costs.size()); + + try { + JDBCBatchInsert.insertMaterialBatch(materials); + JDBCBatchInsert.insertCostBatch(costs); + }catch (Exception e) { + throw new Exception(e.getMessage(), e); + } + + return success(); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index d8d3dce..98c5229 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -5,12 +5,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; -import com.ruoyi.common.annotation.DataSource; import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.core.redis.RedisCache; -import com.ruoyi.common.enums.DataSourceType; -import com.ruoyi.system.domain.cost; -import com.ruoyi.system.domain.material; import com.ruoyi.system.service.*; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -66,9 +62,6 @@ public class SysUserController extends BaseController @Autowired private ISysPostService postService; - @Autowired - private TestService testService; - /** * 获取用户列表 */ @@ -307,588 +300,4 @@ public class SysUserController extends BaseController return success(deptService.selectDeptTreeList(dept)); } - /*===============================================测试====================================================*/ - /**@DataSource(DataSourceType.QUOT) - @Log(title = "用户管理", businessType = BusinessType.EXPORT) - @PreAuthorize("@ss.hasPermi('system:user:export')") - @PostMapping("/export") - public void export(HttpServletResponse response) throws Exception { - List templist = testService.selectTemp(); - List materials = new ArrayList(); - material m = new material(); - - List costs = new ArrayList(); - cost c = new cost(); - - List> averageAssign = ListUtils.partition(templist, 5000); - - - int num = 1; - int num2 = 1; - for(List list:averageAssign){ - for(temp t:list){ - m = new material(); - m.setMaterial_id(num); - m.setMaterial_xingh(t.getModel_1()); - m.setMaterial_guig(t.getSpec_1()); - m.setMaterial_diany(t.getVoltage_1()); - m.setMaterial_dw(t.getUnit_0()); - m.setMaterial_type_id(t.getType_no()); - materials.add(m); - num++; - - if("M001".equals(t.getM_id_M001())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M001()); - c.setCost_cl_qty(t.getName_qty_M001()); - costs.add(c);num2++; - } - if("M002".equals(t.getM_id_M002())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M002()); - c.setCost_cl_qty(t.getName_qty_M002()); - costs.add(c);num2++; - } - if("M003".equals(t.getM_id_M003())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M003()); - c.setCost_cl_qty_2(t.getName_qty_M003_1()); - costs.add(c);num2++; - } - if("M004".equals(t.getM_id_M004())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M004()); - c.setCost_cl_qty(t.getName_qty_M004()); - c.setCost_cl_qty_2(t.getName_qty_M004_1()); - costs.add(c);num2++; - } - if("M005".equals(t.getM_id_M005())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M005()); - c.setCost_cl_qty(t.getName_qty_M005()); - c.setCost_cl_qty_2(t.getName_qty_M005_1()); - costs.add(c);num2++; - } - if("M006".equals(t.getM_id_M006())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M006()); - c.setCost_cl_qty(t.getName_qty_M006()); - costs.add(c);num2++; - } - if("M007".equals(t.getM_id_M007())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M007()); - c.setCost_cl_qty(t.getName_qty_M007()); - costs.add(c);num2++; - } - if("M008".equals(t.getM_id_M008())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M008()); - c.setCost_cl_qty(t.getName_qty_M008()); - costs.add(c);num2++; - } - if("M009".equals(t.getM_id_M009())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M009()); - c.setCost_cl_qty(t.getName_qty_M009()); - costs.add(c);num2++; - } - if("M010".equals(t.getM_id_M010())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M010()); - c.setCost_cl_qty(t.getName_qty_M010()); - c.setCost_cl_qty_2(t.getName_qty_M010_1()); - costs.add(c);num2++; - } - if("M011".equals(t.getM_id_M011())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M011()); - c.setCost_cl_qty(t.getName_qty_M011()); - costs.add(c);num2++; - } - if("M012".equals(t.getM_id_M012())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M012()); - c.setCost_cl_qty(t.getName_qty_M012()); - costs.add(c);num2++; - } - if("M013".equals(t.getM_id_M013())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M013()); - c.setCost_cl_qty(t.getName_qty_M013()); - costs.add(c);num2++; - }if("M014".equals(t.getM_id_M014())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M014()); - c.setCost_cl_qty(t.getName_qty_M014()); - costs.add(c);num2++; - }if("M015".equals(t.getM_id_M015())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M015()); - c.setCost_cl_qty(t.getName_qty_M015()); - costs.add(c);num2++; - } - if("M016".equals(t.getM_id_M016())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M016()); - c.setCost_cl_qty(t.getName_qty_M016()); - costs.add(c);num2++; - } - if("M017".equals(t.getM_id_M017())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M017()); - c.setCost_cl_qty(t.getName_qty_M017()); - costs.add(c);num2++; - } - if("M018".equals(t.getM_id_M018())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M018()); - c.setCost_cl_qty(t.getName_qty_M018()); - costs.add(c);num2++; - }if("M019".equals(t.getM_id_M019())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M019()); - c.setCost_cl_qty(t.getName_qty_M019()); - c.setCost_cl_qty_2(t.getName_qty_M019_1()); - costs.add(c);num2++; - } - if("M020".equals(t.getM_id_M020())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M020()); - c.setCost_cl_qty(t.getName_qty_M020()); - costs.add(c);num2++; - } - if("M021".equals(t.getM_id_M021())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M021()); - c.setCost_cl_qty(t.getName_qty_M021()); - c.setCost_cl_qty_2(t.getName_qty_M021_1()); - costs.add(c);num2++; - } - if("M022".equals(t.getM_id_M022())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M022()); - c.setCost_cl_qty(t.getName_qty_M022()); - costs.add(c);num2++; - } - if("M023".equals(t.getM_id_M023())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M023()); - c.setCost_cl_qty(t.getName_qty_M023()); - costs.add(c);num2++; - }if("M024".equals(t.getM_id_M024())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M024()); - c.setCost_cl_qty(t.getName_qty_M024()); - costs.add(c);num2++; - }if("M025".equals(t.getM_id_M025())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M025()); - c.setCost_cl_qty(t.getName_qty_M025()); - costs.add(c);num2++; - } - if("M026".equals(t.getM_id_M026())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M026()); - c.setCost_cl_qty(t.getName_qty_M026()); - costs.add(c);num2++; - } - if("M027".equals(t.getM_id_M027())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M027()); - c.setCost_cl_qty(t.getName_qty_M027()); - costs.add(c);num2++; - } - if("M028".equals(t.getM_id_M028())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M028()); - c.setCost_cl_qty(t.getName_qty_M028()); - costs.add(c);num2++; - } - if("M029".equals(t.getM_id_M029())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M029()); - c.setCost_cl_qty(t.getName_qty_M029()); - costs.add(c);num2++; - }if("M030".equals(t.getM_id_M030())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M030()); - c.setCost_cl_qty(t.getName_qty_M030()); - costs.add(c);num2++; - }if("M031".equals(t.getM_id_M031())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M031()); - c.setCost_cl_qty(t.getName_qty_M031()); - costs.add(c);num2++; - }if("M032".equals(t.getM_id_M032())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M032()); - c.setCost_cl_qty(t.getName_qty_M032()); - costs.add(c);num2++; - }if("M033".equals(t.getM_id_M033())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M033()); - c.setCost_cl_qty(t.getName_qty_M033()); - costs.add(c);num2++; - }if("M034".equals(t.getM_id_M034())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M034()); - c.setCost_cl_qty(t.getName_qty_M034()); - costs.add(c);num2++; - } - if("M035".equals(t.getM_id_M035())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M035()); - c.setCost_cl_qty(t.getName_qty_M035()); - costs.add(c);num2++; - }if("M036".equals(t.getM_id_M036())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M036()); - c.setCost_cl_qty(t.getName_qty_M036()); - costs.add(c);num2++; - }if("M037".equals(t.getM_id_M037())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M037()); - c.setCost_cl_qty(t.getName_qty_M037()); - c.setCost_cl_qty_2(t.getName_qty_M037_1()); - costs.add(c);num2++; - } - if("M038".equals(t.getM_id_M038())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M038()); - c.setCost_cl_qty(t.getName_qty_M038()); - costs.add(c);num2++; - } - if("M039".equals(t.getM_id_M039())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M039()); - c.setCost_cl_qty(t.getName_qty_M039()); - c.setCost_cl_qty_2(t.getName_qty_M039_1()); - costs.add(c);num2++; - } - if("M040".equals(t.getM_id_M040())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M040()); - c.setCost_cl_qty(t.getName_qty_M040()); - costs.add(c);num2++; - } - if("M041".equals(t.getM_id_M041())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M041()); - c.setCost_cl_qty(t.getName_qty_M041()); - costs.add(c);num2++; - } - if("M042".equals(t.getM_id_M042())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M042()); - c.setCost_cl_qty(t.getName_qty_M042()); - c.setCost_cl_qty_2(t.getName_qty_M042_1()); - costs.add(c);num2++; - } - if("M043".equals(t.getM_id_M043())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M043()); - c.setCost_cl_qty(t.getName_qty_M043()); - costs.add(c);num2++; - } - if("M044".equals(t.getM_id_M044())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M044()); - c.setCost_cl_qty(t.getName_qty_M044()); - costs.add(c);num2++; - } - if("M045".equals(t.getM_id_M045())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M045()); - c.setCost_cl_qty(t.getName_qty_M045()); - costs.add(c);num2++; - } - if("M046".equals(t.getM_id_M046())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M046()); - c.setCost_cl_qty(t.getName_qty_M046()); - costs.add(c);num2++; - }if("M047".equals(t.getM_id_M047())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M047()); - c.setCost_cl_qty(t.getName_qty_M047()); - costs.add(c);num2++; - }if("M048".equals(t.getM_id_M048())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M048()); - c.setCost_cl_qty(t.getName_qty_M048()); - c.setCost_cl_qty_2(t.getName_qty_M048_1()); - costs.add(c);num2++; - }if("M049".equals(t.getM_id_M049())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M049()); - c.setCost_cl_qty(t.getName_qty_M049()); - costs.add(c);num2++; - } - if("M050".equals(t.getM_id_M050())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M050()); - c.setCost_cl_qty(t.getName_qty_M050()); - costs.add(c);num2++; - } - if("M051".equals(t.getM_id_M051())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M051()); - c.setCost_cl_qty(t.getName_qty_M051()); - costs.add(c);num2++; - } - if("M052".equals(t.getM_id_M052())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M052()); - c.setCost_cl_qty(t.getName_qty_M052()); - costs.add(c);num2++; - } - if("M053".equals(t.getM_id_M053())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M053()); - c.setCost_cl_qty(t.getName_qty_M053()); - costs.add(c);num2++; - } - if("M054".equals(t.getM_id_M054())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M054()); - c.setCost_cl_qty(t.getName_qty_M054()); - costs.add(c);num2++; - }if("M055".equals(t.getM_id_M055())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M055()); - c.setCost_cl_qty(t.getName_qty_M055()); - costs.add(c);num2++; - }if("M056".equals(t.getM_id_M056())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M056()); - c.setCost_cl_qty(t.getName_qty_M056()); - costs.add(c);num2++; - }if("M057".equals(t.getM_id_M057())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M057()); - c.setCost_cl_qty(t.getName_qty_M057()); - costs.add(c);num2++; - }if("M058".equals(t.getM_id_M058())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M058()); - c.setCost_cl_qty(t.getName_qty_M058()); - costs.add(c);num2++; - } - if("M059".equals(t.getM_id_M059())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M059()); - c.setCost_cl_qty(t.getName_qty_M059()); - costs.add(c);num2++; - } - if("M060".equals(t.getM_id_M060())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M060()); - c.setCost_cl_qty(t.getName_qty_M060()); - costs.add(c);num2++; - } - if("M061".equals(t.getM_id_M061())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M061()); - c.setCost_cl_qty(t.getName_qty_M061()); - costs.add(c);num2++; - } - if("M062".equals(t.getM_id_M062())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M062()); - c.setCost_cl_qty(t.getName_qty_M062()); - costs.add(c);num2++; - } - if("M063".equals(t.getM_id_M063())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M063()); - c.setCost_cl_qty(t.getName_qty_M063()); - costs.add(c);num2++; - } - if("M064".equals(t.getM_id_M064())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M064()); - c.setCost_cl_qty(t.getName_qty_M064()); - costs.add(c);num2++; - } - if("M065".equals(t.getM_id_M065())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M065()); - c.setCost_cl_qty(t.getName_qty_M065()); - costs.add(c);num2++; - } - if("M066".equals(t.getM_id_M066())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M066()); - c.setCost_cl_qty(t.getName_qty_M066()); - costs.add(c);num2++; - } - if("M067".equals(t.getM_id_M067())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M067()); - c.setCost_cl_qty(t.getName_qty_M067()); - costs.add(c);num2++; - } - if("M068".equals(t.getM_id_M068())){ - c = new cost(); - c.setCost_id(num2); - c.setCost_material_id(m.getMaterial_id()); - c.setCost_cl_id(t.getM_id_M068()); - c.setCost_cl_qty(t.getName_qty_M068()); - costs.add(c);num2++; - } - } - } - - - System.out.println("materials===================="+materials.size()); - System.out.println("costs======================="+costs.size()); - - batchInsert.insertMaterialBatch(materials); - batchInsert.insertCostBatch(costs); - }**/ - - @DataSource(DataSourceType.QUOT) - public void insertMaterialBatch(List temp) { - testService.insertMaterialBatch(temp); - } - - @DataSource(DataSourceType.QUOT) - public void insertCostBatch(List temp) { - testService.insertCostBatch(temp); - } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/DataDBUtils.java b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/DataDBUtils.java deleted file mode 100644 index e84ad4c..0000000 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/DataDBUtils.java +++ /dev/null @@ -1,63 +0,0 @@ -/* -package com.ruoyi.web.Utils; - -import com.mchange.v2.c3p0.ComboPooledDataSource; - -import javax.sql.DataSource; -import java.beans.PropertyVetoException; -import java.sql.Connection; - -*/ -/** - * 数据库操作 - * - * @author Administrator - * - *//* - -public class DataDBUtils { - private static DataSource ds; - - static { - ComboPooledDataSource cpds = null; - try { - cpds = new ComboPooledDataSource(); - cpds.setCheckoutTimeout(30000); - cpds.setIdleConnectionTestPeriod(30); - cpds.setInitialPoolSize(10); - cpds.setMaxIdleTime(30);// - cpds.setMaxPoolSize(30); - cpds.setMaxStatementsPerConnection(100); - cpds.setMinPoolSize(5); - cpds.setMaxStatements(75); - cpds.setAcquireIncrement(3); - cpds.setNumHelperThreads(3); - cpds.setDriverClass("com.microsoft.sqlserver.jdbc.SQLServerDriver"); - cpds.setJdbcUrl("jdbc:sqlserver://192.168.9.99:1433;DatabaseName=jn_quot"); - cpds.setUser("sa"); - cpds.setPassword("Itcenter110-"); - ds = cpds; - } catch (PropertyVetoException e) { - System.out.println("与SqlServer数据库连接失败!"); - } - } - - private DataDBUtils() { - - } - - public static DataSource getDatasSource() { - return ds; - } - - public static Connection getConnection() { - Connection con = null; - try { - con = ds.getConnection();// 每一次从ds中获取一个新的连接 - } catch (Exception e) { - e.printStackTrace(); - } - return con; - } -} -*/ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/JDBCBatchInsert.java b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/JDBCBatchInsert.java new file mode 100644 index 0000000..3ad2c2a --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/JDBCBatchInsert.java @@ -0,0 +1,161 @@ +package com.ruoyi.web.utils; + +import com.ruoyi.material.domain.cost; +import com.ruoyi.material.domain.material; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.List; +import java.util.Random; + +@Component +public class JDBCBatchInsert { + + private static String databaseURL; + public static String getDatabaseURL() { + return databaseURL; + } + + @Value(value = "${spring.datasource.druid.quot.url}") + public void setDatabaseUR(String databaseURL) { + JDBCBatchInsert.databaseURL = databaseURL; + } + + private static String username; + public static String getUsername() {return username;} + + @Value(value = "${spring.datasource.druid.quot.username}") + public void setUsername(String username) { + JDBCBatchInsert.username = username; + } + + private static String password; + public static String getPassword() { + return password; + } + + @Value(value = "${spring.datasource.druid.quot.password}") + public void setPassword(String password) { + JDBCBatchInsert.password = password; + } + + public static void insertMaterialBatch(List list) throws IOException { + Connection connection = null; + PreparedStatement preparedStatement = null; + + try { + connection = DriverManager.getConnection(databaseURL, username, password); + // 关闭自动提交事务,改为手动提交 + connection.setAutoCommit(false); + System.out.println("===== 开始插入数据 ====="); + long startTime = System.currentTimeMillis(); + String sqlInsert = "insert into c_material(material_id, material_xingh, material_guig, material_diany, material_dw,material_type_id) values (?,?,?,?,?,?)"; + preparedStatement = connection.prepareStatement(sqlInsert); + + Random random = new Random(); + for (int i = 0; i < list.size(); i++) { + preparedStatement.setInt(1, list.get(i).getMaterial_id()); + preparedStatement.setString(2, list.get(i).getMaterial_xingh()); + preparedStatement.setString(3, list.get(i).getMaterial_guig()); + preparedStatement.setString(4, list.get(i).getMaterial_diany()); + preparedStatement.setString(5, list.get(i).getMaterial_dw()); + preparedStatement.setString(6, list.get(i).getMaterial_type_id()); + // 添加到批处理中 + preparedStatement.addBatch(); + + if (i % 10000 == 0) { + // 每1000条数据提交一次 + preparedStatement.executeBatch(); + connection.commit(); + System.out.println("成功插入第 "+ i+" 条数据"); + } + + } + // 处理剩余的数据 + preparedStatement.executeBatch(); + connection.commit(); + long spendTime = System.currentTimeMillis()-startTime; + System.out.println("成功插入"+ list.size()+" 条数据,耗时:"+spendTime+"毫秒"); + } catch (SQLException e) { + System.out.println("Error: " + e.getMessage()); + } finally { + if (preparedStatement != null) { + try { + preparedStatement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + + public static void insertCostBatch(List list) throws IOException { + Connection connection = null; + PreparedStatement preparedStatement = null; + + try { + connection = DriverManager.getConnection(databaseURL, username, password); + // 关闭自动提交事务,改为手动提交 + connection.setAutoCommit(false); + System.out.println("===== 开始插入数据 ====="); + long startTime = System.currentTimeMillis(); + String sqlInsert = "insert into c_material_cost(cost_id, cost_material_id, cost_cl_id, cost_cl_qty, cost_cl_qty_2) values (?,?,?,?,?)"; + preparedStatement = connection.prepareStatement(sqlInsert); + + Random random = new Random(); + for (int i = 0; i < list.size(); i++) { + preparedStatement.setInt(1, list.get(i).getCost_id()); + preparedStatement.setInt(2, list.get(i).getCost_material_id()); + preparedStatement.setString(3, list.get(i).getCost_cl_id()); + preparedStatement.setString(4, list.get(i).getCost_cl_qty()); + preparedStatement.setString(5, list.get(i).getCost_cl_qty_2()); + // 添加到批处理中 + preparedStatement.addBatch(); + + if (i % 10000 == 0) { + // 每1000条数据提交一次 + preparedStatement.executeBatch(); + connection.commit(); + System.out.println("成功插入第 "+ i+" 条数据"); + } + + } + // 处理剩余的数据 + preparedStatement.executeBatch(); + connection.commit(); + long spendTime = System.currentTimeMillis()-startTime; + System.out.println("成功插入"+ list.size()+" 条数据,耗时:"+spendTime+"毫秒"); + } catch (SQLException e) { + System.out.println("Error: " + e.getMessage()); + } finally { + if (preparedStatement != null) { + try { + preparedStatement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/batchInsert.java b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/batchInsert.java deleted file mode 100644 index b72522c..0000000 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/batchInsert.java +++ /dev/null @@ -1,118 +0,0 @@ -/* -package com.ruoyi.web.Utils; - -import com.ruoyi.system.domain.cost; -import com.ruoyi.system.domain.material; -import javax.swing.*; -import java.sql.*; -import java.util.List; - -public class batchInsert extends JFrame { - - public static Connection conn; - public static Statement stm; - public static PreparedStatement stmt; - public static ResultSet rs; - - */ -/** - * 对数据库进行批量插入数据操作 执行次数100万 - *//* - - public static void insertMaterialBatch(List list) throws Exception { - // 思路:将100万条数据分成n等份,1等份为1000条数据 - // 如何实现? - // 1、必须将Connection接口的自动提交方式改为手动 - // 2、利用Statement接口中的如下三个方法:addBatch、clearBath、executeBatch - conn = DataDBUtils.getConnection(); - conn.setAutoCommit(false); - */ -/*stmt = conn.prepareStatement( - "insert into [dbo].[sapcontract_test](uid,bh,type,custom,salesman,project,htje,startdate,enddate,remark,htzt) values (?,?,?,?,?,?,?,?,?,?,?)");*//* - - stmt = conn.prepareStatement( - "insert into c_material(material_id, material_xingh, material_guig, material_diany, material_dw,material_type_id) values (?,?,?,?,?,?)"); - int count = 0; - System.err.println("Start"); - for (material pay : list) { - count++; - stmt.setInt(1, pay.getMaterial_id()); - stmt.setString(2, pay.getMaterial_xingh()); - stmt.setString(3, pay.getMaterial_guig()); - stmt.setString(4, pay.getMaterial_diany()); - stmt.setString(5, pay.getMaterial_dw()); - stmt.setString(6, pay.getMaterial_type_id()); - - stmt.addBatch(); - if (count % 5000 == 0) {// 当增加了500个批处理的时候再提交 - stmt.executeBatch();// 执行批处理 - conn.commit(); - } - } - - stmt.executeBatch();// 执行批处理 - conn.commit(); - - close(); // 关闭资源 - - } - - */ -/** - * 对数据库进行批量插入数据操作 执行次数100万 - *//* - - public static void insertCostBatch(List list) throws Exception { - // 思路:将100万条数据分成n等份,1等份为1000条数据 - // 如何实现? - // 1、必须将Connection接口的自动提交方式改为手动 - // 2、利用Statement接口中的如下三个方法:addBatch、clearBath、executeBatch - conn = DataDBUtils.getConnection(); - conn.setAutoCommit(false); - */ -/*stmt = conn.prepareStatement( - "insert into [dbo].[sapcontract_test](uid,bh,type,custom,salesman,project,htje,startdate,enddate,remark,htzt) values (?,?,?,?,?,?,?,?,?,?,?)");*//* - - stmt = conn.prepareStatement( - "insert into c_material_cost(cost_id, cost_material_id, cost_cl_id, cost_cl_qty, cost_cl_qty_2) values (?,?,?,?,?)"); - int count = 0; - System.err.println("Start"); - for (cost pay : list) { - count++; - stmt.setInt(1, pay.getCost_id()); - stmt.setInt(2, pay.getCost_material_id()); - stmt.setString(3, pay.getCost_cl_id()); - stmt.setString(4, pay.getCost_cl_qty()); - stmt.setString(5, pay.getCost_cl_qty_2()); - - stmt.addBatch(); - if (count % 5000 == 0) {// 当增加了500个批处理的时候再提交 - stmt.executeBatch();// 执行批处理 - conn.commit(); - } - } - - stmt.executeBatch();// 执行批处理 - conn.commit(); - - close(); // 关闭资源 - - } - - public static void close() { - try { - if (rs != null) - rs.close(); - if (stmt != null) - stmt.close(); - if (stm != null) - stm.close(); - if (conn != null) - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - -} -*/ diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 03d13e3..bf6a1f7 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -5,7 +5,7 @@ ruoyi: # 版本 version: 3.8.7 # 版权年份 - copyrightYear: 2023 + copyrightYear: 2024 # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java index 4625f5e..97135fb 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java @@ -157,7 +157,7 @@ public class Constants /** * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加) */ - public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" }; + public static final String[] JOB_WHITELIST_STR = { "com.ruoyi.quartz.task" }; /** * 定时任务违规的字符 diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml index e5ef6d0..d6c8d26 100644 --- a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml @@ -14,12 +14,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time + select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time from sys_job_log - + - + - + - + delete from sys_job_log where job_log_id = #{jobLogId} - + delete from sys_job_log where job_log_id in #{jobLogId} - + - + truncate table sys_job_log - + insert into sys_job_log( job_log_id, @@ -92,4 +93,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) - \ No newline at end of file + diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/cost.java b/ruoyi-system/src/main/java/com/ruoyi/material/domain/cost.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/cost.java rename to ruoyi-system/src/main/java/com/ruoyi/material/domain/cost.java index 5441460..8ac9a7c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/cost.java +++ b/ruoyi-system/src/main/java/com/ruoyi/material/domain/cost.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.domain; +package com.ruoyi.material.domain; public class cost { private Integer cost_id; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/material.java b/ruoyi-system/src/main/java/com/ruoyi/material/domain/material.java similarity index 97% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/material.java rename to ruoyi-system/src/main/java/com/ruoyi/material/domain/material.java index e4c8044..32c84d7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/material.java +++ b/ruoyi-system/src/main/java/com/ruoyi/material/domain/material.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.domain; +package com.ruoyi.material.domain; public class material { private Integer material_id; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/temp.java b/ruoyi-system/src/main/java/com/ruoyi/material/domain/temp.java similarity index 99% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/temp.java rename to ruoyi-system/src/main/java/com/ruoyi/material/domain/temp.java index 4a3d67c..d290424 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/temp.java +++ b/ruoyi-system/src/main/java/com/ruoyi/material/domain/temp.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.domain; +package com.ruoyi.material.domain; public class temp { private String type_no; diff --git a/ruoyi-system/src/main/java/com/ruoyi/material/mapper/CMaterialMapper.java b/ruoyi-system/src/main/java/com/ruoyi/material/mapper/CMaterialMapper.java index 055acd1..32989e8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/material/mapper/CMaterialMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/material/mapper/CMaterialMapper.java @@ -3,18 +3,19 @@ package com.ruoyi.material.mapper; import java.util.List; import com.ruoyi.material.domain.CMaterial; import com.ruoyi.material.domain.CMaterialCost; +import com.ruoyi.material.domain.temp; /** * 物料管理Mapper接口 - * + * * @author ruoyi * @date 2024-02-28 */ -public interface CMaterialMapper +public interface CMaterialMapper { /** * 查询物料管理 - * + * * @param materialId 物料管理主键 * @return 物料管理 */ @@ -22,7 +23,7 @@ public interface CMaterialMapper /** * 查询物料管理列表 - * + * * @param cMaterial 物料管理 * @return 物料管理集合 */ @@ -30,7 +31,7 @@ public interface CMaterialMapper /** * 新增物料管理 - * + * * @param cMaterial 物料管理 * @return 结果 */ @@ -38,7 +39,7 @@ public interface CMaterialMapper /** * 修改物料管理 - * + * * @param cMaterial 物料管理 * @return 结果 */ @@ -46,7 +47,7 @@ public interface CMaterialMapper /** * 删除物料管理 - * + * * @param materialId 物料管理主键 * @return 结果 */ @@ -54,7 +55,7 @@ public interface CMaterialMapper /** * 批量删除物料管理 - * + * * @param materialIds 需要删除的数据主键集合 * @return 结果 */ @@ -62,26 +63,32 @@ public interface CMaterialMapper /** * 批量删除物料成本 - * + * * @param materialIds 需要删除的数据主键集合 * @return 结果 */ public int deleteCMaterialCostByCostMaterialIds(Long[] materialIds); - + /** * 批量新增物料成本 - * + * * @param cMaterialCostList 物料成本列表 * @return 结果 */ public int batchCMaterialCost(List cMaterialCostList); - + /** * 通过物料管理主键删除物料成本信息 - * + * * @param materialId 物料管理ID * @return 结果 */ public int deleteCMaterialCostByCostMaterialId(Long materialId); + + /** + * 拉取临时物料及用量表 + * @return + */ + List selectTemp(); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/material/service/ICMaterialService.java b/ruoyi-system/src/main/java/com/ruoyi/material/service/ICMaterialService.java index 764fe46..9d3df9e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/material/service/ICMaterialService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/material/service/ICMaterialService.java @@ -1,6 +1,7 @@ package com.ruoyi.material.service; import com.ruoyi.material.domain.CMaterial; +import com.ruoyi.material.domain.temp; import java.util.List; @@ -59,4 +60,10 @@ public interface ICMaterialService * @return 结果 */ public int deleteCMaterialByMaterialId(Long materialId); + + /** + * 拉取临时物料及用量表 + * @return + */ + List selectTemp(); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/material/service/impl/CMaterialServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/material/service/impl/CMaterialServiceImpl.java index 9c0ee54..301946a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/material/service/impl/CMaterialServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/material/service/impl/CMaterialServiceImpl.java @@ -3,6 +3,7 @@ package com.ruoyi.material.service.impl; import java.util.List; import com.ruoyi.material.domain.CMaterial; +import com.ruoyi.material.domain.temp; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -129,4 +130,13 @@ public class CMaterialServiceImpl implements ICMaterialService } } } + + /** + * 拉取临时物料及用量表 + * @return + */ + @Override + public List selectTemp() { + return cMaterialMapper.selectTemp(); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/testMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/testMapper.java deleted file mode 100644 index 8713a83..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/testMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.ruoyi.system.mapper; - -import com.ruoyi.system.domain.SysConfig; -import com.ruoyi.system.domain.cost; -import com.ruoyi.system.domain.material; -import com.ruoyi.system.domain.temp; - -import java.util.List; - -/** - * 参数配置 数据层 - * - * @author ruoyi - */ -public interface testMapper -{ - public List selectTemp(); - - void insertMaterialBatch(List temp); - - void insertCostBatch(List temp); -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/TestService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/TestService.java deleted file mode 100644 index ae52ae3..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/TestService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.ruoyi.system.service; - -import com.ruoyi.system.domain.cost; -import com.ruoyi.system.domain.material; -import com.ruoyi.system.domain.temp; - -import java.util.List; - -/** - * 用户 业务层 - * - * @author ruoyi - */ -public interface TestService -{ - public List selectTemp(); - - void insertMaterialBatch(List temp); - - void insertCostBatch(List temp); -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestServiceImpl.java deleted file mode 100644 index 222b540..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestServiceImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.ruoyi.system.service.impl; - -import com.ruoyi.common.annotation.DataScope; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.domain.entity.SysRole; -import com.ruoyi.common.core.domain.entity.SysUser; -import com.ruoyi.common.exception.ServiceException; -import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.bean.BeanValidators; -import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.system.domain.*; -import com.ruoyi.system.mapper.*; -import com.ruoyi.system.service.ISysConfigService; -import com.ruoyi.system.service.ISysUserService; -import com.ruoyi.system.service.TestService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; - -import javax.annotation.Resource; -import javax.validation.Validator; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -/** - * 用户 业务层处理 - * - * @author ruoyi - */ -@Service -public class TestServiceImpl implements TestService -{ - private static final Logger log = LoggerFactory.getLogger(TestServiceImpl.class); - - @Resource - private testMapper testmapper; - - - @Override - public List selectTemp() { - return testmapper.selectTemp(); - } - - @Override - public void insertMaterialBatch(List temp) { - testmapper.insertMaterialBatch(temp); - } - - @Override - public void insertCostBatch(List temp) { - testmapper.insertCostBatch(temp); - } -} diff --git a/ruoyi-system/src/main/resources/mapper/material/CMaterialMapper.xml b/ruoyi-system/src/main/resources/mapper/material/CMaterialMapper.xml index 276983f..fa47ecc 100644 --- a/ruoyi-system/src/main/resources/mapper/material/CMaterialMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/material/CMaterialMapper.xml @@ -126,4 +126,163 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ( #{item.costMaterialId}, #{item.costClId}, cast(#{item.costClQty} as decimal(18,4)), cast(#{item.costClQty2} as decimal(18,4))) + + diff --git a/ruoyi-ui/src/api/material/material.js b/ruoyi-ui/src/api/material/material.js index 6667287..5e1719f 100644 --- a/ruoyi-ui/src/api/material/material.js +++ b/ruoyi-ui/src/api/material/material.js @@ -60,3 +60,11 @@ export function listMaterialType(query) { params: query }) } + +//同步物料材料用量 +export function synchronizeUpdate() { + return request({ + url: '/material/material/synchronizeUpdate', + method: 'post' + }) +} diff --git a/ruoyi-ui/src/views/material/material/index.vue b/ruoyi-ui/src/views/material/material/index.vue index 6d86375..3bb7a61 100644 --- a/ruoyi-ui/src/views/material/material/index.vue +++ b/ruoyi-ui/src/views/material/material/index.vue @@ -84,6 +84,16 @@ v-hasPermi="['material:material:export']" >导出 + + 同步物料材料用量 + @@ -247,7 +257,7 @@ }