76 lines
3.0 KiB
Plaintext
76 lines
3.0 KiB
Plaintext
|
package th.co.muangthai.endrprint.controller.service;
|
||
|
|
||
|
|
||
|
import org.apache.log4j.Logger;
|
||
|
import org.springframework.beans.BeanUtils;
|
||
|
import th.co.muangthai.endrprint.controller.AbstractMasterController;
|
||
|
import th.co.muangthai.endrprint.model.bean.form.MsgErrorForm;
|
||
|
import th.co.muangthai.endrprint.model.bean.form.master.MstTeamTabForm;
|
||
|
import th.co.muangthai.endrprint.model.bean.master.MstTeamTabBean;
|
||
|
|
||
|
import java.util.List;
|
||
|
|
||
|
public class ENDR700Service extends AbstractMasterController {
|
||
|
|
||
|
static Logger log = Logger.getLogger(ENDR700Service.class);
|
||
|
|
||
|
|
||
|
public MsgErrorForm saveTeamTabNewData(MstTeamTabForm newData) {
|
||
|
MsgErrorForm msgErrorForm = new MsgErrorForm();
|
||
|
try {
|
||
|
//check Duplicate
|
||
|
MstTeamTabForm schTeamTab = new MstTeamTabForm();
|
||
|
schTeamTab.setTeam(newData.getTeam());
|
||
|
schTeamTab.setBpmTeam(newData.getBpmTeam());
|
||
|
List<MstTeamTabForm> result = commonService.searchMstTeamTabBeanByBean(schTeamTab);
|
||
|
if (result != null && result.size() > 0) {
|
||
|
msgErrorForm.setErrorFlag(getBigDecimal("1"));
|
||
|
msgErrorForm.setErrorDesc("ข้อมูลนี้มีในระบบแล้ว");
|
||
|
return msgErrorForm;
|
||
|
}
|
||
|
|
||
|
|
||
|
//save new Data
|
||
|
MstTeamTabBean teamTabBeanSave = new MstTeamTabBean();
|
||
|
BeanUtils.copyProperties(newData, teamTabBeanSave);
|
||
|
|
||
|
|
||
|
commonService.insertTeamTab(teamTabBeanSave);
|
||
|
} catch (Exception e) {
|
||
|
msgErrorForm.setErrorFlag(getBigDecimal("1"));
|
||
|
msgErrorForm.setErrorDesc("save Team Error");
|
||
|
log.error(e.toString(), e);
|
||
|
}
|
||
|
return msgErrorForm;
|
||
|
}
|
||
|
|
||
|
public MsgErrorForm saveTeamTabData(MstTeamTabForm newData, MstTeamTabForm oldData) {
|
||
|
MsgErrorForm msgErrorForm = new MsgErrorForm();
|
||
|
try {
|
||
|
if (!newData.getBpmTeam().equals(oldData.getBpmTeam())) {//กรณี BPM Team ถูกเปลี่ยน
|
||
|
//check Duplicate
|
||
|
MstTeamTabForm schTeamTab = new MstTeamTabForm();
|
||
|
schTeamTab.setTeam(newData.getTeam());
|
||
|
schTeamTab.setBpmTeam(newData.getBpmTeam());
|
||
|
List<MstTeamTabForm> result = commonService.searchMstTeamTabBeanByBean(schTeamTab);
|
||
|
if (result != null && result.size() > 0) {
|
||
|
msgErrorForm.setErrorFlag(getBigDecimal("1"));
|
||
|
msgErrorForm.setErrorDesc("ข้อมูลนี้มีในระบบแล้ว");
|
||
|
return msgErrorForm;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
MstTeamTabBean teamTabBeanSave = new MstTeamTabBean();
|
||
|
BeanUtils.copyProperties(newData, teamTabBeanSave);
|
||
|
|
||
|
commonService.insertTeamTab(teamTabBeanSave);
|
||
|
} catch (Exception e) {
|
||
|
msgErrorForm.setErrorFlag(getBigDecimal("1"));
|
||
|
msgErrorForm.setErrorDesc("save Team Error");
|
||
|
log.error(e.toString(), e);
|
||
|
}
|
||
|
return msgErrorForm;
|
||
|
}
|
||
|
|
||
|
}
|