正在显示
8 个修改的文件
包含
33 行增加
和
11 行删除
| @@ -305,8 +305,29 @@ public class JeecgController2<T, t, b,w, V extends IService<t>, S extends IServi | @@ -305,8 +305,29 @@ public class JeecgController2<T, t, b,w, V extends IService<t>, S extends IServi | ||
| 305 | return Result.error("文件导入失败!"); | 305 | return Result.error("文件导入失败!"); |
| 306 | } | 306 | } |
| 307 | 307 | ||
| 308 | - //工资导入 | 308 | + // 去除列表中对象字段的空格 |
| 309 | + private void trimSpaces(List<T> list) { | ||
| 310 | + for (T item : list) { | ||
| 311 | + Field[] fields = item.getClass().getDeclaredFields(); | ||
| 312 | + for (Field field : fields) { | ||
| 313 | + field.setAccessible(true); // 确保可以访问私有字段 | ||
| 314 | + try { | ||
| 315 | + if (field.getType() == String.class) { | ||
| 316 | + String value = (String) field.get(item); | ||
| 317 | + if (value != null) { | ||
| 318 | + // 去除空格并更新字段值 | ||
| 319 | + String trimmedValue = value.replaceAll("\\s", ""); | ||
| 320 | + field.set(item, trimmedValue); | ||
| 321 | + } | ||
| 322 | + } | ||
| 323 | + } catch (IllegalAccessException e) { | ||
| 324 | + // 异常处理 | ||
| 325 | + } | ||
| 326 | + } | ||
| 327 | + } | ||
| 328 | + } | ||
| 309 | 329 | ||
| 330 | + //工资导入 | ||
| 310 | @Transactional | 331 | @Transactional |
| 311 | public Result<?> importExcelgz(HttpServletRequest request, HttpServletResponse response, Class<T> clazz, Class<b> base,Class<w> workTime) { | 332 | public Result<?> importExcelgz(HttpServletRequest request, HttpServletResponse response, Class<T> clazz, Class<b> base,Class<w> workTime) { |
| 312 | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; | 333 | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
| @@ -323,7 +344,8 @@ public class JeecgController2<T, t, b,w, V extends IService<t>, S extends IServi | @@ -323,7 +344,8 @@ public class JeecgController2<T, t, b,w, V extends IService<t>, S extends IServi | ||
| 323 | 344 | ||
| 324 | try { | 345 | try { |
| 325 | List<T> list = ExcelImportUtil.importExcel(file.getInputStream(), clazz, params); | 346 | List<T> list = ExcelImportUtil.importExcel(file.getInputStream(), clazz, params); |
| 326 | - | 347 | + // 去除导入数据的空格 |
| 348 | + trimSpaces(list); | ||
| 327 | List<T> shuju = new ArrayList<>(); | 349 | List<T> shuju = new ArrayList<>(); |
| 328 | //update-begin-author:taoyan date:20190528 for:批量插入数据 | 350 | //update-begin-author:taoyan date:20190528 for:批量插入数据 |
| 329 | long start = System.currentTimeMillis(); | 351 | long start = System.currentTimeMillis(); |
| @@ -77,7 +77,7 @@ public class TblProductionGongxuController extends JeecgController<TblProduction | @@ -77,7 +77,7 @@ public class TblProductionGongxuController extends JeecgController<TblProduction | ||
| 77 | @PostMapping(value = "/add") | 77 | @PostMapping(value = "/add") |
| 78 | @Transactional(rollbackFor = Exception.class) | 78 | @Transactional(rollbackFor = Exception.class) |
| 79 | public Result<?> add(@RequestBody List<TblProductionGongxu> tblProductionGongxuList) { | 79 | public Result<?> add(@RequestBody List<TblProductionGongxu> tblProductionGongxuList) { |
| 80 | - tblProductionGongxuService.saveOrUpdateBatch(tblProductionGongxuList); | 80 | + tblProductionGongxuService.saveBatch(tblProductionGongxuList); |
| 81 | TblOrderForm tblOrderForm=new TblOrderForm(); | 81 | TblOrderForm tblOrderForm=new TblOrderForm(); |
| 82 | BigDecimal totalWorkHours = new BigDecimal(0); | 82 | BigDecimal totalWorkHours = new BigDecimal(0); |
| 83 | for (TblProductionGongxu order : tblProductionGongxuList) { | 83 | for (TblProductionGongxu order : tblProductionGongxuList) { |
| @@ -200,7 +200,6 @@ public class TblSalaryBaseController extends JeecgController<TblSalaryBase, Tbl | @@ -200,7 +200,6 @@ public class TblSalaryBaseController extends JeecgController<TblSalaryBase, Tbl | ||
| 200 | tblSalaryBase.setJobTitle("OfficeAdministrative"); | 200 | tblSalaryBase.setJobTitle("OfficeAdministrative"); |
| 201 | } | 201 | } |
| 202 | tblSalaryBaseService.updateById(tblSalaryBase); | 202 | tblSalaryBaseService.updateById(tblSalaryBase); |
| 203 | - tblSalaryCalculationService.selectAndUpd(); | ||
| 204 | } | 203 | } |
| 205 | 204 | ||
| 206 | return Result.OK("编辑成功!"); | 205 | return Result.OK("编辑成功!"); |
| @@ -237,7 +237,7 @@ public class TblSalaryCalculationController extends JeecgController2<TblSalaryCa | @@ -237,7 +237,7 @@ public class TblSalaryCalculationController extends JeecgController2<TblSalaryCa | ||
| 237 | Boolean zhi= tblSalaryCalculationService.updateByBase(salaryMonth); | 237 | Boolean zhi= tblSalaryCalculationService.updateByBase(salaryMonth); |
| 238 | if(zhi){ | 238 | if(zhi){ |
| 239 | tblSalaryCalculationService.upjisuan(tblSalaryCalculationService.select(salaryMonth)); | 239 | tblSalaryCalculationService.upjisuan(tblSalaryCalculationService.select(salaryMonth)); |
| 240 | - tblSalaryCalculationService.selectAndUpd(); | 240 | + tblSalaryCalculationService.selectAndUpd(salaryMonth); |
| 241 | return Result.OK("成功!"); | 241 | return Result.OK("成功!"); |
| 242 | } | 242 | } |
| 243 | // tblSalaryCalculationService.qi(); | 243 | // tblSalaryCalculationService.qi(); |
| @@ -28,7 +28,7 @@ public interface TblSalaryCalculationMapper extends BaseMapper<TblSalaryCalculat | @@ -28,7 +28,7 @@ public interface TblSalaryCalculationMapper extends BaseMapper<TblSalaryCalculat | ||
| 28 | 28 | ||
| 29 | List<TblSalaryCalculation> select(Date salaryMonth); | 29 | List<TblSalaryCalculation> select(Date salaryMonth); |
| 30 | 30 | ||
| 31 | - void selectAndUpd(); | 31 | + void selectAndUpd(Date salaryMonth); |
| 32 | 32 | ||
| 33 | TblSalaryBase all(String jobId, String userName); | 33 | TblSalaryBase all(String jobId, String userName); |
| 34 | 34 |
| @@ -43,14 +43,15 @@ | @@ -43,14 +43,15 @@ | ||
| 43 | select * from tbl_salary_calculation | 43 | select * from tbl_salary_calculation |
| 44 | where salary_month=#{salaryMonth} | 44 | where salary_month=#{salaryMonth} |
| 45 | </select> | 45 | </select> |
| 46 | - <select id="selectAndUpd"> | 46 | + <update id="selectAndUpd"> |
| 47 | UPDATE tbl_salary_calculation AS sc | 47 | UPDATE tbl_salary_calculation AS sc |
| 48 | JOIN tbl_salary_base AS sb ON sc.user_name = sb.user_name and sc.job_id =sb.job_id | 48 | JOIN tbl_salary_base AS sb ON sc.user_name = sb.user_name and sc.job_id =sb.job_id |
| 49 | SET | 49 | SET |
| 50 | sc.phone = sb.phone, | 50 | sc.phone = sb.phone, |
| 51 | sc.id_card=sb.id_card, | 51 | sc.id_card=sb.id_card, |
| 52 | sc.bank_card=sb.bank_card | 52 | sc.bank_card=sb.bank_card |
| 53 | - </select> | 53 | + where sc.salary_month=#{salaryMonth} |
| 54 | + </update> | ||
| 54 | <select id="all" resultType="org.jeecg.modules.erp.salary.entity.TblSalaryBase"> | 55 | <select id="all" resultType="org.jeecg.modules.erp.salary.entity.TblSalaryBase"> |
| 55 | select * from tbl_salary_base | 56 | select * from tbl_salary_base |
| 56 | where job_id=#{jobId} and user_name=#{userName} | 57 | where job_id=#{jobId} and user_name=#{userName} |
| @@ -26,5 +26,5 @@ public interface ITblSalaryCalculationService extends IService<TblSalaryCalculat | @@ -26,5 +26,5 @@ public interface ITblSalaryCalculationService extends IService<TblSalaryCalculat | ||
| 26 | 26 | ||
| 27 | List<TblSalaryCalculation> select(Date salaryMonth); | 27 | List<TblSalaryCalculation> select(Date salaryMonth); |
| 28 | 28 | ||
| 29 | - void selectAndUpd(); | 29 | + void selectAndUpd(Date salaryMonth); |
| 30 | } | 30 | } |
| @@ -51,8 +51,8 @@ public class TblSalaryCalculationServiceImpl extends ServiceImpl<TblSalaryCalcul | @@ -51,8 +51,8 @@ public class TblSalaryCalculationServiceImpl extends ServiceImpl<TblSalaryCalcul | ||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | @Override | 53 | @Override |
| 54 | - public void selectAndUpd() { | ||
| 55 | - tblSalaryCalculationMapper.selectAndUpd(); | 54 | + public void selectAndUpd(Date salaryMonth) { |
| 55 | + tblSalaryCalculationMapper.selectAndUpd(salaryMonth); | ||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | @Override | 58 | @Override |
-
请 注册 或 登录 后发表评论