作者 张晓杰

修改工资信息导入模板下载,新增基础信息导出,物料下拉追加规格型号

@@ -7,6 +7,7 @@ import org.jeecg.modules.erp.meterial.entity.TblMaterial; @@ -7,6 +7,7 @@ import org.jeecg.modules.erp.meterial.entity.TblMaterial;
7 import org.jeecg.modules.erp.meterial.entity.TblMaterialPart; 7 import org.jeecg.modules.erp.meterial.entity.TblMaterialPart;
8 8
9 import java.util.List; 9 import java.util.List;
  10 +import java.util.Map;
10 11
11 /** 12 /**
12 * @Description: tbl_material 13 * @Description: tbl_material
@@ -24,4 +25,6 @@ public interface TblMaterialMapper extends BaseMapper<TblMaterial> { @@ -24,4 +25,6 @@ public interface TblMaterialMapper extends BaseMapper<TblMaterial> {
24 25
25 @Select("select part_number from tbl_material where part_number like CONCAT('%',#{partNumber},'%')") 26 @Select("select part_number from tbl_material where part_number like CONCAT('%',#{partNumber},'%')")
26 List<String> queryPartNumber(@Param("partNumber") String partNumber); 27 List<String> queryPartNumber(@Param("partNumber") String partNumber);
  28 +
  29 + List<Map<String,String>> getOptions();
27 } 30 }
@@ -10,5 +10,7 @@ @@ -10,5 +10,7 @@
10 WHERE 10 WHERE
11 id = #{subclassId} 11 id = #{subclassId}
12 </select> 12 </select>
13 - 13 + <select id="getOptions" resultType="java.util.Map">
  14 + SELECT part_number as partNumber,CONCAT(product_name,if(spec != '' ,' - ',''),if(spec != '',spec,''),if(type != '',' - ',''),if(type != '',type,'')) productName from tbl_material
  15 + </select>
14 </mapper> 16 </mapper>
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService; @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
6 import java.io.Serializable; 6 import java.io.Serializable;
7 import java.util.Collection; 7 import java.util.Collection;
8 import java.util.List; 8 import java.util.List;
  9 +import java.util.Map;
9 10
10 /** 11 /**
11 * @Description: tbl_material 12 * @Description: tbl_material
@@ -47,5 +48,6 @@ public interface ITblMaterialService extends IService<TblMaterial> { @@ -47,5 +48,6 @@ public interface ITblMaterialService extends IService<TblMaterial> {
47 48
48 List<String> queryPartNumber(String partNum); 49 List<String> queryPartNumber(String partNum);
49 50
  51 +// List<Map<String,String>> getAll();
50 List<TblMaterial> getAll(); 52 List<TblMaterial> getAll();
51 } 53 }
@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional; @@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
14 import java.io.Serializable; 14 import java.io.Serializable;
15 import java.util.Collection; 15 import java.util.Collection;
16 import java.util.List; 16 import java.util.List;
  17 +import java.util.Map;
17 18
18 /** 19 /**
19 * @Description: tbl_material 20 * @Description: tbl_material
@@ -91,9 +92,12 @@ public class TblMaterialServiceImpl extends ServiceImpl<TblMaterialMapper, TblMa @@ -91,9 +92,12 @@ public class TblMaterialServiceImpl extends ServiceImpl<TblMaterialMapper, TblMa
91 } 92 }
92 93
93 @Override 94 @Override
  95 +// public List<Map<String,String>> getAll() {
  96 +// return tblMaterialMapper.getOptions();
  97 +// }
  98 +
94 public List<TblMaterial> getAll() { 99 public List<TblMaterial> getAll() {
95 - QueryWrapper<TblMaterial> queryWrapper = new QueryWrapper<>();  
96 - return this.list(queryWrapper); 100 + return this.list();
97 } 101 }
98 102
99 } 103 }
@@ -36,6 +36,7 @@ import org.jeecgframework.poi.excel.entity.ExportParams; @@ -36,6 +36,7 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
36 import org.jeecgframework.poi.excel.entity.ImportParams; 36 import org.jeecgframework.poi.excel.entity.ImportParams;
37 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; 37 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
38 import org.springframework.beans.factory.annotation.Autowired; 38 import org.springframework.beans.factory.annotation.Autowired;
  39 +import org.springframework.transaction.annotation.Transactional;
39 import org.springframework.web.bind.annotation.*; 40 import org.springframework.web.bind.annotation.*;
40 import org.springframework.web.multipart.MultipartFile; 41 import org.springframework.web.multipart.MultipartFile;
41 import org.springframework.web.multipart.MultipartHttpServletRequest; 42 import org.springframework.web.multipart.MultipartHttpServletRequest;
@@ -104,16 +105,17 @@ public class TblOrderFormController extends JeecgController<TblOrderForm, ITblOr @@ -104,16 +105,17 @@ public class TblOrderFormController extends JeecgController<TblOrderForm, ITblOr
104 * @param tblOrderForm 105 * @param tblOrderForm
105 * @return 106 * @return
106 */ 107 */
  108 + @Transactional(rollbackFor = Exception.class)
107 @AutoLog(value = "订单表-添加") 109 @AutoLog(value = "订单表-添加")
108 @ApiOperation(value="订单表-添加", notes="订单表-添加") 110 @ApiOperation(value="订单表-添加", notes="订单表-添加")
109 @PostMapping(value = "/add") 111 @PostMapping(value = "/add")
110 public Result<String> add(@RequestBody TblOrderForm tblOrderForm) { 112 public Result<String> add(@RequestBody TblOrderForm tblOrderForm) {
111 // 产品类型 113 // 产品类型
112 String type = tblOrderForm.getProductType() + DateUtil.format(new Date(), "YYYYMM"); 114 String type = tblOrderForm.getProductType() + DateUtil.format(new Date(), "YYYYMM");
113 - Integer count = tblOrderFormService.getCountByType(type);  
114 - log.info("订单编号:"+ count);  
115 - String orderId= type + StrUtil.padPre(String.valueOf(count+1),4, '0');  
116 - tblOrderForm.setOrderId(orderId); 115 + String orderId = tblOrderFormService.getCountByType(type);
  116 + log.info("订单编号:"+ orderId);
  117 + String orderIdNew= type + StrUtil.padPre(String.valueOf(Integer.valueOf(orderId.substring(8))+1),4, '0');
  118 + tblOrderForm.setOrderId(orderIdNew);
117 //任务下达日期 119 //任务下达日期
118 tblOrderForm.setOrderDate(new Date()); 120 tblOrderForm.setOrderDate(new Date());
119 //是否分派设计 0 未分派 1已分派 121 //是否分派设计 0 未分派 1已分派
@@ -133,6 +135,7 @@ public class TblOrderFormController extends JeecgController<TblOrderForm, ITblOr @@ -133,6 +135,7 @@ public class TblOrderFormController extends JeecgController<TblOrderForm, ITblOr
133 * @param tblOrderForm 135 * @param tblOrderForm
134 * @return 136 * @return
135 */ 137 */
  138 + @Transactional(rollbackFor = Exception.class)
136 @AutoLog(value = "订单表-编辑") 139 @AutoLog(value = "订单表-编辑")
137 @ApiOperation(value="订单表-编辑", notes="订单表-编辑") 140 @ApiOperation(value="订单表-编辑", notes="订单表-编辑")
138 @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) 141 @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
@@ -194,15 +197,17 @@ public class TblOrderFormController extends JeecgController<TblOrderForm, ITblOr @@ -194,15 +197,17 @@ public class TblOrderFormController extends JeecgController<TblOrderForm, ITblOr
194 * @param id 197 * @param id
195 * @return 198 * @return
196 */ 199 */
  200 + @Transactional(rollbackFor = Exception.class)
197 @AutoLog(value = "订单表-通过id删除") 201 @AutoLog(value = "订单表-通过id删除")
198 @ApiOperation(value="订单表-通过id删除", notes="订单表-通过id删除") 202 @ApiOperation(value="订单表-通过id删除", notes="订单表-通过id删除")
199 @DeleteMapping(value = "/delete") 203 @DeleteMapping(value = "/delete")
200 public Result<String> delete(@RequestParam(name="id",required=true) String id) { 204 public Result<String> delete(@RequestParam(name="id",required=true) String id) {
201 - TblOrderForm orderForm = tblOrderFormService.getById(id);  
202 - if (!orderForm.getStatus().equals("未下单")){  
203 - return Result.error("订单已开始,不允许删除");  
204 - }  
205 - tblOrderFormService.delMain(id); 205 +// TblOrderForm orderForm = tblOrderFormService.getById(id);
  206 +// if (!orderForm.getStatus().equals("未下单")){
  207 +// return Result.error("订单已开始,不允许删除");
  208 +// }
  209 +// tblOrderFormService.delMain(id);
  210 + tblOrderFormService.removeById(id);
206 return Result.OK("删除成功!"); 211 return Result.OK("删除成功!");
207 } 212 }
208 213
@@ -19,7 +19,7 @@ public interface TblOrderFormMapper extends BaseMapper<TblOrderForm> { @@ -19,7 +19,7 @@ public interface TblOrderFormMapper extends BaseMapper<TblOrderForm> {
19 19
20 List<TblOrderForm> pageTblOrderFormDate(Integer integer); 20 List<TblOrderForm> pageTblOrderFormDate(Integer integer);
21 21
22 - Integer getCountByType(String productType); 22 + String getMaxorderIdByType(String productType);
23 23
24 TblOrderForm selectOneById(String id); 24 TblOrderForm selectOneById(String id);
25 25
@@ -30,9 +30,9 @@ @@ -30,9 +30,9 @@
30 <!-- tbl_order_form a--> 30 <!-- tbl_order_form a-->
31 <!-- LEFT JOIN tbl_product_type b on a.product_type = b.product_type_id--> 31 <!-- LEFT JOIN tbl_product_type b on a.product_type = b.product_type_id-->
32 <!-- </select>--> 32 <!-- </select>-->
33 - <select id="getCountByType" parameterType="java.lang.String" resultType="java.lang.Integer"> 33 + <select id="getMaxorderIdByType" parameterType="java.lang.String" resultType="java.lang.String">
34 SELECT 34 SELECT
35 - count(product_type) 35 + max(order_id)
36 FROM 36 FROM
37 tbl_order_form 37 tbl_order_form
38 WHERE 38 WHERE
@@ -35,7 +35,7 @@ public interface ITblOrderFormService extends IService<TblOrderForm> { @@ -35,7 +35,7 @@ public interface ITblOrderFormService extends IService<TblOrderForm> {
35 35
36 List<TblOrderForm> pageTblOrderFormDate(Integer integer); 36 List<TblOrderForm> pageTblOrderFormDate(Integer integer);
37 37
38 - Integer getCountByType(String productType); 38 + String getCountByType(String productType);
39 39
40 TblOrderForm selectOneById(String id); 40 TblOrderForm selectOneById(String id);
41 41
@@ -51,8 +51,8 @@ public class TblOrderFormServiceImpl extends ServiceImpl<TblOrderFormMapper, Tbl @@ -51,8 +51,8 @@ public class TblOrderFormServiceImpl extends ServiceImpl<TblOrderFormMapper, Tbl
51 } 51 }
52 52
53 @Override 53 @Override
54 - public Integer getCountByType(String productType) {  
55 - return tblOrderFormMapper.getCountByType(productType); 54 + public String getCountByType(String productType) {
  55 + return tblOrderFormMapper.getMaxorderIdByType(productType);
56 } 56 }
57 57
58 @Override 58 @Override
@@ -11,12 +11,16 @@ import org.apache.poi.ss.formula.functions.T; @@ -11,12 +11,16 @@ import org.apache.poi.ss.formula.functions.T;
11 import org.jeecg.common.api.vo.Result; 11 import org.jeecg.common.api.vo.Result;
12 import org.jeecg.common.aspect.annotation.AutoLog; 12 import org.jeecg.common.aspect.annotation.AutoLog;
13 import org.jeecg.common.constant.CommonConstant; 13 import org.jeecg.common.constant.CommonConstant;
  14 +import org.jeecg.common.system.base.controller.JeecgController;
14 import org.jeecg.common.system.query.QueryGenerator; 15 import org.jeecg.common.system.query.QueryGenerator;
15 import org.jeecg.modules.erp.salary.entity.TblSalaryBase; 16 import org.jeecg.modules.erp.salary.entity.TblSalaryBase;
  17 +import org.jeecg.modules.erp.salary.entity.TblSalarySuanfa;
  18 +import org.jeecg.modules.erp.salary.service.ITblSalarySuanfaService;
16 import org.jeecg.modules.erp.salary.service.TblSalaryBaseService; 19 import org.jeecg.modules.erp.salary.service.TblSalaryBaseService;
17 import org.jeecg.modules.erp.trad.entity.TblTradTender; 20 import org.jeecg.modules.erp.trad.entity.TblTradTender;
18 import org.springframework.beans.factory.annotation.Autowired; 21 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.web.bind.annotation.*; 22 import org.springframework.web.bind.annotation.*;
  23 +import org.springframework.web.servlet.ModelAndView;
20 24
21 import javax.servlet.http.HttpServletRequest; 25 import javax.servlet.http.HttpServletRequest;
22 import java.util.*; 26 import java.util.*;
@@ -31,7 +35,7 @@ import java.util.*; @@ -31,7 +35,7 @@ import java.util.*;
31 @RestController 35 @RestController
32 @RequestMapping("/salary/base") 36 @RequestMapping("/salary/base")
33 @Slf4j 37 @Slf4j
34 -public class TblSalaryBaseController { 38 +public class TblSalaryBaseController extends JeecgController<TblSalaryBase, TblSalaryBaseService> {
35 39
36 @Autowired 40 @Autowired
37 private TblSalaryBaseService tblSalaryBaseService; 41 private TblSalaryBaseService tblSalaryBaseService;
@@ -145,4 +149,15 @@ public class TblSalaryBaseController { @@ -145,4 +149,15 @@ public class TblSalaryBaseController {
145 } 149 }
146 return Result.OK(tblSalaryBase); 150 return Result.OK(tblSalaryBase);
147 } 151 }
  152 +
  153 + /**
  154 + * 导出excel
  155 + *
  156 + * @param request
  157 + * @param tblSalaryBase
  158 + */
  159 + @RequestMapping(value = "/exportXls")
  160 + public ModelAndView exportXls(HttpServletRequest request, TblSalaryBase tblSalaryBase) {
  161 + return super.exportXls(request, tblSalaryBase, TblSalaryBase.class, "基础信息");
  162 + }
148 } 163 }
@@ -19,7 +19,9 @@ import org.jeecg.modules.erp.salary.entity.TblSalaryCalculationVo; @@ -19,7 +19,9 @@ import org.jeecg.modules.erp.salary.entity.TblSalaryCalculationVo;
19 import org.jeecg.modules.erp.salary.service.ITblSalaryCalculationService; 19 import org.jeecg.modules.erp.salary.service.ITblSalaryCalculationService;
20 import org.jeecg.modules.erp.salary.service.ITblSalaryCalculationVoService; 20 import org.jeecg.modules.erp.salary.service.ITblSalaryCalculationVoService;
21 import org.jeecg.modules.erp.salary.service.TblSalaryBaseService; 21 import org.jeecg.modules.erp.salary.service.TblSalaryBaseService;
  22 +import org.jeecg.modules.erp.utils.FileUtils;
22 import org.springframework.beans.factory.annotation.Autowired; 23 import org.springframework.beans.factory.annotation.Autowired;
  24 +import org.springframework.beans.factory.annotation.Value;
23 import org.springframework.core.io.ClassPathResource; 25 import org.springframework.core.io.ClassPathResource;
24 import org.springframework.core.io.Resource; 26 import org.springframework.core.io.Resource;
25 import org.springframework.format.annotation.DateTimeFormat; 27 import org.springframework.format.annotation.DateTimeFormat;
@@ -267,29 +269,42 @@ public class TblSalaryCalculationController extends JeecgController2<TblSalaryCa @@ -267,29 +269,42 @@ public class TblSalaryCalculationController extends JeecgController2<TblSalaryCa
267 } 269 }
268 } 270 }
269 271
  272 + @Value("${jeecg.path.webapp}")
  273 + private String webapp;
  274 +
  275 +// @GetMapping("/download/{fileName}")
  276 +// public void downloadFile( @PathVariable("fileName")String fileName,HttpServletResponse response) throws IOException {
  277 +// // 获取要下载的文件路径(假设文件名为example.pdf)
  278 +//// String filePath = webapp + "/工资导入.xlsx";
  279 +// String filePath = webapp + fileName;
  280 +//
  281 +// // 创建 Resource 对象
  282 +// Resource resource = new ClassPathResource(filePath);
  283 +//
  284 +// // 设置下载响应头
  285 +// response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(resource.getFilename(),"UTF-8"));
  286 +// response.setContentType("application/vnd.ms-excel");
  287 +// response.setContentLength((int) resource.contentLength());
  288 +//
  289 +// // 将文件内容写入响应流
  290 +// try (InputStream inputStream = resource.getInputStream();
  291 +// OutputStream outputStream = response.getOutputStream()) {
  292 +// byte[] buffer = new byte[4096];
  293 +// int bytesRead;
  294 +// while ((bytesRead = inputStream.read(buffer)) != -1) {
  295 +// outputStream.write(buffer, 0, bytesRead);
  296 +// }
  297 +// }
  298 +// }
270 299
271 @GetMapping("/download/{fileName}") 300 @GetMapping("/download/{fileName}")
272 - public void downloadFile(HttpServletResponse response) throws IOException {  
273 - // 获取要下载的文件路径(假设文件名为example.pdf)  
274 - String filePath = "templates/工资导入.xlsx";  
275 -  
276 - // 创建 Resource 对象  
277 - Resource resource = new ClassPathResource(filePath);  
278 -  
279 - // 设置下载响应头  
280 - response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(resource.getFilename(),"UTF-8"));  
281 - response.setContentType("application/vnd.ms-excel");  
282 - response.setContentLength((int) resource.contentLength());  
283 -  
284 - // 将文件内容写入响应流  
285 - try (InputStream inputStream = resource.getInputStream();  
286 - OutputStream outputStream = response.getOutputStream()) {  
287 - byte[] buffer = new byte[4096];  
288 - int bytesRead;  
289 - while ((bytesRead = inputStream.read(buffer)) != -1) {  
290 - outputStream.write(buffer, 0, bytesRead);  
291 - }  
292 - } 301 + public void downloadFile(@PathVariable("fileName")String fileName,HttpServletResponse response) throws IOException {
  302 + String realFileName = System.currentTimeMillis()+"_" + fileName;
  303 + String filePath = webapp +"/"+ fileName;
  304 + response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
  305 + FileUtils.setAttachmentResponseHeader(response, realFileName);
  306 + FileUtils.writeBytes(filePath, response.getOutputStream());
  307 +
293 } 308 }
294 } 309 }
295 310
@@ -153,7 +153,7 @@ public class TblSalarySuanfaController extends JeecgController<TblSalarySuanfa, @@ -153,7 +153,7 @@ public class TblSalarySuanfaController extends JeecgController<TblSalarySuanfa,
153 */ 153 */
154 @RequestMapping(value = "/exportXls") 154 @RequestMapping(value = "/exportXls")
155 public ModelAndView exportXls(HttpServletRequest request, TblSalarySuanfa tblSalarySuanfa) { 155 public ModelAndView exportXls(HttpServletRequest request, TblSalarySuanfa tblSalarySuanfa) {
156 - return super.exportXls(request, tblSalarySuanfa, TblSalarySuanfa.class, "tbl_salary_suanfa"); 156 + return super.exportXls(request, tblSalarySuanfa, TblSalarySuanfa.class, "工资算法");
157 } 157 }
158 158
159 /** 159 /**
@@ -191,9 +191,9 @@ jeecg: @@ -191,9 +191,9 @@ jeecg:
191 uploadType: local 191 uploadType: local
192 path: 192 path:
193 #文件上传根目录 设置 193 #文件上传根目录 设置
194 - upload: /opt/upFiles 194 + upload: ${user.dir}/opt/upFiles
195 #webapp文件路径 195 #webapp文件路径
196 - webapp: /opt/webapp 196 + webapp: ${user.dir}/opt/webapp
197 shiro: 197 shiro:
198 excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/** 198 excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**
199 #阿里云oss存储和大鱼短信秘钥配置 199 #阿里云oss存储和大鱼短信秘钥配置
@@ -187,9 +187,9 @@ jeecg: @@ -187,9 +187,9 @@ jeecg:
187 uploadType: local 187 uploadType: local
188 path: 188 path:
189 #文件上传根目录 设置 189 #文件上传根目录 设置
190 - upload: /opt/jeecg-boot/upload 190 + upload: ${user.dir}/opt/jeecg-boot/upload
191 #webapp文件路径 191 #webapp文件路径
192 - webapp: /opt/jeecg-boot/webapp 192 + webapp: ${user.dir}/opt/jeecg-boot/webapp
193 shiro: 193 shiro:
194 excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/api/getUserInfo 194 excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/api/getUserInfo
195 #阿里云oss存储和大鱼短信秘钥配置 195 #阿里云oss存储和大鱼短信秘钥配置