作者 雷海东

工资表手机号...按月更新,工资导入去空格

... ... @@ -305,8 +305,29 @@ public class JeecgController2<T, t, b,w, V extends IService<t>, S extends IServi
return Result.error("文件导入失败!");
}
//工资导入
// 去除列表中对象字段的空格
private void trimSpaces(List<T> list) {
for (T item : list) {
Field[] fields = item.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true); // 确保可以访问私有字段
try {
if (field.getType() == String.class) {
String value = (String) field.get(item);
if (value != null) {
// 去除空格并更新字段值
String trimmedValue = value.replaceAll("\\s", "");
field.set(item, trimmedValue);
}
}
} catch (IllegalAccessException e) {
// 异常处理
}
}
}
}
//工资导入
@Transactional
public Result<?> importExcelgz(HttpServletRequest request, HttpServletResponse response, Class<T> clazz, Class<b> base,Class<w> workTime) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
... ... @@ -323,7 +344,8 @@ public class JeecgController2<T, t, b,w, V extends IService<t>, S extends IServi
try {
List<T> list = ExcelImportUtil.importExcel(file.getInputStream(), clazz, params);
// 去除导入数据的空格
trimSpaces(list);
List<T> shuju = new ArrayList<>();
//update-begin-author:taoyan date:20190528 for:批量插入数据
long start = System.currentTimeMillis();
... ...
... ... @@ -77,7 +77,7 @@ public class TblProductionGongxuController extends JeecgController<TblProduction
@PostMapping(value = "/add")
@Transactional(rollbackFor = Exception.class)
public Result<?> add(@RequestBody List<TblProductionGongxu> tblProductionGongxuList) {
tblProductionGongxuService.saveOrUpdateBatch(tblProductionGongxuList);
tblProductionGongxuService.saveBatch(tblProductionGongxuList);
TblOrderForm tblOrderForm=new TblOrderForm();
BigDecimal totalWorkHours = new BigDecimal(0);
for (TblProductionGongxu order : tblProductionGongxuList) {
... ...
... ... @@ -200,7 +200,6 @@ public class TblSalaryBaseController extends JeecgController<TblSalaryBase, Tbl
tblSalaryBase.setJobTitle("OfficeAdministrative");
}
tblSalaryBaseService.updateById(tblSalaryBase);
tblSalaryCalculationService.selectAndUpd();
}
return Result.OK("编辑成功!");
... ...
... ... @@ -237,7 +237,7 @@ public class TblSalaryCalculationController extends JeecgController2<TblSalaryCa
Boolean zhi= tblSalaryCalculationService.updateByBase(salaryMonth);
if(zhi){
tblSalaryCalculationService.upjisuan(tblSalaryCalculationService.select(salaryMonth));
tblSalaryCalculationService.selectAndUpd();
tblSalaryCalculationService.selectAndUpd(salaryMonth);
return Result.OK("成功!");
}
// tblSalaryCalculationService.qi();
... ...
... ... @@ -28,7 +28,7 @@ public interface TblSalaryCalculationMapper extends BaseMapper<TblSalaryCalculat
List<TblSalaryCalculation> select(Date salaryMonth);
void selectAndUpd();
void selectAndUpd(Date salaryMonth);
TblSalaryBase all(String jobId, String userName);
... ...
... ... @@ -43,14 +43,15 @@
select * from tbl_salary_calculation
where salary_month=#{salaryMonth}
</select>
<select id="selectAndUpd">
<update id="selectAndUpd">
UPDATE tbl_salary_calculation AS sc
JOIN tbl_salary_base AS sb ON sc.user_name = sb.user_name and sc.job_id =sb.job_id
SET
sc.phone = sb.phone,
sc.id_card=sb.id_card,
sc.bank_card=sb.bank_card
</select>
where sc.salary_month=#{salaryMonth}
</update>
<select id="all" resultType="org.jeecg.modules.erp.salary.entity.TblSalaryBase">
select * from tbl_salary_base
where job_id=#{jobId} and user_name=#{userName}
... ...
... ... @@ -26,5 +26,5 @@ public interface ITblSalaryCalculationService extends IService<TblSalaryCalculat
List<TblSalaryCalculation> select(Date salaryMonth);
void selectAndUpd();
void selectAndUpd(Date salaryMonth);
}
... ...
... ... @@ -51,8 +51,8 @@ public class TblSalaryCalculationServiceImpl extends ServiceImpl<TblSalaryCalcul
}
@Override
public void selectAndUpd() {
tblSalaryCalculationMapper.selectAndUpd();
public void selectAndUpd(Date salaryMonth) {
tblSalaryCalculationMapper.selectAndUpd(salaryMonth);
}
@Override
... ...